Travis: comment out self-host tests in master.
[jackhill/mal.git] / miniMAL / step3_env.json
1 ["do",
2
3 ["load-file", ["`", "miniMAL-core.json"]],
4 ["load-file", ["`", "types.json"]],
5 ["load-file", ["`", "reader.json"]],
6 ["load-file", ["`", "printer.json"]],
7 ["load-file", ["`", "env.json"]],
8
9 ["def", "READ", ["fn", ["strng"],
10 ["read-str", "strng"]]],
11
12 ["def", "eval-ast", ["fn", ["ast", "env"],
13 ["if", ["symbol?", "ast"],
14 ["env-get", "env", "ast"],
15 ["if", ["list?", "ast"],
16 ["map", ["fn", ["x"], ["EVAL", "x", "env"]], "ast"],
17 ["if", ["vector?", "ast"],
18 ["vectorl", ["map", ["fn", ["x"], ["EVAL", "x", "env"]], "ast"]],
19 ["if", ["map?", "ast"],
20 ["let", ["new-hm", ["hash-map"]],
21 ["do",
22 ["map", ["fn", ["k"], ["set", "new-hm",
23 ["EVAL", "k", "env"],
24 ["EVAL", ["get", "ast", "k"], "env"]]],
25 ["keys", "ast"]],
26 "new-hm"]],
27 "ast"]]]]]],
28
29 ["def", "LET", ["fn", ["env", "args"],
30 ["if", [">", ["count", "args"], 0],
31 ["do",
32 ["env-set", "env", ["nth", "args", 0],
33 ["EVAL", ["nth", "args", 1], "env"]],
34 ["LET", "env", ["rest", ["rest", "args"]]]]]]],
35
36 ["def", "EVAL", ["fn", ["ast", "env"],
37 ["if", ["not", ["list?", "ast"]],
38 ["eval-ast", "ast", "env"],
39 ["let", ["a0", ["get", ["first", "ast"], ["`", "val"]]],
40 ["if", ["=", ["`", "def!"], "a0"],
41 ["env-set", "env", ["nth", "ast", 1],
42 ["EVAL", ["nth", "ast", 2], "env"]],
43 ["if", ["=", ["`", "let*"], "a0"],
44 ["let", ["let-env", ["env-new", "env"]],
45 ["do",
46 ["LET", "let-env", ["nth", "ast", 1]],
47 ["EVAL", ["nth", "ast", 2], "let-env"]]],
48 ["let", ["el", ["eval-ast", "ast", "env"],
49 "f", ["first", "el"],
50 "args", ["rest", "el"]],
51 ["apply", "f", "args"]]]]]]]],
52
53 ["def", "PRINT", ["fn", ["exp"],
54 ["pr-str", "exp", true]]],
55
56
57 ["def", "repl-env", ["env-new"]],
58 ["env-set", "repl-env", ["symbol", ["`", "+"]], "+"],
59 ["env-set", "repl-env", ["symbol", ["`", "-"]], "-"],
60 ["env-set", "repl-env", ["symbol", ["`", "*"]], "*"],
61 ["def", "div", ["fn", ["a", "b"], ["parseInt", ["/", "a", "b"]]]],
62 ["env-set", "repl-env", ["symbol", ["`", "/"]], "div"],
63
64 ["def", "rep", ["fn", ["strng"],
65 ["try",
66 ["PRINT", ["EVAL", ["READ", "strng"], "repl-env"]],
67 ["catch", "exc",
68 ["str", ["`", "Error: "], [".", "exc", ["`", "toString"]]]]]]],
69
70 ["repl", ["`", "user> "], "rep"],
71
72 null
73
74 ]