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

Download history 10125/week @ 2018-07-06 11398/week @ 2018-07-13 12664/week @ 2018-07-20 11540/week @ 2018-07-27 13421/week @ 2018-08-03 12604/week @ 2018-08-10 12381/week @ 2018-08-17 12092/week @ 2018-08-24 12500/week @ 2018-08-31 13975/week @ 2018-09-07 14126/week @ 2018-09-14 12856/week @ 2018-09-21 11724/week @ 2018-09-28

36,329 downloads per month
Used in 223 crates (42 directly)

MIT/Apache

691KB
11K SLoC

../README.md


lib.rs:

pest. The Elegant Parser

pest is a general purpose parser written in Rust with a focus on accessibility, correctness, and performance. It uses parsing expression grammars (or PEG) as input, which are similar in spirit to regular expressions, but which offer the enhanced expressivity needed to parse complex languages.

Getting started

The recommended way to start parsing with pest is to read the official book.

Other helpful resources:

  • API reference on docs.rs
  • play with grammars and share them on our fiddle
  • leave feedback, ask questions, or greet us on Gitter

Usage

The core of pest is the trait Parser, which provides an interface to the parsing functionality.

The accompanying crate pest_derive can automatically generate a Parser from a PEG grammar. Using pest_derive is highly encouraged, but it is also possible to implement Parser manually if required.

.pest files

Grammar definitions reside in custom .pest files located in the crate src directory. Parsers are automatically generated from these files using #[derive(Parser)] and a special #[grammar = "..."] attribute on a dummy struct.

#[derive(Parser)]
#[grammar = "path/to/my_grammar.pest"] // relative to src
struct MyParser;

The syntax of .pest files is documented in the pest_derive crate.

Dependencies

~112KB