Merge pull request #377 from asarhaddon/fix-runtests-pre-eval
[jackhill/mal.git] / miniMAL / step3_env.json
index 353c3dd..3aadc8f 100644 (file)
@@ -1,10 +1,10 @@
 ["do",
 
-["load-file", ["`", "miniMAL-core.json"]],
-["load-file", ["`", "types.json"]],
-["load-file", ["`", "reader.json"]],
-["load-file", ["`", "printer.json"]],
-["load-file", ["`", "env.json"]],
+["load", ["`", "miniMAL-core.json"]],
+["load", ["`", "types.json"]],
+["load", ["`", "reader.json"]],
+["load", ["`", "printer.json"]],
+["load", ["`", "env.json"]],
 
 ["def", "READ", ["fn", ["strng"],
   ["read-str", "strng"]]],
     ["env-get", "env", "ast"],
   ["if", ["list?", "ast"],
     ["map", ["fn", ["x"], ["EVAL", "x", "env"]], "ast"],
-  "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", "LET", ["fn", ["env", "args"],
   ["if", [">", ["count", "args"], 0],
 ["def", "EVAL", ["fn", ["ast", "env"],
   ["if", ["not", ["list?", "ast"]],
         ["eval-ast", "ast", "env"],
-        ["let", ["a0", ["get", ["first", "ast"], ["`", "val"]]],
-          ["if", ["=", ["`", "def!"], "a0"],
-            ["env-set", "env", ["nth", "ast", 1],
-                               ["EVAL", ["nth", "ast", 2], "env"]],
-          ["if", ["=", ["`", "let*"], "a0"],
-            ["let", ["let-env", ["env-new", "env"]],
-              ["do",
-                ["LET", "let-env", ["nth", "ast", 1]],
-                ["EVAL", ["nth", "ast", 2], "let-env"]]],
-            ["let", ["el", ["eval-ast", "ast", "env"],
-                     "f", ["first", "el"],
-                     "args", ["rest", "el"]],
-              ["apply", "f", "args"]]]]]]]],
+        ["if", ["empty?", "ast"],
+          "ast",
+          ["let", ["a0", ["get", ["first", "ast"], ["`", "val"]]],
+            ["if", ["=", ["`", "def!"], "a0"],
+              ["env-set", "env", ["nth", "ast", 1],
+                                 ["EVAL", ["nth", "ast", 2], "env"]],
+            ["if", ["=", ["`", "let*"], "a0"],
+              ["let", ["let-env", ["env-new", "env"]],
+                ["do",
+                  ["LET", "let-env", ["nth", "ast", 1]],
+                  ["EVAL", ["nth", "ast", 2], "let-env"]]],
+              ["let", ["el", ["eval-ast", "ast", "env"],
+                       "f", ["first", "el"],
+                       "args", ["rest", "el"]],
+                ["apply", "f", "args"]]]]]]]]],
 
 ["def", "PRINT", ["fn", ["exp"],
   ["pr-str", "exp", true]]],