maiacc
v1.6.1
Published
MaiaCC (tREx): EBNF/XML to JavaScript and C++98 parser generator.
Downloads
374
Maintainers
Readme
MaiaCC Parser Generator (tREx)

A parser generator that reads XML produced from EBNF grammars and emits a JavaScript or C++98 lexer/parser. JavaScript remains the default backend. C++98 supports UTF-8 source input as well as caller-provided tokens; see the generator API.
The parallel C++98 implementation includes
the frontend, grammar model and both emitters, with stable complete native
bootstrap generations. Use bin/tREx-cpp98.sh after its explicit bootstrap build.
Full generator execution through MaiaCpp/MaiaC to WASM is a separate validation gate.
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.
