diff options
Diffstat (limited to 'baremetal')
-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 } |