diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-07-22 19:58:30 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-07-22 20:28:36 -0700 |
commit | ae6d8f0335360886d79e6b0581e90bd0e0b2397d (patch) | |
tree | d5ca89c607de8cdb0f6dbdf91e59fb3b21e3e62d | |
parent | 9acf5c0fc91d7e348c794c8b8181d4e56f393925 (diff) | |
download | mu-ae6d8f0335360886d79e6b0581e90bd0e0b2397d.tar.gz |
3130
Handle multi-character atoms.
-rw-r--r-- | lambda-to-mu.mu | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/lambda-to-mu.mu b/lambda-to-mu.mu index 9afe1ed3..8731f324 100644 --- a/lambda-to-mu.mu +++ b/lambda-to-mu.mu @@ -136,13 +136,18 @@ def parse in:address:stream -> out:address:cell, in:address:stream [ local-scope load-ingredients b:address:buffer <- new-buffer 30 - c:character, in <- read in - b <- append b, c + { + done?:boolean <- end-of-stream? in + break-if done? + c:character, in <- read in + b <- append b, c + loop + } s:address:array:character <- buffer-to-array b out <- new-atom s ] -scenario parse-atom [ +scenario parse-single-letter-atom [ local-scope s:address:array:character <- new [a] x:address:cell <- parse s @@ -153,3 +158,15 @@ scenario parse-atom [ 11:array:character <- [a] ] ] + +scenario parse-atom [ + local-scope + s:address:array:character <- new [abc] + x:address:cell <- parse s + s2:address:array:character, 10:boolean/raw <- maybe-convert *x, atom:variant + 11:array:character/raw <- copy *s2 + memory-should-contain [ + 10 <- 1 # parse result is an atom + 11:array:character <- [abc] + ] +] |