grammar-to-marser — grammar → Marser Rust converter
Start with a grammar example
Convert a Pest or PEG grammar into a ready-to-run Rust parser in your browser using Marser.
Pick Pest or PEG at the top.
Paste your own grammar or load an example to see live Rust output.
When it looks right, download a Cargo project with the generated parser.
The downloaded project includes a README with next steps like AST shaping, error recovery, diagnostics, and tracing.
Try an example<br>Take the tour
Don't show this again
Download Cargo project
Creates a .zip with a complete, ready-to-build Rust project — your grammar file, the generated parser in src/grammar.rs, a Cargo.toml, and a README with next steps.
Project name
Cancel<br>Download .zip
Grammar input
Copy
Generated parser
Copy<br>Download project<br>Share
Rule comments
Trace markers
Errors<br>Copy errors
Grammar reference
Supported
Grouping, sequences, and choice: (...), ~, |
Predicates and repetition: &, !, ?, *, +, {n}, {n,}, {,n}, {n,m}
Rule modifiers: silent _, atomic @, compound atomic $, non-atomic !
Strings, case-insensitive strings, ranges, and node tags: "...", ^"...", 'a'..'z', #name = expr
Implicit trivia via WHITESPACE and COMMENT rules
Builtins: SOI, EOI, ANY, NEWLINE, ASCII_DIGIT, ASCII_NONZERO_DIGIT, ASCII_BIN_DIGIT, ASCII_OCT_DIGIT, ASCII_HEX_DIGIT, ASCII_ALPHA_LOWER, ASCII_ALPHA_UPPER, ASCII_ALPHA, ASCII_ALPHANUMERIC
Right and mutual recursion, up to 12 rules per recursive group
Pest book ↗ · Marser docs ↗
Not yet supported
Stack constructs: PUSH, PUSH_LITERAL, POP, POP_ALL, DROP, PEEK, PEEK_ALL
Left recursion
Recursive groups larger than 12 rules
Pest-style Pair trees, spans, or .memoized()
Some unsupported constructs are still parsed so the editor can point at them precisely, but conversion fails with an explicit error. Generated output returns a typed Parsed enum with one variant per rule; tagged binds become named fields and leaf rules store their matched slice as value.
Supported
Sequences (juxtaposition), choices (/), repetition (* + ?)
Grouping and predicates: (), &, !
String literals, char literals, character classes, and any-character: "...", 'x', [a-z], .
Rule references and tagged binds: name, name=term, #name=term
// line comments
PEG (Wikipedia) ↗ · Marser docs ↗
Differences from Pest
No implicit whitespace — add explicit whitespace rules where needed
Left recursion is not supported
Mutual recursion groups larger than 12 rules
Generated output returns a typed Parsed enum with one variant per rule; tagged binds become named fields and leaf rules store their matched slice as value.
Trace markers
Adds .trace() calls to every rule in the generated parser. When you build and run with the parser-trace feature, each rule attempt and match result is recorded to a JSON file.
Open that file in marser-trace-viewer — a terminal UI where you can step through every parsing decision and see exactly where your grammar matches, backtracks, or fails on a given input.
i step into<br>s step over<br>u step out<br>⌫ jump back<br>q quit
Tracing guide ↗<br>marser-trace-viewer ↗<br>Close
Skip<br>Next