summary_step1.md 1.6 KB

Step 1 — Phase-0 scaffolding (tag: step1)

Commit 18e40b8 — "Phase-0 scaffolding — M2c module-skeleton compiler, 4/4 tests green" (29 files, +2756).

Goal

Prove the toolchain end to end before any language work: Coco/R grammar → generated scanner/parser/driver → gm2 -fiso build → test runner, all inside a new m2c/ folder.

What was built

  • m2c/M2c.atg — module skeleton only: MODULE <name> ; [ BEGIN ] END <name> ., with an inline closing-name check (error 202). No declarations, statements, or symbol table.
  • m2c/compiler.frm — minimal driver (listing + StoreError, ChangeExtension, FileIO-based main), custom message for 202.
  • m2c/scanner.frm, m2c/parser.frm — proven FileIO-based Coco/R frames, reused from the earlier CocoGm2 work.
  • m2c/FileIO.def/.mod — I/O library, reused as-is.
  • m2c/build.sh — regenerate (CRFRAMES=. $CRBIN -m -C M2c.atg, CRBIN overridable), compile with gm2 -fiso, link via the two-phase module-list workaround; produces ./M2c.
  • m2c/run_tests.sh — expect_ok / expect_fail (checks .LST message text, since listings show messages, not codes).

Tests — 4/4

test result
ok_minimal MODULE M; BEGIN END M. accepted
ok_nobegin MODULE M; END M. accepted
bad_mismatch END N rejected with 202
bad_syntax missing . rejected with syntax error

Both SemError (202) and SynError paths verified working.

Notes

  • Grammar name M2c keeps generated modules short (M2cS/M2cP/M2c, no Coco/R truncation surprises).
  • m2comp/coco-chatgpt-doesntwork/ explicitly excluded from all work.