2021-04-07 15:49:00 +03:00
|
|
|
fun read s =
|
2021-03-25 20:59:11 +03:00
|
|
|
readStr s
|
|
|
|
|
2021-04-07 15:49:00 +03:00
|
|
|
fun eval f =
|
2021-03-25 20:59:11 +03:00
|
|
|
f
|
|
|
|
|
2021-04-07 15:49:00 +03:00
|
|
|
fun print f =
|
2021-04-04 19:18:40 +03:00
|
|
|
prReadableStr f
|
2021-03-25 20:59:11 +03:00
|
|
|
|
|
|
|
fun rep s =
|
2021-04-07 15:49:00 +03:00
|
|
|
s |> read |> eval |> print
|
2021-03-25 20:59:11 +03:00
|
|
|
handle SyntaxError msg => "SYNTAX ERROR: " ^ msg
|
2021-03-26 11:08:59 +03:00
|
|
|
| Nothing => ""
|
2021-03-25 20:59:11 +03:00
|
|
|
|
|
|
|
fun repl () =
|
|
|
|
let open TextIO
|
|
|
|
in (
|
|
|
|
print("user> ");
|
|
|
|
case inputLine(stdIn) of
|
|
|
|
SOME(line) => (
|
|
|
|
print(rep(line) ^ "\n");
|
|
|
|
repl ()
|
|
|
|
)
|
|
|
|
| NONE => ()
|
|
|
|
) end
|
2021-03-29 15:06:10 +03:00
|
|
|
|
|
|
|
fun main () = repl ()
|