summary_step8.3.md 2.4 KB

V3 step 8.3 — QbeGen compiles clean; empty statements; 1-char strings (105/105)

Both hand-written compiler modules now compile clean under V3.

What landed

  1. Within-module forward procedure calls (gm2-compatible sources). QbeGen.mod calls 10 internal helpers before their definitions. gm2's FORWARD is unusable (its whole-program pass errors with too many errors in pass 3 — reproduced with a minimal module), and reordering cascades through NewTemp/Op3L/Revive/ HeapSize/InitStack. Fix: declare the 10 helpers in QbeGen.def (its role is already "everything the generated parser needs"), so they are visible throughout the implementation. ArrData/HeapSize signatures use INTEGER in both def and impl.

  2. Single-character string literals for ARRAY OF CHAR. "(", "0", "$" etc. were typed CHAR, so W("(") reported "invalid call". New QbeGen.DeclCharStr synthesizes the equivalent 1-char string descriptor; ActParam uses it when the formal is an array of CHAR and the actual is an immediate CHAR. This cleared all 85 remaining QbeGen errors.

  3. Empty statements. StatSeq = Statement { ";" [ Statement ] } accepts ;;, lone ; and trailing ; — required because Coco/R emits ;; in the generated M2P.mod. New test tests/t_emptystat.mod (42). Also removed a stray END;; in QbeGen.mod.

Result

  • SymTab.def/.mod: clean (step 8.2).
  • QbeGen.def/.mod: clean (this step).
  • Suite 105/105, build warning-free.

Remaining self-hosting gaps (measured)

Coco/R-generated sources src/M2S.mod (30 errors), src/M2P.mod, src/M2.mod:

  • Procedure types are unsupported: GetCH = PROCEDURE (INT32): CHAR; and procedure variables (CurrentCh: GetCH;), and the Error: PROCEDURE (...) callback in M2S.def. This is the main M2S blocker (invalid Type, then cascade). Likely step 9.
  • INT32 (a FileIO.INT32 alias) is seen as "not a type name" in M2S.mod var/param types — need to confirm once procedure types parse.
  • Host FileIO open-file cap: MaxFiles = BitSetSize (16) blocks compiling all ~16 compiler modules in one driver session (Too many files). Raise it, or use the self-hosted FileIO (stage-2 syslib) whose limit can be larger.

Files

compiler/src/{QbeGen.def,QbeGen.mod,M2.atg}, compiler/tests/t_emptystat.mod, compiler/run_tests.sh.