From b89c158e3e2f24cbc6b3f0ebe71d9206e529fcaa Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sun, 28 Feb 2021 13:06:11 -0800 Subject: [PATCH] 7823 --- baremetal/shell/parse.mu | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/baremetal/shell/parse.mu b/baremetal/shell/parse.mu index 7c36673f..c89f8f0d 100644 --- a/baremetal/shell/parse.mu +++ b/baremetal/shell/parse.mu @@ -4,15 +4,19 @@ fn parse-sexpression tokens: (addr stream cell), _out: (addr handle cell), 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 + compare empty?, 0/false { - var done?/eax: boolean <- stream-empty? tokens - compare done?, 0/false - break-if-!= - read-from-stream tokens, curr-token - parse-atom curr-token, _out, trace + break-if-= + error trace, "nothing to parse" return } - abort "unexpected tokens at end; only type in a single expression at a time" + read-from-stream tokens, curr-token + parse-atom curr-token, _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-atom _curr-token: (addr cell), _out: (addr handle cell), trace: (addr trace) {