diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2021-06-23 00:56:39 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2021-06-23 00:56:39 -0700 |
commit | 577123e975bec6d8a4ddef6cc57b9c7cfef6c462 (patch) | |
tree | 4f706e445947fd3843aa55ba50c641885795e728 | |
parent | f174695400fcbaacf9ef6a66a72e3f71ff6bf302 (diff) | |
download | mu-577123e975bec6d8a4ddef6cc57b9c7cfef6c462.tar.gz |
one more bug
-rw-r--r-- | shell/evaluate.mu | 8 | ||||
-rw-r--r-- | shell/infix.mu | 23 |
2 files changed, 22 insertions, 9 deletions
diff --git a/shell/evaluate.mu b/shell/evaluate.mu index 3fcd07d9..b27405e0 100644 --- a/shell/evaluate.mu +++ b/shell/evaluate.mu @@ -1689,7 +1689,7 @@ fn evaluate-backquote _in-ah: (addr handle cell), _out-ah: (addr handle cell), e var in-left-ah/ecx: (addr handle cell) <- get in, left debug-print "10", 4/fg, 0/bg # check for unquote - $macroexpand-iter:unquote: { + $evaluate-backquote:unquote: { var in-left/eax: (addr cell) <- lookup *in-left-ah var unquote?/eax: boolean <- symbol-equal? in-left, "," compare unquote?, 0/false @@ -1705,7 +1705,7 @@ fn evaluate-backquote _in-ah: (addr handle cell), _out-ah: (addr handle cell), e # check for unquote-splice in in-left debug-print "11", 4/fg, 0/bg var out-ah/edi: (addr handle cell) <- copy _out-ah - $macroexpand-iter:unquote-splice: { + $evaluate-backquote:unquote-splice: { #? dump-cell-from-cursor-over-full-screen in-left-ah var in-left/eax: (addr cell) <- lookup *in-left-ah { @@ -1714,11 +1714,11 @@ fn evaluate-backquote _in-ah: (addr handle cell), _out-ah: (addr handle cell), e var in-left-is-nil?/eax: boolean <- nil? in-left compare in-left-is-nil?, 0/false } - break-if-!= $macroexpand-iter:unquote-splice + break-if-!= $evaluate-backquote:unquote-splice var in-left-type/ecx: (addr int) <- get in-left, type debug-print "13", 4/fg, 0/bg compare *in-left-type, 0/pair - break-if-!= $macroexpand-iter:unquote-splice + break-if-!= $evaluate-backquote:unquote-splice var in-left-left-ah/eax: (addr handle cell) <- get in-left, left debug-print "14", 4/fg, 0/bg var in-left-left/eax: (addr cell) <- lookup *in-left-left-ah diff --git a/shell/infix.mu b/shell/infix.mu index 2239ab77..2164eb5c 100644 --- a/shell/infix.mu +++ b/shell/infix.mu @@ -389,7 +389,8 @@ fn test-infix { check-infix "(f a + b)", "(f (+ a b))", "F - test-infix/higher-precedence-than-call" check-infix "(f a + b c + d)", "(f (+ a b) (+ c d))", "F - test-infix/multiple" check-infix "+a", "(+ a)", "F - test-infix/unary-operator-2" - check-infix "-a", "(- a)", "F - test-infix/unary-operator-3" + check-infix "(+a)", "((+ a))", "F - test-infix/unary-operator-3" + check-infix "-a", "(- a)", "F - test-infix/unary-operator-4" check-infix "a+b", "(+ a b)", "F - test-infix/no-spaces" check-infix "',a+b", "',(+ a b)", "F - test-infix/no-spaces-with-nested-quotes" check-infix "$a+b", "(+ $a b)", "F - test-infix/no-spaces-2" @@ -404,8 +405,6 @@ fn test-infix { # helpers -# assumes symbol? is already fully tokenized, -# consists entirely of either operator or non-operator graphemes fn operator-symbol? _x: (addr cell) -> _/eax: boolean { var x/esi: (addr cell) <- copy _x { @@ -434,8 +433,22 @@ fn operator-symbol? _x: (addr cell) -> _/eax: boolean { g <- read-grapheme x-data loop } - var result/eax: boolean <- operator-grapheme? g - return result + { + { + var result/eax: boolean <- operator-grapheme? g + compare result, 0/false + break-if-!= + return 0/false + } + { + var done?/eax: boolean <- stream-empty? x-data + compare done?, 0/false + } + break-if-!= + g <- read-grapheme x-data + loop + } + return 1/true } # just a short list of operator graphemes for now |