about summary refs log tree commit diff stats
path: root/lambda-to-mu.mu
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-07-22 21:16:09 -0700
committerKartik K. Agaram <vc@akkartik.com>2016-07-22 21:16:09 -0700
commitefa4e1242cc78735910927c04b7f9c3e7e58e336 (patch)
tree1ee2c3469ca5b54e6f6bdbafdc3fadb09d882ba9 /lambda-to-mu.mu
parente97e1fa69962800a84b29a990df47e64e75ebf17 (diff)
downloadmu-efa4e1242cc78735910927c04b7f9c3e7e58e336.tar.gz
3135
Parsing pairs of atoms.
Diffstat (limited to 'lambda-to-mu.mu')
-rw-r--r--lambda-to-mu.mu19
1 files changed, 14 insertions, 5 deletions
diff --git a/lambda-to-mu.mu b/lambda-to-mu.mu
index d4dc4739..3bbdd247 100644
--- a/lambda-to-mu.mu
+++ b/lambda-to-mu.mu
@@ -144,21 +144,30 @@ def parse in:address:stream -> out:address:cell, in:address:stream [
     {
       done?:boolean <- end-of-stream? in
       break-if done?
-      c:character, in <- read in
+      # stop before close paren
+      c:character <- peek in
+      done? <- equal c, 41/close-paren
+      break-if done?
+      # stop at spaces after consuming them
+      c <- read in
+      done? <- equal c, 32/space
+      break-if done?
       b <- append b, c
       loop
     }
     s:address:array:character <- buffer-to-array b
     out <- new-atom s
-    reply
   }
   {
     break-unless pair?
     # pair
     read in  # skip the open-paren
-    {
-#?       done?:boolean <- 
-    }
+    first:address:cell, in <- parse in
+    rest:address:cell, in <- parse in
+    c <- read in
+    close-paren?:boolean <- equal c, 41/close-paren
+    assert close-paren?, [currently supports exactly two atoms in pairs]
+    out <- new-pair first, rest
   }
 ]