Parser/preprocess module:
- New src/parser/preprocess.rs handles source-level include inlining
- 'include "path"' at line start splices the target file's content
- Paths resolved relative to the including file's directory
- Circular include detection via visited set (canonicalized paths)
- Non-cycle re-includes allowed (sibling branches can reuse files)
main.rs:
- Both compile() and check() run preprocess_source() before parsing
- Include resolution failures produce a clear error message
Tests: 4 new preprocess unit tests (249 total)
- passthrough, include line parsing, temp-file roundtrip
https://claude.ai/code/session_01W6eQFStA66EuMKHUFo2rx3
Parser:
- p1.button.X and p2.button.X syntax
- Emits Expr::ButtonRead with Some(Player::P1) or Some(Player::P2)
- Plain button.X still works (defaults to P1)
- Removed #[allow(dead_code)] from Player::P1 and Player::P2
Runtime:
- NMI handler now reads both $4016 (JOY1) and $4017 (JOY2) in
the same loop, shifting 8 bits into ZP_INPUT_P1 ($01) and
ZP_INPUT_P2 ($08) simultaneously
- JOY2 register constant added
Codegen:
- Button reads select correct ZP address based on Player variant
- gen_condition and gen_expr both handle P1/P2 dispatching
Tests: 245 (3 new parser tests: p1/p2 button read + shift-assign)
https://claude.ai/code/session_01W6eQFStA66EuMKHUFo2rx3
Sprite/asset pipeline:
- Linker::link_with_assets() places sprite CHR data in ROM at correct tile
- assets::resolve_sprites() walks Program for inline sprite bytes
- CodeGen::with_sprites() maps sprite names to tile indices
- gen_draw() uses correct tile index from sprite declarations
- main.rs wires the full resolution pipeline
Shift-assign operators (<<= and >>=):
- AssignOp::ShiftLeftAssign and ShiftRightAssign variants
- Parser handles in both statement and array index contexts
- Codegen emits ASL A / LSR A
- IR lowering maps to ShiftLeft/ShiftRight ops
Unreachable state warning (W0104):
- BFS from start state finds reachable states via transitions
- States not reached produce W0104 warning
Error polish helpers:
- suggest_var_name() for "did you mean" suggestions
- emit_undefined_var() for E0502 with typo hints
- Used by analyzer for better diagnostics
242 tests pass, clippy clean.
https://claude.ai/code/session_01W6eQFStA66EuMKHUFo2rx3
Issues found by systematic review of all compiler modules.
Each fix includes a regression test.
Parser fixes:
- Add EOF checks to function call arg parsing loops (lines 984, 1269)
to prevent infinite loops on unterminated call expressions
- Fix span end positions: use .end instead of .start for 9 declaration
span computations (var, const, fun, state, bank, sprite, palette,
background, block)
- Add missing compound assignment operators (&= |= ^=) to
parse_assign_op() for array element assignments
Codegen fix:
- Fix NOT operator: old code used EOR #$FF + AND #$01 which produced
wrong results for non-boolean inputs (e.g., NOT 0x42 returned 1
instead of 0). New code uses BEQ/branch to properly map any nonzero
value to 0 and zero to 1.
Assembler fixes:
- Add branch offset range validation: assert offset is in -128..127
range instead of silently wrapping on overflow
- Panic on unresolved labels instead of silently leaving placeholder
0x00 bytes in the output
Verified non-issues (reviewer false positives):
- NMI P register: 6502 hardware pushes P automatically on NMI entry;
RTI restores it. PHP/PLP not needed.
- Controller read buffer: 8 iterations of LSR+ROL fully replace all
8 bits, so prior contents don't matter.
- advance() panic: tokens always has at least Eof from lexer.
4 new regression tests, 225 total.
https://claude.ai/code/session_01W6eQFStA66EuMKHUFo2rx3
README: project overview, quick start, feature list, example table
LICENSE: MIT
4 new examples covering all language features:
- arrays_and_functions: arrays, while loops, inline/regular functions
- state_machine: multi-state flow with on enter/exit handlers
- sprites_and_palettes: inline CHR data, palette switching, scroll, cast
- mmc1_banked: MMC1 mapper, bank declarations, software multiply
Parser fix: draw statement keyword-arg parsing now checks for ':'
lookahead before consuming an identifier, preventing it from eating
the next statement as a keyword argument (e.g., `i += 1` after a draw).
https://claude.ai/code/session_01W6eQFStA66EuMKHUFo2rx3