diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2021-02-28 18:47:34 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2021-02-28 18:47:34 -0800 |
commit | 755c02c4e6ebe42012ed88fcf63c554c53457e5e (patch) | |
tree | 1d04750d8077dd241c57437e9a48aa1601d87bc5 /baremetal/shell | |
parent | 3ce9511621ec78eea2285551df105c4217019b44 (diff) | |
download | mu-755c02c4e6ebe42012ed88fcf63c554c53457e5e.tar.gz |
7827
Diffstat (limited to 'baremetal/shell')
-rw-r--r-- | baremetal/shell/parse.mu | 14 | ||||
-rw-r--r-- | baremetal/shell/read.mu | 2 |
2 files changed, 10 insertions, 6 deletions
diff --git a/baremetal/shell/parse.mu b/baremetal/shell/parse.mu index 7e5aafc3..ab7f440d 100644 --- a/baremetal/shell/parse.mu +++ b/baremetal/shell/parse.mu @@ -1,7 +1,15 @@ +fn parse-input tokens: (addr stream cell), out: (addr handle cell), trace: (addr trace) { + rewind-stream tokens + parse-sexpression tokens, out, trace + var empty?/eax: boolean <- stream-empty? tokens + compare empty?, 0/false + break-if-!= + error trace, "unexpected tokens at end; only type in a single expression at a time" +} + fn parse-sexpression tokens: (addr stream cell), _out: (addr handle cell), trace: (addr trace) { trace-text trace, "read", "parse" trace-lower trace - rewind-stream tokens var curr-token-storage: cell var curr-token/ecx: (addr cell) <- address curr-token-storage var empty?/eax: boolean <- stream-empty? tokens @@ -14,10 +22,6 @@ fn parse-sexpression tokens: (addr stream cell), _out: (addr handle cell), trace read-from-stream tokens, curr-token parse-atom curr-token, _out, trace trace-higher trace - var empty?/eax: boolean <- stream-empty? tokens - compare empty?, 0/false - break-if-!= - error trace, "unexpected tokens at end; only type in a single expression at a time" } fn parse-atom _curr-token: (addr cell), _out: (addr handle cell), trace: (addr trace) { diff --git a/baremetal/shell/read.mu b/baremetal/shell/read.mu index e49fbbac..d3e1dc86 100644 --- a/baremetal/shell/read.mu +++ b/baremetal/shell/read.mu @@ -11,5 +11,5 @@ fn read-cell in: (addr gap-buffer), out: (addr handle cell), trace: (addr trace) } # TODO: insert parens # TODO: transform infix - parse-sexpression tokens, out, trace + parse-input tokens, out, trace } |