maiacc
v1.2.5
Published
MaiaCC (tREx): EBNF/XML to JavaScript lexer/parser generator.
Maintainers
Readme
MaiaCC Parser Generator (tREx)

A JavaScript parser generator that reads XML produced from EBNF grammars and emits a working JavaScript lexer/parser.
Process Documentation
Mandatory cross-repository synchronization workflow:
MaiaCC tREx
tREx.sh is a wrapper script that can:
- Generate a parser from an XML grammar.
- Accept an EBNF grammar, convert it to XML first, then generate a parser.
- Convert EBNF to XML only (without generating a parser).
The script is located at bin/tREx.sh.
For parser-generator internals and self-host details, see parser-generator/README.md.
Requirements
- Node.js 18+ (tested on Node.js 24).
Usage
Run from the project root so relative paths resolve correctly.
bash bin/tREx.sh [options] <grammar-file> [output-parser-file]Options
--ebnfTreat<grammar-file>as EBNF and convert it to XML first.--xmlTreat<grammar-file>as XML grammar (default).--to-xml <xml-file>Output XML path when using--ebnf.--only-xmlConvert EBNF to XML only, do not generate parser.-h,--helpShow help.
Common examples
1) Generate parser from XML
bash bin/tREx.sh parser-generator/examples/grammar.xml parser-generator/examples/arithmetic-parser.js2) Generate parser from EBNF
bash bin/tREx.sh --ebnf parser-generator/examples/sample-grammar.ebnf parser-generator/examples/arithmetic-parser.js3) Convert EBNF to XML only
bash bin/tREx.sh --ebnf --only-xml --to-xml parser-generator/examples/grammar.xml parser-generator/examples/sample-grammar.ebnfNotes
- If
--ebnfis used and--to-xmlis omitted, the XML output is inferred from the input name. --only-xmlrequires--ebnf.--to-xmlrequires--ebnf.
Related docs
parser-generator/README.md: generator internals, self-host flow, and test commands.- Compatibility note: for parser-based programs that use the default collector,
prefer
collector.parse(parser, inputLabel)to get enriched parse errors with line/column/offset. See the section "Error Location Reporting With ParseTreeCollector" inparser-generator/README.md.
