tree-sitter-bnf-tools documentation
A tree-sitter grammar for BNF, plus
ts-bnf-tool, a CLI that converts BNF grammars into tree-sitter grammar.js
notation.
Tutorial
- Getting started — the problem, the solution, installing, and a complete first example
- Syntax walkthrough — every construct of the BNF dialect, and what is not supported
- Grammar-level directives —
%extras,%conflicts,%inline,%supertypes,%axiom,%include - BNF → tree-sitter cheat sheet — every mapping on one page
- End-to-end: from
.bnfto a working parser —convertandhighlights - Analysing a grammar —
check,--summary,firsts - Formatting and refactoring —
format,rename - Visualising a grammar —
railroad,graph
Guides
- Editor setup — syntax highlighting for
.bnffiles in Neovim and other editors
The BNF dialect’s own grammar
The dialect is self-described in
grammar/bnf.bnf,
and its diagrams are generated by the tool itself:
- Railroad diagram (SVG)
- Rule-dependency graph (PDF)
Project
- README — overview and quick reference
- Repository
- Issues
- Changelog