A Parsing Expression Grammar (PEG) parser generator for Rust that builds recursive descent parsers from concise grammar definitions.
rust-peg is a parser generator for Rust that allows developers to define parsers using Parsing Expression Grammars (PEGs) through a convenient macro. It solves the problem of writing reliable and maintainable parsers by generating recursive descent parsers from concise grammar definitions, eliminating much of the boilerplate typically associated with parser implementation.
Rust developers who need to parse custom file formats, domain-specific languages, or complex data structures and want a type-safe, embeddable parser generator with good error reporting.
Developers choose rust-peg for its simplicity, flexibility in input types, helpful error messages, and the ability to embed Rust code directly within grammar rules while benefiting from PEG's deterministic parsing behavior and precedence climbing for expressions.
Parsing Expression Grammar (PEG) parser generator for Rust
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Supports parsing from &str, &[u8], &[T], or custom types implementing traits, as noted in the features, allowing versatile integration with different data sources.
Provides automatic handling of operator precedence for expressions, simplifying the parsing of mathematical or logical syntax without manual work.
Generates clear rustc error messages for grammar errors and offers customizable parse error reporting tools, enhancing debuggability.
Allows rules to accept arguments, enabling reusable grammar components for complex parsers, as highlighted in the comparison table.
Unlike nom, rust-peg cannot parse input in chunks, limiting its use for very large datasets that cannot fit entirely in memory, as indicated in the feature comparison.
Parsing Expression Grammars have inherent constraints, such as difficulty with left-recursive rules, which may require workarounds or alternative approaches for some grammars.
Being a procedural macro, it might cause issues with IDE support, increase compile times, or complicate build processes compared to library-based solutions like nom.