mirror of
https://github.com/kanaka/mal.git
synced 2024-09-21 02:27:10 +03:00
b32495e94b
Also update miniMAL Dockerfile to xenial.
63 lines
1.7 KiB
JSON
63 lines
1.7 KiB
JSON
["do",
|
|
|
|
["load", ["`", "miniMAL-core.json"]],
|
|
["load", ["`", "types.json"]],
|
|
["load", ["`", "reader.json"]],
|
|
["load", ["`", "printer.json"]],
|
|
|
|
["def", "READ", ["fn", ["strng"],
|
|
["read-str", "strng"]]],
|
|
|
|
["def", "eval-ast", ["fn", ["ast", "env"],
|
|
["if", ["symbol?", "ast"],
|
|
["let", ["sym", ["get", "ast", ["`", "val"]]],
|
|
["if", ["contains?", "env", "sym"],
|
|
["get", "env", "sym"],
|
|
["throw", ["str", ["`", "'"], "sym", ["`", "' not found"]]]]],
|
|
["if", ["list?", "ast"],
|
|
["map", ["fn", ["x"], ["EVAL", "x", "env"]], "ast"],
|
|
["if", ["vector?", "ast"],
|
|
["vectorl", ["map", ["fn", ["x"], ["EVAL", "x", "env"]], "ast"]],
|
|
["if", ["map?", "ast"],
|
|
["let", ["new-hm", ["hash-map"]],
|
|
["do",
|
|
["map", ["fn", ["k"], ["set", "new-hm",
|
|
["EVAL", "k", "env"],
|
|
["EVAL", ["get", "ast", "k"], "env"]]],
|
|
["keys", "ast"]],
|
|
"new-hm"]],
|
|
"ast"]]]]]],
|
|
|
|
["def", "EVAL", ["fn", ["ast", "env"],
|
|
["if", ["not", ["list?", "ast"]],
|
|
["eval-ast", "ast", "env"],
|
|
["if", ["empty?", "ast"],
|
|
"ast",
|
|
["let", ["el", ["eval-ast", "ast", "env"],
|
|
"f", ["first", "el"],
|
|
"args", ["rest", "el"]],
|
|
["apply", "f", "args"]]]]]],
|
|
|
|
["def", "PRINT", ["fn", ["exp"],
|
|
["pr-str", "exp", true]]],
|
|
|
|
|
|
["def", "repl-env",
|
|
["hash-map",
|
|
["`", "+"], "+",
|
|
["`", "-"], "-",
|
|
["`", "*"], "*",
|
|
["`", "/"], ["fn", ["a", "b"], ["parseInt", ["/", "a", "b"]]]]],
|
|
|
|
["def", "rep", ["fn", ["strng"],
|
|
["try",
|
|
["PRINT", ["EVAL", ["READ", "strng"], "repl-env"]],
|
|
["catch", "exc",
|
|
["str", ["`", "Error: "], [".", "exc", ["`", "toString"]]]]]]],
|
|
|
|
["repl", ["`", "user> "], "rep"],
|
|
|
|
null
|
|
|
|
]
|