one more bug

This commit is contained in:
Kartik K. Agaram 2021-06-23 00:56:39 -07:00
parent f174695400
commit 577123e975
2 changed files with 22 additions and 9 deletions

View File

@ -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

View File

@ -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