Fix five defects the port uncovered in the reference parser and scanner

Chained subtraction and exponentiation fold left instead of abandoning the
rest of the line -- `1 - 2 - 3` gave -1 and dropped the `- 3`. A unary leaf's
operand moves to .left, so a negative literal is one argument again and a
second argument no longer overwrites it. An operator in a line's final column
survives. Hex literals reach the parser whole. A leading zero is padding, not
a radix.

Item 16 stays pinned: the fix works and costs an upstream golden case, which
is a decision rather than a defect.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-31 11:35:14 -04:00
parent f24201fdef
commit 1eb8f9ffaa
14 changed files with 272 additions and 167 deletions

View File

@@ -1,6 +1,9 @@
10 REM The reference selects base 8 for any lexeme starting with 0, so 010 is 8
20 REM and 08 is a parse error. Commodore BASIC has no octal literals -- this is
30 REM TODO.md section 6 item 10, reproduced deliberately until it is fixed on
40 REM purpose. Pinned here so the eventual fix has to change a golden file.
50 PRINT 010
60 PRINT 08
10 REM A leading zero is padding, not a radix. The reference selects base 8 for
20 REM any lexeme starting with 0, so 010 printed 8 and 08 was a parse error --
30 REM TODO.md section 6 item 10, fixed. Commodore BASIC has no octal literals.
40 REM 0x is the one prefix that changes the base, and it now reaches the scanner
50 REM whole: that was section 6 item 15.
60 PRINT 010
70 PRINT 08
80 PRINT 0xff
90 PRINT 0x10 + 1