fuel_pest/lib.rs
1// pest. The Elegant Parser
2// Copyright (c) 2018 DragoČ™ Tiselice
3//
4// Licensed under the Apache License, Version 2.0
5// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT
6// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
7// option. All files in the project carrying such notice may not be copied,
8// modified, or distributed except according to those terms.
9#![cfg_attr(feature = "const_prec_climber", feature(const_fn_trait_bound))]
10
11//! # pest. The Elegant Parser
12//!
13//! pest is a general purpose parser written in Rust with a focus on accessibility, correctness,
14//! and performance. It uses parsing expression grammars (or [PEG]) as input, which are similar in
15//! spirit to regular expressions, but which offer the enhanced expressivity needed to parse
16//! complex languages.
17//!
18//! [PEG]: https://en.wikipedia.org/wiki/Parsing_expression_grammar
19//!
20//! ## Getting started
21//!
22//! The recommended way to start parsing with pest is to read the official [book].
23//!
24//! Other helpful resources:
25//!
26//! * API reference on [docs.rs]
27//! * play with grammars and share them on our [fiddle]
28//! * leave feedback, ask questions, or greet us on [Gitter]
29//!
30//! [book]: https://pest-parser.github.io/book
31//! [docs.rs]: https://docs.rs/pest
32//! [fiddle]: https://pest-parser.github.io/#editor
33//! [Gitter]: https://gitter.im/dragostis/pest
34//!
35//! ## Usage
36//!
37//! The core of pest is the trait [`Parser`], which provides an interface to the parsing
38//! functionality.
39//!
40//! The accompanying crate `pest_derive` can automatically generate a [`Parser`] from a PEG
41//! grammar. Using `pest_derive` is highly encouraged, but it is also possible to implement
42//! [`Parser`] manually if required.
43//!
44//! ## `.pest` files
45//!
46//! Grammar definitions reside in custom `.pest` files located in the crate `src` directory.
47//! Parsers are automatically generated from these files using `#[derive(Parser)]` and a special
48//! `#[grammar = "..."]` attribute on a dummy struct.
49//!
50//! ```ignore
51//! #[derive(Parser)]
52//! #[grammar = "path/to/my_grammar.pest"] // relative to src
53//! struct MyParser;
54//! ```
55//!
56//! The syntax of `.pest` files is documented in the [`pest_derive` crate].
57//!
58//! ## Inline grammars
59//!
60//! Grammars can also be inlined by using the `#[grammar_inline = "..."]` attribute.
61//!
62//! [`Parser`]: trait.Parser.html
63//! [`pest_derive` crate]: https://docs.rs/pest_derive/
64
65#![doc(html_root_url = "https://docs.rs/pest")]
66
67extern crate alloc;
68extern crate ucd_trie;
69
70#[cfg(feature = "pretty-print")]
71extern crate serde;
72#[cfg(feature = "pretty-print")]
73extern crate serde_json;
74
75pub use parser::Parser;
76pub use parser_state::{state, Atomicity, Lookahead, MatchDir, ParseResult, ParserState};
77pub use position::Position;
78pub use span::{Lines, Span};
79use std::fmt::Debug;
80use std::hash::Hash;
81pub use token::Token;
82
83pub mod error;
84pub mod iterators;
85mod macros;
86mod parser;
87mod parser_state;
88mod position;
89pub mod prec_climber;
90mod span;
91mod stack;
92mod token;
93#[doc(hidden)]
94pub mod unicode;
95
96/// A trait which parser rules must implement.
97///
98/// This trait is set up so that any struct that implements all of its required traits will
99/// automatically implement this trait as well.
100///
101/// This is essentially a [trait alias](https://github.com/rust-lang/rfcs/pull/1733). When trait
102/// aliases are implemented, this may be replaced by one.
103pub trait RuleType: Copy + Debug + Eq + Hash + Ord {}
104
105impl<T: Copy + Debug + Eq + Hash + Ord> RuleType for T {}