mirror of
https://github.com/kanaka/mal.git
synced 2024-09-21 02:27:10 +03:00
dd7a4f55f3
Fixes made to: ada, c, chuck, clojure, coffee, common-lisp, cpp, crystal, d, dart, elm, erlang, es6, factor, fsharp, gnu-smalltalk, groovy, guile, haxe, hy, js, livescript, matlab, miniMAL, nasm, nim, objc, objpascal, ocaml, perl, perl6, php, plsql, ps, python, r, rpython, ruby, scheme, swift3, tcl, ts, vb, vimscript, wasm, yorick. Catchless try* test is an optional test. Not all implementations support catchless try* but a number were fixed so they at least don't crash on catchless try*.
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 ()
|