Repository navigation
The first release: the library for Rust and Python, the fpeg command and the documentation.
- Grammars are plain text, read at runtime: rules and terminals written much like EBNF, named fields, operator precedence blocks, parameterized rules, keywords, flags, cuts and left recursion.
- Layout and context: blocks by indentation, and captures with back references.
- Modules:
%extendsbuilds a grammar on another, with...for the alternatives it inherits, and%importtakes single rules from others. The grammarscommon,jsonandpythoncome with fpeg as bases for your own. - Errors say where a parse failed and what was expected there. Labels and messages written in the grammar name a mistake, error alternatives give common mistakes a message of their own, and
%recoverlets a parse go on past mistakes and return a tree with error and missing items. !.is the end of the input. Where text is left, an error lists the end of the input among what was expected, inside terminals too. In a syntactic rule it skips ignored text first, and an error raised while skipping ends the parse.- The engine compiles a grammar to bytecode for a parsing machine, which builds a compact, lossless tree with exact spans. An optimizer leaves out work that a grammar seems to ask for, and limits on steps, depth and memory bound every parse.
- Python:
Grammar, views of the tree that make Python objects only for what you read, theTransformer, theInterpreter, theVisitorand value builders written in the grammar, errors shown with the line they stand in, andfpeg.python, which turns Python 3.15 source into the trees ofast. - The command line:
fpeg checkreports problems in a grammar with stable codes,fpeg parseparses inputs, andfpeg profileshows where a parse spends its work.