summaryrefslogtreecommitdiffstats
path: root/vendor/pest_meta
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
commitdc0db358abe19481e475e10c32149b53370f1a1c (patch)
treeab8ce99c4b255ce46f99ef402c27916055b899ee /vendor/pest_meta
parentReleasing progress-linux version 1.71.1+dfsg1-2~progress7.99u1. (diff)
downloadrustc-dc0db358abe19481e475e10c32149b53370f1a1c.tar.xz
rustc-dc0db358abe19481e475e10c32149b53370f1a1c.zip
Merging upstream version 1.72.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/pest_meta')
-rw-r--r--vendor/pest_meta/.cargo-checksum.json2
-rw-r--r--vendor/pest_meta/Cargo.toml15
-rw-r--r--vendor/pest_meta/_README.md5
-rw-r--r--vendor/pest_meta/src/ast.rs19
-rw-r--r--vendor/pest_meta/src/grammar.pest165
-rw-r--r--vendor/pest_meta/src/grammar.rs2
-rw-r--r--vendor/pest_meta/src/optimizer/concatenator.rs1
-rw-r--r--vendor/pest_meta/src/optimizer/factorizer.rs1
-rw-r--r--vendor/pest_meta/src/optimizer/lister.rs1
-rw-r--r--vendor/pest_meta/src/optimizer/mod.rs7
-rw-r--r--vendor/pest_meta/src/optimizer/rotater.rs1
-rw-r--r--vendor/pest_meta/src/optimizer/skipper.rs1
-rw-r--r--vendor/pest_meta/src/parser.rs146
-rw-r--r--vendor/pest_meta/src/validator.rs1017
14 files changed, 1278 insertions, 105 deletions
diff --git a/vendor/pest_meta/.cargo-checksum.json b/vendor/pest_meta/.cargo-checksum.json
index 0d3f7bba7..418099f4b 100644
--- a/vendor/pest_meta/.cargo-checksum.json
+++ b/vendor/pest_meta/.cargo-checksum.json
@@ -1 +1 @@
-{"files":{"Cargo.toml":"2cbe14113604630a7f47107363fb06e9845496b59432be525b2dd8bcce61a491","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","_README.md":"647dbcab0b7ed9837cc066cb3731aa2db7fbecb0e9aa187995a0a7a03af3938d","src/ast.rs":"94a0f29ef97a93b161a22042f5ca25b3d83056b45360598431a87c8beac9d489","src/grammar.pest":"43287956e748ca2dd16df376f2557c3ea3f361fb74225b11377d8d55f409540d","src/grammar.rs":"4365a14398ec647cded6ad863a40fa8fdc7a49dd481c5d9d525b8284cf6276f8","src/lib.rs":"a8cfd7c64bbd2b9dc9f0d21b4f3a6139095ead0964f12da86f4ee8079e546c1e","src/optimizer/concatenator.rs":"b77e6ec1d4d79d5383c74435d86e888a048c134fc5cff250356de9405e0ecfab","src/optimizer/factorizer.rs":"451a12845a9013c54e9888506ce7b14b99355682ebca1b918b617085e2152f0f","src/optimizer/lister.rs":"706812c52df72753071bf2db039dffb1061c1a0f030e4c1af67302c632ff15cd","src/optimizer/mod.rs":"e7b9de8206bd8eca4f496c6e51d7f5a0d38345d8542874aef9bff9f59604d2d4","src/optimizer/restorer.rs":"8b65cfe7dfd4d812bee6ac3cdbcc3d0026e03fd2b456a7c866dd83e6fdbf26a7","src/optimizer/rotater.rs":"7256bc8c01a09c5489fdb8d1cc52461bcc5ccf826db478b1420b01473b9b6c62","src/optimizer/skipper.rs":"8a7cd27713c8ffc795a82471242225b5fbbecec221c75fe8ac48e878d5a6088e","src/optimizer/unroller.rs":"f4010f2bf3b2bb0740d17b04c73f772284f576bfb57b9cac16b98293168ffb7a","src/parser.rs":"3320a064905601626c4ad1d4125305c11fa4e19573b2db9ebec893adb1b0c35a","src/validator.rs":"ddc4559f0c05a500c445c57859f011f3c728beaf1608323ee1b917250ce0d127"},"package":"6733073c7cff3d8459fda0e42f13a047870242aed8b509fe98000928975f359e"} \ No newline at end of file
+{"files":{"Cargo.toml":"7c3dbbbad844a574adde0f3ce3a29635bd80e046431fada0fc87fb2458fa10dc","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","_README.md":"b49ff086f7c9e37c8bb432f445168061d74bdaddf713d968b15f5316f940f285","src/ast.rs":"19b227e4a7b9fad226f9f763eda577da5cf5618488ae240b15090fa94d7f1ed1","src/grammar.pest":"90077510db0513bed4eb723548aee349e85837ab3a4286a6379b32b9bc237ac8","src/grammar.rs":"94f1db63dd5dbd176eaafad5dac9dc63da2c2c87ca36868288de4b12bca15605","src/lib.rs":"a8cfd7c64bbd2b9dc9f0d21b4f3a6139095ead0964f12da86f4ee8079e546c1e","src/optimizer/concatenator.rs":"ab613bedc7001ab2057a8afee295ee72fc5ba7fc1017f6806477b8caa37af3c8","src/optimizer/factorizer.rs":"b79591db09a2066315f30398a5a2911db19c982ce49bbc7aa6acce894b4e3ede","src/optimizer/lister.rs":"01acfdcadd197c6a1d9dcf313ea9d0bf13983ef34a1c8638e5b439036b7ee924","src/optimizer/mod.rs":"9a6389ba1f29d53077fc64a5a6a899236efc0d102051c62a56e432e9ed3fcad6","src/optimizer/restorer.rs":"8b65cfe7dfd4d812bee6ac3cdbcc3d0026e03fd2b456a7c866dd83e6fdbf26a7","src/optimizer/rotater.rs":"08da3716296a6bd7d1872b3dacd961814b87854cdd0d9c714974507fe7aca307","src/optimizer/skipper.rs":"4e9b01e93eac9225d4e05481ce362003bad05121f45543f55f58e5da89857a15","src/optimizer/unroller.rs":"f4010f2bf3b2bb0740d17b04c73f772284f576bfb57b9cac16b98293168ffb7a","src/parser.rs":"e537f204d0529ee7bae552ed649dd9792db0446549aed48bf6a29460c8b89960","src/validator.rs":"98b02bead02f8d1dc36245dafb02658c63324a4549ee98f2c942b8356923c5d4"},"package":"a01f71cb40bd8bb94232df14b946909e14660e33fc05db3e50ae2a82d7ea0ca0"} \ No newline at end of file
diff --git a/vendor/pest_meta/Cargo.toml b/vendor/pest_meta/Cargo.toml
index 75e7d097c..1763a727a 100644
--- a/vendor/pest_meta/Cargo.toml
+++ b/vendor/pest_meta/Cargo.toml
@@ -11,9 +11,9 @@
[package]
edition = "2021"
-rust-version = "1.56"
+rust-version = "1.60"
name = "pest_meta"
-version = "2.5.7"
+version = "2.7.0"
authors = ["Dragoș Tiselice <dragostiselice@gmail.com>"]
exclude = ["src/grammar.pest"]
include = [
@@ -41,8 +41,17 @@ repository = "https://github.com/pest-parser/pest"
version = "1.8.0"
[dependencies.pest]
-version = "2.5.7"
+version = "2.7.0"
+
+[build-dependencies.cargo]
+version = "0.70"
+optional = true
[build-dependencies.sha2]
version = "0.10"
default-features = false
+
+[features]
+default = []
+grammar-extras = []
+not-bootstrap-in-src = ["dep:cargo"]
diff --git a/vendor/pest_meta/_README.md b/vendor/pest_meta/_README.md
index cb8055eb0..2bfc5664a 100644
--- a/vendor/pest_meta/_README.md
+++ b/vendor/pest_meta/_README.md
@@ -11,7 +11,7 @@
[![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)
[![codecov](https://codecov.io/gh/pest-parser/pest/branch/master/graph/badge.svg)](https://codecov.io/gh/pest-parser/pest)
-<a href="https://blog.rust-lang.org/2021/11/01/Rust-1.56.1.html"><img alt="Rustc Version 1.56.1+" src="https://img.shields.io/badge/rustc-1.56.1%2B-lightgrey.svg"/></a>
+<a href="https://blog.rust-lang.org/2021/11/01/Rust-1.60.0.html"><img alt="Rustc Version 1.60.0+" src="https://img.shields.io/badge/rustc-1.60.0%2B-lightgrey.svg"/></a>
[![Crates.io](https://img.shields.io/crates/d/pest.svg)](https://crates.io/crates/pest)
[![Crates.io](https://img.shields.io/crates/v/pest.svg)](https://crates.io/crates/pest)
@@ -199,10 +199,11 @@ You can find more projects and ecosystem tools in the [awesome-pest](https://git
* [qubit](https://github.com/abhimanyu003/qubit)
* [caith](https://github.com/Geobert/caith) (a dice roller crate)
* [Melody](https://github.com/yoav-lavi/melody)
+* [json5-nodes](https://github.com/jlyonsmith/json5-nodes)
## Minimum Supported Rust Version (MSRV)
-This library should always compile with default features on **Rust 1.56.1**
+This library should always compile with default features on **Rust 1.60.0**
or **Rust 1.61** with `const_prec_climber`.
## no_std support
diff --git a/vendor/pest_meta/src/ast.rs b/vendor/pest_meta/src/ast.rs
index 77c48e879..d7316832e 100644
--- a/vendor/pest_meta/src/ast.rs
+++ b/vendor/pest_meta/src/ast.rs
@@ -94,6 +94,9 @@ pub enum Expr {
Skip(Vec<String>),
/// Matches an expression and pushes it to the stack, e.g. `push(e)`
Push(Box<Expr>),
+ /// Matches an expression and assigns a label to it, e.g. #label = exp
+ #[cfg(feature = "grammar-extras")]
+ NodeTag(Box<Expr>, String),
}
impl Expr {
@@ -114,7 +117,6 @@ impl Expr {
let expr = f(expr);
match expr {
- // TODO: Use box syntax when it gets stabilized.
Expr::PosPred(expr) => {
let mapped = Box::new(map_internal(*expr, f));
Expr::PosPred(mapped)
@@ -165,6 +167,11 @@ impl Expr {
let mapped = Box::new(map_internal(*expr, f));
Expr::Push(mapped)
}
+ #[cfg(feature = "grammar-extras")]
+ Expr::NodeTag(expr, tag) => {
+ let mapped = Box::new(map_internal(*expr, f));
+ Expr::NodeTag(mapped, tag)
+ }
expr => expr,
}
}
@@ -183,7 +190,6 @@ impl Expr {
{
let mapped = match expr {
Expr::PosPred(expr) => {
- // TODO: Use box syntax when it gets stabilized.
let mapped = Box::new(map_internal(*expr, f));
Expr::PosPred(mapped)
}
@@ -233,6 +239,11 @@ impl Expr {
let mapped = Box::new(map_internal(*expr, f));
Expr::Push(mapped)
}
+ #[cfg(feature = "grammar-extras")]
+ Expr::NodeTag(expr, tag) => {
+ let mapped = Box::new(map_internal(*expr, f));
+ Expr::NodeTag(mapped, tag)
+ }
expr => expr,
};
@@ -285,6 +296,10 @@ impl ExprTopDownIterator {
| Expr::Push(expr) => {
self.next = Some(*expr);
}
+ #[cfg(feature = "grammar-extras")]
+ Expr::NodeTag(expr, _) => {
+ self.next = Some(*expr);
+ }
_ => {
self.next = None;
}
diff --git a/vendor/pest_meta/src/grammar.pest b/vendor/pest_meta/src/grammar.pest
index cb02941d6..d97caba00 100644
--- a/vendor/pest_meta/src/grammar.pest
+++ b/vendor/pest_meta/src/grammar.pest
@@ -1,6 +1,6 @@
// pest. The Elegant Parser
// Copyright (c) 2018 Dragoș Tiselice
-//
+//
// Licensed under the Apache License, Version 2.0
// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT
// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
@@ -16,97 +16,126 @@
//! future (e.g. by increasing MSRV and non_exhaustive annotations).
/// The top-level rule of a grammar.
-grammar_rules = _{ SOI ~ grammar_doc* ~ (grammar_rule)+ ~ EOI }
+grammar_rules = _{ SOI ~ grammar_doc* ~ grammar_rule* ~ EOI }
/// A rule of a grammar.
grammar_rule = {
- identifier ~ assignment_operator ~ modifier? ~
- opening_brace ~ expression ~ closing_brace |
- line_doc
+ identifier ~ assignment_operator ~ modifier? ~ opening_brace ~ expression ~ closing_brace
+ | line_doc
}
/// Assignment operator.
assignment_operator = { "=" }
+
/// Opening brace for a rule.
-opening_brace = { "{" }
+opening_brace = { "{" }
+
/// Closing brace for a rule.
-closing_brace = { "}" }
+closing_brace = { "}" }
+
/// Opening parenthesis for a branch, PUSH, etc.
-opening_paren = { "(" }
+opening_paren = { "(" }
+
/// Closing parenthesis for a branch, PUSH, etc.
-closing_paren = { ")" }
+closing_paren = { ")" }
+
/// Opening bracket for PEEK (slice inside).
-opening_brack = { "[" }
+opening_brack = { "[" }
+
/// Closing bracket for PEEK (slice inside).
-closing_brack = { "]" }
+closing_brack = { "]" }
/// A rule modifier.
modifier = _{
- silent_modifier |
- atomic_modifier |
- compound_atomic_modifier |
- non_atomic_modifier
+ silent_modifier
+ | atomic_modifier
+ | compound_atomic_modifier
+ | non_atomic_modifier
}
/// Silent rule prefix.
-silent_modifier = { "_" }
+silent_modifier = { "_" }
+
/// Atomic rule prefix.
-atomic_modifier = { "@" }
+atomic_modifier = { "@" }
+
/// Compound atomic rule prefix.
compound_atomic_modifier = { "$" }
+
/// Non-atomic rule prefix.
-non_atomic_modifier = { "!" }
+non_atomic_modifier = { "!" }
+
+/// A tag label.
+tag_id = @{ "#" ~ ("_" | alpha) ~ ("_" | alpha_num)* }
+
+/// For assigning labels to nodes.
+node_tag = _{ tag_id ~ assignment_operator }
/// A rule expression.
-expression = { choice_operator? ~ term ~ (infix_operator ~ term)* }
+expression = { choice_operator? ~ term ~ (infix_operator ~ term)* }
+
/// A rule term.
-term = { prefix_operator* ~ node ~ postfix_operator* }
+term = { node_tag? ~ prefix_operator* ~ node ~ postfix_operator* }
+
/// A rule node (inside terms).
-node = _{ opening_paren ~ expression ~ closing_paren | terminal }
+node = _{ opening_paren ~ expression ~ closing_paren | terminal }
+
/// A terminal expression.
-terminal = _{ _push | peek_slice | identifier | string | insensitive_string | range }
+terminal = _{ _push | peek_slice | identifier | string | insensitive_string | range }
/// Possible predicates for a rule.
-prefix_operator = _{ positive_predicate_operator | negative_predicate_operator }
+prefix_operator = _{ positive_predicate_operator | negative_predicate_operator }
+
/// Branches or sequences.
-infix_operator = _{ sequence_operator | choice_operator }
+infix_operator = _{ sequence_operator | choice_operator }
+
/// Possible modifiers for a rule.
postfix_operator = _{
- optional_operator |
- repeat_operator |
- repeat_once_operator |
- repeat_exact |
- repeat_min |
- repeat_max |
- repeat_min_max
+ optional_operator
+ | repeat_operator
+ | repeat_once_operator
+ | repeat_exact
+ | repeat_min
+ | repeat_max
+ | repeat_min_max
}
/// A positive predicate.
positive_predicate_operator = { "&" }
+
/// A negative predicate.
negative_predicate_operator = { "!" }
+
/// A sequence operator.
-sequence_operator = { "~" }
+sequence_operator = { "~" }
+
/// A choice operator.
-choice_operator = { "|" }
+choice_operator = { "|" }
+
/// An optional operator.
-optional_operator = { "?" }
+optional_operator = { "?" }
+
/// A repeat operator.
-repeat_operator = { "*" }
+repeat_operator = { "*" }
+
/// A repeat at least once operator.
-repeat_once_operator = { "+" }
+repeat_once_operator = { "+" }
/// A repeat exact times.
-repeat_exact = { opening_brace ~ number ~ closing_brace }
+repeat_exact = { opening_brace ~ number ~ closing_brace }
+
/// A repeat at least times.
-repeat_min = { opening_brace ~ number ~ comma ~ closing_brace }
+repeat_min = { opening_brace ~ number ~ comma ~ closing_brace }
+
/// A repeat at most times.
-repeat_max = { opening_brace ~ comma ~ number ~ closing_brace }
+repeat_max = { opening_brace ~ comma ~ number ~ closing_brace }
+
/// A repeat in a range.
repeat_min_max = { opening_brace ~ number ~ comma ~ number ~ closing_brace }
/// A number.
number = @{ '0'..'9'+ }
+
/// An integer number (positive or negative).
integer = @{ number | "-" ~ "0"* ~ '1'..'9' ~ number? }
@@ -115,62 +144,82 @@ comma = { "," }
/// A PUSH expression.
_push = { "PUSH" ~ opening_paren ~ expression ~ closing_paren }
+
/// A PEEK expression.
peek_slice = { "PEEK" ~ opening_brack ~ integer? ~ range_operator ~ integer? ~ closing_brack }
/// An identifier.
identifier = @{ !"PUSH" ~ ("_" | alpha) ~ ("_" | alpha_num)* }
+
/// An alpha character.
-alpha = _{ 'a'..'z' | 'A'..'Z' }
+alpha = _{ 'a'..'z' | 'A'..'Z' }
+
/// An alphanumeric character.
-alpha_num = _{ alpha | '0'..'9' }
+alpha_num = _{ alpha | '0'..'9' }
/// A string.
-string = ${ quote ~ inner_str ~ quote }
+string = ${ quote ~ inner_str ~ quote }
+
/// An insensitive string.
-insensitive_string = { "^" ~ string }
+insensitive_string = { "^" ~ string }
+
/// A character range.
-range = { character ~ range_operator ~ character }
+range = { character ~ range_operator ~ character }
+
/// A single quoted character
-character = ${ single_quote ~ inner_chr ~ single_quote }
+character = ${ single_quote ~ inner_chr ~ single_quote }
/// A quoted string.
inner_str = @{ (!("\"" | "\\") ~ ANY)* ~ (escape ~ inner_str)? }
+
/// An escaped or any character.
inner_chr = @{ escape | ANY }
+
/// An escape sequence.
-escape = @{ "\\" ~ ("\"" | "\\" | "r" | "n" | "t" | "0" | "'" | code | unicode) }
+escape = @{ "\\" ~ ("\"" | "\\" | "r" | "n" | "t" | "0" | "'" | code | unicode) }
+
/// A hexadecimal code.
-code = @{ "x" ~ hex_digit{2} }
+code = @{ "x" ~ hex_digit{2} }
+
/// A unicode code.
-unicode = @{ "u" ~ opening_brace ~ hex_digit{2, 6} ~ closing_brace }
+unicode = @{ "u" ~ opening_brace ~ hex_digit{2, 6} ~ closing_brace }
+
/// A hexadecimal digit.
hex_digit = @{ '0'..'9' | 'a'..'f' | 'A'..'F' }
/// A double quote.
-quote = { "\"" }
+quote = { "\"" }
+
/// A single quote.
-single_quote = { "'" }
+single_quote = { "'" }
+
/// A range operator.
range_operator = { ".." }
/// A newline character.
-newline = _{ "\n" | "\r\n" }
+newline = _{ "\n" | "\r\n" }
+
/// A whitespace character.
-WHITESPACE = _{ " " | "\t" | newline }
+WHITESPACE = _{ " " | "\t" | newline }
+
/// A single line comment.
-line_comment = _{ ("//" ~ !("/" | "!") ~ (!newline ~ ANY)*) }
+line_comment = _{ ("//" ~ !("/" | "!") ~ (!newline ~ ANY)*) }
+
/// A multi-line comment.
-block_comment = _{ "/*" ~ (block_comment | !"*/" ~ ANY)* ~ "*/" }
+block_comment = _{ "/*" ~ (block_comment | !"*/" ~ ANY)* ~ "*/" }
+
/// A grammar comment.
-COMMENT = _{ block_comment | line_comment }
+COMMENT = _{ block_comment | line_comment }
// ref: https://doc.rust-lang.org/reference/comments.html
/// A space character.
-space = _{ " " | "\t" }
+space = _{ " " | "\t" }
+
/// A top-level comment.
grammar_doc = ${ "//!" ~ space? ~ inner_doc }
+
/// A rule comment.
-line_doc = ${ "///" ~ space? ~ inner_doc }
+line_doc = ${ "///" ~ space? ~ inner_doc }
+
/// A comment content.
-inner_doc = @{ (!newline ~ ANY)* }
+inner_doc = @{ (!newline ~ ANY)* }
diff --git a/vendor/pest_meta/src/grammar.rs b/vendor/pest_meta/src/grammar.rs
index 775116186..32ef4bef0 100644
--- a/vendor/pest_meta/src/grammar.rs
+++ b/vendor/pest_meta/src/grammar.rs
@@ -1,2 +1,2 @@
pub struct PestParser;
-# [doc = "Pest meta-grammar\n\n# Warning: Semantic Versioning\nThere may be non-breaking changes to the meta-grammar\nbetween minor versions. Those non-breaking changes, however,\nmay translate into semver-breaking changes due to the additional variants\nadded to the `Rule` enum. This is a known issue and will be fixed in the\nfuture (e.g. by increasing MSRV and non_exhaustive annotations)."] # [allow (dead_code , non_camel_case_types , clippy :: upper_case_acronyms)] # [derive (Clone , Copy , Debug , Eq , Hash , Ord , PartialEq , PartialOrd)] pub enum Rule { EOI , # [doc = "The top-level rule of a grammar."] r#grammar_rules , # [doc = "A rule of a grammar."] r#grammar_rule , # [doc = "Assignment operator."] r#assignment_operator , # [doc = "Opening brace for a rule."] r#opening_brace , # [doc = "Closing brace for a rule."] r#closing_brace , # [doc = "Opening parenthesis for a branch, PUSH, etc."] r#opening_paren , # [doc = "Closing parenthesis for a branch, PUSH, etc."] r#closing_paren , # [doc = "Opening bracket for PEEK (slice inside)."] r#opening_brack , # [doc = "Closing bracket for PEEK (slice inside)."] r#closing_brack , # [doc = "A rule modifier."] r#modifier , # [doc = "Silent rule prefix."] r#silent_modifier , # [doc = "Atomic rule prefix."] r#atomic_modifier , # [doc = "Compound atomic rule prefix."] r#compound_atomic_modifier , # [doc = "Non-atomic rule prefix."] r#non_atomic_modifier , # [doc = "A rule expression."] r#expression , # [doc = "A rule term."] r#term , # [doc = "A rule node (inside terms)."] r#node , # [doc = "A terminal expression."] r#terminal , # [doc = "Possible predicates for a rule."] r#prefix_operator , # [doc = "Branches or sequences."] r#infix_operator , # [doc = "Possible modifiers for a rule."] r#postfix_operator , # [doc = "A positive predicate."] r#positive_predicate_operator , # [doc = "A negative predicate."] r#negative_predicate_operator , # [doc = "A sequence operator."] r#sequence_operator , # [doc = "A choice operator."] r#choice_operator , # [doc = "An optional operator."] r#optional_operator , # [doc = "A repeat operator."] r#repeat_operator , # [doc = "A repeat at least once operator."] r#repeat_once_operator , # [doc = "A repeat exact times."] r#repeat_exact , # [doc = "A repeat at least times."] r#repeat_min , # [doc = "A repeat at most times."] r#repeat_max , # [doc = "A repeat in a range."] r#repeat_min_max , # [doc = "A number."] r#number , # [doc = "An integer number (positive or negative)."] r#integer , # [doc = "A comma terminal."] r#comma , # [doc = "A PUSH expression."] r#_push , # [doc = "A PEEK expression."] r#peek_slice , # [doc = "An identifier."] r#identifier , # [doc = "An alpha character."] r#alpha , # [doc = "An alphanumeric character."] r#alpha_num , # [doc = "A string."] r#string , # [doc = "An insensitive string."] r#insensitive_string , # [doc = "A character range."] r#range , # [doc = "A single quoted character"] r#character , # [doc = "A quoted string."] r#inner_str , # [doc = "An escaped or any character."] r#inner_chr , # [doc = "An escape sequence."] r#escape , # [doc = "A hexadecimal code."] r#code , # [doc = "A unicode code."] r#unicode , # [doc = "A hexadecimal digit."] r#hex_digit , # [doc = "A double quote."] r#quote , # [doc = "A single quote."] r#single_quote , # [doc = "A range operator."] r#range_operator , # [doc = "A newline character."] r#newline , # [doc = "A whitespace character."] r#WHITESPACE , # [doc = "A single line comment."] r#line_comment , # [doc = "A multi-line comment."] r#block_comment , # [doc = "A grammar comment."] r#COMMENT , # [doc = "A space character."] r#space , # [doc = "A top-level comment."] r#grammar_doc , # [doc = "A rule comment."] r#line_doc , # [doc = "A comment content."] r#inner_doc } # [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 r#grammar_rules (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . sequence (| state | { self :: r#SOI (state) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { state . sequence (| state | { state . optional (| state | { self :: r#grammar_doc (state) . and_then (| state | { state . repeat (| state | { state . sequence (| state | { super :: hidden :: skip (state) . and_then (| state | { self :: r#grammar_doc (state) }) }) }) }) }) }) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { state . sequence (| state | { self :: r#grammar_rule (state) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { state . sequence (| state | { state . optional (| state | { self :: r#grammar_rule (state) . and_then (| state | { state . repeat (| state | { state . sequence (| state | { super :: hidden :: skip (state) . and_then (| state | { self :: r#grammar_rule (state) }) }) }) }) }) }) }) }) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: r#EOI (state) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#grammar_rule (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#grammar_rule , | state | { state . sequence (| state | { self :: r#identifier (state) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: r#assignment_operator (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { state . optional (| state | { self :: r#modifier (state) }) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: r#opening_brace (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: r#expression (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: r#closing_brace (state) }) }) . or_else (| state | { self :: r#line_doc (state) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#assignment_operator (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#assignment_operator , | state | { state . match_string ("=") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#opening_brace (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#opening_brace , | state | { state . match_string ("{") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#closing_brace (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#closing_brace , | state | { state . match_string ("}") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#opening_paren (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#opening_paren , | state | { state . match_string ("(") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#closing_paren (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#closing_paren , | state | { state . match_string (")") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#opening_brack (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#opening_brack , | state | { state . match_string ("[") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#closing_brack (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#closing_brack , | state | { state . match_string ("]") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#modifier (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { self :: r#silent_modifier (state) . or_else (| state | { self :: r#atomic_modifier (state) }) . or_else (| state | { self :: r#compound_atomic_modifier (state) }) . or_else (| state | { self :: r#non_atomic_modifier (state) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#silent_modifier (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#silent_modifier , | state | { state . match_string ("_") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#atomic_modifier (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#atomic_modifier , | state | { state . match_string ("@") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#compound_atomic_modifier (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#compound_atomic_modifier , | state | { state . match_string ("$") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#non_atomic_modifier (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#non_atomic_modifier , | state | { state . match_string ("!") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#expression (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#expression , | state | { state . sequence (| state | { state . optional (| state | { self :: r#choice_operator (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: r#term (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { state . sequence (| state | { state . optional (| state | { state . sequence (| state | { self :: r#infix_operator (state) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: r#term (state) }) }) . and_then (| state | { state . repeat (| state | { state . sequence (| state | { super :: hidden :: skip (state) . and_then (| state | { state . sequence (| state | { self :: r#infix_operator (state) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: r#term (state) }) }) }) }) }) }) }) }) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#term (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#term , | state | { state . sequence (| state | { state . sequence (| state | { state . optional (| state | { self :: r#prefix_operator (state) . and_then (| state | { state . repeat (| state | { state . sequence (| state | { super :: hidden :: skip (state) . and_then (| state | { self :: r#prefix_operator (state) }) }) }) }) }) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: r#node (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { state . sequence (| state | { state . optional (| state | { self :: r#postfix_operator (state) . and_then (| state | { state . repeat (| state | { state . sequence (| state | { super :: hidden :: skip (state) . and_then (| state | { self :: r#postfix_operator (state) }) }) }) }) }) }) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#node (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . sequence (| state | { self :: r#opening_paren (state) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: r#expression (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: r#closing_paren (state) }) }) . or_else (| state | { self :: r#terminal (state) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#terminal (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { self :: r#_push (state) . or_else (| state | { self :: r#peek_slice (state) }) . or_else (| state | { self :: r#identifier (state) }) . or_else (| state | { self :: r#string (state) }) . or_else (| state | { self :: r#insensitive_string (state) }) . or_else (| state | { self :: r#range (state) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#prefix_operator (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { self :: r#positive_predicate_operator (state) . or_else (| state | { self :: r#negative_predicate_operator (state) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#infix_operator (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { self :: r#sequence_operator (state) . or_else (| state | { self :: r#choice_operator (state) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#postfix_operator (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { self :: r#optional_operator (state) . or_else (| state | { self :: r#repeat_operator (state) }) . or_else (| state | { self :: r#repeat_once_operator (state) }) . or_else (| state | { self :: r#repeat_exact (state) }) . or_else (| state | { self :: r#repeat_min (state) }) . or_else (| state | { self :: r#repeat_max (state) }) . or_else (| state | { self :: r#repeat_min_max (state) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#positive_predicate_operator (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#positive_predicate_operator , | state | { state . match_string ("&") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#negative_predicate_operator (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#negative_predicate_operator , | state | { state . match_string ("!") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#sequence_operator (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#sequence_operator , | state | { state . match_string ("~") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#choice_operator (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#choice_operator , | state | { state . match_string ("|") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#optional_operator (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#optional_operator , | state | { state . match_string ("?") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#repeat_operator (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#repeat_operator , | state | { state . match_string ("*") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#repeat_once_operator (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#repeat_once_operator , | state | { state . match_string ("+") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#repeat_exact (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#repeat_exact , | state | { state . sequence (| state | { self :: r#opening_brace (state) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: r#number (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: r#closing_brace (state) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#repeat_min (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#repeat_min , | state | { state . sequence (| state | { self :: r#opening_brace (state) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: r#number (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: r#comma (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: r#closing_brace (state) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#repeat_max (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#repeat_max , | state | { state . sequence (| state | { self :: r#opening_brace (state) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: r#comma (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: r#number (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: r#closing_brace (state) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#repeat_min_max (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#repeat_min_max , | state | { state . sequence (| state | { self :: r#opening_brace (state) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: r#number (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: r#comma (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: r#number (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: r#closing_brace (state) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#number (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#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 r#integer (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#integer , | state | { state . atomic (:: pest :: Atomicity :: Atomic , | state | { self :: r#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 :: r#number (state) }) }) }) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#comma (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#comma , | state | { state . match_string (",") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#_push (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#_push , | state | { state . sequence (| state | { state . match_string ("PUSH") . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: r#opening_paren (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: r#expression (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: r#closing_paren (state) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#peek_slice (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#peek_slice , | state | { state . sequence (| state | { state . match_string ("PEEK") . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: r#opening_brack (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { state . optional (| state | { self :: r#integer (state) }) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: r#range_operator (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { state . optional (| state | { self :: r#integer (state) }) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: r#closing_brack (state) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#identifier (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#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 :: r#alpha (state) }) }) . and_then (| state | { state . repeat (| state | { state . match_string ("_") . or_else (| state | { self :: r#alpha_num (state) }) }) }) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#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 r#alpha_num (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { self :: r#alpha (state) . or_else (| state | { state . match_range ('0' .. '9') }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#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 :: r#string , | state | { state . sequence (| state | { self :: r#quote (state) . and_then (| state | { self :: r#inner_str (state) }) . and_then (| state | { self :: r#quote (state) }) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#insensitive_string (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#insensitive_string , | state | { state . sequence (| state | { state . match_string ("^") . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: r#string (state) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#range (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#range , | state | { state . sequence (| state | { self :: r#character (state) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: r#range_operator (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: r#character (state) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#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 :: r#character , | state | { state . sequence (| state | { self :: r#single_quote (state) . and_then (| state | { self :: r#inner_chr (state) }) . and_then (| state | { self :: r#single_quote (state) }) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#inner_str (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#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 :: r#escape (state) . and_then (| state | { self :: r#inner_str (state) }) }) }) }) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#inner_chr (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#inner_chr , | state | { state . atomic (:: pest :: Atomicity :: Atomic , | state | { self :: r#escape (state) . or_else (| state | { self :: r#ANY (state) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#escape (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#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 :: r#code (state) }) . or_else (| state | { self :: r#unicode (state) }) }) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#code (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#code , | state | { state . atomic (:: pest :: Atomicity :: Atomic , | state | { state . sequence (| state | { state . match_string ("x") . and_then (| state | { self :: r#hex_digit (state) }) . and_then (| state | { self :: r#hex_digit (state) }) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#unicode (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#unicode , | state | { state . atomic (:: pest :: Atomicity :: Atomic , | state | { state . sequence (| state | { state . match_string ("u") . and_then (| state | { self :: r#opening_brace (state) }) . and_then (| state | { state . sequence (| state | { self :: r#hex_digit (state) . and_then (| state | { self :: r#hex_digit (state) }) . and_then (| state | { state . optional (| state | { self :: r#hex_digit (state) }) }) . and_then (| state | { state . optional (| state | { self :: r#hex_digit (state) }) }) . and_then (| state | { state . optional (| state | { self :: r#hex_digit (state) }) }) . and_then (| state | { state . optional (| state | { self :: r#hex_digit (state) }) }) }) }) . and_then (| state | { self :: r#closing_brace (state) }) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#hex_digit (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#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 r#quote (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#quote , | state | { state . match_string ("\"") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#single_quote (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#single_quote , | state | { state . match_string ("'") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#range_operator (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#range_operator , | state | { state . match_string ("..") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#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 r#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 :: r#newline (state) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#line_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 . lookahead (false , | state | { state . match_string ("/") . or_else (| state | { state . match_string ("!") }) }) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { state . sequence (| state | { state . optional (| state | { state . sequence (| state | { state . lookahead (false , | state | { self :: r#newline (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: r#ANY (state) }) }) . and_then (| state | { state . repeat (| state | { state . sequence (| state | { super :: hidden :: skip (state) . and_then (| state | { state . sequence (| state | { state . lookahead (false , | state | { self :: r#newline (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: r#ANY (state) }) }) }) }) }) }) }) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#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 :: r#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 :: r#ANY (state) }) }) }) . and_then (| state | { state . repeat (| state | { state . sequence (| state | { super :: hidden :: skip (state) . and_then (| state | { self :: r#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 :: r#ANY (state) }) }) }) }) }) }) }) }) }) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { state . match_string ("*/") }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#COMMENT (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . atomic (:: pest :: Atomicity :: Atomic , | state | { self :: r#block_comment (state) . or_else (| state | { self :: r#line_comment (state) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#space (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . match_string (" ") . or_else (| state | { state . match_string ("\t") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#grammar_doc (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . atomic (:: pest :: Atomicity :: CompoundAtomic , | state | { state . rule (Rule :: r#grammar_doc , | state | { state . sequence (| state | { state . match_string ("//!") . and_then (| state | { state . optional (| state | { self :: r#space (state) }) }) . and_then (| state | { self :: r#inner_doc (state) }) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#line_doc (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . atomic (:: pest :: Atomicity :: CompoundAtomic , | state | { state . rule (Rule :: r#line_doc , | state | { state . sequence (| state | { state . match_string ("///") . and_then (| state | { state . optional (| state | { self :: r#space (state) }) }) . and_then (| state | { self :: r#inner_doc (state) }) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#inner_doc (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#inner_doc , | state | { state . atomic (:: pest :: Atomicity :: Atomic , | state | { state . repeat (| state | { state . sequence (| state | { state . lookahead (false , | state | { self :: r#newline (state) }) . and_then (| state | { self :: r#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 :: r#grammar_rules => rules :: r#grammar_rules (state) , Rule :: r#grammar_rule => rules :: r#grammar_rule (state) , Rule :: r#assignment_operator => rules :: r#assignment_operator (state) , Rule :: r#opening_brace => rules :: r#opening_brace (state) , Rule :: r#closing_brace => rules :: r#closing_brace (state) , Rule :: r#opening_paren => rules :: r#opening_paren (state) , Rule :: r#closing_paren => rules :: r#closing_paren (state) , Rule :: r#opening_brack => rules :: r#opening_brack (state) , Rule :: r#closing_brack => rules :: r#closing_brack (state) , Rule :: r#modifier => rules :: r#modifier (state) , Rule :: r#silent_modifier => rules :: r#silent_modifier (state) , Rule :: r#atomic_modifier => rules :: r#atomic_modifier (state) , Rule :: r#compound_atomic_modifier => rules :: r#compound_atomic_modifier (state) , Rule :: r#non_atomic_modifier => rules :: r#non_atomic_modifier (state) , Rule :: r#expression => rules :: r#expression (state) , Rule :: r#term => rules :: r#term (state) , Rule :: r#node => rules :: r#node (state) , Rule :: r#terminal => rules :: r#terminal (state) , Rule :: r#prefix_operator => rules :: r#prefix_operator (state) , Rule :: r#infix_operator => rules :: r#infix_operator (state) , Rule :: r#postfix_operator => rules :: r#postfix_operator (state) , Rule :: r#positive_predicate_operator => rules :: r#positive_predicate_operator (state) , Rule :: r#negative_predicate_operator => rules :: r#negative_predicate_operator (state) , Rule :: r#sequence_operator => rules :: r#sequence_operator (state) , Rule :: r#choice_operator => rules :: r#choice_operator (state) , Rule :: r#optional_operator => rules :: r#optional_operator (state) , Rule :: r#repeat_operator => rules :: r#repeat_operator (state) , Rule :: r#repeat_once_operator => rules :: r#repeat_once_operator (state) , Rule :: r#repeat_exact => rules :: r#repeat_exact (state) , Rule :: r#repeat_min => rules :: r#repeat_min (state) , Rule :: r#repeat_max => rules :: r#repeat_max (state) , Rule :: r#repeat_min_max => rules :: r#repeat_min_max (state) , Rule :: r#number => rules :: r#number (state) , Rule :: r#integer => rules :: r#integer (state) , Rule :: r#comma => rules :: r#comma (state) , Rule :: r#_push => rules :: r#_push (state) , Rule :: r#peek_slice => rules :: r#peek_slice (state) , Rule :: r#identifier => rules :: r#identifier (state) , Rule :: r#alpha => rules :: r#alpha (state) , Rule :: r#alpha_num => rules :: r#alpha_num (state) , Rule :: r#string => rules :: r#string (state) , Rule :: r#insensitive_string => rules :: r#insensitive_string (state) , Rule :: r#range => rules :: r#range (state) , Rule :: r#character => rules :: r#character (state) , Rule :: r#inner_str => rules :: r#inner_str (state) , Rule :: r#inner_chr => rules :: r#inner_chr (state) , Rule :: r#escape => rules :: r#escape (state) , Rule :: r#code => rules :: r#code (state) , Rule :: r#unicode => rules :: r#unicode (state) , Rule :: r#hex_digit => rules :: r#hex_digit (state) , Rule :: r#quote => rules :: r#quote (state) , Rule :: r#single_quote => rules :: r#single_quote (state) , Rule :: r#range_operator => rules :: r#range_operator (state) , Rule :: r#newline => rules :: r#newline (state) , Rule :: r#WHITESPACE => rules :: r#WHITESPACE (state) , Rule :: r#line_comment => rules :: r#line_comment (state) , Rule :: r#block_comment => rules :: r#block_comment (state) , Rule :: r#COMMENT => rules :: r#COMMENT (state) , Rule :: r#space => rules :: r#space (state) , Rule :: r#grammar_doc => rules :: r#grammar_doc (state) , Rule :: r#line_doc => rules :: r#line_doc (state) , Rule :: r#inner_doc => rules :: r#inner_doc (state) , Rule :: EOI => rules :: EOI (state) } }) } }
+# [doc = "Pest meta-grammar\n\n# Warning: Semantic Versioning\nThere may be non-breaking changes to the meta-grammar\nbetween minor versions. Those non-breaking changes, however,\nmay translate into semver-breaking changes due to the additional variants\nadded to the `Rule` enum. This is a known issue and will be fixed in the\nfuture (e.g. by increasing MSRV and non_exhaustive annotations)."] # [allow (dead_code , non_camel_case_types , clippy :: upper_case_acronyms)] # [derive (Clone , Copy , Debug , Eq , Hash , Ord , PartialEq , PartialOrd)] pub enum Rule { EOI , # [doc = "The top-level rule of a grammar."] r#grammar_rules , # [doc = "A rule of a grammar."] r#grammar_rule , # [doc = "Assignment operator."] r#assignment_operator , # [doc = "Opening brace for a rule."] r#opening_brace , # [doc = "Closing brace for a rule."] r#closing_brace , # [doc = "Opening parenthesis for a branch, PUSH, etc."] r#opening_paren , # [doc = "Closing parenthesis for a branch, PUSH, etc."] r#closing_paren , # [doc = "Opening bracket for PEEK (slice inside)."] r#opening_brack , # [doc = "Closing bracket for PEEK (slice inside)."] r#closing_brack , # [doc = "A rule modifier."] r#modifier , # [doc = "Silent rule prefix."] r#silent_modifier , # [doc = "Atomic rule prefix."] r#atomic_modifier , # [doc = "Compound atomic rule prefix."] r#compound_atomic_modifier , # [doc = "Non-atomic rule prefix."] r#non_atomic_modifier , # [doc = "A tag label."] r#tag_id , # [doc = "For assigning labels to nodes."] r#node_tag , # [doc = "A rule expression."] r#expression , # [doc = "A rule term."] r#term , # [doc = "A rule node (inside terms)."] r#node , # [doc = "A terminal expression."] r#terminal , # [doc = "Possible predicates for a rule."] r#prefix_operator , # [doc = "Branches or sequences."] r#infix_operator , # [doc = "Possible modifiers for a rule."] r#postfix_operator , # [doc = "A positive predicate."] r#positive_predicate_operator , # [doc = "A negative predicate."] r#negative_predicate_operator , # [doc = "A sequence operator."] r#sequence_operator , # [doc = "A choice operator."] r#choice_operator , # [doc = "An optional operator."] r#optional_operator , # [doc = "A repeat operator."] r#repeat_operator , # [doc = "A repeat at least once operator."] r#repeat_once_operator , # [doc = "A repeat exact times."] r#repeat_exact , # [doc = "A repeat at least times."] r#repeat_min , # [doc = "A repeat at most times."] r#repeat_max , # [doc = "A repeat in a range."] r#repeat_min_max , # [doc = "A number."] r#number , # [doc = "An integer number (positive or negative)."] r#integer , # [doc = "A comma terminal."] r#comma , # [doc = "A PUSH expression."] r#_push , # [doc = "A PEEK expression."] r#peek_slice , # [doc = "An identifier."] r#identifier , # [doc = "An alpha character."] r#alpha , # [doc = "An alphanumeric character."] r#alpha_num , # [doc = "A string."] r#string , # [doc = "An insensitive string."] r#insensitive_string , # [doc = "A character range."] r#range , # [doc = "A single quoted character"] r#character , # [doc = "A quoted string."] r#inner_str , # [doc = "An escaped or any character."] r#inner_chr , # [doc = "An escape sequence."] r#escape , # [doc = "A hexadecimal code."] r#code , # [doc = "A unicode code."] r#unicode , # [doc = "A hexadecimal digit."] r#hex_digit , # [doc = "A double quote."] r#quote , # [doc = "A single quote."] r#single_quote , # [doc = "A range operator."] r#range_operator , # [doc = "A newline character."] r#newline , # [doc = "A whitespace character."] r#WHITESPACE , # [doc = "A single line comment."] r#line_comment , # [doc = "A multi-line comment."] r#block_comment , # [doc = "A grammar comment."] r#COMMENT , # [doc = "A space character."] r#space , # [doc = "A top-level comment."] r#grammar_doc , # [doc = "A rule comment."] r#line_doc , # [doc = "A comment content."] r#inner_doc } # [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 r#grammar_rules (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . sequence (| state | { self :: r#SOI (state) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { state . sequence (| state | { state . optional (| state | { self :: r#grammar_doc (state) . and_then (| state | { state . repeat (| state | { state . sequence (| state | { super :: hidden :: skip (state) . and_then (| state | { self :: r#grammar_doc (state) }) }) }) }) }) }) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { state . sequence (| state | { state . optional (| state | { self :: r#grammar_rule (state) . and_then (| state | { state . repeat (| state | { state . sequence (| state | { super :: hidden :: skip (state) . and_then (| state | { self :: r#grammar_rule (state) }) }) }) }) }) }) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: r#EOI (state) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#grammar_rule (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#grammar_rule , | state | { state . sequence (| state | { self :: r#identifier (state) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: r#assignment_operator (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { state . optional (| state | { self :: r#modifier (state) }) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: r#opening_brace (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: r#expression (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: r#closing_brace (state) }) }) . or_else (| state | { self :: r#line_doc (state) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#assignment_operator (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#assignment_operator , | state | { state . match_string ("=") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#opening_brace (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#opening_brace , | state | { state . match_string ("{") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#closing_brace (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#closing_brace , | state | { state . match_string ("}") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#opening_paren (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#opening_paren , | state | { state . match_string ("(") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#closing_paren (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#closing_paren , | state | { state . match_string (")") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#opening_brack (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#opening_brack , | state | { state . match_string ("[") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#closing_brack (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#closing_brack , | state | { state . match_string ("]") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#modifier (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { self :: r#silent_modifier (state) . or_else (| state | { self :: r#atomic_modifier (state) }) . or_else (| state | { self :: r#compound_atomic_modifier (state) }) . or_else (| state | { self :: r#non_atomic_modifier (state) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#silent_modifier (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#silent_modifier , | state | { state . match_string ("_") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#atomic_modifier (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#atomic_modifier , | state | { state . match_string ("@") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#compound_atomic_modifier (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#compound_atomic_modifier , | state | { state . match_string ("$") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#non_atomic_modifier (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#non_atomic_modifier , | state | { state . match_string ("!") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#tag_id (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#tag_id , | state | { state . atomic (:: pest :: Atomicity :: Atomic , | state | { state . sequence (| state | { state . match_string ("#") . and_then (| state | { state . match_string ("_") . or_else (| state | { self :: r#alpha (state) }) }) . and_then (| state | { state . repeat (| state | { state . match_string ("_") . or_else (| state | { self :: r#alpha_num (state) }) }) }) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#node_tag (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . sequence (| state | { self :: r#tag_id (state) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: r#assignment_operator (state) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#expression (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#expression , | state | { state . sequence (| state | { state . optional (| state | { self :: r#choice_operator (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: r#term (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { state . sequence (| state | { state . optional (| state | { state . sequence (| state | { self :: r#infix_operator (state) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: r#term (state) }) }) . and_then (| state | { state . repeat (| state | { state . sequence (| state | { super :: hidden :: skip (state) . and_then (| state | { state . sequence (| state | { self :: r#infix_operator (state) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: r#term (state) }) }) }) }) }) }) }) }) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#term (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#term , | state | { state . sequence (| state | { state . optional (| state | { self :: r#node_tag (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { state . sequence (| state | { state . optional (| state | { self :: r#prefix_operator (state) . and_then (| state | { state . repeat (| state | { state . sequence (| state | { super :: hidden :: skip (state) . and_then (| state | { self :: r#prefix_operator (state) }) }) }) }) }) }) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: r#node (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { state . sequence (| state | { state . optional (| state | { self :: r#postfix_operator (state) . and_then (| state | { state . repeat (| state | { state . sequence (| state | { super :: hidden :: skip (state) . and_then (| state | { self :: r#postfix_operator (state) }) }) }) }) }) }) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#node (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . sequence (| state | { self :: r#opening_paren (state) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: r#expression (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: r#closing_paren (state) }) }) . or_else (| state | { self :: r#terminal (state) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#terminal (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { self :: r#_push (state) . or_else (| state | { self :: r#peek_slice (state) }) . or_else (| state | { self :: r#identifier (state) }) . or_else (| state | { self :: r#string (state) }) . or_else (| state | { self :: r#insensitive_string (state) }) . or_else (| state | { self :: r#range (state) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#prefix_operator (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { self :: r#positive_predicate_operator (state) . or_else (| state | { self :: r#negative_predicate_operator (state) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#infix_operator (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { self :: r#sequence_operator (state) . or_else (| state | { self :: r#choice_operator (state) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#postfix_operator (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { self :: r#optional_operator (state) . or_else (| state | { self :: r#repeat_operator (state) }) . or_else (| state | { self :: r#repeat_once_operator (state) }) . or_else (| state | { self :: r#repeat_exact (state) }) . or_else (| state | { self :: r#repeat_min (state) }) . or_else (| state | { self :: r#repeat_max (state) }) . or_else (| state | { self :: r#repeat_min_max (state) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#positive_predicate_operator (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#positive_predicate_operator , | state | { state . match_string ("&") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#negative_predicate_operator (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#negative_predicate_operator , | state | { state . match_string ("!") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#sequence_operator (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#sequence_operator , | state | { state . match_string ("~") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#choice_operator (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#choice_operator , | state | { state . match_string ("|") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#optional_operator (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#optional_operator , | state | { state . match_string ("?") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#repeat_operator (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#repeat_operator , | state | { state . match_string ("*") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#repeat_once_operator (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#repeat_once_operator , | state | { state . match_string ("+") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#repeat_exact (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#repeat_exact , | state | { state . sequence (| state | { self :: r#opening_brace (state) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: r#number (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: r#closing_brace (state) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#repeat_min (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#repeat_min , | state | { state . sequence (| state | { self :: r#opening_brace (state) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: r#number (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: r#comma (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: r#closing_brace (state) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#repeat_max (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#repeat_max , | state | { state . sequence (| state | { self :: r#opening_brace (state) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: r#comma (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: r#number (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: r#closing_brace (state) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#repeat_min_max (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#repeat_min_max , | state | { state . sequence (| state | { self :: r#opening_brace (state) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: r#number (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: r#comma (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: r#number (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: r#closing_brace (state) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#number (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#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 r#integer (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#integer , | state | { state . atomic (:: pest :: Atomicity :: Atomic , | state | { self :: r#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 :: r#number (state) }) }) }) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#comma (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#comma , | state | { state . match_string (",") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#_push (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#_push , | state | { state . sequence (| state | { state . match_string ("PUSH") . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: r#opening_paren (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: r#expression (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: r#closing_paren (state) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#peek_slice (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#peek_slice , | state | { state . sequence (| state | { state . match_string ("PEEK") . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: r#opening_brack (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { state . optional (| state | { self :: r#integer (state) }) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: r#range_operator (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { state . optional (| state | { self :: r#integer (state) }) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: r#closing_brack (state) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#identifier (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#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 :: r#alpha (state) }) }) . and_then (| state | { state . repeat (| state | { state . match_string ("_") . or_else (| state | { self :: r#alpha_num (state) }) }) }) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#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 r#alpha_num (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { self :: r#alpha (state) . or_else (| state | { state . match_range ('0' .. '9') }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#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 :: r#string , | state | { state . sequence (| state | { self :: r#quote (state) . and_then (| state | { self :: r#inner_str (state) }) . and_then (| state | { self :: r#quote (state) }) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#insensitive_string (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#insensitive_string , | state | { state . sequence (| state | { state . match_string ("^") . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: r#string (state) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#range (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#range , | state | { state . sequence (| state | { self :: r#character (state) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: r#range_operator (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: r#character (state) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#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 :: r#character , | state | { state . sequence (| state | { self :: r#single_quote (state) . and_then (| state | { self :: r#inner_chr (state) }) . and_then (| state | { self :: r#single_quote (state) }) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#inner_str (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#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 :: r#escape (state) . and_then (| state | { self :: r#inner_str (state) }) }) }) }) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#inner_chr (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#inner_chr , | state | { state . atomic (:: pest :: Atomicity :: Atomic , | state | { self :: r#escape (state) . or_else (| state | { self :: r#ANY (state) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#escape (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#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 :: r#code (state) }) . or_else (| state | { self :: r#unicode (state) }) }) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#code (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#code , | state | { state . atomic (:: pest :: Atomicity :: Atomic , | state | { state . sequence (| state | { state . match_string ("x") . and_then (| state | { self :: r#hex_digit (state) }) . and_then (| state | { self :: r#hex_digit (state) }) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#unicode (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#unicode , | state | { state . atomic (:: pest :: Atomicity :: Atomic , | state | { state . sequence (| state | { state . match_string ("u") . and_then (| state | { self :: r#opening_brace (state) }) . and_then (| state | { state . sequence (| state | { self :: r#hex_digit (state) . and_then (| state | { self :: r#hex_digit (state) }) . and_then (| state | { state . optional (| state | { self :: r#hex_digit (state) }) }) . and_then (| state | { state . optional (| state | { self :: r#hex_digit (state) }) }) . and_then (| state | { state . optional (| state | { self :: r#hex_digit (state) }) }) . and_then (| state | { state . optional (| state | { self :: r#hex_digit (state) }) }) }) }) . and_then (| state | { self :: r#closing_brace (state) }) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#hex_digit (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#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 r#quote (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#quote , | state | { state . match_string ("\"") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#single_quote (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#single_quote , | state | { state . match_string ("'") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#range_operator (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#range_operator , | state | { state . match_string ("..") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#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 r#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 :: r#newline (state) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#line_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 . lookahead (false , | state | { state . match_string ("/") . or_else (| state | { state . match_string ("!") }) }) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { state . sequence (| state | { state . optional (| state | { state . sequence (| state | { state . lookahead (false , | state | { self :: r#newline (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: r#ANY (state) }) }) . and_then (| state | { state . repeat (| state | { state . sequence (| state | { super :: hidden :: skip (state) . and_then (| state | { state . sequence (| state | { state . lookahead (false , | state | { self :: r#newline (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: r#ANY (state) }) }) }) }) }) }) }) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#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 :: r#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 :: r#ANY (state) }) }) }) . and_then (| state | { state . repeat (| state | { state . sequence (| state | { super :: hidden :: skip (state) . and_then (| state | { self :: r#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 :: r#ANY (state) }) }) }) }) }) }) }) }) }) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { state . match_string ("*/") }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#COMMENT (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . atomic (:: pest :: Atomicity :: Atomic , | state | { self :: r#block_comment (state) . or_else (| state | { self :: r#line_comment (state) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#space (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . match_string (" ") . or_else (| state | { state . match_string ("\t") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#grammar_doc (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . atomic (:: pest :: Atomicity :: CompoundAtomic , | state | { state . rule (Rule :: r#grammar_doc , | state | { state . sequence (| state | { state . match_string ("//!") . and_then (| state | { state . optional (| state | { self :: r#space (state) }) }) . and_then (| state | { self :: r#inner_doc (state) }) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#line_doc (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . atomic (:: pest :: Atomicity :: CompoundAtomic , | state | { state . rule (Rule :: r#line_doc , | state | { state . sequence (| state | { state . match_string ("///") . and_then (| state | { state . optional (| state | { self :: r#space (state) }) }) . and_then (| state | { self :: r#inner_doc (state) }) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn r#inner_doc (state : :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < '_ , Rule >> > { state . rule (Rule :: r#inner_doc , | state | { state . atomic (:: pest :: Atomicity :: Atomic , | state | { state . repeat (| state | { state . sequence (| state | { state . lookahead (false , | state | { self :: r#newline (state) }) . and_then (| state | { self :: r#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 :: r#grammar_rules => rules :: r#grammar_rules (state) , Rule :: r#grammar_rule => rules :: r#grammar_rule (state) , Rule :: r#assignment_operator => rules :: r#assignment_operator (state) , Rule :: r#opening_brace => rules :: r#opening_brace (state) , Rule :: r#closing_brace => rules :: r#closing_brace (state) , Rule :: r#opening_paren => rules :: r#opening_paren (state) , Rule :: r#closing_paren => rules :: r#closing_paren (state) , Rule :: r#opening_brack => rules :: r#opening_brack (state) , Rule :: r#closing_brack => rules :: r#closing_brack (state) , Rule :: r#modifier => rules :: r#modifier (state) , Rule :: r#silent_modifier => rules :: r#silent_modifier (state) , Rule :: r#atomic_modifier => rules :: r#atomic_modifier (state) , Rule :: r#compound_atomic_modifier => rules :: r#compound_atomic_modifier (state) , Rule :: r#non_atomic_modifier => rules :: r#non_atomic_modifier (state) , Rule :: r#tag_id => rules :: r#tag_id (state) , Rule :: r#node_tag => rules :: r#node_tag (state) , Rule :: r#expression => rules :: r#expression (state) , Rule :: r#term => rules :: r#term (state) , Rule :: r#node => rules :: r#node (state) , Rule :: r#terminal => rules :: r#terminal (state) , Rule :: r#prefix_operator => rules :: r#prefix_operator (state) , Rule :: r#infix_operator => rules :: r#infix_operator (state) , Rule :: r#postfix_operator => rules :: r#postfix_operator (state) , Rule :: r#positive_predicate_operator => rules :: r#positive_predicate_operator (state) , Rule :: r#negative_predicate_operator => rules :: r#negative_predicate_operator (state) , Rule :: r#sequence_operator => rules :: r#sequence_operator (state) , Rule :: r#choice_operator => rules :: r#choice_operator (state) , Rule :: r#optional_operator => rules :: r#optional_operator (state) , Rule :: r#repeat_operator => rules :: r#repeat_operator (state) , Rule :: r#repeat_once_operator => rules :: r#repeat_once_operator (state) , Rule :: r#repeat_exact => rules :: r#repeat_exact (state) , Rule :: r#repeat_min => rules :: r#repeat_min (state) , Rule :: r#repeat_max => rules :: r#repeat_max (state) , Rule :: r#repeat_min_max => rules :: r#repeat_min_max (state) , Rule :: r#number => rules :: r#number (state) , Rule :: r#integer => rules :: r#integer (state) , Rule :: r#comma => rules :: r#comma (state) , Rule :: r#_push => rules :: r#_push (state) , Rule :: r#peek_slice => rules :: r#peek_slice (state) , Rule :: r#identifier => rules :: r#identifier (state) , Rule :: r#alpha => rules :: r#alpha (state) , Rule :: r#alpha_num => rules :: r#alpha_num (state) , Rule :: r#string => rules :: r#string (state) , Rule :: r#insensitive_string => rules :: r#insensitive_string (state) , Rule :: r#range => rules :: r#range (state) , Rule :: r#character => rules :: r#character (state) , Rule :: r#inner_str => rules :: r#inner_str (state) , Rule :: r#inner_chr => rules :: r#inner_chr (state) , Rule :: r#escape => rules :: r#escape (state) , Rule :: r#code => rules :: r#code (state) , Rule :: r#unicode => rules :: r#unicode (state) , Rule :: r#hex_digit => rules :: r#hex_digit (state) , Rule :: r#quote => rules :: r#quote (state) , Rule :: r#single_quote => rules :: r#single_quote (state) , Rule :: r#range_operator => rules :: r#range_operator (state) , Rule :: r#newline => rules :: r#newline (state) , Rule :: r#WHITESPACE => rules :: r#WHITESPACE (state) , Rule :: r#line_comment => rules :: r#line_comment (state) , Rule :: r#block_comment => rules :: r#block_comment (state) , Rule :: r#COMMENT => rules :: r#COMMENT (state) , Rule :: r#space => rules :: r#space (state) , Rule :: r#grammar_doc => rules :: r#grammar_doc (state) , Rule :: r#line_doc => rules :: r#line_doc (state) , Rule :: r#inner_doc => rules :: r#inner_doc (state) , Rule :: EOI => rules :: EOI (state) } }) } }
diff --git a/vendor/pest_meta/src/optimizer/concatenator.rs b/vendor/pest_meta/src/optimizer/concatenator.rs
index 31d3aa531..c67d3636e 100644
--- a/vendor/pest_meta/src/optimizer/concatenator.rs
+++ b/vendor/pest_meta/src/optimizer/concatenator.rs
@@ -16,7 +16,6 @@ pub fn concatenate(rule: Rule) -> Rule {
ty,
expr: expr.map_bottom_up(|expr| {
if ty == RuleType::Atomic {
- // TODO: Use box syntax when it gets stabilized.
match expr {
Expr::Seq(lhs, rhs) => match (*lhs, *rhs) {
(Expr::Str(lhs), Expr::Str(rhs)) => Expr::Str(lhs + &rhs),
diff --git a/vendor/pest_meta/src/optimizer/factorizer.rs b/vendor/pest_meta/src/optimizer/factorizer.rs
index cff018b64..e6fd8ff62 100644
--- a/vendor/pest_meta/src/optimizer/factorizer.rs
+++ b/vendor/pest_meta/src/optimizer/factorizer.rs
@@ -15,7 +15,6 @@ pub fn factor(rule: Rule) -> Rule {
name,
ty,
expr: expr.map_top_down(|expr| {
- // TODO: Use box syntax when it gets stabilized.
match expr {
Expr::Choice(lhs, rhs) => match (*lhs, *rhs) {
(Expr::Seq(l1, r1), Expr::Seq(l2, r2)) => {
diff --git a/vendor/pest_meta/src/optimizer/lister.rs b/vendor/pest_meta/src/optimizer/lister.rs
index e19885032..03c9902c5 100644
--- a/vendor/pest_meta/src/optimizer/lister.rs
+++ b/vendor/pest_meta/src/optimizer/lister.rs
@@ -15,7 +15,6 @@ pub fn list(rule: Rule) -> Rule {
name,
ty,
expr: expr.map_bottom_up(|expr| {
- // TODO: Use box syntax when it gets stabilized.
match expr {
Expr::Seq(l, r) => match *l {
Expr::Rep(l) => {
diff --git a/vendor/pest_meta/src/optimizer/mod.rs b/vendor/pest_meta/src/optimizer/mod.rs
index f9cde831c..b69163ed3 100644
--- a/vendor/pest_meta/src/optimizer/mod.rs
+++ b/vendor/pest_meta/src/optimizer/mod.rs
@@ -68,6 +68,8 @@ fn rule_to_optimized_rule(rule: Rule) -> OptimizedRule {
Expr::Rep(expr) => OptimizedExpr::Rep(Box::new(to_optimized(*expr))),
Expr::Skip(strings) => OptimizedExpr::Skip(strings),
Expr::Push(expr) => OptimizedExpr::Push(Box::new(to_optimized(*expr))),
+ #[cfg(feature = "grammar-extras")]
+ Expr::NodeTag(expr, tag) => OptimizedExpr::NodeTag(Box::new(to_optimized(*expr)), tag),
Expr::RepOnce(_)
| Expr::RepExact(..)
| Expr::RepMin(..)
@@ -137,6 +139,9 @@ pub enum OptimizedExpr {
Skip(Vec<String>),
/// Matches an expression and pushes it to the stack, e.g. `push(e)`
Push(Box<OptimizedExpr>),
+ /// Matches an expression and assigns a label to it, e.g. #label = exp
+ #[cfg(feature = "grammar-extras")]
+ NodeTag(Box<OptimizedExpr>, String),
/// Restores an expression's checkpoint
RestoreOnErr(Box<OptimizedExpr>),
}
@@ -159,7 +164,6 @@ impl OptimizedExpr {
let expr = f(expr);
match expr {
- // TODO: Use box syntax when it gets stabilized.
OptimizedExpr::PosPred(expr) => {
let mapped = Box::new(map_internal(*expr, f));
OptimizedExpr::PosPred(mapped)
@@ -208,7 +212,6 @@ impl OptimizedExpr {
{
let mapped = match expr {
OptimizedExpr::PosPred(expr) => {
- // TODO: Use box syntax when it gets stabilized.
let mapped = Box::new(map_internal(*expr, f));
OptimizedExpr::PosPred(mapped)
}
diff --git a/vendor/pest_meta/src/optimizer/rotater.rs b/vendor/pest_meta/src/optimizer/rotater.rs
index 7a7d8fba4..b019c80c3 100644
--- a/vendor/pest_meta/src/optimizer/rotater.rs
+++ b/vendor/pest_meta/src/optimizer/rotater.rs
@@ -12,7 +12,6 @@ use crate::ast::*;
pub fn rotate(rule: Rule) -> Rule {
fn rotate_internal(expr: Expr) -> Expr {
match expr {
- // TODO: Use box syntax when it gets stabilized.
Expr::Seq(lhs, rhs) => {
let lhs = *lhs;
match lhs {
diff --git a/vendor/pest_meta/src/optimizer/skipper.rs b/vendor/pest_meta/src/optimizer/skipper.rs
index 40bc5a16f..8300309b9 100644
--- a/vendor/pest_meta/src/optimizer/skipper.rs
+++ b/vendor/pest_meta/src/optimizer/skipper.rs
@@ -34,7 +34,6 @@ pub fn skip(rule: Rule) -> Rule {
ty,
expr: if ty == RuleType::Atomic {
expr.map_top_down(|expr| {
- // TODO: Use box syntax when it gets stabilized.
if let Expr::Rep(expr) = expr.clone() {
if let Expr::Seq(lhs, rhs) = *expr {
if let (Expr::NegPred(expr), Expr::Ident(ident)) = (*lhs, *rhs) {
diff --git a/vendor/pest_meta/src/parser.rs b/vendor/pest_meta/src/parser.rs
index eb957a163..a4e8d1b33 100644
--- a/vendor/pest_meta/src/parser.rs
+++ b/vendor/pest_meta/src/parser.rs
@@ -15,20 +15,18 @@ use std::iter::Peekable;
use pest::error::{Error, ErrorVariant};
use pest::iterators::{Pair, Pairs};
use pest::pratt_parser::{Assoc, Op, PrattParser};
-use pest::{Parser, Span};
+use pest::{Parser, Position, 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
-)]
+#[allow(missing_docs, unused_qualifications)]
mod grammar {
+ #[cfg(not(feature = "not-bootstrap-in-src"))]
include!("grammar.rs");
+
+ #[cfg(feature = "not-bootstrap-in-src")]
+ include!(concat!(env!("OUT_DIR"), "/__pest_grammar.rs"));
}
pub use self::grammar::*;
@@ -76,7 +74,6 @@ impl<'i> ParserNode<'i> {
}
match node.expr {
- // TODO: Use box syntax when it gets stabilized.
ParserExpr::PosPred(node) => {
filter_internal(*node, f, result);
}
@@ -164,6 +161,9 @@ pub enum ParserExpr<'i> {
RepMinMax(Box<ParserNode<'i>>, u32, u32),
/// Matches an expression and pushes it to the stack, e.g. `push(e)`
Push(Box<ParserNode<'i>>),
+ /// Matches an expression and assigns a label to it, e.g. #label = exp
+ #[cfg(feature = "grammar-extras")]
+ NodeTag(Box<ParserNode<'i>>, String),
}
fn convert_rule(rule: ParserRule<'_>) -> AstRule {
@@ -199,6 +199,8 @@ fn convert_node(node: ParserNode<'_>) -> Expr {
Expr::RepMinMax(Box::new(convert_node(*node)), min, max)
}
ParserExpr::Push(node) => Expr::Push(Box::new(convert_node(*node))),
+ #[cfg(feature = "grammar-extras")]
+ ParserExpr::NodeTag(node, tag) => Expr::NodeTag(Box::new(convert_node(*node)), tag),
}
}
@@ -305,6 +307,29 @@ fn consume_rules_with_spans(
.collect()
}
+fn get_node_tag<'i>(
+ pairs: &mut Peekable<Pairs<'i, Rule>>,
+) -> (Pair<'i, Rule>, Option<(String, Position<'i>)>) {
+ let pair_or_tag = pairs.next().unwrap();
+ if let Some(next_pair) = pairs.peek() {
+ if next_pair.as_rule() == Rule::assignment_operator {
+ pairs.next().unwrap();
+ let pair = pairs.next().unwrap();
+ (
+ pair,
+ Some((
+ pair_or_tag.as_str()[1..].to_string(),
+ pair_or_tag.as_span().start_pos(),
+ )),
+ )
+ } else {
+ (pair_or_tag, None)
+ }
+ } else {
+ (pair_or_tag, None)
+ }
+}
+
fn consume_expr<'i>(
pairs: Peekable<Pairs<'i, Rule>>,
pratt: &PrattParser<Rule>,
@@ -313,7 +338,10 @@ fn consume_expr<'i>(
mut pairs: Peekable<Pairs<'i, Rule>>,
pratt: &PrattParser<Rule>,
) -> Result<ParserNode<'i>, Vec<Error<Rule>>> {
- let pair = pairs.next().unwrap();
+ #[cfg(feature = "grammar-extras")]
+ let (pair, tag_start) = get_node_tag(&mut pairs);
+ #[cfg(not(feature = "grammar-extras"))]
+ let (pair, _tag_start) = get_node_tag(&mut pairs);
let node = match pair.as_rule() {
Rule::opening_paren => {
@@ -370,7 +398,7 @@ fn consume_expr<'i>(
pairs.next().unwrap(); // ..
pair_start.as_str().parse().unwrap()
}
- _ => unreachable!(),
+ _ => unreachable!("peek start"),
};
let pair_end = pairs.next().unwrap(); // integer or }
let end: Option<i32> = match pair_end.as_rule() {
@@ -379,7 +407,7 @@ fn consume_expr<'i>(
pairs.next().unwrap(); // }
Some(pair_end.as_str().parse().unwrap())
}
- _ => unreachable!(),
+ _ => unreachable!("peek end"),
};
ParserNode {
expr: ParserExpr::PeekSlice(start, end),
@@ -422,7 +450,7 @@ fn consume_expr<'i>(
span: start_pos.span(&end_pos),
}
}
- _ => unreachable!(),
+ x => unreachable!("other rule: {:?}", x),
};
pairs.fold(
@@ -600,7 +628,7 @@ fn consume_expr<'i>(
span: start.span(&pair.as_span().end_pos()),
}
}
- _ => unreachable!(),
+ rule => unreachable!("node: {:?}", rule),
};
Ok(node)
@@ -608,7 +636,17 @@ fn consume_expr<'i>(
)?
}
};
-
+ #[cfg(feature = "grammar-extras")]
+ if let Some((tag, start)) = tag_start {
+ let span = start.span(&node.span.end_pos());
+ Ok(ParserNode {
+ expr: ParserExpr::NodeTag(Box::new(node), tag),
+ span,
+ })
+ } else {
+ Ok(node)
+ }
+ #[cfg(not(feature = "grammar-extras"))]
Ok(node)
}
@@ -640,7 +678,7 @@ fn consume_expr<'i>(
span: start.span(&end),
})
}
- _ => unreachable!(),
+ _ => unreachable!("infix"),
};
pratt.map_primary(term).map_infix(infix).parse(pairs)
@@ -1143,7 +1181,7 @@ mod tests {
parser: PestParser,
input: "0",
rule: Rule::grammar_rules,
- positives: vec![Rule::grammar_rule, Rule::grammar_doc],
+ positives: vec![Rule::EOI, Rule::grammar_rule, Rule::grammar_doc],
negatives: vec![],
pos: 0
};
@@ -1358,6 +1396,80 @@ mod tests {
}
#[test]
+ fn node_tag() {
+ parses_to! {
+ parser: PestParser,
+ input: "#a = a",
+ rule: Rule::expression,
+ tokens: [
+ expression(0, 6, [
+ term(0, 6, [
+ tag_id(0, 2),
+ assignment_operator(3, 4),
+ identifier(5, 6)
+ ])
+ ])
+ ]
+ };
+ }
+
+ #[test]
+ fn incomplete_node_tag() {
+ fails_with! {
+ parser: PestParser,
+ input: "a = { # }",
+ rule: Rule::grammar_rules,
+ positives: vec![
+ Rule::expression
+ ],
+ negatives: vec![],
+ pos: 6
+ };
+ }
+
+ #[test]
+ fn incomplete_node_tag_assignment() {
+ fails_with! {
+ parser: PestParser,
+ input: "a = { #a = }",
+ rule: Rule::grammar_rules,
+ positives: vec![
+ Rule::opening_paren,
+ Rule::positive_predicate_operator,
+ Rule::negative_predicate_operator,
+ Rule::_push,
+ Rule::peek_slice,
+ Rule::identifier,
+ Rule::insensitive_string,
+ Rule::quote,
+ Rule::single_quote
+ ],
+ negatives: vec![],
+ pos: 11
+ };
+ }
+
+ #[test]
+ fn incomplete_node_tag_pound_key() {
+ fails_with! {
+ parser: PestParser,
+ input: "a = { a = a }",
+ rule: Rule::grammar_rules,
+ positives: vec![
+ Rule::opening_brace,
+ Rule::closing_brace,
+ Rule::sequence_operator,
+ Rule::choice_operator,
+ Rule::optional_operator,
+ Rule::repeat_operator,
+ Rule::repeat_once_operator
+ ],
+ negatives: vec![],
+ pos: 8
+ };
+ }
+
+ #[test]
fn ast() {
let input = r##"
/// This is line comment
diff --git a/vendor/pest_meta/src/validator.rs b/vendor/pest_meta/src/validator.rs
index d9c2ed3c5..16d387999 100644
--- a/vendor/pest_meta/src/validator.rs
+++ b/vendor/pest_meta/src/validator.rs
@@ -216,6 +216,12 @@ pub fn validate_undefined<'i>(
pub fn validate_ast<'a, 'i: 'a>(rules: &'a Vec<ParserRule<'i>>) -> Vec<Error<Rule>> {
let mut errors = vec![];
+ // WARNING: validate_{repetition,choice,whitespace_comment}
+ // use is_non_failing and is_non_progressing breaking assumptions:
+ // - for every `ParserExpr::RepMinMax(inner,min,max)`,
+ // `min<=max` was not checked
+ // - left recursion was not checked
+ // - Every expression might not be checked
errors.extend(validate_repetition(rules));
errors.extend(validate_choices(rules));
errors.extend(validate_whitespace_comment(rules));
@@ -229,15 +235,32 @@ pub fn validate_ast<'a, 'i: 'a>(rules: &'a Vec<ParserRule<'i>>) -> Vec<Error<Rul
errors
}
+/// Checks if `expr` is non-progressing, that is the expression does not
+/// consume any input or any stack. This includes expressions matching the empty input,
+/// `SOI` and ̀ `EOI`, predicates and repetitions.
+///
+/// # Example
+///
+/// ```pest
+/// not_progressing_1 = { "" }
+/// not_progressing_2 = { "a"? }
+/// not_progressing_3 = { !"a" }
+/// ```
+///
+/// # Assumptions
+/// - In `ParserExpr::RepMinMax(inner,min,max)`, `min<=max`
+/// - All rules identiers have a matching definition
+/// - There is no left-recursion (if only this one is broken returns false)
+/// - Every expression is being checked
fn is_non_progressing<'i>(
expr: &ParserExpr<'i>,
rules: &HashMap<String, &ParserNode<'i>>,
trace: &mut Vec<String>,
) -> bool {
match *expr {
- ParserExpr::Str(ref string) => string.is_empty(),
+ ParserExpr::Str(ref string) | ParserExpr::Insens(ref string) => string.is_empty(),
ParserExpr::Ident(ref ident) => {
- if ident == "soi" || ident == "eoi" {
+ if ident == "SOI" || ident == "EOI" {
return true;
}
@@ -249,12 +272,27 @@ fn is_non_progressing<'i>(
return result;
}
+ // else
+ // the ident is
+ // - "POP","PEEK" => false
+ // the slice being checked is not non_progressing since every
+ // PUSH is being checked (assumption 4) and the expr
+ // of a PUSH has to be non_progressing.
+ // - "POPALL", "PEEKALL" => false
+ // same as "POP", "PEEK" unless the following:
+ // BUG: if the stack is empty they are non_progressing
+ // - "DROP" => false doesn't consume the input but consumes the stack,
+ // - "ANY", "ASCII_*", UNICODE categories, "NEWLINE" => false
+ // - referring to another rule that is undefined (breaks assumption)
}
+ // else referring to another rule that was already seen.
+ // this happens only if there is a left-recursion
+ // that is only if an assumption is broken,
+ // WARNING: we can choose to return false, but that might
+ // cause bugs into the left_recursion check
false
}
- ParserExpr::PosPred(_) => true,
- ParserExpr::NegPred(_) => true,
ParserExpr::Seq(ref lhs, ref rhs) => {
is_non_progressing(&lhs.expr, rules, trace)
&& is_non_progressing(&rhs.expr, rules, trace)
@@ -263,17 +301,58 @@ fn is_non_progressing<'i>(
is_non_progressing(&lhs.expr, rules, trace)
|| is_non_progressing(&rhs.expr, rules, trace)
}
- _ => false,
+ // WARNING: the predicate indeed won't make progress on input but it
+ // might progress on the stack
+ // ex: @{ PUSH(ANY) ~ (&(DROP))* ~ ANY }, input="AA"
+ // Notice that this is ex not working as of now, the debugger seems
+ // to run into an infinite loop on it
+ ParserExpr::PosPred(_) | ParserExpr::NegPred(_) => true,
+ ParserExpr::Rep(_) | ParserExpr::Opt(_) | ParserExpr::RepMax(_, _) => true,
+ // it either always fail (failing is progressing)
+ // or always match at least a character
+ ParserExpr::Range(_, _) => false,
+ ParserExpr::PeekSlice(_, _) => {
+ // the slice being checked is not non_progressing since every
+ // PUSH is being checked (assumption 4) and the expr
+ // of a PUSH has to be non_progressing.
+ // BUG: if the slice is of size 0, or the stack is not large
+ // enough it might be non-progressing
+ false
+ }
+
+ ParserExpr::RepExact(ref inner, min)
+ | ParserExpr::RepMin(ref inner, min)
+ | ParserExpr::RepMinMax(ref inner, min, _) => {
+ min == 0 || is_non_progressing(&inner.expr, rules, trace)
+ }
+ ParserExpr::Push(ref inner) => is_non_progressing(&inner.expr, rules, trace),
+ ParserExpr::RepOnce(ref inner) => is_non_progressing(&inner.expr, rules, trace),
+ #[cfg(feature = "grammar-extras")]
+ ParserExpr::NodeTag(ref inner, _) => is_non_progressing(&inner.expr, rules, trace),
}
}
+/// Checks if `expr` is non-failing, that is it matches any input.
+///
+/// # Example
+///
+/// ```pest
+/// non_failing_1 = { "" }
+/// ```
+///
+/// # Assumptions
+/// - In `ParserExpr::RepMinMax(inner,min,max)`, `min<=max`
+/// - In `ParserExpr::PeekSlice(max,Some(min))`, `max>=min`
+/// - All rules identiers have a matching definition
+/// - There is no left-recursion
+/// - All rules are being checked
fn is_non_failing<'i>(
expr: &ParserExpr<'i>,
rules: &HashMap<String, &ParserNode<'i>>,
trace: &mut Vec<String>,
) -> bool {
match *expr {
- ParserExpr::Str(ref string) => string.is_empty(),
+ ParserExpr::Str(ref string) | ParserExpr::Insens(ref string) => string.is_empty(),
ParserExpr::Ident(ref ident) => {
if !trace.contains(ident) {
if let Some(node) = rules.get(ident) {
@@ -281,21 +360,68 @@ fn is_non_failing<'i>(
let result = is_non_failing(&node.expr, rules, trace);
trace.pop().unwrap();
- return result;
+ result
+ } else {
+ // else
+ // the ident is
+ // - "POP","PEEK" => false
+ // the slice being checked is not non_failing since every
+ // PUSH is being checked (assumption 4) and the expr
+ // of a PUSH has to be non_failing.
+ // - "POP_ALL", "PEEK_ALL" => false
+ // same as "POP", "PEEK" unless the following:
+ // BUG: if the stack is empty they are non_failing
+ // - "DROP" => false
+ // - "ANY", "ASCII_*", UNICODE categories, "NEWLINE",
+ // "SOI", "EOI" => false
+ // - referring to another rule that is undefined (breaks assumption)
+ // WARNING: might want to introduce a panic or report the error
+ false
}
+ } else {
+ // referring to another rule R that was already seen
+ // WARNING: this might mean there is a circular non-failing path
+ // it's not obvious wether this can happen without left-recursion
+ // and thus breaking the assumption. Until there is answer to
+ // this, to avoid changing behaviour we return:
+ false
}
-
- false
}
ParserExpr::Opt(_) => true,
ParserExpr::Rep(_) => true,
+ ParserExpr::RepMax(_, _) => true,
ParserExpr::Seq(ref lhs, ref rhs) => {
is_non_failing(&lhs.expr, rules, trace) && is_non_failing(&rhs.expr, rules, trace)
}
ParserExpr::Choice(ref lhs, ref rhs) => {
is_non_failing(&lhs.expr, rules, trace) || is_non_failing(&rhs.expr, rules, trace)
}
- _ => false,
+ // it either always fail
+ // or always match at least a character
+ ParserExpr::Range(_, _) => false,
+ ParserExpr::PeekSlice(_, _) => {
+ // the slice being checked is not non_failing since every
+ // PUSH is being checked (assumption 4) and the expr
+ // of a PUSH has to be non_failing.
+ // BUG: if the slice is of size 0, or the stack is not large
+ // enough it might be non-failing
+ false
+ }
+ ParserExpr::RepExact(ref inner, min)
+ | ParserExpr::RepMin(ref inner, min)
+ | ParserExpr::RepMinMax(ref inner, min, _) => {
+ min == 0 || is_non_failing(&inner.expr, rules, trace)
+ }
+ // BUG: the predicate may always fail, resulting in this expr non_failing
+ // ex of always failing predicates :
+ // @{EOI ~ ANY | ANY ~ SOI | &("A") ~ &("B") | 'z'..'a'}
+ ParserExpr::NegPred(_) => false,
+ ParserExpr::RepOnce(ref inner) => is_non_failing(&inner.expr, rules, trace),
+ ParserExpr::Push(ref inner) | ParserExpr::PosPred(ref inner) => {
+ is_non_failing(&inner.expr, rules, trace)
+ }
+ #[cfg(feature = "grammar-extras")]
+ ParserExpr::NodeTag(ref inner, _) => is_non_failing(&inner.expr, rules, trace),
}
}
@@ -583,18 +709,881 @@ mod tests {
--> 1:13
|
-1 | COMMENT = { soi }
+1 | COMMENT = { SOI }
| ^-^
|
= COMMENT is non-progressing and will repeat infinitely")]
fn non_progressing_comment() {
- let input = "COMMENT = { soi }";
+ let input = "COMMENT = { SOI }";
unwrap_or_report(consume_rules(
PestParser::parse(Rule::grammar_rules, input).unwrap(),
));
}
#[test]
+ fn non_progressing_empty_string() {
+ assert!(is_non_failing(
+ &ParserExpr::Insens("".into()),
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+ assert!(is_non_progressing(
+ &ParserExpr::Str("".into()),
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+ }
+
+ #[test]
+ fn progressing_non_empty_string() {
+ assert!(!is_non_progressing(
+ &ParserExpr::Insens("non empty".into()),
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+ assert!(!is_non_progressing(
+ &ParserExpr::Str("non empty".into()),
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+ }
+
+ #[test]
+ fn non_progressing_soi_eoi() {
+ assert!(is_non_progressing(
+ &ParserExpr::Ident("SOI".into()),
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+ assert!(is_non_progressing(
+ &ParserExpr::Ident("EOI".into()),
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+ }
+
+ #[test]
+ fn non_progressing_predicates() {
+ let progressing = ParserExpr::Str("A".into());
+
+ assert!(is_non_progressing(
+ &ParserExpr::PosPred(Box::new(ParserNode {
+ expr: progressing.clone(),
+ span: Span::new(" ", 0, 1).unwrap(),
+ })),
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+ assert!(is_non_progressing(
+ &ParserExpr::NegPred(Box::new(ParserNode {
+ expr: progressing,
+ span: Span::new(" ", 0, 1).unwrap(),
+ })),
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+ }
+
+ #[test]
+ fn non_progressing_0_length_repetitions() {
+ let input_progressing_node = Box::new(ParserNode {
+ expr: ParserExpr::Str("A".into()),
+ span: Span::new(" ", 0, 1).unwrap(),
+ });
+
+ assert!(!is_non_progressing(
+ &input_progressing_node.clone().expr,
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+
+ assert!(is_non_progressing(
+ &ParserExpr::Rep(input_progressing_node.clone()),
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+ assert!(is_non_progressing(
+ &ParserExpr::Opt(input_progressing_node.clone()),
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+ assert!(is_non_progressing(
+ &ParserExpr::RepExact(input_progressing_node.clone(), 0),
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+ assert!(is_non_progressing(
+ &ParserExpr::RepMin(input_progressing_node.clone(), 0),
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+ assert!(is_non_progressing(
+ &ParserExpr::RepMax(input_progressing_node.clone(), 0),
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+ assert!(is_non_progressing(
+ &ParserExpr::RepMax(input_progressing_node.clone(), 17),
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+
+ assert!(is_non_progressing(
+ &ParserExpr::RepMinMax(input_progressing_node.clone(), 0, 12),
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+ }
+
+ #[test]
+ fn non_progressing_nonzero_repetitions_with_non_progressing_expr() {
+ let a = "";
+ let non_progressing_node = Box::new(ParserNode {
+ expr: ParserExpr::Str(a.into()),
+ span: Span::new(a, 0, 0).unwrap(),
+ });
+ let exact = ParserExpr::RepExact(non_progressing_node.clone(), 7);
+ let min = ParserExpr::RepMin(non_progressing_node.clone(), 23);
+ let minmax = ParserExpr::RepMinMax(non_progressing_node.clone(), 12, 13);
+ let reponce = ParserExpr::RepOnce(non_progressing_node);
+
+ assert!(is_non_progressing(&exact, &HashMap::new(), &mut Vec::new()));
+ assert!(is_non_progressing(&min, &HashMap::new(), &mut Vec::new()));
+ assert!(is_non_progressing(
+ &minmax,
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+ assert!(is_non_progressing(
+ &reponce,
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+ }
+
+ #[test]
+ fn progressing_repetitions() {
+ let a = "A";
+ let input_progressing_node = Box::new(ParserNode {
+ expr: ParserExpr::Str(a.into()),
+ span: Span::new(a, 0, 1).unwrap(),
+ });
+ let exact = ParserExpr::RepExact(input_progressing_node.clone(), 1);
+ let min = ParserExpr::RepMin(input_progressing_node.clone(), 2);
+ let minmax = ParserExpr::RepMinMax(input_progressing_node.clone(), 4, 5);
+ let reponce = ParserExpr::RepOnce(input_progressing_node);
+
+ assert!(!is_non_progressing(
+ &exact,
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+ assert!(!is_non_progressing(&min, &HashMap::new(), &mut Vec::new()));
+ assert!(!is_non_progressing(
+ &minmax,
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+ assert!(!is_non_progressing(
+ &reponce,
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+ }
+
+ #[test]
+ fn non_progressing_push() {
+ let a = "";
+ let non_progressing_node = Box::new(ParserNode {
+ expr: ParserExpr::Str(a.into()),
+ span: Span::new(a, 0, 0).unwrap(),
+ });
+ let push = ParserExpr::Push(non_progressing_node.clone());
+
+ assert!(is_non_progressing(&push, &HashMap::new(), &mut Vec::new()));
+ }
+
+ #[test]
+ fn progressing_push() {
+ let a = "i'm make progress";
+ let progressing_node = Box::new(ParserNode {
+ expr: ParserExpr::Str(a.into()),
+ span: Span::new(a, 0, 1).unwrap(),
+ });
+ let push = ParserExpr::Push(progressing_node.clone());
+
+ assert!(!is_non_progressing(&push, &HashMap::new(), &mut Vec::new()));
+ }
+
+ #[test]
+ fn node_tag_forwards_is_non_progressing() {
+ let progressing_node = Box::new(ParserNode {
+ expr: ParserExpr::Str("i'm make progress".into()),
+ span: Span::new(" ", 0, 1).unwrap(),
+ });
+ assert!(!is_non_progressing(
+ &progressing_node.clone().expr,
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+ let non_progressing_node = Box::new(ParserNode {
+ expr: ParserExpr::Str("".into()),
+ span: Span::new(" ", 0, 1).unwrap(),
+ });
+ assert!(is_non_progressing(
+ &non_progressing_node.clone().expr,
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+ #[cfg(feature = "grammar-extras")]
+ {
+ let progressing = ParserExpr::NodeTag(progressing_node.clone(), "TAG".into());
+ let non_progressing = ParserExpr::NodeTag(non_progressing_node.clone(), "TAG".into());
+
+ assert!(!is_non_progressing(
+ &progressing,
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+ assert!(is_non_progressing(
+ &non_progressing,
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+ }
+ }
+
+ #[test]
+ fn progressing_range() {
+ let progressing = ParserExpr::Range("A".into(), "Z".into());
+ let failing_is_progressing = ParserExpr::Range("Z".into(), "A".into());
+
+ assert!(!is_non_progressing(
+ &progressing,
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+ assert!(!is_non_progressing(
+ &failing_is_progressing,
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+ }
+
+ #[test]
+ fn progressing_choice() {
+ let left_progressing_node = Box::new(ParserNode {
+ expr: ParserExpr::Str("i'm make progress".into()),
+ span: Span::new(" ", 0, 1).unwrap(),
+ });
+ assert!(!is_non_progressing(
+ &left_progressing_node.clone().expr,
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+
+ let right_progressing_node = Box::new(ParserNode {
+ expr: ParserExpr::Ident("DROP".into()),
+ span: Span::new("DROP", 0, 3).unwrap(),
+ });
+
+ assert!(!is_non_progressing(
+ &ParserExpr::Choice(left_progressing_node, right_progressing_node),
+ &HashMap::new(),
+ &mut Vec::new()
+ ))
+ }
+
+ #[test]
+ fn non_progressing_choices() {
+ let left_progressing_node = Box::new(ParserNode {
+ expr: ParserExpr::Str("i'm make progress".into()),
+ span: Span::new(" ", 0, 1).unwrap(),
+ });
+
+ assert!(!is_non_progressing(
+ &left_progressing_node.clone().expr,
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+
+ let left_non_progressing_node = Box::new(ParserNode {
+ expr: ParserExpr::Str("".into()),
+ span: Span::new(" ", 0, 1).unwrap(),
+ });
+
+ assert!(is_non_progressing(
+ &left_non_progressing_node.clone().expr,
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+
+ let right_progressing_node = Box::new(ParserNode {
+ expr: ParserExpr::Ident("DROP".into()),
+ span: Span::new("DROP", 0, 3).unwrap(),
+ });
+
+ assert!(!is_non_progressing(
+ &right_progressing_node.clone().expr,
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+
+ let right_non_progressing_node = Box::new(ParserNode {
+ expr: ParserExpr::Opt(Box::new(ParserNode {
+ expr: ParserExpr::Str(" ".into()),
+ span: Span::new(" ", 0, 1).unwrap(),
+ })),
+ span: Span::new(" ", 0, 1).unwrap(),
+ });
+
+ assert!(is_non_progressing(
+ &right_non_progressing_node.clone().expr,
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+
+ assert!(is_non_progressing(
+ &ParserExpr::Choice(left_non_progressing_node.clone(), right_progressing_node),
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+ assert!(is_non_progressing(
+ &ParserExpr::Choice(left_progressing_node, right_non_progressing_node.clone()),
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+ assert!(is_non_progressing(
+ &ParserExpr::Choice(left_non_progressing_node, right_non_progressing_node),
+ &HashMap::new(),
+ &mut Vec::new()
+ ))
+ }
+
+ #[test]
+ fn non_progressing_seq() {
+ let left_non_progressing_node = Box::new(ParserNode {
+ expr: ParserExpr::Str("".into()),
+ span: Span::new(" ", 0, 1).unwrap(),
+ });
+
+ let right_non_progressing_node = Box::new(ParserNode {
+ expr: ParserExpr::Opt(Box::new(ParserNode {
+ expr: ParserExpr::Str(" ".into()),
+ span: Span::new(" ", 0, 1).unwrap(),
+ })),
+ span: Span::new(" ", 0, 1).unwrap(),
+ });
+
+ assert!(is_non_progressing(
+ &ParserExpr::Seq(left_non_progressing_node, right_non_progressing_node),
+ &HashMap::new(),
+ &mut Vec::new()
+ ))
+ }
+
+ #[test]
+ fn progressing_seqs() {
+ let left_progressing_node = Box::new(ParserNode {
+ expr: ParserExpr::Str("i'm make progress".into()),
+ span: Span::new(" ", 0, 1).unwrap(),
+ });
+
+ assert!(!is_non_progressing(
+ &left_progressing_node.clone().expr,
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+
+ let left_non_progressing_node = Box::new(ParserNode {
+ expr: ParserExpr::Str("".into()),
+ span: Span::new(" ", 0, 1).unwrap(),
+ });
+
+ assert!(is_non_progressing(
+ &left_non_progressing_node.clone().expr,
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+
+ let right_progressing_node = Box::new(ParserNode {
+ expr: ParserExpr::Ident("DROP".into()),
+ span: Span::new("DROP", 0, 3).unwrap(),
+ });
+
+ assert!(!is_non_progressing(
+ &right_progressing_node.clone().expr,
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+
+ let right_non_progressing_node = Box::new(ParserNode {
+ expr: ParserExpr::Opt(Box::new(ParserNode {
+ expr: ParserExpr::Str(" ".into()),
+ span: Span::new(" ", 0, 1).unwrap(),
+ })),
+ span: Span::new(" ", 0, 1).unwrap(),
+ });
+
+ assert!(is_non_progressing(
+ &right_non_progressing_node.clone().expr,
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+
+ assert!(!is_non_progressing(
+ &ParserExpr::Seq(left_non_progressing_node, right_progressing_node.clone()),
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+ assert!(!is_non_progressing(
+ &ParserExpr::Seq(left_progressing_node.clone(), right_non_progressing_node),
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+ assert!(!is_non_progressing(
+ &ParserExpr::Seq(left_progressing_node, right_progressing_node),
+ &HashMap::new(),
+ &mut Vec::new()
+ ))
+ }
+
+ #[test]
+ fn progressing_stack_operations() {
+ assert!(!is_non_progressing(
+ &ParserExpr::Ident("DROP".into()),
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+ assert!(!is_non_progressing(
+ &ParserExpr::Ident("PEEK".into()),
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+ assert!(!is_non_progressing(
+ &ParserExpr::Ident("POP".into()),
+ &HashMap::new(),
+ &mut Vec::new()
+ ))
+ }
+
+ #[test]
+ fn non_failing_string() {
+ let insens = ParserExpr::Insens("".into());
+ let string = ParserExpr::Str("".into());
+
+ assert!(is_non_failing(&insens, &HashMap::new(), &mut Vec::new()));
+
+ assert!(is_non_failing(&string, &HashMap::new(), &mut Vec::new()))
+ }
+
+ #[test]
+ fn failing_string() {
+ assert!(!is_non_failing(
+ &ParserExpr::Insens("i may fail!".into()),
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+ assert!(!is_non_failing(
+ &ParserExpr::Str("failure is not fatal".into()),
+ &HashMap::new(),
+ &mut Vec::new()
+ ))
+ }
+
+ #[test]
+ fn failing_stack_operations() {
+ assert!(!is_non_failing(
+ &ParserExpr::Ident("DROP".into()),
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+ assert!(!is_non_failing(
+ &ParserExpr::Ident("POP".into()),
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+ assert!(!is_non_failing(
+ &ParserExpr::Ident("PEEK".into()),
+ &HashMap::new(),
+ &mut Vec::new()
+ ))
+ }
+
+ #[test]
+ fn non_failing_zero_length_repetitions() {
+ let failing = Box::new(ParserNode {
+ expr: ParserExpr::Range("A".into(), "B".into()),
+ span: Span::new(" ", 0, 1).unwrap(),
+ });
+ assert!(!is_non_failing(
+ &failing.clone().expr,
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+ assert!(is_non_failing(
+ &ParserExpr::Opt(failing.clone()),
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+ assert!(is_non_failing(
+ &ParserExpr::Rep(failing.clone()),
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+ assert!(is_non_failing(
+ &ParserExpr::RepExact(failing.clone(), 0),
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+ assert!(is_non_failing(
+ &ParserExpr::RepMin(failing.clone(), 0),
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+ assert!(is_non_failing(
+ &ParserExpr::RepMax(failing.clone(), 0),
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+ assert!(is_non_failing(
+ &ParserExpr::RepMax(failing.clone(), 22),
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+ assert!(is_non_failing(
+ &ParserExpr::RepMinMax(failing.clone(), 0, 73),
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+ }
+
+ #[test]
+ fn non_failing_non_zero_repetitions_with_non_failing_expr() {
+ let non_failing = Box::new(ParserNode {
+ expr: ParserExpr::Opt(Box::new(ParserNode {
+ expr: ParserExpr::Range("A".into(), "B".into()),
+ span: Span::new(" ", 0, 1).unwrap(),
+ })),
+ span: Span::new(" ", 0, 1).unwrap(),
+ });
+ assert!(is_non_failing(
+ &non_failing.clone().expr,
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+ assert!(is_non_failing(
+ &ParserExpr::RepOnce(non_failing.clone()),
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+ assert!(is_non_failing(
+ &ParserExpr::RepExact(non_failing.clone(), 1),
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+ assert!(is_non_failing(
+ &ParserExpr::RepMin(non_failing.clone(), 6),
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+ assert!(is_non_failing(
+ &ParserExpr::RepMinMax(non_failing.clone(), 32, 73),
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+ }
+
+ #[test]
+ #[cfg(feature = "grammar-extras")]
+ fn failing_non_zero_repetitions() {
+ let failing = Box::new(ParserNode {
+ expr: ParserExpr::NodeTag(
+ Box::new(ParserNode {
+ expr: ParserExpr::Range("A".into(), "B".into()),
+ span: Span::new(" ", 0, 1).unwrap(),
+ }),
+ "Tag".into(),
+ ),
+ span: Span::new(" ", 0, 1).unwrap(),
+ });
+ assert!(!is_non_failing(
+ &failing.clone().expr,
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+ assert!(!is_non_failing(
+ &ParserExpr::RepOnce(failing.clone()),
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+ assert!(!is_non_failing(
+ &ParserExpr::RepExact(failing.clone(), 3),
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+ assert!(!is_non_failing(
+ &ParserExpr::RepMin(failing.clone(), 14),
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+ assert!(!is_non_failing(
+ &ParserExpr::RepMinMax(failing.clone(), 47, 73),
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+ }
+
+ #[test]
+ fn failing_choice() {
+ let left_failing_node = Box::new(ParserNode {
+ expr: ParserExpr::Str("i'm a failure".into()),
+ span: Span::new(" ", 0, 1).unwrap(),
+ });
+ assert!(!is_non_failing(
+ &left_failing_node.clone().expr,
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+
+ let right_failing_node = Box::new(ParserNode {
+ expr: ParserExpr::Ident("DROP".into()),
+ span: Span::new("DROP", 0, 3).unwrap(),
+ });
+
+ assert!(!is_non_failing(
+ &ParserExpr::Choice(left_failing_node, right_failing_node),
+ &HashMap::new(),
+ &mut Vec::new()
+ ))
+ }
+
+ #[test]
+ fn non_failing_choices() {
+ let left_failing_node = Box::new(ParserNode {
+ expr: ParserExpr::Str("i'm a failure".into()),
+ span: Span::new(" ", 0, 1).unwrap(),
+ });
+
+ assert!(!is_non_failing(
+ &left_failing_node.clone().expr,
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+
+ let left_non_failing_node = Box::new(ParserNode {
+ expr: ParserExpr::Str("".into()),
+ span: Span::new(" ", 0, 1).unwrap(),
+ });
+
+ assert!(is_non_failing(
+ &left_non_failing_node.clone().expr,
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+
+ let right_failing_node = Box::new(ParserNode {
+ expr: ParserExpr::Ident("DROP".into()),
+ span: Span::new("DROP", 0, 3).unwrap(),
+ });
+
+ assert!(!is_non_failing(
+ &right_failing_node.clone().expr,
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+
+ let right_non_failing_node = Box::new(ParserNode {
+ expr: ParserExpr::Opt(Box::new(ParserNode {
+ expr: ParserExpr::Str(" ".into()),
+ span: Span::new(" ", 0, 1).unwrap(),
+ })),
+ span: Span::new(" ", 0, 1).unwrap(),
+ });
+
+ assert!(is_non_failing(
+ &right_non_failing_node.clone().expr,
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+
+ assert!(is_non_failing(
+ &ParserExpr::Choice(left_non_failing_node.clone(), right_failing_node),
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+ assert!(is_non_failing(
+ &ParserExpr::Choice(left_failing_node, right_non_failing_node.clone()),
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+ assert!(is_non_failing(
+ &ParserExpr::Choice(left_non_failing_node, right_non_failing_node),
+ &HashMap::new(),
+ &mut Vec::new()
+ ))
+ }
+
+ #[test]
+ fn non_failing_seq() {
+ let left_non_failing_node = Box::new(ParserNode {
+ expr: ParserExpr::Str("".into()),
+ span: Span::new(" ", 0, 1).unwrap(),
+ });
+
+ let right_non_failing_node = Box::new(ParserNode {
+ expr: ParserExpr::Opt(Box::new(ParserNode {
+ expr: ParserExpr::Str(" ".into()),
+ span: Span::new(" ", 0, 1).unwrap(),
+ })),
+ span: Span::new(" ", 0, 1).unwrap(),
+ });
+
+ assert!(is_non_failing(
+ &ParserExpr::Seq(left_non_failing_node, right_non_failing_node),
+ &HashMap::new(),
+ &mut Vec::new()
+ ))
+ }
+
+ #[test]
+ fn failing_seqs() {
+ let left_failing_node = Box::new(ParserNode {
+ expr: ParserExpr::Str("i'm a failure".into()),
+ span: Span::new(" ", 0, 1).unwrap(),
+ });
+
+ assert!(!is_non_failing(
+ &left_failing_node.clone().expr,
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+
+ let left_non_failing_node = Box::new(ParserNode {
+ expr: ParserExpr::Str("".into()),
+ span: Span::new(" ", 0, 1).unwrap(),
+ });
+
+ assert!(is_non_failing(
+ &left_non_failing_node.clone().expr,
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+
+ let right_failing_node = Box::new(ParserNode {
+ expr: ParserExpr::Ident("DROP".into()),
+ span: Span::new("DROP", 0, 3).unwrap(),
+ });
+
+ assert!(!is_non_failing(
+ &right_failing_node.clone().expr,
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+
+ let right_non_failing_node = Box::new(ParserNode {
+ expr: ParserExpr::Opt(Box::new(ParserNode {
+ expr: ParserExpr::Str(" ".into()),
+ span: Span::new(" ", 0, 1).unwrap(),
+ })),
+ span: Span::new(" ", 0, 1).unwrap(),
+ });
+
+ assert!(is_non_failing(
+ &right_non_failing_node.clone().expr,
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+
+ assert!(!is_non_failing(
+ &ParserExpr::Seq(left_non_failing_node, right_failing_node.clone()),
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+ assert!(!is_non_failing(
+ &ParserExpr::Seq(left_failing_node.clone(), right_non_failing_node),
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+ assert!(!is_non_failing(
+ &ParserExpr::Seq(left_failing_node, right_failing_node),
+ &HashMap::new(),
+ &mut Vec::new()
+ ))
+ }
+
+ #[test]
+ fn failing_range() {
+ let failing = ParserExpr::Range("A".into(), "Z".into());
+ let always_failing = ParserExpr::Range("Z".into(), "A".into());
+
+ assert!(!is_non_failing(&failing, &HashMap::new(), &mut Vec::new()));
+ assert!(!is_non_failing(
+ &always_failing,
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+ }
+
+ #[test]
+ fn _push_node_tag_pos_pred_forwarding_is_non_failing() {
+ let failing_node = Box::new(ParserNode {
+ expr: ParserExpr::Str("i'm a failure".into()),
+ span: Span::new(" ", 0, 1).unwrap(),
+ });
+ assert!(!is_non_failing(
+ &failing_node.clone().expr,
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+ let non_failing_node = Box::new(ParserNode {
+ expr: ParserExpr::Str("".into()),
+ span: Span::new(" ", 0, 1).unwrap(),
+ });
+ assert!(is_non_failing(
+ &non_failing_node.clone().expr,
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+
+ #[cfg(feature = "grammar-extras")]
+ {
+ assert!(!is_non_failing(
+ &ParserExpr::NodeTag(failing_node.clone(), "TAG".into()),
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+ assert!(is_non_failing(
+ &ParserExpr::NodeTag(non_failing_node.clone(), "TAG".into()),
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+ }
+
+ assert!(!is_non_failing(
+ &ParserExpr::Push(failing_node.clone()),
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+ assert!(is_non_failing(
+ &ParserExpr::Push(non_failing_node.clone()),
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+
+ assert!(!is_non_failing(
+ &ParserExpr::PosPred(failing_node.clone()),
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+ assert!(is_non_failing(
+ &ParserExpr::PosPred(non_failing_node.clone()),
+ &HashMap::new(),
+ &mut Vec::new()
+ ));
+ }
+
+ #[test]
#[should_panic(expected = "grammar error
--> 1:7
@@ -647,12 +1636,12 @@ mod tests {
--> 1:7
|
-1 | a = { (\"\" ~ &\"a\" ~ !\"a\" ~ (soi | eoi))* }
+1 | a = { (\"\" ~ &\"a\" ~ !\"a\" ~ (SOI | EOI))* }
| ^-------------------------------^
|
= expression inside repetition is non-progressing and will repeat infinitely")]
fn non_progressing_repetition() {
- let input = "a = { (\"\" ~ &\"a\" ~ !\"a\" ~ (soi | eoi))* }";
+ let input = "a = { (\"\" ~ &\"a\" ~ !\"a\" ~ (SOI | EOI))* }";
unwrap_or_report(consume_rules(
PestParser::parse(Rule::grammar_rules, input).unwrap(),
));