summary_step8.1.md 2.2 KB

V3 step 8.1 — Redux sweep of the compiler sources (done 2026-09-22)

Step-8 prep: make V3 able to compile the compiler's own sources by removing gm2-dialect syntax from them (Kowarsch/Redux cleanups). Suite 103/103, build warning-free.

The sweep

A scripted conversion (skipping string literals and (* *) comments) applied to M2.atg, SymTab.mod, QbeGen.mod, compiler.frm, parser.frm, scanner.frm:

  • & → AND, ~ → NOT, <> → #.
  • Octal char-code literals NNC → CHR(decimal) (0C→CHR(0), 15C→CHR(13), 32C→CHR(26), 177C→CHR(127), …).

(FileIO.def/.mod untouched — it stays the host library for the stage-1 build.)

Result: the sources are Redux-clean and still compile under gm2; the full suite is green. Generated M2S/M2P/M2 are regenerated from the swept frames/grammar.

V3 grammar: lenient SYSTEM imports

FROM SYSTEM IMPORT TSIZE; (and any pervasive name) now parses: TSIZE/SIZE/ADR/HIGH/LEN/CHR/ORD/VAL/ABS/INC/DEC are accepted as import items and ignored (the built-in applies). gm2 still needs the import, V3 ignores it — one source, both compilers.

Gap analysis: V3 compiling SymTab (still fails)

Running V3 over SymTab.def + SymTab.mod (with Storage, SysShim, FileIO) surfaces the next work:

  1. Named-CONST folding. Array/subrange bounds like ARRAY [0 .. MaxPend - 1] are "not supported yet": the grammar only folds literals (ConstInt on an immediate), while a named CONST loads as a temporary. V3 must fold constant expressions (named CONSTs, +/-) at compile time. This is the dominant cause of the mass of 230s.
  2. Type-operand TSIZE/SIZE. TSIZE(ScopeNode) passes a type name, not a designator; V3's built-in takes a designator.
  3. Cascading parser errors (ident expected at END of records, stray 201s) that clear once the above are fixed.

These are the core of step 8 proper (plus cross-stage FileIO selection and the fixpoint script).

Files

compiler/src/M2.atg (lenient imports; swept actions), SymTab.mod, QbeGen.mod, compiler.frm, parser.frm, scanner.frm (Redux-clean). Harness/suite unchanged (103/103).