Compiler: accept unnumbered programs, fix string concat in PRINT
Three fixes that lift seven test programs from skipped to passing, bringing the AOT compiler harness from 56/56 to 63/63. - Unnumbered programs (compiler_main.c): src/compiler_main.c skipped any line that didn't start with a digit, so direct-mode .bas files like hello.bas, math_ops.bas, string_ops.bas (no line numbers) failed with "No program lines found". load_file now auto-assigns line numbers (last_num + 10) to unnumbered lines, with overflow protection at line 65520. - String concatenation in PRINT (codegen.c): emit_str_atom had a broken concat loop that emitted "; _cat = gw_str_concat(&... _cat.sval ...)" — _cat was never declared, so any program with a string-literal concat in PRINT (like PRINT "ABC" + "DEF") failed to link. Concat is properly handled by emit_str_expr's outer loop; remove the dead/broken code in the atom. Fixes string_ops.bas. - Transcendental result type (codegen.c): peek_expr_type returned VT_DBL for ATN/LOG/EXP/VAL, so PRINT formatted them with 15-digit double precision (e.g. 3.141592653589793) while real GW-BASIC and the interpreter format the single-precision result as 3.141593. Real GW-BASIC's transcendentals are single-precision; only CDBL forces double. Demote ATN/LOG/EXP/VAL to VT_SNG; CDBL stays VT_DBL. Fixes math_ops.bas. Also: tests/run_compiler_tests.sh now runs the compiled binary from the project root rather than the tempdir where it was built, so test programs that reference tests/programs/ via relative paths (chain_test, common_test, run_file, misc_stmts) resolve their targets. Earlier I'd misdiagnosed those failures as ON ERROR divergence — they were just CWD-dependent path lookups. Doc/test counts: 56 → 63 in README, docs/index.md, docs/development.md, docs/roadmap.md. Roadmap updated to note the compiler now accepts unnumbered programs.
This commit is contained in:
+2
-2
@@ -26,8 +26,8 @@
|
||||
|
||||
72 automated test programs in `tests/programs/`, plus 4 classic interactive
|
||||
programs in `tests/classic/` (Hamurabi, Lunar Lander, Gunner, Diamond from
|
||||
David Ahl's *BASIC Computer Games*). 14 Jupyter kernel tests. 56 compiler
|
||||
tests (eligible numbered programs compiled to native executables via
|
||||
David Ahl's *BASIC Computer Games*). 14 Jupyter kernel tests. 63 compiler
|
||||
tests (eligible programs compiled to native executables via
|
||||
`gwbasic-compile`; run `bash tests/run_compiler_tests.sh`).
|
||||
|
||||
Run the full automated suite:
|
||||
|
||||
Reference in New Issue
Block a user