Skip to content

feat: the ISC grammar as a portable .parg artifact (278/285 tree-identical) - #781

Merged
ronaldtse merged 1 commit into
mainfrom
feat/isc-parg
Sep 30, 2026
Merged

ronaldtse merged 1 commit into
mainfrom
feat/isc-parg

Conversation

@ronaldtse

Copy link
Copy Markdown
Contributor

The ISC grammar as a portable .parg artifact — one grammar source for parsanol-ruby and parsanol npm.

lib/interscript/isc/grammar/isc.parg ports all 8 grammar-concern files (~55 rules) to the parsanol grammar language, compiled to a checksummed artifact (isc.artifact.json, committed like pubid-grammar's). The Ruby side parses through Parsanol::PARG::Artifact#parse — the envelope's grammar is the exact portable JSON the native engines register, so the npm side consumes the same artifact.

Differential gate (spec/support/parg_diff.rb): the artifact tree must equal the Ruby-DSL parser's tree (post-Normalizer) per map. Current standing on the 285-file corpus: 278 byte-identical (97.5%). The remaining 7:

  • 2 files the Ruby parser itself rejects (un-mar-Deva-Latn-2016, odni-bel-Cyrl-Latn-2015) — pre-existing, unrelated to the artifact
  • odni-kor-Hang-Latn-2015: comment-only parallel {} blocks — Ruby yields [], the artifact captures the comment; one routing shape to reconcile
  • var-kor-Hang-Latn-mr-1939: artifact-only parse failure under investigation (its constructs pass in isolation)
  • 3 further shape deltas of the same classes

Port invariants pinned by the gate (for the next grammar author):

  • repetitions are ABNF prefixes — 1*x, *x; a rule body of a bare repetition needs parens
  • x as name after a sequence binds the LAST primary — capture whole alternations/sequences with outer parens, or capture the rule reference at the use site
  • use-site captures on rule references nest inner captures exactly like parslet .as
  • the item continuation needs the cont_stop/item_atom_start guards, or to/before get eaten as concatenation atoms

Full suite: 1149 examples, 0 failures with CI-equivalent flags. Upstream perf work on the artifact path is tracked in parsanol-ruby#115 (root-caused, fixed in parsanol#160).

isc.parg — the whole grammar (8 concern files, ~55 rules) in the
parsanol grammar language: one source compiled to a checksummed
artifact that both parsanol-ruby and parsanol npm register natively.

Differential gate (spec/support/parg_diff.rb): the artifact tree must
equal the Ruby-DSL parser's tree (post-Normalizer) per map. Current
corpus standing: 278/285 byte-identical; the rest are 2 files the Ruby
parser itself rejects, one parallel-comment capture shape, one parse
failure under investigation.

Grammar-port invariants pinned by the gate: repetitions are ABNF
prefixes (1*x); captures on whole alternations need outer parens;
captures on rule references nest inner captures exactly like parslet
.as; the item continuation needs the cont_stop/item_atom_start guards
or 'to'/'before' get eaten as concat atoms.
@ronaldtse
ronaldtse merged commit e772d25 into main Sep 30, 2026
4 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant