Browse Source

m2comp day wrap-up: steps 1-4 session note

Eric Streit 3 weeks ago
parent
commit
b37ae599fa
1 changed files with 50 additions and 0 deletions
  1. 50 0
      docs/session_steps1-4.md

+ 50 - 0
docs/session_steps1-4.md

@@ -0,0 +1,50 @@
+# m2comp sessions, steps 1–4 — day wrap-up
+
+Date: 2026-09-16. Built in one day, with E. directing grammar
+choices against Kowarsch (arXiv:1809.07080) and the Blaise pipeline
+as process reference.
+
+## Where we stand (all committed and tagged)
+
+| Step | Tag | Content | Suite |
+| ---- | --- | ------- | ----- |
+| 1 | m2comp-step1 | Coco/R lexer+parser, `gm2 -fiso`, LL(1)-clean | 3/3 |
+| 1.1 | m2comp-step1.1 | Bare subrange type, syntax showcase | 4/4 |
+| 2 | m2comp-step2 | SymTab semantic analysis (200–224, 230/232/233) | 19/19 |
+| 3 | m2comp-step3 | AST layer (Mössenböck recipe) + dump | 25/25 |
+| 4 | m2comp-step4 | MC64 tree-walking backend, `.MC4` under `mcint` | 41/41 |
+
+Layout: all sources in `m2comp/src/` (grammar, frames, FileIO,
+SymTab, AST, MGen, generated scanner/parser/driver), binary at
+`m2comp/M2comp`, tests in `m2comp/tests/` (check + reject + AST
+dump + execution with ExitCode values), docs in `m2comp/docs/`
+(per-step summaries, Kowarsch text, `AST.pdf`, `oberon-master/`
+reference, this note).
+
+## Hard-won facts (don't rediscover)
+
+- gm2 is multipass: `FORWARD` is rejected ("too many errors in
+  pass 3"); CR's `-m` flag comments forwards out; m2c has none.
+- Op-code ranges must be globally unique for tree-walk dispatch
+  (Add 0–2, Mul 10–14, Rel 20–27); overlap silently misroutes.
+- `51H`/`70H` store orders differ; use `70H` (`[addr, value]`).
+- Bodies emitted inline need jump-over (`Jmp/DefLabel`).
+- `| head` masks VM hangs (rc is head's); harness uses `timeout`
+  + rc checks; diverging programs fail fast.
+- `showcase.mod` diverges by construction (infinite regress);
+  check-only. `ok_proc` fixed to terminate.
+- Negative-vs-zero `D5` quirk reproduces byte-identically under
+  m2c — VM domain, avoided in tests.
+
+## Tomorrow: step 5 candidates (in priority order)
+
+1. `DEFINITION`/`IMPLEMENTATION` separate compilation
+   (multi-`.MC4`, `depCount` loader path) — biggest language gap.
+2. Opaque types + procedure types.
+3. `WITH` / `CASE` (grammar + SymTab already shaped for them).
+4. `LONGINT`/`LONGREAL` quads (`0C5–CC`, `0x12`).
+5. Debug listings / OPDF-style debug info.
+
+`SymTab` (`ByNum`, exports, bounds), `AST` (pnum/typ/aux/tag),
+`MGen` (scope stack, image assembly) are ready for all of these.
+Start with `./build.sh && ./run_tests.sh` (41/41, ~2 min).