mirror of
https://github.com/kanaka/mal.git
synced 2024-09-11 21:57:38 +03:00
28 lines
479 B
Standard ML
28 lines
479 B
Standard ML
fun read s =
|
|
readStr s
|
|
|
|
fun eval f =
|
|
f
|
|
|
|
fun print f =
|
|
prReadableStr f
|
|
|
|
fun rep s =
|
|
s |> read |> eval |> print
|
|
handle SyntaxError msg => "SYNTAX ERROR: " ^ msg
|
|
| Nothing => ""
|
|
|
|
fun repl () =
|
|
let open TextIO
|
|
in (
|
|
print("user> ");
|
|
case inputLine(stdIn) of
|
|
SOME(line) => (
|
|
print(rep(line) ^ "\n");
|
|
repl ()
|
|
)
|
|
| NONE => ()
|
|
) end
|
|
|
|
fun main () = repl ()
|