mirror of
https://github.com/kanaka/mal.git
synced 2024-08-18 02:00:40 +03:00
8a19f60386
- Reorder README to have implementation list after "learning tool" bullet. - This also moves tests/ and libs/ into impls. It would be preferrable to have these directories at the top level. However, this causes difficulties with the wasm implementations which need pre-open directories and have trouble with paths starting with "../../". So in lieu of that, symlink those directories to the top-level. - Move the run_argv_test.sh script into the tests directory for general hygiene.
44 lines
965 B
Forth
44 lines
965 B
Forth
module REPL
|
|
open System
|
|
|
|
let READ input =
|
|
try
|
|
Reader.read_str input
|
|
with
|
|
| Error.ReaderError(msg) ->
|
|
printfn "%s" msg
|
|
[]
|
|
|
|
let EVAL ast =
|
|
Some(ast)
|
|
|
|
let PRINT v =
|
|
v
|
|
|> Seq.singleton
|
|
|> Printer.pr_str
|
|
|> printfn "%s"
|
|
|
|
let REP input =
|
|
READ input
|
|
|> Seq.ofList
|
|
|> Seq.map (fun form -> EVAL form)
|
|
|> Seq.filter Option.isSome
|
|
|> Seq.iter (fun value -> PRINT value.Value)
|
|
|
|
let getReadlineMode args =
|
|
if args |> Array.exists (fun e -> e = "--raw") then
|
|
Readline.Mode.Raw
|
|
else
|
|
Readline.Mode.Terminal
|
|
|
|
[<EntryPoint>]
|
|
let main args =
|
|
let mode = getReadlineMode args
|
|
let rec loop () =
|
|
match Readline.read "user> " mode with
|
|
| null -> 0
|
|
| input ->
|
|
REP input
|
|
loop()
|
|
loop ()
|