# topspeed-grammar Corpus harness for the historical **TopSpeed / JPI V3** dialect, using the sidecar grammar `compiler/src/TopSpeed-V3-M2.atg`. The sidecar is a *grammar* deliverable: it parses the TS-V3 dialect (pragmas, `H`/`C`/`B` literals, `::=`, anchored subranges, address constructors, `CLASS`/`IS`/`VIRTUAL`, manifest constants, tagless and trailing-`|` variant records, ...). Constructs the current backend cannot lower yet still **parse** and end with the standard `SemError(230)` marker (parse-now / lower-later), exactly like `M2.atg`. ## Build ```sh ./build.sh # -> build/TSM2 (build/ is git-ignored) ``` It copies the grammar, the frames and the V3 `SymTab`/`QbeGen`/`FileIO` sources into `build/`, runs `CR -m -C`, compiles with `gm2 -fiso` and links `TSM2`. Needs the project `CR` (`$HOME/Projets/Projets-Modula2/MyWork/CocoGm2/CR`) and GNU Modula-2. The sidecar uses **its own scanner frame** — `scanner.frm` in this directory — which adds TopSpeed **conditional compilation** `(*%T cond*)` / `(*%F cond*)` / `(*%E*)`: a `CondFilter` blanks the inactive regions of the source buffer (CR/LF kept) before scanning. The define set is `{_fdata, _mthread, _fptr, _fcall}` (see `InitDefs`); tune it there. V3's own `compiler/src/scanner.frm` is left untouched, so the sidecar never affects the self-hosting compiler. ## Corpus check ```sh ./corpus.sh [corpus-dir] # default: $HOME/bin/Dos/M2/TS-V3 ``` Runs `TSM2` over every `.DEF`/`.MOD`, copying each into a scratch tree so the `.LST` listings never touch the corpus, and reports: - **parse-OK** — only the deliberate `230`/semantic markers, - **syntax-bad** — a real Coco/R error (`'x' expected`, `invalid X`). Current result on the TS-V3 tree (662 files, 352 `.DEF` + 310 `.MOD`): **644 parse-OK / 18 syntax-bad** — see `docs/summary_topspeed-corpus.md`.