summary_m2comp_step1.1.md 2.0 KB

m2comp step 1.1 — bare subrange type + syntax showcase (tag: m2comp-step1.1)

Follow-up to step 1 (m2comp-step1): one grammar fix found while writing a full-syntax showcase, plus the showcase itself as a regression test.

Grammar fix

  • Type was missing the bare-subrange alternative [lo .. hi] (only IndexType had it), so TYPE Sub = [0 .. 9]; failed with invalid Type. Added the alternative to Type, mirroring SimpleType in m2c/pimmod2.atg. Still LL(1)-clean, rebuilt via build.sh (M2compP.mod regenerated).

Showcase — tests/showcase.mod (accepted)

Exercises every M2comp.atg production in one program module:

  • both IMPORT forms (FROM In IMPORT x, IMPORT y, z);
  • CONST with decimal, 0FFH hex, reals (3.14, 2.0E+3), both string quotes, unary-minus expr (-N + 2);
  • all six Type alternatives: qualified+subrange (INTEGER[1..N]), bare [0..9], abbreviated 2-D ARRAY, RECORD/empty record, SET OF, POINTER TO;
  • procedures with VAR params, function result, nesting;
  • local MODULE with [Priority], FROM..IMPORT, EXPORT QUALIFIED, own procedure + BEGIN init body;
  • all statement forms: assign, calls (with/without parens, bare), IF/ELSIF/ELSE, WHILE, REPEAT/UNTIL, LOOP/EXIT, FOR/BY, RETURN with and without expression;
  • all relations (= # <> < <= > >= IN), OR/AND/NOT/DIV/MOD, +x, -Factor (-k + 1), ^ deref, multi-index m[1,2], dotted Local.q, nested (* *) comments.

Tests — 4/4 (run_tests.sh)

test result
ok_minimal accepted
ok_proc accepted
showcase accepted
bad_mismatch rejected (Incorrect source)

Notes

  • Two test-authoring slips (not grammar bugs): local MODULE declarations need ; not . (END Local;).
  • Still open from step 1: drop <> (§2.2)? (*$ *) pragma section (§2.3/2.4)? Nested-ARRAY OF ARRAY long-form flag (step-2 semantic check)?
  • Next: step 2 SymTab (200/201/202/210-224 checks) + MC64 backend.