PRINT USING: embed token bytes in generated C and call gw_print_using()
at runtime. Variable values synced to interpreter table before the call
so gw_eval() can resolve them. Unlocks fibonacci, temp_table, calendar.
STRING$ (single-byte token 0xD4): handle in emit_str_expr and PRINT
string detection. Emits gw_fn_strings() call.
INSTR (single-byte token 0xD6): handle in emit_atom with start position
detection. Emits gw_fn_instr() call.
PRINT USING token skip fix: skip past TOK_USING before embedding bytes
(gw_print_using expects text_ptr after USING, not at it).
27 of 72 tests now pass. New: fibonacci, calendar, temp_table.
Array name emission: use emit_name_str() to avoid null bytes in C string
literals when variable name has only one significant character.
Combined relationals: handle <=, >=, <> token pairs (TOK_LT+TOK_EQ etc.)
in the precedence climber. Previously these emitted "unknown tok 0xe5"
which broke WHILE X <= 10 and similar conditions.
Expression type tracking: peek_expr_type() determines VT_INT/VT_SNG/VT_DBL
from the leading token in PRINT expressions. PRINT now emits the correct
gw_value_t type for proper number formatting (single vs double precision).
23 of 72 tests now pass (up from 19). New: arrays, hailstone, while_wend,
prime_sieve, leibniz.
Arrays: DIM creates arrays via gwrt_dim() runtime call. Array element
read/write uses gwrt_array_elem() with buffered subscript expressions
(open_memstream) to correctly determine dimension count. Auto-DIM with
default size 10 for undeclared arrays.
Number formatting: PRINT now uses gw_print_value() (same as interpreter)
instead of gwrt_print_sng(), producing correct type-specific output.
OPEN fix: analysis pass skips OPEN statement arguments to avoid
misidentifying OUTPUT/INPUT/APPEND as variable names.
OPEN/CLOSE/INPUT: emit skip stubs (file I/O compilation is Phase 3).
19 of 72 tests now pass (up from 17). New: hanoi, text_adventure.
Add WHILE/WEND, ON n GOTO/GOSUB, ON ERROR GOTO, DIM (stub), SWAP,
POKE, DEF SEG, RANDOMIZE, COLOR, LOCATE, SCREEN, WIDTH, KEY, WRITE,
OPTION BASE, DEFINT/DEFSNG/DEFDBL/DEFSTR, TRON/TROFF.
Fix MOD/IDIV/POW operators: buffer left operand via open_memstream so
both sides can be properly cast (MOD/IDIV → int16_t, POW → pow()).
Previously MOD on float operands was a C compile error.
Handle all extended statement tokens (0xFE prefix): graphics, sound,
file I/O, view/window, environ, timer — either with real codegen or
graceful skip.
17 of 72 tests now pass (up from 15). 26 compile errors (down from 30).
- FOR/NEXT: use a FOR stack to match NEXT variables to their corresponding
FOR labels, fixing nested loops (e.g., FOR I...FOR J...NEXT J...NEXT I)
- Remove unused emit_int_expr function
- Build now zero warnings across all targets
- Compiler passes 15 of 72 test programs (Phase 1 target: ~30)
- codegen.c: refactor one-liner function cases to proper multi-line blocks,
eliminating all -Wmisleading-indentation warnings
- codegen.c: escape quotes and backslashes in DATA pool string literals
- codegen.c: guard NEXT against for_label_counter=0 (NEXT without FOR)
- codegen.c: remove unused functions (emit_expr, read_sng, read_dbl)
- analysis.c: add bounds check on data_line_map writes
- Build now produces zero warnings across all three targets