Expand description
Emit an ABNF representation of an instance’s live grammar.
This reads ONLY the running engine (options + installed rule specs); it
never depends on @tabnas/abnf. That independence is a hard constraint
— the emitter is the inverse of abnf’s forward encoding, and proving it
with abnf as a dependency would be circular.
The mapping: tabnas rules become ABNF productions, OPEN alts become
/-separated alternatives, the token sequence (s) plus any
push/replace target (p/r) becomes a space-separated element list,
and each token resolves to an ABNF terminal via the fixed-literal /
match-regex config.
Actions carry no ABNF meaning and are ignored. Constructs that cannot be represented (an arbitrary match regex, say) are emitted as ABNF comments, so the output stays valid and self-documenting even though such rules will not round-trip.
Ported from ts/src/debug.ts (emitAbnf and friends), which is
canonical.
Functions§
- abnf
- Emit the ABNF for
parser’s live grammar.