@choo-choo/parser-peg
v0.1.3
Published
PEG (peggy / PEG.js dialect) grammar parser for choo-choo.
Maintainers
Readme
@choo-choo/parser-peg
PEG (peggy / PEG.js dialect) grammar parser for Choo Choo railroad diagrams.
Parses a PEG grammar 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-pegExample
import { render } from "@choo-choo/core";
import { pegParser } from "@choo-choo/parser-peg";
const source = `
digit = "0" / "1"
pair = digit digit
`;
const parsed = pegParser.parse(source);
const pair = parsed.rules.find((r) => r.name === "pair")!;
const svg = render(pair.diagram);Learn more
License
MIT
