44 releases (7 stable)
|1.0.6||Feb 21, 2018|
|1.0.3||Jan 26, 2018|
|1.0.0-beta.17||Dec 19, 2017|
|1.0.0-beta.16||Oct 21, 2017|
|0.3.2||Jun 28, 2016|
#4 in Parsing tools
36,329 downloads per month
pest is a PEG parser built with simplicity and speed in mind.
pest works mainly through a
Parser, which provides an interface to the parsing
Parser is a
trait, parsing needs to be defined either though the
#[derive(Parser)] attribute, or manually through the
The use of the
derive is highly encouraged since this is the only way you can make use of
pest's PEG grammar, while manual parser definition can be used where highly specific or
efficient parsing is required.
pest comes with a procedural macro crate--
pest_derive--which needs to be included in
Cargo.toml in order to enable the
pest_derive = "*"
Grammar definitions reside in custom
.pest files located in the
src directory. Their path is
src and is specified between the
derive attribute and an empty
Parser will be derived on.
Because of a limitation in procedural macros, there is no way for Cargo to know that a module
needs to be recompiled based on the file that the procedural macro is opening. This leads to the
case where modifying a
.pest file without touching the file where the
derive is does not
recompile it if it already has a working binary in the cache. To avoid this issue, the grammar
file can be included in a dummy
const definition while debugging.
#[cfg(debug_assertions)] const _GRAMMAR: &'static str = include_str!("path/to/my_grammar.pest"); // relative to this file #[derive(Parser)] #[grammar = "path/to/my_grammar.pest"] // relative to src struct MyParser;
The grammar of
.pest files is documented in the
- No runtime deps