summaryrefslogtreecommitdiffstats
path: root/vendor/pest_meta
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--vendor/pest_meta/.cargo-checksum.json2
-rw-r--r--vendor/pest_meta/Cargo.toml10
-rw-r--r--vendor/pest_meta/_README.md43
-rw-r--r--vendor/pest_meta/src/ast.rs31
-rw-r--r--vendor/pest_meta/src/grammar.rs2
-rw-r--r--vendor/pest_meta/src/lib.rs138
-rw-r--r--vendor/pest_meta/src/optimizer/mod.rs27
-rw-r--r--vendor/pest_meta/src/parser.rs124
-rw-r--r--vendor/pest_meta/src/validator.rs61
9 files changed, 270 insertions, 168 deletions
diff --git a/vendor/pest_meta/.cargo-checksum.json b/vendor/pest_meta/.cargo-checksum.json
index 5a98eadb3..af5eb5bec 100644
--- a/vendor/pest_meta/.cargo-checksum.json
+++ b/vendor/pest_meta/.cargo-checksum.json
@@ -1 +1 @@
-{"files":{"Cargo.toml":"3673efe1bf8eb36b5ae86959a918a846040826779babf8729a2725d651a6d035","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","_README.md":"01ba71f02581f9f5018962e083ca77bc8e8af2b6f8a73111bfa04e847a6440e2","src/ast.rs":"782e31c3e3ad194209975d9515b5df42883f7b7e316cd342e4603bcd5b3ec8d6","src/grammar.pest":"697e32f6fee403c3199317404891481b13dee127b956d6c3ec5a6a6116d18921","src/grammar.rs":"ed08400f1d37fee264359077666a02df0b6ac0d52500040b1157957502ab04ad","src/lib.rs":"8773adeac67a4c7de66f129f0d88fcf88748acc9a44b32949d7e1a3bcd338448","src/optimizer/concatenator.rs":"b77e6ec1d4d79d5383c74435d86e888a048c134fc5cff250356de9405e0ecfab","src/optimizer/factorizer.rs":"ffe510cc8c33fdb89c2a4e575f4d54f7894f126e71e6ae010d9614679d26254e","src/optimizer/lister.rs":"706812c52df72753071bf2db039dffb1061c1a0f030e4c1af67302c632ff15cd","src/optimizer/mod.rs":"18daf1ee2e6789ee4c9afddd34e1081364c7b30b2163ca0c6bf843fee865420e","src/optimizer/restorer.rs":"8b65cfe7dfd4d812bee6ac3cdbcc3d0026e03fd2b456a7c866dd83e6fdbf26a7","src/optimizer/rotater.rs":"7256bc8c01a09c5489fdb8d1cc52461bcc5ccf826db478b1420b01473b9b6c62","src/optimizer/skipper.rs":"8a7cd27713c8ffc795a82471242225b5fbbecec221c75fe8ac48e878d5a6088e","src/optimizer/unroller.rs":"f4010f2bf3b2bb0740d17b04c73f772284f576bfb57b9cac16b98293168ffb7a","src/parser.rs":"11b030a345afb092d1a66cf1481c6653f3d192e585632fbe8fa5641b771e5236","src/validator.rs":"97be65d88cc064c0857deb3ab73c3373560882e454c6ed2cd6a4a9d8d773beaf"},"package":"1538eb784f07615c6d9a8ab061089c6c54a344c5b4301db51990ca1c241e8c04"} \ No newline at end of file
+{"files":{"Cargo.toml":"fdca38afe81ce810dd1adcd190ce4b37ceb5d15afab9b6c79157f10b706a7835","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","_README.md":"190b4279777e3cd3c5adf3258114b89be536fc647d819620ada15be39d2259cc","src/ast.rs":"afaa813cf8299fd0762d7db504a9a84d2c42f2fc8a1eede5ea5e2f7e50fb3a86","src/grammar.pest":"697e32f6fee403c3199317404891481b13dee127b956d6c3ec5a6a6116d18921","src/grammar.rs":"d837889d938d6b3c7b7024071d1a1f57fdb0469ed730d196967fb57477d9fbf6","src/lib.rs":"a8cfd7c64bbd2b9dc9f0d21b4f3a6139095ead0964f12da86f4ee8079e546c1e","src/optimizer/concatenator.rs":"b77e6ec1d4d79d5383c74435d86e888a048c134fc5cff250356de9405e0ecfab","src/optimizer/factorizer.rs":"ffe510cc8c33fdb89c2a4e575f4d54f7894f126e71e6ae010d9614679d26254e","src/optimizer/lister.rs":"706812c52df72753071bf2db039dffb1061c1a0f030e4c1af67302c632ff15cd","src/optimizer/mod.rs":"f4ccfb4d133f769ae2e95f66fb71c404079d12d4aaafce10134c98e6e6170931","src/optimizer/restorer.rs":"8b65cfe7dfd4d812bee6ac3cdbcc3d0026e03fd2b456a7c866dd83e6fdbf26a7","src/optimizer/rotater.rs":"7256bc8c01a09c5489fdb8d1cc52461bcc5ccf826db478b1420b01473b9b6c62","src/optimizer/skipper.rs":"8a7cd27713c8ffc795a82471242225b5fbbecec221c75fe8ac48e878d5a6088e","src/optimizer/unroller.rs":"f4010f2bf3b2bb0740d17b04c73f772284f576bfb57b9cac16b98293168ffb7a","src/parser.rs":"0f9360ffbfef6d4cd083c868f0a28c87709997205d3966965815ea42b4ee0789","src/validator.rs":"ccb901e1f1c5762f9b2d958aa9b7da1091cff1406e3129debc69e97e90a88755"},"package":"984298b75898e30a843e278a9f2452c31e349a073a0ce6fd950a12a74464e065"} \ No newline at end of file
diff --git a/vendor/pest_meta/Cargo.toml b/vendor/pest_meta/Cargo.toml
index 347b7db37..e08ede441 100644
--- a/vendor/pest_meta/Cargo.toml
+++ b/vendor/pest_meta/Cargo.toml
@@ -10,10 +10,10 @@
# See Cargo.toml.orig for the original contents.
[package]
-edition = "2018"
+edition = "2021"
rust-version = "1.56"
name = "pest_meta"
-version = "2.3.0"
+version = "2.5.2"
authors = ["Dragoș Tiselice <dragostiselice@gmail.com>"]
exclude = ["src/grammar.pest"]
include = [
@@ -24,7 +24,7 @@ include = [
"LICENSE-*",
]
description = "pest meta language parser and validator"
-homepage = "https://pest-parser.github.io/"
+homepage = "https://pest.rs/"
documentation = "https://docs.rs/pest"
readme = "_README.md"
keywords = [
@@ -41,8 +41,8 @@ repository = "https://github.com/pest-parser/pest"
version = "1.8.0"
[dependencies.pest]
-version = "2.3.0"
+version = "2.5.2"
-[build-dependencies.sha-1]
+[build-dependencies.sha1]
version = "0.10"
default-features = false
diff --git a/vendor/pest_meta/_README.md b/vendor/pest_meta/_README.md
index f91188ccb..da30ab74e 100644
--- a/vendor/pest_meta/_README.md
+++ b/vendor/pest_meta/_README.md
@@ -5,8 +5,8 @@
# pest. The Elegant Parser
-[![Join the chat at https://gitter.im/dragostis/pest](https://badges.gitter.im/dragostis/pest.svg)](https://gitter.im/dragostis/pest?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
-[![Book](https://img.shields.io/badge/book-WIP-4d76ae.svg)](https://pest-parser.github.io/book)
+[![Join the chat at https://gitter.im/pest-parser/pest](https://badges.gitter.im/dragostis/pest.svg)](https://gitter.im/pest-parser/pest?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
+[![Book](https://img.shields.io/badge/book-WIP-4d76ae.svg)](https://pest.rs/book)
[![Docs](https://docs.rs/pest/badge.svg)](https://docs.rs/pest)
[![pest Continuous Integration](https://github.com/pest-parser/pest/actions/workflows/ci.yml/badge.svg)](https://github.com/pest-parser/pest/actions/workflows/ci.yml)
@@ -31,25 +31,28 @@ 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]
+* find previous common questions answered or ask questions on [GitHub Discussions]
+* leave feedback, ask questions, or greet us on [Gitter] or [Discord]
-[book]: https://pest-parser.github.io/book
+[book]: https://pest.rs/book
[docs.rs]: https://docs.rs/pest
-[fiddle]: https://pest-parser.github.io/#editor
-[Gitter]: https://gitter.im/dragostis/pest
+[fiddle]: https://pest.rs/#editor
+[Gitter]: https://gitter.im/pest-parser/pest
+[Discord]: https://discord.gg/XEGACtWpT2
+[GitHub Discussions]: https://github.com/pest-parser/pest/discussions
## Example
The following is an example of a grammar for a list of alphanumeric identifiers
-where the first identifier does not start with a digit:
+where all identifiers don't start with a digit:
```rust
alpha = { 'a'..'z' | 'A'..'Z' }
digit = { '0'..'9' }
-ident = { (alpha | digit)+ }
+ident = { !digit ~ (alpha | digit)+ }
-ident_list = _{ !digit ~ ident ~ (" " ~ ident)+ }
+ident_list = _{ ident ~ (" " ~ ident)* }
// ^
// ident_list rule is silent which means it produces no tokens
```
@@ -81,6 +84,9 @@ thread 'main' panicked at ' --> 1:1
= expected ident', src/main.rs:12
```
+These error messages can be obtained from their default `Display` implementation,
+e.g. `panic!("{}", parser_result.unwrap_err())` or `println!("{}", e)`.
+
## Pairs API
The grammar can be used to derive a `Parser` implementation automatically.
@@ -133,6 +139,25 @@ Letter: b
Digit: 2
```
+### Defining multiple parsers in a single file
+The current automatic `Parser` derivation will produce the `Rule` enum
+which would have name conflicts if one tried to define multiple such structs
+that automatically derive `Parser`. One possible way around it is to put each
+parser struct in a separate namespace:
+
+```rust
+mod a {
+ #[derive(Parser)]
+ #[grammar = "a.pest"]
+ pub struct ParserA;
+}
+mod b {
+ #[derive(Parser)]
+ #[grammar = "b.pest"]
+ pub struct ParserB;
+}
+```
+
## Other features
* Precedence climbing
diff --git a/vendor/pest_meta/src/ast.rs b/vendor/pest_meta/src/ast.rs
index da6ee5278..ffac8ea7a 100644
--- a/vendor/pest_meta/src/ast.rs
+++ b/vendor/pest_meta/src/ast.rs
@@ -7,22 +7,48 @@
// option. All files in the project carrying such notice may not be copied,
// modified, or distributed except according to those terms.
+//! Types for the pest's abstract syntax tree.
+
+/// A grammar rule
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct Rule {
+ /// The name of the rule
pub name: String,
+ /// The rule's type (silent, atomic, ...)
pub ty: RuleType,
+ /// The rule's expression
pub expr: Expr,
}
+/// All possible rule types
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum RuleType {
+ /// The normal rule type
Normal,
+ /// Silent rules are just like normal rules
+ /// — when run, they function the same way —
+ /// except they do not produce pairs or tokens.
+ /// If a rule is silent, it will never appear in a parse result.
+ /// (their syntax is `_{ ... }`)
Silent,
+ /// atomic rule prevent implicit whitespace: inside an atomic rule,
+ /// the tilde ~ means "immediately followed by",
+ /// and repetition operators (asterisk * and plus sign +)
+ /// have no implicit separation. In addition, all other rules
+ /// called from an atomic rule are also treated as atomic.
+ /// In an atomic rule, interior matching rules are silent.
+ /// (their syntax is `@{ ... }`)
Atomic,
+ /// Compound atomic rules are similar to atomic rules,
+ /// but they produce inner tokens as normal.
+ /// (their syntax is `${ ... }`)
CompoundAtomic,
+ /// Non-atomic rules cancel the effect of atomic rules.
+ /// (their syntax is `!{ ... }`)
NonAtomic,
}
+/// All possible rule expressions
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum Expr {
/// Matches an exact string, e.g. `"a"`
@@ -64,10 +90,12 @@ pub enum Expr {
}
impl Expr {
+ /// Returns the iterator that steps the expression from top to bottom.
pub fn iter_top_down(&self) -> ExprTopDownIterator {
ExprTopDownIterator::new(self)
}
+ /// Applies `f` to the expression and all its children (top to bottom).
pub fn map_top_down<F>(self, mut f: F) -> Expr
where
F: FnMut(Expr) -> Expr,
@@ -137,6 +165,7 @@ impl Expr {
map_internal(self, &mut f)
}
+ /// Applies `f` to the expression and all its children (bottom up).
pub fn map_bottom_up<F>(self, mut f: F) -> Expr
where
F: FnMut(Expr) -> Expr,
@@ -207,6 +236,7 @@ impl Expr {
}
}
+/// The top down iterator for an expression.
pub struct ExprTopDownIterator {
current: Option<Expr>,
next: Option<Expr>,
@@ -214,6 +244,7 @@ pub struct ExprTopDownIterator {
}
impl ExprTopDownIterator {
+ /// Constructs a top-down iterator from the expression.
pub fn new(expr: &Expr) -> Self {
let mut iter = ExprTopDownIterator {
current: None,
diff --git a/vendor/pest_meta/src/grammar.rs b/vendor/pest_meta/src/grammar.rs
index e42982b06..4e6488833 100644
--- a/vendor/pest_meta/src/grammar.rs
+++ b/vendor/pest_meta/src/grammar.rs
@@ -1,2 +1,2 @@
pub struct PestParser;
-# [allow (dead_code , non_camel_case_types , clippy :: upper_case_acronyms)] # [derive (Clone , Copy , Debug , Eq , Hash , Ord , PartialEq , PartialOrd)] pub enum Rule { EOI , grammar_rules , grammar_rule , assignment_operator , opening_brace , closing_brace , opening_paren , closing_paren , opening_brack , closing_brack , modifier , silent_modifier , atomic_modifier , compound_atomic_modifier , non_atomic_modifier , expression , term , node , terminal , prefix_operator , infix_operator , postfix_operator , positive_predicate_operator , negative_predicate_operator , sequence_operator , choice_operator , optional_operator , repeat_operator , repeat_once_operator , repeat_exact , repeat_min , repeat_max , repeat_min_max , number , integer , comma , _push , peek_slice , identifier , alpha , alpha_num , string , insensitive_string , range , character , inner_str , inner_chr , escape , code , unicode , hex_digit , quote , single_quote , range_operator , newline , WHITESPACE , block_comment , COMMENT } # [allow (clippy :: all)] impl :: pest :: Parser < Rule > for PestParser { fn parse < 'i > (rule : Rule , input : & 'i str) -> :: std :: result :: Result < :: pest :: iterators :: Pairs < 'i , Rule > , :: pest :: error :: Error < Rule > > { mod rules { # ! [allow (clippy :: upper_case_acronyms)] pub mod hidden { use super :: super :: Rule ; # [inline] # [allow (dead_code , non_snake_case , unused_variables)] pub fn skip (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { if state . atomicity () == :: pest :: Atomicity :: NonAtomic { state . sequence (| state | { state . repeat (| state | super :: visible :: WHITESPACE (state)) . and_then (| state | { state . repeat (| state | { state . sequence (| state | { super :: visible :: COMMENT (state) . and_then (| state | { state . repeat (| state | super :: visible :: WHITESPACE (state)) }) }) }) }) }) } else { Ok (state) } } } pub mod visible { use super :: super :: Rule ; # [inline] # [allow (non_snake_case , unused_variables)] pub fn grammar_rules (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . sequence (| state | { self :: SOI (state) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { state . sequence (| state | { self :: grammar_rule (state) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { state . sequence (| state | { state . optional (| state | { self :: grammar_rule (state) . and_then (| state | { state . repeat (| state | { state . sequence (| state | { super :: hidden :: skip (state) . and_then (| state | { self :: grammar_rule (state) }) }) }) }) }) }) }) }) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: EOI (state) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn grammar_rule (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: grammar_rule , | state | { state . sequence (| state | { self :: identifier (state) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: assignment_operator (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { state . optional (| state | { self :: modifier (state) }) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: opening_brace (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: expression (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: closing_brace (state) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn assignment_operator (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: assignment_operator , | state | { state . match_string ("=") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn opening_brace (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: opening_brace , | state | { state . match_string ("{") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn closing_brace (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: closing_brace , | state | { state . match_string ("}") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn opening_paren (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: opening_paren , | state | { state . match_string ("(") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn closing_paren (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: closing_paren , | state | { state . match_string (")") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn opening_brack (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: opening_brack , | state | { state . match_string ("[") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn closing_brack (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: closing_brack , | state | { state . match_string ("]") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn modifier (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { self :: silent_modifier (state) . or_else (| state | { self :: atomic_modifier (state) }) . or_else (| state | { self :: compound_atomic_modifier (state) }) . or_else (| state | { self :: non_atomic_modifier (state) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn silent_modifier (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: silent_modifier , | state | { state . match_string ("_") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn atomic_modifier (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: atomic_modifier , | state | { state . match_string ("@") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn compound_atomic_modifier (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: compound_atomic_modifier , | state | { state . match_string ("$") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn non_atomic_modifier (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: non_atomic_modifier , | state | { state . match_string ("!") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn expression (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: expression , | state | { state . sequence (| state | { state . optional (| state | { self :: choice_operator (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: term (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { state . sequence (| state | { state . optional (| state | { state . sequence (| state | { self :: infix_operator (state) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: term (state) }) }) . and_then (| state | { state . repeat (| state | { state . sequence (| state | { super :: hidden :: skip (state) . and_then (| state | { state . sequence (| state | { self :: infix_operator (state) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: term (state) }) }) }) }) }) }) }) }) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn term (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: term , | state | { state . sequence (| state | { state . sequence (| state | { state . optional (| state | { self :: prefix_operator (state) . and_then (| state | { state . repeat (| state | { state . sequence (| state | { super :: hidden :: skip (state) . and_then (| state | { self :: prefix_operator (state) }) }) }) }) }) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: node (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { state . sequence (| state | { state . optional (| state | { self :: postfix_operator (state) . and_then (| state | { state . repeat (| state | { state . sequence (| state | { super :: hidden :: skip (state) . and_then (| state | { self :: postfix_operator (state) }) }) }) }) }) }) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn node (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . sequence (| state | { self :: opening_paren (state) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: expression (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: closing_paren (state) }) }) . or_else (| state | { self :: terminal (state) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn terminal (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { self :: _push (state) . or_else (| state | { self :: peek_slice (state) }) . or_else (| state | { self :: identifier (state) }) . or_else (| state | { self :: string (state) }) . or_else (| state | { self :: insensitive_string (state) }) . or_else (| state | { self :: range (state) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn prefix_operator (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { self :: positive_predicate_operator (state) . or_else (| state | { self :: negative_predicate_operator (state) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn infix_operator (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { self :: sequence_operator (state) . or_else (| state | { self :: choice_operator (state) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn postfix_operator (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { self :: optional_operator (state) . or_else (| state | { self :: repeat_operator (state) }) . or_else (| state | { self :: repeat_once_operator (state) }) . or_else (| state | { self :: repeat_exact (state) }) . or_else (| state | { self :: repeat_min (state) }) . or_else (| state | { self :: repeat_max (state) }) . or_else (| state | { self :: repeat_min_max (state) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn positive_predicate_operator (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: positive_predicate_operator , | state | { state . match_string ("&") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn negative_predicate_operator (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: negative_predicate_operator , | state | { state . match_string ("!") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn sequence_operator (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: sequence_operator , | state | { state . match_string ("~") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn choice_operator (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: choice_operator , | state | { state . match_string ("|") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn optional_operator (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: optional_operator , | state | { state . match_string ("?") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn repeat_operator (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: repeat_operator , | state | { state . match_string ("*") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn repeat_once_operator (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: repeat_once_operator , | state | { state . match_string ("+") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn repeat_exact (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: repeat_exact , | state | { state . sequence (| state | { self :: opening_brace (state) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: number (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: closing_brace (state) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn repeat_min (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: repeat_min , | state | { state . sequence (| state | { self :: opening_brace (state) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: number (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: comma (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: closing_brace (state) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn repeat_max (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: repeat_max , | state | { state . sequence (| state | { self :: opening_brace (state) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: comma (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: number (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: closing_brace (state) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn repeat_min_max (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: repeat_min_max , | state | { state . sequence (| state | { self :: opening_brace (state) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: number (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: comma (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: number (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: closing_brace (state) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn number (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: number , | state | { state . atomic (:: pest :: Atomicity :: Atomic , | state | { state . sequence (| state | { state . match_range ('0' .. '9') . and_then (| state | { state . repeat (| state | { state . match_range ('0' .. '9') }) }) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn integer (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: integer , | state | { state . atomic (:: pest :: Atomicity :: Atomic , | state | { self :: number (state) . or_else (| state | { state . sequence (| state | { state . match_string ("-") . and_then (| state | { state . repeat (| state | { state . match_string ("0") }) }) . and_then (| state | { state . match_range ('1' .. '9') }) . and_then (| state | { state . optional (| state | { self :: number (state) }) }) }) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn comma (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: comma , | state | { state . match_string (",") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn _push (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: _push , | state | { state . sequence (| state | { state . match_string ("PUSH") . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: opening_paren (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: expression (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: closing_paren (state) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn peek_slice (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: peek_slice , | state | { state . sequence (| state | { state . match_string ("PEEK") . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: opening_brack (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { state . optional (| state | { self :: integer (state) }) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: range_operator (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { state . optional (| state | { self :: integer (state) }) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: closing_brack (state) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn identifier (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: identifier , | state | { state . atomic (:: pest :: Atomicity :: Atomic , | state | { state . sequence (| state | { state . lookahead (false , | state | { state . match_string ("PUSH") }) . and_then (| state | { state . match_string ("_") . or_else (| state | { self :: alpha (state) }) }) . and_then (| state | { state . repeat (| state | { state . match_string ("_") . or_else (| state | { self :: alpha_num (state) }) }) }) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn alpha (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . match_range ('a' .. 'z') . or_else (| state | { state . match_range ('A' .. 'Z') }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn alpha_num (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { self :: alpha (state) . or_else (| state | { state . match_range ('0' .. '9') }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn string (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . atomic (:: pest :: Atomicity :: CompoundAtomic , | state | { state . rule (Rule :: string , | state | { state . sequence (| state | { self :: quote (state) . and_then (| state | { self :: inner_str (state) }) . and_then (| state | { self :: quote (state) }) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn insensitive_string (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: insensitive_string , | state | { state . sequence (| state | { state . match_string ("^") . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: string (state) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn range (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: range , | state | { state . sequence (| state | { self :: character (state) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: range_operator (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: character (state) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn character (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . atomic (:: pest :: Atomicity :: CompoundAtomic , | state | { state . rule (Rule :: character , | state | { state . sequence (| state | { self :: single_quote (state) . and_then (| state | { self :: inner_chr (state) }) . and_then (| state | { self :: single_quote (state) }) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn inner_str (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: inner_str , | state | { state . atomic (:: pest :: Atomicity :: Atomic , | state | { state . sequence (| state | { let strings = ["\"" , "\\"] ; state . skip_until (& strings) . and_then (| state | { state . optional (| state | { state . sequence (| state | { self :: escape (state) . and_then (| state | { self :: inner_str (state) }) }) }) }) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn inner_chr (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: inner_chr , | state | { state . atomic (:: pest :: Atomicity :: Atomic , | state | { self :: escape (state) . or_else (| state | { self :: ANY (state) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn escape (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: escape , | state | { state . atomic (:: pest :: Atomicity :: Atomic , | state | { state . sequence (| state | { state . match_string ("\\") . and_then (| state | { state . match_string ("\"") . or_else (| state | { state . match_string ("\\") }) . or_else (| state | { state . match_string ("r") }) . or_else (| state | { state . match_string ("n") }) . or_else (| state | { state . match_string ("t") }) . or_else (| state | { state . match_string ("0") }) . or_else (| state | { state . match_string ("'") }) . or_else (| state | { self :: code (state) }) . or_else (| state | { self :: unicode (state) }) }) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn code (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: code , | state | { state . atomic (:: pest :: Atomicity :: Atomic , | state | { state . sequence (| state | { state . match_string ("x") . and_then (| state | { self :: hex_digit (state) }) . and_then (| state | { self :: hex_digit (state) }) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn unicode (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: unicode , | state | { state . atomic (:: pest :: Atomicity :: Atomic , | state | { state . sequence (| state | { state . match_string ("u") . and_then (| state | { self :: opening_brace (state) }) . and_then (| state | { state . sequence (| state | { self :: hex_digit (state) . and_then (| state | { self :: hex_digit (state) }) . and_then (| state | { state . optional (| state | { self :: hex_digit (state) }) }) . and_then (| state | { state . optional (| state | { self :: hex_digit (state) }) }) . and_then (| state | { state . optional (| state | { self :: hex_digit (state) }) }) . and_then (| state | { state . optional (| state | { self :: hex_digit (state) }) }) }) }) . and_then (| state | { self :: closing_brace (state) }) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn hex_digit (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: hex_digit , | state | { state . atomic (:: pest :: Atomicity :: Atomic , | state | { state . match_range ('0' .. '9') . or_else (| state | { state . match_range ('a' .. 'f') }) . or_else (| state | { state . match_range ('A' .. 'F') }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn quote (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: quote , | state | { state . match_string ("\"") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn single_quote (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: single_quote , | state | { state . match_string ("'") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn range_operator (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: range_operator , | state | { state . match_string ("..") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn newline (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . match_string ("\n") . or_else (| state | { state . match_string ("\r\n") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn WHITESPACE (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . atomic (:: pest :: Atomicity :: Atomic , | state | { state . match_string (" ") . or_else (| state | { state . match_string ("\t") }) . or_else (| state | { self :: newline (state) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn block_comment (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . sequence (| state | { state . match_string ("/*") . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { state . sequence (| state | { state . optional (| state | { self :: block_comment (state) . or_else (| state | { state . sequence (| state | { state . lookahead (false , | state | { state . match_string ("*/") }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: ANY (state) }) }) }) . and_then (| state | { state . repeat (| state | { state . sequence (| state | { super :: hidden :: skip (state) . and_then (| state | { self :: block_comment (state) . or_else (| state | { state . sequence (| state | { state . lookahead (false , | state | { state . match_string ("*/") }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: ANY (state) }) }) }) }) }) }) }) }) }) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { state . match_string ("*/") }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn COMMENT (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . atomic (:: pest :: Atomicity :: Atomic , | state | { self :: block_comment (state) . or_else (| state | { state . sequence (| state | { state . match_string ("//") . and_then (| state | { state . repeat (| state | { state . sequence (| state | { state . lookahead (false , | state | { self :: newline (state) }) . and_then (| state | { self :: ANY (state) }) }) }) }) }) }) }) } # [inline] # [allow (dead_code , non_snake_case , unused_variables)] pub fn ANY (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . skip (1) } # [inline] # [allow (dead_code , non_snake_case , unused_variables)] pub fn EOI (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: EOI , | state | state . end_of_input ()) } # [inline] # [allow (dead_code , non_snake_case , unused_variables)] pub fn SOI (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . start_of_input () } } pub use self :: visible :: * ; } :: pest :: state (input , | state | { match rule { Rule :: grammar_rules => rules :: grammar_rules (state) , Rule :: grammar_rule => rules :: grammar_rule (state) , Rule :: assignment_operator => rules :: assignment_operator (state) , Rule :: opening_brace => rules :: opening_brace (state) , Rule :: closing_brace => rules :: closing_brace (state) , Rule :: opening_paren => rules :: opening_paren (state) , Rule :: closing_paren => rules :: closing_paren (state) , Rule :: opening_brack => rules :: opening_brack (state) , Rule :: closing_brack => rules :: closing_brack (state) , Rule :: modifier => rules :: modifier (state) , Rule :: silent_modifier => rules :: silent_modifier (state) , Rule :: atomic_modifier => rules :: atomic_modifier (state) , Rule :: compound_atomic_modifier => rules :: compound_atomic_modifier (state) , Rule :: non_atomic_modifier => rules :: non_atomic_modifier (state) , Rule :: expression => rules :: expression (state) , Rule :: term => rules :: term (state) , Rule :: node => rules :: node (state) , Rule :: terminal => rules :: terminal (state) , Rule :: prefix_operator => rules :: prefix_operator (state) , Rule :: infix_operator => rules :: infix_operator (state) , Rule :: postfix_operator => rules :: postfix_operator (state) , Rule :: positive_predicate_operator => rules :: positive_predicate_operator (state) , Rule :: negative_predicate_operator => rules :: negative_predicate_operator (state) , Rule :: sequence_operator => rules :: sequence_operator (state) , Rule :: choice_operator => rules :: choice_operator (state) , Rule :: optional_operator => rules :: optional_operator (state) , Rule :: repeat_operator => rules :: repeat_operator (state) , Rule :: repeat_once_operator => rules :: repeat_once_operator (state) , Rule :: repeat_exact => rules :: repeat_exact (state) , Rule :: repeat_min => rules :: repeat_min (state) , Rule :: repeat_max => rules :: repeat_max (state) , Rule :: repeat_min_max => rules :: repeat_min_max (state) , Rule :: number => rules :: number (state) , Rule :: integer => rules :: integer (state) , Rule :: comma => rules :: comma (state) , Rule :: _push => rules :: _push (state) , Rule :: peek_slice => rules :: peek_slice (state) , Rule :: identifier => rules :: identifier (state) , Rule :: alpha => rules :: alpha (state) , Rule :: alpha_num => rules :: alpha_num (state) , Rule :: string => rules :: string (state) , Rule :: insensitive_string => rules :: insensitive_string (state) , Rule :: range => rules :: range (state) , Rule :: character => rules :: character (state) , Rule :: inner_str => rules :: inner_str (state) , Rule :: inner_chr => rules :: inner_chr (state) , Rule :: escape => rules :: escape (state) , Rule :: code => rules :: code (state) , Rule :: unicode => rules :: unicode (state) , Rule :: hex_digit => rules :: hex_digit (state) , Rule :: quote => rules :: quote (state) , Rule :: single_quote => rules :: single_quote (state) , Rule :: range_operator => rules :: range_operator (state) , Rule :: newline => rules :: newline (state) , Rule :: WHITESPACE => rules :: WHITESPACE (state) , Rule :: block_comment => rules :: block_comment (state) , Rule :: COMMENT => rules :: COMMENT (state) , Rule :: EOI => rules :: EOI (state) } }) } }
+# [allow (dead_code , non_camel_case_types , clippy :: upper_case_acronyms)] # [derive (Clone , Copy , Debug , Eq , Hash , Ord , PartialEq , PartialOrd)] pub enum Rule { EOI , grammar_rules , grammar_rule , assignment_operator , opening_brace , closing_brace , opening_paren , closing_paren , opening_brack , closing_brack , modifier , silent_modifier , atomic_modifier , compound_atomic_modifier , non_atomic_modifier , expression , term , node , terminal , prefix_operator , infix_operator , postfix_operator , positive_predicate_operator , negative_predicate_operator , sequence_operator , choice_operator , optional_operator , repeat_operator , repeat_once_operator , repeat_exact , repeat_min , repeat_max , repeat_min_max , number , integer , comma , _push , peek_slice , identifier , alpha , alpha_num , string , insensitive_string , range , character , inner_str , inner_chr , escape , code , unicode , hex_digit , quote , single_quote , range_operator , newline , WHITESPACE , block_comment , COMMENT } # [allow (clippy :: all)] impl :: pest :: Parser < Rule > for PestParser { fn parse < 'i > (rule : Rule , input : & 'i str) -> :: std :: result :: Result < :: pest :: iterators :: Pairs < 'i , Rule > , :: pest :: error :: Error < Rule > > { mod rules { # ! [allow (clippy :: upper_case_acronyms)] pub mod hidden { use super :: super :: Rule ; # [inline] # [allow (dead_code , non_snake_case , unused_variables)] pub fn skip (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { if state . atomicity () == :: pest :: Atomicity :: NonAtomic { state . sequence (| state | { state . repeat (| state | super :: visible :: WHITESPACE (state)) . and_then (| state | { state . repeat (| state | { state . sequence (| state | { super :: visible :: COMMENT (state) . and_then (| state | { state . repeat (| state | super :: visible :: WHITESPACE (state)) }) }) }) }) }) } else { Ok (state) } } } pub mod visible { use super :: super :: Rule ; # [inline] # [allow (non_snake_case , unused_variables)] pub fn grammar_rules (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . sequence (| state | { self :: SOI (state) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { state . sequence (| state | { self :: grammar_rule (state) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { state . sequence (| state | { state . optional (| state | { self :: grammar_rule (state) . and_then (| state | { state . repeat (| state | { state . sequence (| state | { super :: hidden :: skip (state) . and_then (| state | { self :: grammar_rule (state) }) }) }) }) }) }) }) }) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: EOI (state) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn grammar_rule (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: grammar_rule , | state | { state . sequence (| state | { self :: identifier (state) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: assignment_operator (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { state . optional (| state | { self :: modifier (state) }) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: opening_brace (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: expression (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: closing_brace (state) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn assignment_operator (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: assignment_operator , | state | { state . match_string ("=") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn opening_brace (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: opening_brace , | state | { state . match_string ("{") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn closing_brace (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: closing_brace , | state | { state . match_string ("}") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn opening_paren (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: opening_paren , | state | { state . match_string ("(") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn closing_paren (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: closing_paren , | state | { state . match_string (")") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn opening_brack (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: opening_brack , | state | { state . match_string ("[") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn closing_brack (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: closing_brack , | state | { state . match_string ("]") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn modifier (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { self :: silent_modifier (state) . or_else (| state | { self :: atomic_modifier (state) }) . or_else (| state | { self :: compound_atomic_modifier (state) }) . or_else (| state | { self :: non_atomic_modifier (state) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn silent_modifier (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: silent_modifier , | state | { state . match_string ("_") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn atomic_modifier (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: atomic_modifier , | state | { state . match_string ("@") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn compound_atomic_modifier (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: compound_atomic_modifier , | state | { state . match_string ("$") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn non_atomic_modifier (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: non_atomic_modifier , | state | { state . match_string ("!") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn expression (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: expression , | state | { state . sequence (| state | { state . optional (| state | { self :: choice_operator (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: term (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { state . sequence (| state | { state . optional (| state | { state . sequence (| state | { self :: infix_operator (state) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: term (state) }) }) . and_then (| state | { state . repeat (| state | { state . sequence (| state | { super :: hidden :: skip (state) . and_then (| state | { state . sequence (| state | { self :: infix_operator (state) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: term (state) }) }) }) }) }) }) }) }) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn term (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: term , | state | { state . sequence (| state | { state . sequence (| state | { state . optional (| state | { self :: prefix_operator (state) . and_then (| state | { state . repeat (| state | { state . sequence (| state | { super :: hidden :: skip (state) . and_then (| state | { self :: prefix_operator (state) }) }) }) }) }) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: node (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { state . sequence (| state | { state . optional (| state | { self :: postfix_operator (state) . and_then (| state | { state . repeat (| state | { state . sequence (| state | { super :: hidden :: skip (state) . and_then (| state | { self :: postfix_operator (state) }) }) }) }) }) }) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn node (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . sequence (| state | { self :: opening_paren (state) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: expression (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: closing_paren (state) }) }) . or_else (| state | { self :: terminal (state) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn terminal (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { self :: _push (state) . or_else (| state | { self :: peek_slice (state) }) . or_else (| state | { self :: identifier (state) }) . or_else (| state | { self :: string (state) }) . or_else (| state | { self :: insensitive_string (state) }) . or_else (| state | { self :: range (state) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn prefix_operator (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { self :: positive_predicate_operator (state) . or_else (| state | { self :: negative_predicate_operator (state) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn infix_operator (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { self :: sequence_operator (state) . or_else (| state | { self :: choice_operator (state) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn postfix_operator (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { self :: optional_operator (state) . or_else (| state | { self :: repeat_operator (state) }) . or_else (| state | { self :: repeat_once_operator (state) }) . or_else (| state | { self :: repeat_exact (state) }) . or_else (| state | { self :: repeat_min (state) }) . or_else (| state | { self :: repeat_max (state) }) . or_else (| state | { self :: repeat_min_max (state) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn positive_predicate_operator (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: positive_predicate_operator , | state | { state . match_string ("&") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn negative_predicate_operator (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: negative_predicate_operator , | state | { state . match_string ("!") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn sequence_operator (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: sequence_operator , | state | { state . match_string ("~") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn choice_operator (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: choice_operator , | state | { state . match_string ("|") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn optional_operator (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: optional_operator , | state | { state . match_string ("?") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn repeat_operator (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: repeat_operator , | state | { state . match_string ("*") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn repeat_once_operator (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: repeat_once_operator , | state | { state . match_string ("+") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn repeat_exact (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: repeat_exact , | state | { state . sequence (| state | { self :: opening_brace (state) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: number (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: closing_brace (state) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn repeat_min (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: repeat_min , | state | { state . sequence (| state | { self :: opening_brace (state) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: number (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: comma (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: closing_brace (state) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn repeat_max (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: repeat_max , | state | { state . sequence (| state | { self :: opening_brace (state) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: comma (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: number (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: closing_brace (state) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn repeat_min_max (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: repeat_min_max , | state | { state . sequence (| state | { self :: opening_brace (state) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: number (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: comma (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: number (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: closing_brace (state) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn number (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: number , | state | { state . atomic (:: pest :: Atomicity :: Atomic , | state | { state . sequence (| state | { state . match_range ('0' .. '9') . and_then (| state | { state . repeat (| state | { state . match_range ('0' .. '9') }) }) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn integer (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: integer , | state | { state . atomic (:: pest :: Atomicity :: Atomic , | state | { self :: number (state) . or_else (| state | { state . sequence (| state | { state . match_string ("-") . and_then (| state | { state . repeat (| state | { state . match_string ("0") }) }) . and_then (| state | { state . match_range ('1' .. '9') }) . and_then (| state | { state . optional (| state | { self :: number (state) }) }) }) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn comma (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: comma , | state | { state . match_string (",") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn _push (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: _push , | state | { state . sequence (| state | { state . match_string ("PUSH") . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: opening_paren (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: expression (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: closing_paren (state) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn peek_slice (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: peek_slice , | state | { state . sequence (| state | { state . match_string ("PEEK") . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: opening_brack (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { state . optional (| state | { self :: integer (state) }) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: range_operator (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { state . optional (| state | { self :: integer (state) }) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: closing_brack (state) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn identifier (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: identifier , | state | { state . atomic (:: pest :: Atomicity :: Atomic , | state | { state . sequence (| state | { state . lookahead (false , | state | { state . match_string ("PUSH") }) . and_then (| state | { state . match_string ("_") . or_else (| state | { self :: alpha (state) }) }) . and_then (| state | { state . repeat (| state | { state . match_string ("_") . or_else (| state | { self :: alpha_num (state) }) }) }) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn alpha (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . match_range ('a' .. 'z') . or_else (| state | { state . match_range ('A' .. 'Z') }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn alpha_num (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { self :: alpha (state) . or_else (| state | { state . match_range ('0' .. '9') }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn string (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . atomic (:: pest :: Atomicity :: CompoundAtomic , | state | { state . rule (Rule :: string , | state | { state . sequence (| state | { self :: quote (state) . and_then (| state | { self :: inner_str (state) }) . and_then (| state | { self :: quote (state) }) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn insensitive_string (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: insensitive_string , | state | { state . sequence (| state | { state . match_string ("^") . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: string (state) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn range (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: range , | state | { state . sequence (| state | { self :: character (state) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: range_operator (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: character (state) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn character (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . atomic (:: pest :: Atomicity :: CompoundAtomic , | state | { state . rule (Rule :: character , | state | { state . sequence (| state | { self :: single_quote (state) . and_then (| state | { self :: inner_chr (state) }) . and_then (| state | { self :: single_quote (state) }) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn inner_str (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: inner_str , | state | { state . atomic (:: pest :: Atomicity :: Atomic , | state | { state . sequence (| state | { let strings = ["\"" , "\\"] ; state . skip_until (& strings) . and_then (| state | { state . optional (| state | { state . sequence (| state | { self :: escape (state) . and_then (| state | { self :: inner_str (state) }) }) }) }) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn inner_chr (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: inner_chr , | state | { state . atomic (:: pest :: Atomicity :: Atomic , | state | { self :: escape (state) . or_else (| state | { self :: ANY (state) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn escape (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: escape , | state | { state . atomic (:: pest :: Atomicity :: Atomic , | state | { state . sequence (| state | { state . match_string ("\\") . and_then (| state | { state . match_string ("\"") . or_else (| state | { state . match_string ("\\") }) . or_else (| state | { state . match_string ("r") }) . or_else (| state | { state . match_string ("n") }) . or_else (| state | { state . match_string ("t") }) . or_else (| state | { state . match_string ("0") }) . or_else (| state | { state . match_string ("'") }) . or_else (| state | { self :: code (state) }) . or_else (| state | { self :: unicode (state) }) }) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn code (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: code , | state | { state . atomic (:: pest :: Atomicity :: Atomic , | state | { state . sequence (| state | { state . match_string ("x") . and_then (| state | { self :: hex_digit (state) }) . and_then (| state | { self :: hex_digit (state) }) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn unicode (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: unicode , | state | { state . atomic (:: pest :: Atomicity :: Atomic , | state | { state . sequence (| state | { state . match_string ("u") . and_then (| state | { self :: opening_brace (state) }) . and_then (| state | { state . sequence (| state | { self :: hex_digit (state) . and_then (| state | { self :: hex_digit (state) }) . and_then (| state | { state . optional (| state | { self :: hex_digit (state) }) }) . and_then (| state | { state . optional (| state | { self :: hex_digit (state) }) }) . and_then (| state | { state . optional (| state | { self :: hex_digit (state) }) }) . and_then (| state | { state . optional (| state | { self :: hex_digit (state) }) }) }) }) . and_then (| state | { self :: closing_brace (state) }) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn hex_digit (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: hex_digit , | state | { state . atomic (:: pest :: Atomicity :: Atomic , | state | { state . match_range ('0' .. '9') . or_else (| state | { state . match_range ('a' .. 'f') }) . or_else (| state | { state . match_range ('A' .. 'F') }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn quote (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: quote , | state | { state . match_string ("\"") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn single_quote (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: single_quote , | state | { state . match_string ("'") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn range_operator (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: range_operator , | state | { state . match_string ("..") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn newline (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . match_string ("\n") . or_else (| state | { state . match_string ("\r\n") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn WHITESPACE (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . atomic (:: pest :: Atomicity :: Atomic , | state | { state . match_string (" ") . or_else (| state | { state . match_string ("\t") }) . or_else (| state | { self :: newline (state) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn block_comment (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . sequence (| state | { state . match_string ("/*") . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { state . sequence (| state | { state . optional (| state | { self :: block_comment (state) . or_else (| state | { state . sequence (| state | { state . lookahead (false , | state | { state . match_string ("*/") }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: ANY (state) }) }) }) . and_then (| state | { state . repeat (| state | { state . sequence (| state | { super :: hidden :: skip (state) . and_then (| state | { self :: block_comment (state) . or_else (| state | { state . sequence (| state | { state . lookahead (false , | state | { state . match_string ("*/") }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: ANY (state) }) }) }) }) }) }) }) }) }) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { state . match_string ("*/") }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn COMMENT (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . atomic (:: pest :: Atomicity :: Atomic , | state | { self :: block_comment (state) . or_else (| state | { state . sequence (| state | { state . match_string ("//") . and_then (| state | { state . repeat (| state | { state . sequence (| state | { state . lookahead (false , | state | { self :: newline (state) }) . and_then (| state | { self :: ANY (state) }) }) }) }) }) }) }) } # [inline] # [allow (dead_code , non_snake_case , unused_variables)] pub fn ANY (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . skip (1) } # [inline] # [allow (dead_code , non_snake_case , unused_variables)] pub fn EOI (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: EOI , | state | state . end_of_input ()) } # [inline] # [allow (dead_code , non_snake_case , unused_variables)] pub fn SOI (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . start_of_input () } } pub use self :: visible :: * ; } :: pest :: state (input , | state | { match rule { Rule :: grammar_rules => rules :: grammar_rules (state) , Rule :: grammar_rule => rules :: grammar_rule (state) , Rule :: assignment_operator => rules :: assignment_operator (state) , Rule :: opening_brace => rules :: opening_brace (state) , Rule :: closing_brace => rules :: closing_brace (state) , Rule :: opening_paren => rules :: opening_paren (state) , Rule :: closing_paren => rules :: closing_paren (state) , Rule :: opening_brack => rules :: opening_brack (state) , Rule :: closing_brack => rules :: closing_brack (state) , Rule :: modifier => rules :: modifier (state) , Rule :: silent_modifier => rules :: silent_modifier (state) , Rule :: atomic_modifier => rules :: atomic_modifier (state) , Rule :: compound_atomic_modifier => rules :: compound_atomic_modifier (state) , Rule :: non_atomic_modifier => rules :: non_atomic_modifier (state) , Rule :: expression => rules :: expression (state) , Rule :: term => rules :: term (state) , Rule :: node => rules :: node (state) , Rule :: terminal => rules :: terminal (state) , Rule :: prefix_operator => rules :: prefix_operator (state) , Rule :: infix_operator => rules :: infix_operator (state) , Rule :: postfix_operator => rules :: postfix_operator (state) , Rule :: positive_predicate_operator => rules :: positive_predicate_operator (state) , Rule :: negative_predicate_operator => rules :: negative_predicate_operator (state) , Rule :: sequence_operator => rules :: sequence_operator (state) , Rule :: choice_operator => rules :: choice_operator (state) , Rule :: optional_operator => rules :: optional_operator (state) , Rule :: repeat_operator => rules :: repeat_operator (state) , Rule :: repeat_once_operator => rules :: repeat_once_operator (state) , Rule :: repeat_exact => rules :: repeat_exact (state) , Rule :: repeat_min => rules :: repeat_min (state) , Rule :: repeat_max => rules :: repeat_max (state) , Rule :: repeat_min_max => rules :: repeat_min_max (state) , Rule :: number => rules :: number (state) , Rule :: integer => rules :: integer (state) , Rule :: comma => rules :: comma (state) , Rule :: _push => rules :: _push (state) , Rule :: peek_slice => rules :: peek_slice (state) , Rule :: identifier => rules :: identifier (state) , Rule :: alpha => rules :: alpha (state) , Rule :: alpha_num => rules :: alpha_num (state) , Rule :: string => rules :: string (state) , Rule :: insensitive_string => rules :: insensitive_string (state) , Rule :: range => rules :: range (state) , Rule :: character => rules :: character (state) , Rule :: inner_str => rules :: inner_str (state) , Rule :: inner_chr => rules :: inner_chr (state) , Rule :: escape => rules :: escape (state) , Rule :: code => rules :: code (state) , Rule :: unicode => rules :: unicode (state) , Rule :: hex_digit => rules :: hex_digit (state) , Rule :: quote => rules :: quote (state) , Rule :: single_quote => rules :: single_quote (state) , Rule :: range_operator => rules :: range_operator (state) , Rule :: newline => rules :: newline (state) , Rule :: WHITESPACE => rules :: WHITESPACE (state) , Rule :: block_comment => rules :: block_comment (state) , Rule :: COMMENT => rules :: COMMENT (state) , Rule :: EOI => rules :: EOI (state) } }) } }
diff --git a/vendor/pest_meta/src/lib.rs b/vendor/pest_meta/src/lib.rs
index 4e178be6f..198001a06 100644
--- a/vendor/pest_meta/src/lib.rs
+++ b/vendor/pest_meta/src/lib.rs
@@ -6,21 +6,33 @@
// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. All files in the project carrying such notice may not be copied,
// modified, or distributed except according to those terms.
+//! # pest meta
+//!
+//! This crate parses, validates, optimizes, and converts pest's own grammars to ASTs.
+
+#![doc(
+ html_logo_url = "https://raw.githubusercontent.com/pest-parser/pest/master/pest-logo.svg",
+ html_favicon_url = "https://raw.githubusercontent.com/pest-parser/pest/master/pest-logo.svg"
+)]
+#![warn(missing_docs, rust_2018_idioms, unused_qualifications)]
-extern crate once_cell;
#[cfg(test)]
#[macro_use]
extern crate pest;
-#[cfg(not(test))]
-extern crate pest;
+use once_cell::sync::Lazy;
use std::fmt::Display;
+use pest::error::Error;
+use pest::unicode::unicode_property_names;
+
pub mod ast;
pub mod optimizer;
pub mod parser;
pub mod validator;
+/// A helper that will unwrap the result or panic
+/// with the nicely formatted error message.
pub fn unwrap_or_report<T, E>(result: Result<T, E>) -> T
where
E: IntoIterator,
@@ -28,7 +40,8 @@ where
{
result.unwrap_or_else(|e| {
panic!(
- "grammar error\n\n{}",
+ "{}{}",
+ "grammar error\n\n".to_owned(),
&e.into_iter()
.map(|error| format!("{}", error))
.collect::<Vec<_>>()
@@ -37,98 +50,27 @@ where
})
}
+/// A tuple returned by the validation and processing of the parsed grammar.
+/// The first element is the vector of used builtin rule names,
+/// the second element is the vector of optimized rules.
+type UsedBuiltinAndOptimized<'i> = (Vec<&'i str>, Vec<optimizer::OptimizedRule>);
+
+/// Parses, validates, processes and optimizes the provided grammar.
+pub fn parse_and_optimize(
+ grammar: &str,
+) -> Result<UsedBuiltinAndOptimized<'_>, Vec<Error<parser::Rule>>> {
+ let pairs = match parser::parse(parser::Rule::grammar_rules, grammar) {
+ Ok(pairs) => Ok(pairs),
+ Err(error) => Err(vec![error]),
+ }?;
+
+ let defaults = validator::validate_pairs(pairs.clone())?;
+ let ast = parser::consume_rules(pairs)?;
+
+ Ok((defaults, optimizer::optimize(ast)))
+}
+
#[doc(hidden)]
-pub static UNICODE_PROPERTY_NAMES: &[&str] = &[
- /* BINARY */
- "ALPHABETIC",
- "BIDI_CONTROL",
- "CASE_IGNORABLE",
- "CASED",
- "CHANGES_WHEN_CASEFOLDED",
- "CHANGES_WHEN_CASEMAPPED",
- "CHANGES_WHEN_LOWERCASED",
- "CHANGES_WHEN_TITLECASED",
- "CHANGES_WHEN_UPPERCASED",
- "DASH",
- "DEFAULT_IGNORABLE_CODE_POINT",
- "DEPRECATED",
- "DIACRITIC",
- "EXTENDER",
- "GRAPHEME_BASE",
- "GRAPHEME_EXTEND",
- "GRAPHEME_LINK",
- "HEX_DIGIT",
- "HYPHEN",
- "IDS_BINARY_OPERATOR",
- "IDS_TRINARY_OPERATOR",
- "ID_CONTINUE",
- "ID_START",
- "IDEOGRAPHIC",
- "JOIN_CONTROL",
- "LOGICAL_ORDER_EXCEPTION",
- "LOWERCASE",
- "MATH",
- "NONCHARACTER_CODE_POINT",
- "OTHER_ALPHABETIC",
- "OTHER_DEFAULT_IGNORABLE_CODE_POINT",
- "OTHER_GRAPHEME_EXTEND",
- "OTHER_ID_CONTINUE",
- "OTHER_ID_START",
- "OTHER_LOWERCASE",
- "OTHER_MATH",
- "OTHER_UPPERCASE",
- "PATTERN_SYNTAX",
- "PATTERN_WHITE_SPACE",
- "PREPENDED_CONCATENATION_MARK",
- "QUOTATION_MARK",
- "RADICAL",
- "REGIONAL_INDICATOR",
- "SENTENCE_TERMINAL",
- "SOFT_DOTTED",
- "TERMINAL_PUNCTUATION",
- "UNIFIED_IDEOGRAPH",
- "UPPERCASE",
- "VARIATION_SELECTOR",
- "WHITE_SPACE",
- "XID_CONTINUE",
- "XID_START",
- /* CATEGORY */
- "CASED_LETTER",
- "CLOSE_PUNCTUATION",
- "CONNECTOR_PUNCTUATION",
- "CONTROL",
- "CURRENCY_SYMBOL",
- "DASH_PUNCTUATION",
- "DECIMAL_NUMBER",
- "ENCLOSING_MARK",
- "FINAL_PUNCTUATION",
- "FORMAT",
- "INITIAL_PUNCTUATION",
- "LETTER",
- "LETTER_NUMBER",
- "LINE_SEPARATOR",
- "LOWERCASE_LETTER",
- "MARK",
- "MATH_SYMBOL",
- "MODIFIER_LETTER",
- "MODIFIER_SYMBOL",
- "NONSPACING_MARK",
- "NUMBER",
- "OPEN_PUNCTUATION",
- "OTHER",
- "OTHER_LETTER",
- "OTHER_NUMBER",
- "OTHER_PUNCTUATION",
- "OTHER_SYMBOL",
- "PARAGRAPH_SEPARATOR",
- "PRIVATE_USE",
- "PUNCTUATION",
- "SEPARATOR",
- "SPACE_SEPARATOR",
- "SPACING_MARK",
- "SURROGATE",
- "SYMBOL",
- "TITLECASE_LETTER",
- "UNASSIGNED",
- "UPPERCASE_LETTER",
-];
+#[deprecated(note = "use `pest::unicode::unicode_property_names` instead")]
+pub static UNICODE_PROPERTY_NAMES: Lazy<Vec<&str>> =
+ Lazy::new(|| unicode_property_names().collect::<Vec<_>>());
diff --git a/vendor/pest_meta/src/optimizer/mod.rs b/vendor/pest_meta/src/optimizer/mod.rs
index e0cbdb0de..2038753b8 100644
--- a/vendor/pest_meta/src/optimizer/mod.rs
+++ b/vendor/pest_meta/src/optimizer/mod.rs
@@ -7,6 +7,8 @@
// option. All files in the project carrying such notice may not be copied,
// modified, or distributed except according to those terms.
+//! Different optimizations for pest's ASTs.
+
use crate::ast::*;
use std::collections::HashMap;
@@ -26,6 +28,7 @@ mod rotater;
mod skipper;
mod unroller;
+/// Takes pest's ASTs and optimizes them
pub fn optimize(rules: Vec<Rule>) -> Vec<OptimizedRule> {
let optimized: Vec<OptimizedRule> = rules
.into_iter()
@@ -87,36 +90,57 @@ fn to_hash_map(rules: &[OptimizedRule]) -> HashMap<String, OptimizedExpr> {
.collect()
}
+/// The optimized version of the pest AST's `Rule`.
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct OptimizedRule {
+ /// The name of the rule.
pub name: String,
+ /// The type of the rule.
pub ty: RuleType,
+ /// The optimized expression of the rule.
pub expr: OptimizedExpr,
}
+/// The optimized version of the pest AST's `Expr`.
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum OptimizedExpr {
+ /// Matches an exact string, e.g. `"a"`
Str(String),
+ /// Matches an exact string, case insensitively (ASCII only), e.g. `^"a"`
Insens(String),
+ /// Matches one character in the range, e.g. `'a'..'z'`
Range(String, String),
+ /// Matches the rule with the given name, e.g. `a`
Ident(String),
+ /// Matches a custom part of the stack, e.g. `PEEK[..]`
PeekSlice(i32, Option<i32>),
+ /// Positive lookahead; matches expression without making progress, e.g. `&e`
PosPred(Box<OptimizedExpr>),
+ /// Negative lookahead; matches if expression doesn't match, without making progress, e.g. `!e`
NegPred(Box<OptimizedExpr>),
+ /// Matches a sequence of two expressions, e.g. `e1 ~ e2`
Seq(Box<OptimizedExpr>, Box<OptimizedExpr>),
+ /// Matches either of two expressions, e.g. `e1 | e2`
Choice(Box<OptimizedExpr>, Box<OptimizedExpr>),
+ /// Optionally matches an expression, e.g. `e?`
Opt(Box<OptimizedExpr>),
+ /// Matches an expression zero or more times, e.g. `e*`
Rep(Box<OptimizedExpr>),
+ /// Continues to match expressions until one of the strings in the `Vec` is found
Skip(Vec<String>),
+ /// Matches an expression and pushes it to the stack, e.g. `push(e)`
Push(Box<OptimizedExpr>),
+ /// Restores an expression's checkpoint
RestoreOnErr(Box<OptimizedExpr>),
}
impl OptimizedExpr {
+ /// Returns a top-down iterator over the `OptimizedExpr`.
pub fn iter_top_down(&self) -> OptimizedExprTopDownIterator {
OptimizedExprTopDownIterator::new(self)
}
+ /// Applies `f` to the `OptimizedExpr` top-down.
pub fn map_top_down<F>(self, mut f: F) -> OptimizedExpr
where
F: FnMut(OptimizedExpr) -> OptimizedExpr,
@@ -166,6 +190,7 @@ impl OptimizedExpr {
map_internal(self, &mut f)
}
+ /// Applies `f` to the `OptimizedExpr` bottom-up.
pub fn map_bottom_up<F>(self, mut f: F) -> OptimizedExpr
where
F: FnMut(OptimizedExpr) -> OptimizedExpr,
@@ -216,6 +241,7 @@ impl OptimizedExpr {
}
}
+/// A top-down iterator over an `OptimizedExpr`.
pub struct OptimizedExprTopDownIterator {
current: Option<OptimizedExpr>,
next: Option<OptimizedExpr>,
@@ -223,6 +249,7 @@ pub struct OptimizedExprTopDownIterator {
}
impl OptimizedExprTopDownIterator {
+ /// Creates a new top down iterator from an `OptimizedExpr`.
pub fn new(expr: &OptimizedExpr) -> Self {
let mut iter = OptimizedExprTopDownIterator {
current: None,
diff --git a/vendor/pest_meta/src/parser.rs b/vendor/pest_meta/src/parser.rs
index 72abd810d..fc0224b38 100644
--- a/vendor/pest_meta/src/parser.rs
+++ b/vendor/pest_meta/src/parser.rs
@@ -7,42 +7,62 @@
// option. All files in the project carrying such notice may not be copied,
// modified, or distributed except according to those terms.
+//! Types and helpers for the pest's own grammar parser.
+
use std::char;
use std::iter::Peekable;
use pest::error::{Error, ErrorVariant};
use pest::iterators::{Pair, Pairs};
-use pest::prec_climber::{Assoc, Operator, PrecClimber};
+use pest::pratt_parser::{Assoc, Op, PrattParser};
use pest::{Parser, Span};
use crate::ast::{Expr, Rule as AstRule, RuleType};
use crate::validator;
+/// TODO: fix the generator to at least add explicit lifetimes
+#[allow(
+ missing_docs,
+ unused_attributes,
+ elided_lifetimes_in_paths,
+ unused_qualifications
+)]
mod grammar {
include!("grammar.rs");
}
pub use self::grammar::*;
-pub fn parse(rule: Rule, data: &str) -> Result<Pairs<Rule>, Error<Rule>> {
+/// A helper that will parse using the pest grammar
+#[allow(clippy::perf)]
+pub fn parse(rule: Rule, data: &str) -> Result<Pairs<'_, Rule>, Error<Rule>> {
PestParser::parse(rule, data)
}
+/// The pest grammar rule
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct ParserRule<'i> {
+ /// The rule's name
pub name: String,
+ /// The rule's span
pub span: Span<'i>,
+ /// The rule's type
pub ty: RuleType,
+ /// The rule's parser node
pub node: ParserNode<'i>,
}
+/// The pest grammar node
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct ParserNode<'i> {
+ /// The node's expression
pub expr: ParserExpr<'i>,
+ /// The node's span
pub span: Span<'i>,
}
impl<'i> ParserNode<'i> {
+ /// will remove nodes that do not match `f`
pub fn filter_map_top_down<F, T>(self, mut f: F) -> Vec<T>
where
F: FnMut(ParserNode<'i>) -> Option<T>,
@@ -107,34 +127,52 @@ impl<'i> ParserNode<'i> {
}
}
+/// All possible parser expressions
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum ParserExpr<'i> {
+ /// Matches an exact string, e.g. `"a"`
Str(String),
+ /// Matches an exact string, case insensitively (ASCII only), e.g. `^"a"`
Insens(String),
+ /// Matches one character in the range, e.g. `'a'..'z'`
Range(String, String),
+ /// Matches the rule with the given name, e.g. `a`
Ident(String),
+ /// Matches a custom part of the stack, e.g. `PEEK[..]`
PeekSlice(i32, Option<i32>),
+ /// Positive lookahead; matches expression without making progress, e.g. `&e`
PosPred(Box<ParserNode<'i>>),
+ /// Negative lookahead; matches if expression doesn't match, without making progress, e.g. `!e`
NegPred(Box<ParserNode<'i>>),
+ /// Matches a sequence of two expressions, e.g. `e1 ~ e2`
Seq(Box<ParserNode<'i>>, Box<ParserNode<'i>>),
+ /// Matches either of two expressions, e.g. `e1 | e2`
Choice(Box<ParserNode<'i>>, Box<ParserNode<'i>>),
+ /// Optionally matches an expression, e.g. `e?`
Opt(Box<ParserNode<'i>>),
+ /// Matches an expression zero or more times, e.g. `e*`
Rep(Box<ParserNode<'i>>),
+ /// Matches an expression one or more times, e.g. `e+`
RepOnce(Box<ParserNode<'i>>),
+ /// Matches an expression an exact number of times, e.g. `e{n}`
RepExact(Box<ParserNode<'i>>, u32),
+ /// Matches an expression at least a number of times, e.g. `e{n,}`
RepMin(Box<ParserNode<'i>>, u32),
+ /// Matches an expression at most a number of times, e.g. `e{,n}`
RepMax(Box<ParserNode<'i>>, u32),
+ /// Matches an expression a number of times within a range, e.g. `e{m, n}`
RepMinMax(Box<ParserNode<'i>>, u32, u32),
+ /// Matches an expression and pushes it to the stack, e.g. `push(e)`
Push(Box<ParserNode<'i>>),
}
-fn convert_rule(rule: ParserRule) -> AstRule {
+fn convert_rule(rule: ParserRule<'_>) -> AstRule {
let ParserRule { name, ty, node, .. } = rule;
let expr = convert_node(node);
AstRule { name, ty, expr }
}
-fn convert_node(node: ParserNode) -> Expr {
+fn convert_node(node: ParserNode<'_>) -> Expr {
match node.expr {
ParserExpr::Str(string) => Expr::Str(string),
ParserExpr::Insens(string) => Expr::Insens(string),
@@ -164,7 +202,8 @@ fn convert_node(node: ParserNode) -> Expr {
}
}
-pub fn consume_rules(pairs: Pairs<Rule>) -> Result<Vec<AstRule>, Vec<Error<Rule>>> {
+/// Converts a parser's result (`Pairs`) to an AST
+pub fn consume_rules(pairs: Pairs<'_, Rule>) -> Result<Vec<AstRule>, Vec<Error<Rule>>> {
let rules = consume_rules_with_spans(pairs)?;
let errors = validator::validate_ast(&rules);
if errors.is_empty() {
@@ -174,11 +213,46 @@ pub fn consume_rules(pairs: Pairs<Rule>) -> Result<Vec<AstRule>, Vec<Error<Rule>
}
}
-fn consume_rules_with_spans(pairs: Pairs<Rule>) -> Result<Vec<ParserRule>, Vec<Error<Rule>>> {
- let climber = PrecClimber::new(vec![
- Operator::new(Rule::choice_operator, Assoc::Left),
- Operator::new(Rule::sequence_operator, Assoc::Left),
- ]);
+/// A helper function to rename verbose rules
+/// for the sake of better error messages
+#[inline]
+pub fn rename_meta_rule(rule: &Rule) -> String {
+ match *rule {
+ Rule::grammar_rule => "rule".to_owned(),
+ Rule::_push => "PUSH".to_owned(),
+ Rule::assignment_operator => "`=`".to_owned(),
+ Rule::silent_modifier => "`_`".to_owned(),
+ Rule::atomic_modifier => "`@`".to_owned(),
+ Rule::compound_atomic_modifier => "`$`".to_owned(),
+ Rule::non_atomic_modifier => "`!`".to_owned(),
+ Rule::opening_brace => "`{`".to_owned(),
+ Rule::closing_brace => "`}`".to_owned(),
+ Rule::opening_brack => "`[`".to_owned(),
+ Rule::closing_brack => "`]`".to_owned(),
+ Rule::opening_paren => "`(`".to_owned(),
+ Rule::positive_predicate_operator => "`&`".to_owned(),
+ Rule::negative_predicate_operator => "`!`".to_owned(),
+ Rule::sequence_operator => "`&`".to_owned(),
+ Rule::choice_operator => "`|`".to_owned(),
+ Rule::optional_operator => "`?`".to_owned(),
+ Rule::repeat_operator => "`*`".to_owned(),
+ Rule::repeat_once_operator => "`+`".to_owned(),
+ Rule::comma => "`,`".to_owned(),
+ Rule::closing_paren => "`)`".to_owned(),
+ Rule::quote => "`\"`".to_owned(),
+ Rule::insensitive_string => "`^`".to_owned(),
+ Rule::range_operator => "`..`".to_owned(),
+ Rule::single_quote => "`'`".to_owned(),
+ other_rule => format!("{:?}", other_rule),
+ }
+}
+
+fn consume_rules_with_spans(
+ pairs: Pairs<'_, Rule>,
+) -> Result<Vec<ParserRule<'_>>, Vec<Error<Rule>>> {
+ let pratt = PrattParser::new()
+ .op(Op::infix(Rule::choice_operator, Assoc::Left))
+ .op(Op::infix(Rule::sequence_operator, Assoc::Left));
pairs
.filter(|pair| pair.as_rule() == Rule::grammar_rule)
@@ -210,7 +284,7 @@ fn consume_rules_with_spans(pairs: Pairs<Rule>) -> Result<Vec<ParserRule>, Vec<E
inner_nodes.next().unwrap();
}
- let node = consume_expr(inner_nodes, &climber)?;
+ let node = consume_expr(inner_nodes, &pratt)?;
Ok(ParserRule {
name,
@@ -224,17 +298,17 @@ fn consume_rules_with_spans(pairs: Pairs<Rule>) -> Result<Vec<ParserRule>, Vec<E
fn consume_expr<'i>(
pairs: Peekable<Pairs<'i, Rule>>,
- climber: &PrecClimber<Rule>,
+ pratt: &PrattParser<Rule>,
) -> Result<ParserNode<'i>, Vec<Error<Rule>>> {
fn unaries<'i>(
mut pairs: Peekable<Pairs<'i, Rule>>,
- climber: &PrecClimber<Rule>,
+ pratt: &PrattParser<Rule>,
) -> Result<ParserNode<'i>, Vec<Error<Rule>>> {
let pair = pairs.next().unwrap();
let node = match pair.as_rule() {
Rule::opening_paren => {
- let node = unaries(pairs, climber)?;
+ let node = unaries(pairs, pratt)?;
let end = node.span.end_pos();
ParserNode {
@@ -243,7 +317,7 @@ fn consume_expr<'i>(
}
}
Rule::positive_predicate_operator => {
- let node = unaries(pairs, climber)?;
+ let node = unaries(pairs, pratt)?;
let end = node.span.end_pos();
ParserNode {
@@ -252,7 +326,7 @@ fn consume_expr<'i>(
}
}
Rule::negative_predicate_operator => {
- let node = unaries(pairs, climber)?;
+ let node = unaries(pairs, pratt)?;
let end = node.span.end_pos();
ParserNode {
@@ -262,14 +336,14 @@ fn consume_expr<'i>(
}
other_rule => {
let node = match other_rule {
- Rule::expression => consume_expr(pair.into_inner().peekable(), climber)?,
+ Rule::expression => consume_expr(pair.into_inner().peekable(), pratt)?,
Rule::_push => {
let start = pair.clone().as_span().start_pos();
let mut pairs = pair.into_inner();
pairs.next().unwrap(); // opening_paren
let pair = pairs.next().unwrap();
- let node = consume_expr(pair.into_inner().peekable(), climber)?;
+ let node = consume_expr(pair.into_inner().peekable(), pratt)?;
let end = node.span.end_pos();
ParserNode {
@@ -529,7 +603,7 @@ fn consume_expr<'i>(
Ok(node)
}
- let term = |pair: Pair<'i, Rule>| unaries(pair.into_inner().peekable(), climber);
+ let term = |pair: Pair<'i, Rule>| unaries(pair.into_inner().peekable(), pratt);
let infix = |lhs: Result<ParserNode<'i>, Vec<Error<Rule>>>,
op: Pair<'i, Rule>,
rhs: Result<ParserNode<'i>, Vec<Error<Rule>>>| match op.as_rule() {
@@ -560,7 +634,7 @@ fn consume_expr<'i>(
_ => unreachable!(),
};
- climber.climb(pairs, term, infix)
+ pratt.map_primary(term).map_infix(infix).parse(pairs)
}
fn unescape(string: &str) -> Option<String> {
@@ -1528,19 +1602,19 @@ mod tests {
));
const ERROR: &str = "call limit reached";
pest::set_call_limit(Some(5_000usize.try_into().unwrap()));
- let s1 = crate::parser::parse(crate::parser::Rule::grammar_rules, sample1);
+ let s1 = parse(Rule::grammar_rules, sample1);
assert!(s1.is_err());
assert_eq!(s1.unwrap_err().variant.message(), ERROR);
- let s2 = crate::parser::parse(crate::parser::Rule::grammar_rules, sample2);
+ let s2 = parse(Rule::grammar_rules, sample2);
assert!(s2.is_err());
assert_eq!(s2.unwrap_err().variant.message(), ERROR);
- let s3 = crate::parser::parse(crate::parser::Rule::grammar_rules, sample3);
+ let s3 = parse(Rule::grammar_rules, sample3);
assert!(s3.is_err());
assert_eq!(s3.unwrap_err().variant.message(), ERROR);
- let s4 = crate::parser::parse(crate::parser::Rule::grammar_rules, sample4);
+ let s4 = parse(Rule::grammar_rules, sample4);
assert!(s4.is_err());
assert_eq!(s4.unwrap_err().variant.message(), ERROR);
- let s5 = crate::parser::parse(crate::parser::Rule::grammar_rules, sample5);
+ let s5 = parse(Rule::grammar_rules, sample5);
assert!(s5.is_err());
assert_eq!(s5.unwrap_err().variant.message(), ERROR);
}
diff --git a/vendor/pest_meta/src/validator.rs b/vendor/pest_meta/src/validator.rs
index 5448c3bcd..cfc445f0e 100644
--- a/vendor/pest_meta/src/validator.rs
+++ b/vendor/pest_meta/src/validator.rs
@@ -7,15 +7,18 @@
// option. All files in the project carrying such notice may not be copied,
// modified, or distributed except according to those terms.
+//! Helpers for validating pest grammars that could help with debugging
+//! and provide a more user-friendly error message.
+
use once_cell::sync::Lazy;
use std::collections::{HashMap, HashSet};
use pest::error::{Error, ErrorVariant, InputLocation};
use pest::iterators::Pairs;
+use pest::unicode::unicode_property_names;
use pest::Span;
use crate::parser::{ParserExpr, ParserNode, ParserRule, Rule};
-use crate::UNICODE_PROPERTY_NAMES;
static RUST_KEYWORDS: Lazy<HashSet<&'static str>> = Lazy::new(|| {
[
@@ -63,16 +66,24 @@ static BUILTINS: Lazy<HashSet<&'static str>> = Lazy::new(|| {
]
.iter()
.cloned()
- .chain(UNICODE_PROPERTY_NAMES.iter().cloned())
+ .chain(unicode_property_names())
.collect::<HashSet<&str>>()
});
-pub fn validate_pairs(pairs: Pairs<Rule>) -> Result<Vec<&str>, Vec<Error<Rule>>> {
+/// It checks the parsed grammar for common mistakes:
+/// - using Pest keywords
+/// - duplicate rules
+/// - undefined rules
+///
+/// It returns a `Result` with a `Vec` of `Error`s if any of the above is found.
+/// If no errors are found, it returns the vector of names of used builtin rules.
+pub fn validate_pairs(pairs: Pairs<'_, Rule>) -> Result<Vec<&str>, Vec<Error<Rule>>> {
let definitions: Vec<_> = pairs
.clone()
.filter(|pair| pair.as_rule() == Rule::grammar_rule)
.map(|pair| pair.into_inner().next().unwrap().as_span())
.collect();
+
let called_rules: Vec<_> = pairs
.clone()
.filter(|pair| pair.as_rule() == Rule::grammar_rule)
@@ -87,7 +98,6 @@ pub fn validate_pairs(pairs: Pairs<Rule>) -> Result<Vec<&str>, Vec<Error<Rule>>>
let mut errors = vec![];
- errors.extend(validate_rust_keywords(&definitions));
errors.extend(validate_pest_keywords(&definitions));
errors.extend(validate_already_defined(&definitions));
errors.extend(validate_undefined(&definitions, &called_rules));
@@ -104,8 +114,10 @@ pub fn validate_pairs(pairs: Pairs<Rule>) -> Result<Vec<&str>, Vec<Error<Rule>>>
Ok(defaults.cloned().collect())
}
+/// Validates that the given `definitions` do not contain any Rust keywords.
#[allow(clippy::ptr_arg)]
-pub fn validate_rust_keywords(definitions: &Vec<Span>) -> Vec<Error<Rule>> {
+#[deprecated = "Rust keywords are no longer restricted from the pest grammar"]
+pub fn validate_rust_keywords(definitions: &Vec<Span<'_>>) -> Vec<Error<Rule>> {
let mut errors = vec![];
for definition in definitions {
@@ -124,8 +136,9 @@ pub fn validate_rust_keywords(definitions: &Vec<Span>) -> Vec<Error<Rule>> {
errors
}
+/// Validates that the given `definitions` do not contain any Pest keywords.
#[allow(clippy::ptr_arg)]
-pub fn validate_pest_keywords(definitions: &Vec<Span>) -> Vec<Error<Rule>> {
+pub fn validate_pest_keywords(definitions: &Vec<Span<'_>>) -> Vec<Error<Rule>> {
let mut errors = vec![];
for definition in definitions {
@@ -144,8 +157,9 @@ pub fn validate_pest_keywords(definitions: &Vec<Span>) -> Vec<Error<Rule>> {
errors
}
+/// Validates that the given `definitions` do not contain any duplicate rules.
#[allow(clippy::ptr_arg)]
-pub fn validate_already_defined(definitions: &Vec<Span>) -> Vec<Error<Rule>> {
+pub fn validate_already_defined(definitions: &Vec<Span<'_>>) -> Vec<Error<Rule>> {
let mut errors = vec![];
let mut defined = HashSet::new();
@@ -167,6 +181,7 @@ pub fn validate_already_defined(definitions: &Vec<Span>) -> Vec<Error<Rule>> {
errors
}
+/// Validates that the given `definitions` do not contain any undefined rules.
#[allow(clippy::ptr_arg)]
pub fn validate_undefined<'i>(
definitions: &Vec<Span<'i>>,
@@ -191,6 +206,10 @@ pub fn validate_undefined<'i>(
errors
}
+/// Validates the abstract syntax tree for common mistakes:
+/// - infinite repetitions
+/// - choices that cannot be reached
+/// - left recursion
#[allow(clippy::ptr_arg)]
pub fn validate_ast<'a, 'i: 'a>(rules: &'a Vec<ParserRule<'i>>) -> Vec<Error<Rule>> {
let mut errors = vec![];
@@ -423,7 +442,7 @@ fn left_recursion<'a, 'i: 'a>(rules: HashMap<String, &'a ParserNode<'i>>) -> Vec
return Some(Error::new_from_span(
ErrorVariant::CustomError {
message: format!(
- "rule {} is left-recursive ({}); pest::prec_climber might be useful \
+ "rule {} is left-recursive ({}); pest::pratt_parser might be useful \
in this case",
node.span.as_str(),
chain
@@ -490,22 +509,6 @@ mod tests {
--> 1:1
|
-1 | let = { \"a\" }
- | ^-^
- |
- = let is a rust keyword")]
- fn rust_keyword() {
- let input = "let = { \"a\" }";
- unwrap_or_report(validate_pairs(
- PestParser::parse(Rule::grammar_rules, input).unwrap(),
- ));
- }
-
- #[test]
- #[should_panic(expected = "grammar error
-
- --> 1:1
- |
1 | ANY = { \"a\" }
| ^-^
|
@@ -677,7 +680,7 @@ mod tests {
1 | a = { a }
| ^
|
- = rule a is left-recursive (a -> a); pest::prec_climber might be useful in this case")]
+ = rule a is left-recursive (a -> a); pest::pratt_parser might be useful in this case")]
fn simple_left_recursion() {
let input = "a = { a }";
unwrap_or_report(consume_rules(
@@ -693,14 +696,14 @@ mod tests {
1 | a = { b } b = { a }
| ^
|
- = rule b is left-recursive (b -> a -> b); pest::prec_climber might be useful in this case
+ = rule b is left-recursive (b -> a -> b); pest::pratt_parser might be useful in this case
--> 1:17
|
1 | a = { b } b = { a }
| ^
|
- = rule a is left-recursive (a -> b -> a); pest::prec_climber might be useful in this case")]
+ = rule a is left-recursive (a -> b -> a); pest::pratt_parser might be useful in this case")]
fn indirect_left_recursion() {
let input = "a = { b } b = { a }";
unwrap_or_report(consume_rules(
@@ -716,7 +719,7 @@ mod tests {
1 | a = { \"\" ~ \"a\"? ~ \"a\"* ~ (\"a\" | \"\") ~ a }
| ^
|
- = rule a is left-recursive (a -> a); pest::prec_climber might be useful in this case")]
+ = rule a is left-recursive (a -> a); pest::pratt_parser might be useful in this case")]
fn non_failing_left_recursion() {
let input = "a = { \"\" ~ \"a\"? ~ \"a\"* ~ (\"a\" | \"\") ~ a }";
unwrap_or_report(consume_rules(
@@ -732,7 +735,7 @@ mod tests {
1 | a = { \"a\" | a }
| ^
|
- = rule a is left-recursive (a -> a); pest::prec_climber might be useful in this case")]
+ = rule a is left-recursive (a -> a); pest::pratt_parser might be useful in this case")]
fn non_primary_choice_left_recursion() {
let input = "a = { \"a\" | a }";
unwrap_or_report(consume_rules(