@choo-choo/parser-ebnf
v0.1.3
Published
EBNF (ISO/IEC 14977 subset) grammar parser for choo-choo.
Maintainers
Readme
@choo-choo/parser-ebnf
EBNF (ISO/IEC 14977 subset) grammar parser for Choo Choo railroad diagrams.
Parses an EBNF source string and returns an ordered list of rules, each with an IR tree ready to render.
Install
npm install @choo-choo/core @choo-choo/parser-ebnfExample
import { render } from "@choo-choo/core";
import { ebnfParser } from "@choo-choo/parser-ebnf";
const source = `
digit = "0" | "1" ;
pair = digit , digit ;
`;
const parsed = ebnfParser.parse(source);
const pair = parsed.rules.find((r) => r.name === "pair")!;
const svg = render(pair.diagram);Learn more
License
MIT
