@tabnas/bnf
v0.1.10
Published
Shared compiler for BNF-family grammar front-ends on the tabnas parser: grammar IR in, tabnas GrammarSpec out.
Maintainers
Readme
@tabnas/bnf
The shared compiler behind the BNF-family grammar front-ends for the tabnas parsing engine.
This package holds no notation of its own. It defines a grammar IR and
compiles it into a tabnas GrammarSpec; a front-end parses one concrete
syntax into that IR:
ABNF / GBNF / EBNF text ──front-end──▶ Grammar ──emitGrammarSpec──▶ GrammarSpec| Front-end | Notation |
|---|---|
| @tabnas/abnf | RFC 5234 ABNF |
| @tabnas/gbnf | llama.cpp GBNF |
| @tabnas/ebnf | EBNF (best effort) |
const { emitGrammarSpec } = require('@tabnas/bnf')
const spec = emitGrammarSpec({
productions: [
{ name: 'val', alts: [[{ kind: 'ref', name: 'add' }]] },
{ name: 'add', alts: [[{ kind: 'token', name: '#NR' }]] },
],
}, { tag: 'demo' })Everything downstream of the IR is shared and lives here: desugaring
repetition into helper rules, left-recursion elimination, tail-repeat
rewriting, the probe/rewind dispatcher for prefixes beyond the engine's
bounded lookahead, literal lifting, token allocation, first-set analysis,
and $stepN chain emission.
Full documentation, including the IR contract and the options table, is in the repository README.
Install
npm install @tabnas/bnf @tabnas/parserLicense
MIT. Copyright (c) 2026 tabnas.
