Phase 7.10: workaround else-if bug in lexSkipWhitespace

Lexer (src_bux/lexer.bux):
- Rewrote lexSkipWhitespace to use nested if/else instead of else-if
  chain (workaround for Nim C backend else-if lowering bug)
- lexPeek: mask with & 255 for UTF-8 signed char bytes

Known: buxc2 project build hangs on ast.bux parsing (infinite loop).
buxc2 single-file build works correctly with else-if.
All 18 examples pass, all unit tests pass.
This commit is contained in:
2026-05-31 18:24:44 +03:00
parent 74117595d2
commit 6744a35c03
2 changed files with 24 additions and 16 deletions
+12 -8
View File
@@ -227,16 +227,20 @@ func lexSkipBlockComment(lex: *Lexer) {
func lexSkipWhitespace(lex: *Lexer) {
while !lexIsAtEnd(lex) {
let c: uint32 = lexPeek(lex, 0);
if c == 32 || c == 9 || c == 13 { // space, tab, CR
if c == 32 || c == 9 || c == 13 {
discard lexAdvance(lex);
} else if c == 47 && lexPeek(lex, 1) == 47 { // //
lexSkipLineComment(lex);
} else if c == 47 && lexPeek(lex, 1) == 42 { // /*
discard lexAdvance(lex);
discard lexAdvance(lex);
lexSkipBlockComment(lex);
} else {
break;
if c == 47 && lexPeek(lex, 1) == 47 {
lexSkipLineComment(lex);
} else {
if c == 47 && lexPeek(lex, 1) == 42 {
discard lexAdvance(lex);
discard lexAdvance(lex);
lexSkipBlockComment(lex);
} else {
break;
}
}
}
}
}
+12 -8
View File
@@ -227,16 +227,20 @@ func lexSkipBlockComment(lex: *Lexer) {
func lexSkipWhitespace(lex: *Lexer) {
while !lexIsAtEnd(lex) {
let c: uint32 = lexPeek(lex, 0);
if c == 32 || c == 9 || c == 13 { // space, tab, CR
if c == 32 || c == 9 || c == 13 {
discard lexAdvance(lex);
} else if c == 47 && lexPeek(lex, 1) == 47 { // //
lexSkipLineComment(lex);
} else if c == 47 && lexPeek(lex, 1) == 42 { // /*
discard lexAdvance(lex);
discard lexAdvance(lex);
lexSkipBlockComment(lex);
} else {
break;
if c == 47 && lexPeek(lex, 1) == 47 {
lexSkipLineComment(lex);
} else {
if c == 47 && lexPeek(lex, 1) == 42 {
discard lexAdvance(lex);
discard lexAdvance(lex);
lexSkipBlockComment(lex);
} else {
break;
}
}
}
}
}