summary_step1.md 1.9 KB

V3 step 1 — minimal integer pipeline (done 2026-09-19)

End-to-end: Modula-2 source → Coco/R frontend → SymTab checks → fresh QbeGen → gen_ssa/<Mod>.ssa → qbe → cc → native binary returning ExitCode. Blaise Phase-1 equivalent (bootstrap pipeline).

Subset

MODULE + CONST (signed literal) + VAR .. : INTEGER + assignment + integer expressions (+ - * DIV MOD, leading sign, parens, H hex). Errors: 200/201/202/210/211/221 + step-1 230s (REAL/STRING literals, non-INTEGER VAR type, non-literal CONST, imported names as values). Grammar is LL(1)-clean (Compilation completed. No errors detected.); one conflict found and fixed during the step (trailing ; in StatSeq).

Files

  • compiler/src/M2.atg (fresh, ~250 lines) — the interactive artefact.
  • compiler/src/QbeGen.def/.mod (fresh) — Test2-compatible signatures (LoadVar/StoreVar/Op3/NegQ keep isReal params) so step 2 grows without ATG rewrites. Deterministic %tN counters (fixpoint-safe).
  • Reused proven: FileIO, SymTab (full Test2 copies), scanner/parser/compiler.frm (230 text retargeted to step 1).
  • compiler/build.sh, compiler/run_tests.sh, 5 tests.

Results — 5/5

3 run (t_minimal→0, t_exit→7, t_arith→25: precedence, DIV truncation, hex 10H=16, CONST loads) + 2 reject (201 undeclared, 202 name mismatch). Verified TArith.ssa by hand.

Known step-1 limits (each a later step)

  • Assignment targets emit a dead load before the store (valid QBE, inherited Test2 inefficiency).
  • DIV/MOD are truncating (C/QBE semantics, not Modula-2 floor).
  • No TYPE, no procedures, no composites, no U-literals — all syntax errors today, 230s where tokens exist (real/string).
  • gen_ssa/ binaries/logs are build outputs (gitignored).

Next: step 2 (scalar type system: REAL/BOOLEAN/CHAR/enum, relations, IF/WHILE) reusing the same harness.