about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-04-15 17:38:14 -0700
committerKartik K. Agaram <vc@akkartik.com>2021-04-15 17:38:14 -0700
commit60ef3caa4dc2610028e32b9c2a37ef560d4d1a5a (patch)
tree45cbd62f1572a6ca0b327fdfb0f1c2bc5feacf4a
parentd0578257cda0ff0719aa54f6476b1e72ebc65bed (diff)
downloadmu-60ef3caa4dc2610028e32b9c2a37ef560d4d1a5a.tar.gz
shell: starting to parse dotted lists
-rw-r--r--shell/parse.mu30
1 files changed, 20 insertions, 10 deletions
diff --git a/shell/parse.mu b/shell/parse.mu
index 9fd555b3..dde7da4d 100644
--- a/shell/parse.mu
+++ b/shell/parse.mu
@@ -65,18 +65,28 @@ fn parse-sexpression tokens: (addr stream cell), _out: (addr handle cell), trace
     {
       break-if-=
       var curr/esi: (addr handle cell) <- copy _out
-      $parse-sexpression:list-loop: {
-        allocate-pair curr
+      allocate-pair curr
+      var curr-addr/eax: (addr cell) <- lookup *curr
+      var left/ecx: (addr handle cell) <- get curr-addr, left
+      {
+        var close-paren?/eax: boolean <- parse-sexpression tokens, left, trace
+        compare close-paren?, 0/false
+        break-if-!=
         var curr-addr/eax: (addr cell) <- lookup *curr
-        var left/ecx: (addr handle cell) <- get curr-addr, left
-        {
-          var close-paren?/eax: boolean <- parse-sexpression tokens, left, trace
-          compare close-paren?, 0/false
-          break-if-!= $parse-sexpression:list-loop
-        }
-        #
         curr <- get curr-addr, right
-        loop
+        $parse-sexpression:list-loop: {
+          allocate-pair curr
+          var curr-addr/eax: (addr cell) <- lookup *curr
+          var left/ecx: (addr handle cell) <- get curr-addr, left
+          {
+            var close-paren?/eax: boolean <- parse-sexpression tokens, left, trace
+            compare close-paren?, 0/false
+            break-if-!= $parse-sexpression:list-loop
+          }
+          #
+          curr <- get curr-addr, right
+          loop
+        }
       }
       break $parse-sexpression:type-check
     }