A general-purpose parser for Rust using Parsing Expression Grammars (PEG) with a focus on accessibility, correctness, and performance.
pest is a general-purpose parser library for Rust that uses Parsing Expression Grammars (PEG) to define and parse languages. It solves the problem of parsing complex languages by providing a clean, maintainable grammar definition separate from code, with a focus on accessibility, correctness, and performance.
Rust developers building parsers for domain-specific languages, configuration files, data formats, or any structured text that requires formal grammar definitions.
Developers choose pest for its elegant separation of grammar and code, meaningful error reporting, and robust PEG-based approach, which offers greater expressivity than regular expressions while maintaining performance and correctness.
The Elegant Parser
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Grammars are defined in .pest files, keeping them isolated from code for better maintainability and readability, as shown in the ident_list example.
Automatically generates human-readable error messages that pinpoint issues in input, like unexpected digits, based on grammar rules.
Derives a Parser that returns nested token pairs, enabling easy iteration over parsed structures, demonstrated in the main example with ident parsing.
Runs on stable Rust and supports embedded environments by disabling default features, making it versatile for various project types.
Includes support for operator precedence handling in grammars, simplifying expression parsing without extra code.
PEGs do not natively support left recursion, requiring grammar transformations that can complicate definitions for certain languages.
Defining multiple parsers in one file requires workarounds like separate namespaces, adding boilerplate and complexity for modular projects.
The ecosystem, while growing, lacks extensive IDE integrations or advanced debugging tools compared to more mature parser generators.
Although error reporting is automatic, integrating custom errors or advanced error handling can involve additional boilerplate and manual effort.