pest is a Rust parser generator driven by PEG grammars kept in separate .pest files. It emphasizes readable grammars, automatic error messages, and performance suitable for production parsers.
Overview
pest takes parsing expression grammars similar to regular expressions but expressive enough for programming languages. Grammars live in dedicated .pest files apart from application code, which keeps the language definition easy to read and maintain.
The generated parser reports line and column errors derived from grammar rules, such as unexpected digits or missing identifiers. A pairs API yields nested token iterators for walking parse trees, and multiple parsers can coexist using separate modules to avoid Rule enum name clashes.
The crate runs on stable Rust with optional no_std builds for embedded targets. Optional native stack guarding on common Linux, macOS, and Windows targets complements a separate call-limit budget for untrusted input.
Ecosystem resources include an official book, a web fiddle for experimenting with grammars, and precedence climbing and custom error hooks for advanced grammars.
Key features
- PEG grammar files separate from code
- Automatic syntax error reporting
- Pairs iterator API for parse trees
- Precedence climbing support
- no_std and embedded builds
- Optional native stack guard
- Stable Rust toolchain support
Use cases
- Parse domain-specific languages in Rust
- Build JSON or config parsers from grammars
- Prototype grammars in the online fiddle
- Embed parsers in constrained no_std firmware