From 2ff14448863ac1a1dd9533461708e29aae170c2d Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:06:31 +0200 Subject: Adding debian version 1.65.0+dfsg1-2. Signed-off-by: Daniel Baumann --- vendor/pest_meta/.cargo-checksum.json | 2 +- vendor/pest_meta/Cargo.toml | 46 ++--- vendor/pest_meta/_README.md | 23 ++- vendor/pest_meta/src/ast.rs | 2 +- vendor/pest_meta/src/grammar.pest | 2 +- vendor/pest_meta/src/grammar.rs | 2 +- vendor/pest_meta/src/lib.rs | 20 +-- vendor/pest_meta/src/optimizer/concatenator.rs | 39 +++-- vendor/pest_meta/src/optimizer/factorizer.rs | 61 ++++--- vendor/pest_meta/src/optimizer/lister.rs | 42 +++++ vendor/pest_meta/src/optimizer/mod.rs | 104 ++++++++++-- vendor/pest_meta/src/optimizer/restorer.rs | 14 +- vendor/pest_meta/src/optimizer/rotater.rs | 13 +- vendor/pest_meta/src/optimizer/skipper.rs | 39 +++-- vendor/pest_meta/src/optimizer/unroller.rs | 107 ++++++------ vendor/pest_meta/src/parser.rs | 93 +++++++++-- vendor/pest_meta/src/validator.rs | 222 ++++++++++--------------- 17 files changed, 496 insertions(+), 335 deletions(-) create mode 100644 vendor/pest_meta/src/optimizer/lister.rs (limited to 'vendor/pest_meta') diff --git a/vendor/pest_meta/.cargo-checksum.json b/vendor/pest_meta/.cargo-checksum.json index f51cb5967..5a98eadb3 100644 --- a/vendor/pest_meta/.cargo-checksum.json +++ b/vendor/pest_meta/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"Cargo.toml":"adf86f275ddc1ae02311ab5e1b51a165dc034edf466fc74dea6cbe63fe80d9b3","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","_README.md":"e9901b6c4d50403bfda7e08a92b5c395a8c51eba868c7bd07b03e00ccba702f3","src/ast.rs":"b2d0b054d66525b6c9ceed7a9b24cabcdd1074b525b230fc99a1a31019010f58","src/grammar.pest":"fac55bde3f3b59058293d220fec96ef033e61cb24fc032cad21d76aa6f963bc1","src/grammar.rs":"eb8f1f0c964467c081564de8830f3db4966499311868127342b9b651e8cee06f","src/lib.rs":"b248cf6bc5d4a8537f682c23f8d2c8910eb764ee5f1cc02b2c344b0b920943da","src/optimizer/concatenator.rs":"94c2a79d39ebeddbc413d30f2c20d0b50ae2c0e2e86bff90a029b70aa028e2fc","src/optimizer/factorizer.rs":"84df67d6e3f1b507b3e970cb8fba1ab9e2254c3ba778c4a0cf100452b36f1e08","src/optimizer/mod.rs":"69f25916112cbfa4b3d2225f8af463a03ebe706ae757d9c97be523c5601d7b3c","src/optimizer/restorer.rs":"182561b972752ec961fa45d0ca705a9852462010003e4e1ab646e5cd486bedd1","src/optimizer/rotater.rs":"e59f6c3e9197dc3cb4f21edf0c5ffb1a2638a81e4ce9b0373a2d2147a12a3bd5","src/optimizer/skipper.rs":"ab52c7a44a35aefcd1546da5e2084af642c472f07565dcb1be1bb3e2b5fc5a41","src/optimizer/unroller.rs":"99b4940906b0eb443a8b0bf6499130098d59a8141f2693ec50a653cb21c534d5","src/parser.rs":"04a93b2d36bcf199cbc5ab3e943a85cc1730529af83bb3f4a1a9f6b80e2eda4a","src/validator.rs":"5436c0cafc8fa91e45e4988e280220057c8f43ec7a796491abb8e9b22f80582d"},"package":"54be6e404f5317079812fc8f9f5279de376d8856929e21c184ecf6bbd692a11d"} \ No newline at end of file +{"files":{"Cargo.toml":"3673efe1bf8eb36b5ae86959a918a846040826779babf8729a2725d651a6d035","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","_README.md":"01ba71f02581f9f5018962e083ca77bc8e8af2b6f8a73111bfa04e847a6440e2","src/ast.rs":"782e31c3e3ad194209975d9515b5df42883f7b7e316cd342e4603bcd5b3ec8d6","src/grammar.pest":"697e32f6fee403c3199317404891481b13dee127b956d6c3ec5a6a6116d18921","src/grammar.rs":"ed08400f1d37fee264359077666a02df0b6ac0d52500040b1157957502ab04ad","src/lib.rs":"8773adeac67a4c7de66f129f0d88fcf88748acc9a44b32949d7e1a3bcd338448","src/optimizer/concatenator.rs":"b77e6ec1d4d79d5383c74435d86e888a048c134fc5cff250356de9405e0ecfab","src/optimizer/factorizer.rs":"ffe510cc8c33fdb89c2a4e575f4d54f7894f126e71e6ae010d9614679d26254e","src/optimizer/lister.rs":"706812c52df72753071bf2db039dffb1061c1a0f030e4c1af67302c632ff15cd","src/optimizer/mod.rs":"18daf1ee2e6789ee4c9afddd34e1081364c7b30b2163ca0c6bf843fee865420e","src/optimizer/restorer.rs":"8b65cfe7dfd4d812bee6ac3cdbcc3d0026e03fd2b456a7c866dd83e6fdbf26a7","src/optimizer/rotater.rs":"7256bc8c01a09c5489fdb8d1cc52461bcc5ccf826db478b1420b01473b9b6c62","src/optimizer/skipper.rs":"8a7cd27713c8ffc795a82471242225b5fbbecec221c75fe8ac48e878d5a6088e","src/optimizer/unroller.rs":"f4010f2bf3b2bb0740d17b04c73f772284f576bfb57b9cac16b98293168ffb7a","src/parser.rs":"11b030a345afb092d1a66cf1481c6653f3d192e585632fbe8fa5641b771e5236","src/validator.rs":"97be65d88cc064c0857deb3ab73c3373560882e454c6ed2cd6a4a9d8d773beaf"},"package":"1538eb784f07615c6d9a8ab061089c6c54a344c5b4301db51990ca1c241e8c04"} \ No newline at end of file diff --git a/vendor/pest_meta/Cargo.toml b/vendor/pest_meta/Cargo.toml index 74f837745..347b7db37 100644 --- a/vendor/pest_meta/Cargo.toml +++ b/vendor/pest_meta/Cargo.toml @@ -3,40 +3,46 @@ # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies -# to registry (e.g., crates.io) dependencies +# to registry (e.g., crates.io) dependencies. # -# If you believe there's an error in this file please file an -# issue against the rust-lang/cargo repository. If you're -# editing this file be aware that the upstream Cargo.toml -# will likely look very different (and much more reasonable) +# If you are reading this file be aware that the original Cargo.toml +# will likely look very different (and much more reasonable). +# See Cargo.toml.orig for the original contents. [package] +edition = "2018" +rust-version = "1.56" name = "pest_meta" -version = "2.1.3" +version = "2.3.0" authors = ["DragoČ™ Tiselice "] exclude = ["src/grammar.pest"] -include = ["Cargo.toml", "src/**/*", "src/grammar.rs", "_README.md", "LICENSE-*"] +include = [ + "Cargo.toml", + "src/**/*", + "src/grammar.rs", + "_README.md", + "LICENSE-*", +] description = "pest meta language parser and validator" homepage = "https://pest-parser.github.io/" documentation = "https://docs.rs/pest" readme = "_README.md" -keywords = ["pest", "parser", "meta", "optimizer"] +keywords = [ + "pest", + "parser", + "meta", + "optimizer", +] categories = ["parsing"] license = "MIT/Apache-2.0" repository = "https://github.com/pest-parser/pest" -[dependencies.maplit] -version = "1.0" + +[dependencies.once_cell] +version = "1.8.0" [dependencies.pest] -version = "2.1.0" +version = "2.3.0" + [build-dependencies.sha-1] -version = "0.8" +version = "0.10" default-features = false -[badges.codecov] -repository = "pest-parser/pest" - -[badges.maintenance] -status = "actively-developed" - -[badges.travis-ci] -repository = "pest-parser/pest" diff --git a/vendor/pest_meta/_README.md b/vendor/pest_meta/_README.md index 8e55f29a2..f91188ccb 100644 --- a/vendor/pest_meta/_README.md +++ b/vendor/pest_meta/_README.md @@ -1,3 +1,4 @@ +

@@ -8,9 +9,10 @@ [![Book](https://img.shields.io/badge/book-WIP-4d76ae.svg)](https://pest-parser.github.io/book) [![Docs](https://docs.rs/pest/badge.svg)](https://docs.rs/pest) -[![Build Status](https://travis-ci.org/pest-parser/pest.svg?branch=master)](https://travis-ci.org/pest-parser/pest) +[![pest Continuous Integration](https://github.com/pest-parser/pest/actions/workflows/ci.yml/badge.svg)](https://github.com/pest-parser/pest/actions/workflows/ci.yml) [![codecov](https://codecov.io/gh/pest-parser/pest/branch/master/graph/badge.svg)](https://codecov.io/gh/pest-parser/pest) -[![Fuzzit Status](https://app.fuzzit.dev/badge?org_id=pest-parser)](https://app.fuzzit.dev/orgs/pest-parser/dashboard) +Rustc Version 1.56.1+ + [![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) @@ -38,7 +40,7 @@ Other helpful resources: ## Example -The following is an example of a grammar for a list of alpha-numeric identifiers +The following is an example of a grammar for a list of alphanumeric identifiers where the first identifier does not start with a digit: ```rust @@ -143,16 +145,18 @@ Digit: 2 * [pest_meta](https://github.com/pest-parser/pest/blob/master/meta/src/grammar.pest) (bootstrapped) * [AshPaper](https://github.com/shnewto/ashpaper) * [brain](https://github.com/brain-lang/brain) -* [Chelone](https://github.com/Aaronepower/chelone) +* [cicada](https://github.com/mitnk/cicada) * [comrak](https://github.com/kivikakk/comrak) * [elastic-rs](https://github.com/cch123/elastic-rs) * [graphql-parser](https://github.com/Keats/graphql-parser) * [handlebars-rust](https://github.com/sunng87/handlebars-rust) * [hexdino](https://github.com/Luz/hexdino) * [Huia](https://gitlab.com/jimsy/huia/) +* [insta](https://github.com/mitsuhiko/insta) * [jql](https://github.com/yamafaktory/jql) * [json5-rs](https://github.com/callum-oakley/json5-rs) * [mt940](https://github.com/svenstaro/mt940-rs) +* [Myoxine](https://github.com/d3bate/myoxine) * [py_literal](https://github.com/jturner314/py_literal) * [rouler](https://github.com/jarcane/rouler) * [RuSh](https://github.com/lwandrebeck/RuSh) @@ -162,6 +166,17 @@ Digit: 2 * [ui_gen](https://github.com/emoon/ui_gen) * [ukhasnet-parser](https://github.com/adamgreig/ukhasnet-parser) * [ZoKrates](https://github.com/ZoKrates/ZoKrates) +* [Vector](https://github.com/timberio/vector) +* [AutoCorrect](https://github.com/huacnlee/autocorrect) +* [yaml-peg](https://github.com/aofdev/yaml-peg) +* [qubit](https://github.com/abhimanyu003/qubit) +* [caith](https://github.com/Geobert/caith) (a dice roller crate) +* [Melody](https://github.com/yoav-lavi/melody) + +## Minimum Supported Rust Version (MSRV) + +This library should always compile with default features on **Rust 1.56.1** +or **Rust 1.61** with `const_prec_climber`. ## Special thanks diff --git a/vendor/pest_meta/src/ast.rs b/vendor/pest_meta/src/ast.rs index b80c59630..da6ee5278 100644 --- a/vendor/pest_meta/src/ast.rs +++ b/vendor/pest_meta/src/ast.rs @@ -280,7 +280,7 @@ mod tests { Box::new(Expr::Str(String::from("a"))), Box::new(Expr::Str(String::from("b"))), ); - let mut top_down = expr.clone().iter_top_down(); + let mut top_down = expr.iter_top_down(); assert_eq!(top_down.next(), Some(expr)); assert_eq!(top_down.next(), Some(Expr::Str(String::from("a")))); assert_eq!(top_down.next(), Some(Expr::Str(String::from("b")))); diff --git a/vendor/pest_meta/src/grammar.pest b/vendor/pest_meta/src/grammar.pest index 0d03ba899..282ca35b8 100644 --- a/vendor/pest_meta/src/grammar.pest +++ b/vendor/pest_meta/src/grammar.pest @@ -34,7 +34,7 @@ atomic_modifier = { "@" } compound_atomic_modifier = { "$" } non_atomic_modifier = { "!" } -expression = { term ~ (infix_operator ~ term)* } +expression = { choice_operator? ~ term ~ (infix_operator ~ term)* } term = { prefix_operator* ~ node ~ postfix_operator* } node = _{ opening_paren ~ expression ~ closing_paren | terminal } terminal = _{ _push | peek_slice | identifier | string | insensitive_string | range } diff --git a/vendor/pest_meta/src/grammar.rs b/vendor/pest_meta/src/grammar.rs index bf94a1e3a..e42982b06 100644 --- a/vendor/pest_meta/src/grammar.rs +++ b/vendor/pest_meta/src/grammar.rs @@ -1,2 +1,2 @@ pub struct PestParser; -# [ allow ( dead_code , non_camel_case_types ) ] # [ derive ( Clone , Copy , Debug , Eq , Hash , Ord , PartialEq , PartialOrd ) ] pub enum Rule { EOI , grammar_rules , grammar_rule , assignment_operator , opening_brace , closing_brace , opening_paren , closing_paren , opening_brack , closing_brack , modifier , silent_modifier , atomic_modifier , compound_atomic_modifier , non_atomic_modifier , expression , term , node , terminal , prefix_operator , infix_operator , postfix_operator , positive_predicate_operator , negative_predicate_operator , sequence_operator , choice_operator , optional_operator , repeat_operator , repeat_once_operator , repeat_exact , repeat_min , repeat_max , repeat_min_max , number , integer , comma , _push , peek_slice , identifier , alpha , alpha_num , string , insensitive_string , range , character , inner_str , inner_chr , escape , code , unicode , hex_digit , quote , single_quote , range_operator , newline , WHITESPACE , block_comment , COMMENT } # [ allow ( clippy :: all ) ] impl :: pest :: Parser < Rule > for PestParser { fn parse < 'i > ( rule : Rule , input : & 'i str ) -> :: std :: result :: Result < :: pest :: iterators :: Pairs < 'i , Rule > , :: pest :: error :: Error < Rule > > { mod rules { pub mod hidden { use super :: super :: Rule ; # [ inline ] # [ allow ( dead_code , non_snake_case , unused_variables ) ] pub fn skip ( state : Box < :: pest :: ParserState < Rule >> ) -> :: pest :: ParseResult < Box < :: pest :: ParserState < Rule >> > { if state . atomicity ( ) == :: pest :: Atomicity :: NonAtomic { state . sequence ( | state | { state . repeat ( | state | super :: visible :: WHITESPACE ( state ) ) . and_then ( | state | { state . repeat ( | state | { state . sequence ( | state | { super :: visible :: COMMENT ( state ) . and_then ( | state | { state . repeat ( | state | super :: visible :: WHITESPACE ( state ) ) } ) } ) } ) } ) } ) } else { Ok ( state ) } } } pub mod visible { use super :: super :: Rule ; # [ inline ] # [ allow ( non_snake_case , unused_variables ) ] pub fn grammar_rules ( state : Box < :: pest :: ParserState < Rule >> ) -> :: pest :: ParseResult < Box < :: pest :: ParserState < Rule >> > { state . sequence ( | state | { self :: SOI ( state ) . and_then ( | state | { super :: hidden :: skip ( state ) } ) . and_then ( | state | { state . sequence ( | state | { self :: grammar_rule ( state ) . and_then ( | state | { super :: hidden :: skip ( state ) } ) . and_then ( | state | { state . sequence ( | state | { state . optional ( | state | { self :: grammar_rule ( state ) . and_then ( | state | { state . repeat ( | state | { state . sequence ( | state | { super :: hidden :: skip ( state ) . and_then ( | state | { self :: grammar_rule ( state ) } ) } ) } ) } ) } ) } ) } ) } ) } ) . and_then ( | state | { super :: hidden :: skip ( state ) } ) . and_then ( | state | { self :: EOI ( state ) } ) } ) } # [ inline ] # [ allow ( non_snake_case , unused_variables ) ] pub fn grammar_rule ( state : Box < :: pest :: ParserState < Rule >> ) -> :: pest :: ParseResult < Box < :: pest :: ParserState < Rule >> > { state . rule ( Rule :: grammar_rule , | state | { state . sequence ( | state | { self :: identifier ( state ) . and_then ( | state | { super :: hidden :: skip ( state ) } ) . and_then ( | state | { self :: assignment_operator ( state ) } ) . and_then ( | state | { super :: hidden :: skip ( state ) } ) . and_then ( | state | { state . optional ( | state | { self :: modifier ( state ) } ) } ) . and_then ( | state | { super :: hidden :: skip ( state ) } ) . and_then ( | state | { self :: opening_brace ( state ) } ) . and_then ( | state | { super :: hidden :: skip ( state ) } ) . and_then ( | state | { self :: expression ( state ) } ) . and_then ( | state | { super :: hidden :: skip ( state ) } ) . and_then ( | state | { self :: closing_brace ( state ) } ) } ) } ) } # [ inline ] # [ allow ( non_snake_case , unused_variables ) ] pub fn assignment_operator ( state : Box < :: pest :: ParserState < Rule >> ) -> :: pest :: ParseResult < Box < :: pest :: ParserState < Rule >> > { state . rule ( Rule :: assignment_operator , | state | { state . match_string ( "=" ) } ) } # [ inline ] # [ allow ( non_snake_case , unused_variables ) ] pub fn opening_brace ( state : Box < :: pest :: ParserState < Rule >> ) -> :: pest :: ParseResult < Box < :: pest :: ParserState < Rule >> > { state . rule ( Rule :: opening_brace , | state | { state . match_string ( "{" ) } ) } # [ inline ] # [ allow ( non_snake_case , unused_variables ) ] pub fn closing_brace ( state : Box < :: pest :: ParserState < Rule >> ) -> :: pest :: ParseResult < Box < :: pest :: ParserState < Rule >> > { state . rule ( Rule :: closing_brace , | state | { state . match_string ( "}" ) } ) } # [ inline ] # [ allow ( non_snake_case , unused_variables ) ] pub fn opening_paren ( state : Box < :: pest :: ParserState < Rule >> ) -> :: pest :: ParseResult < Box < :: pest :: ParserState < Rule >> > { state . rule ( Rule :: opening_paren , | state | { state . match_string ( "(" ) } ) } # [ inline ] # [ allow ( non_snake_case , unused_variables ) ] pub fn closing_paren ( state : Box < :: pest :: ParserState < Rule >> ) -> :: pest :: ParseResult < Box < :: pest :: ParserState < Rule >> > { state . rule ( Rule :: closing_paren , | state | { state . match_string ( ")" ) } ) } # [ inline ] # [ allow ( non_snake_case , unused_variables ) ] pub fn opening_brack ( state : Box < :: pest :: ParserState < Rule >> ) -> :: pest :: ParseResult < Box < :: pest :: ParserState < Rule >> > { state . rule ( Rule :: opening_brack , | state | { state . match_string ( "[" ) } ) } # [ inline ] # [ allow ( non_snake_case , unused_variables ) ] pub fn closing_brack ( state : Box < :: pest :: ParserState < Rule >> ) -> :: pest :: ParseResult < Box < :: pest :: ParserState < Rule >> > { state . rule ( Rule :: closing_brack , | state | { state . match_string ( "]" ) } ) } # [ inline ] # [ allow ( non_snake_case , unused_variables ) ] pub fn modifier ( state : Box < :: pest :: ParserState < Rule >> ) -> :: pest :: ParseResult < Box < :: pest :: ParserState < Rule >> > { self :: silent_modifier ( state ) . or_else ( | state | { self :: atomic_modifier ( state ) } ) . or_else ( | state | { self :: compound_atomic_modifier ( state ) } ) . or_else ( | state | { self :: non_atomic_modifier ( state ) } ) } # [ inline ] # [ allow ( non_snake_case , unused_variables ) ] pub fn silent_modifier ( state : Box < :: pest :: ParserState < Rule >> ) -> :: pest :: ParseResult < Box < :: pest :: ParserState < Rule >> > { state . rule ( Rule :: silent_modifier , | state | { state . match_string ( "_" ) } ) } # [ inline ] # [ allow ( non_snake_case , unused_variables ) ] pub fn atomic_modifier ( state : Box < :: pest :: ParserState < Rule >> ) -> :: pest :: ParseResult < Box < :: pest :: ParserState < Rule >> > { state . rule ( Rule :: atomic_modifier , | state | { state . match_string ( "@" ) } ) } # [ inline ] # [ allow ( non_snake_case , unused_variables ) ] pub fn compound_atomic_modifier ( state : Box < :: pest :: ParserState < Rule >> ) -> :: pest :: ParseResult < Box < :: pest :: ParserState < Rule >> > { state . rule ( Rule :: compound_atomic_modifier , | state | { state . match_string ( "$" ) } ) } # [ inline ] # [ allow ( non_snake_case , unused_variables ) ] pub fn non_atomic_modifier ( state : Box < :: pest :: ParserState < Rule >> ) -> :: pest :: ParseResult < Box < :: pest :: ParserState < Rule >> > { state . rule ( Rule :: non_atomic_modifier , | state | { state . match_string ( "!" ) } ) } # [ inline ] # [ allow ( non_snake_case , unused_variables ) ] pub fn expression ( state : Box < :: pest :: ParserState < Rule >> ) -> :: pest :: ParseResult < Box < :: pest :: ParserState < Rule >> > { state . rule ( Rule :: expression , | state | { state . sequence ( | state | { self :: term ( state ) . and_then ( | state | { super :: hidden :: skip ( state ) } ) . and_then ( | state | { state . sequence ( | state | { state . optional ( | state | { state . sequence ( | state | { self :: infix_operator ( state ) . and_then ( | state | { super :: hidden :: skip ( state ) } ) . and_then ( | state | { self :: term ( state ) } ) } ) . and_then ( | state | { state . repeat ( | state | { state . sequence ( | state | { super :: hidden :: skip ( state ) . and_then ( | state | { state . sequence ( | state | { self :: infix_operator ( state ) . and_then ( | state | { super :: hidden :: skip ( state ) } ) . and_then ( | state | { self :: term ( state ) } ) } ) } ) } ) } ) } ) } ) } ) } ) } ) } ) } # [ inline ] # [ allow ( non_snake_case , unused_variables ) ] pub fn term ( state : Box < :: pest :: ParserState < Rule >> ) -> :: pest :: ParseResult < Box < :: pest :: ParserState < Rule >> > { state . rule ( Rule :: term , | state | { state . sequence ( | state | { state . sequence ( | state | { state . optional ( | state | { self :: prefix_operator ( state ) . and_then ( | state | { state . repeat ( | state | { state . sequence ( | state | { super :: hidden :: skip ( state ) . and_then ( | state | { self :: prefix_operator ( state ) } ) } ) } ) } ) } ) } ) . and_then ( | state | { super :: hidden :: skip ( state ) } ) . and_then ( | state | { self :: node ( state ) } ) . and_then ( | state | { super :: hidden :: skip ( state ) } ) . and_then ( | state | { state . sequence ( | state | { state . optional ( | state | { self :: postfix_operator ( state ) . and_then ( | state | { state . repeat ( | state | { state . sequence ( | state | { super :: hidden :: skip ( state ) . and_then ( | state | { self :: postfix_operator ( state ) } ) } ) } ) } ) } ) } ) } ) } ) } ) } # [ inline ] # [ allow ( non_snake_case , unused_variables ) ] pub fn node ( state : Box < :: pest :: ParserState < Rule >> ) -> :: pest :: ParseResult < Box < :: pest :: ParserState < Rule >> > { state . sequence ( | state | { self :: opening_paren ( state ) . and_then ( | state | { super :: hidden :: skip ( state ) } ) . and_then ( | state | { self :: expression ( state ) } ) . and_then ( | state | { super :: hidden :: skip ( state ) } ) . and_then ( | state | { self :: closing_paren ( state ) } ) } ) . or_else ( | state | { self :: terminal ( state ) } ) } # [ inline ] # [ allow ( non_snake_case , unused_variables ) ] pub fn terminal ( state : Box < :: pest :: ParserState < Rule >> ) -> :: pest :: ParseResult < Box < :: pest :: ParserState < Rule >> > { self :: _push ( state ) . or_else ( | state | { self :: peek_slice ( state ) } ) . or_else ( | state | { self :: identifier ( state ) } ) . or_else ( | state | { self :: string ( state ) } ) . or_else ( | state | { self :: insensitive_string ( state ) } ) . or_else ( | state | { self :: range ( state ) } ) } # [ inline ] # [ allow ( non_snake_case , unused_variables ) ] pub fn prefix_operator ( state : Box < :: pest :: ParserState < Rule >> ) -> :: pest :: ParseResult < Box < :: pest :: ParserState < Rule >> > { self :: positive_predicate_operator ( state ) . or_else ( | state | { self :: negative_predicate_operator ( state ) } ) } # [ inline ] # [ allow ( non_snake_case , unused_variables ) ] pub fn infix_operator ( state : Box < :: pest :: ParserState < Rule >> ) -> :: pest :: ParseResult < Box < :: pest :: ParserState < Rule >> > { self :: sequence_operator ( state ) . or_else ( | state | { self :: choice_operator ( state ) } ) } # [ inline ] # [ allow ( non_snake_case , unused_variables ) ] pub fn postfix_operator ( state : Box < :: pest :: ParserState < Rule >> ) -> :: pest :: ParseResult < Box < :: pest :: ParserState < Rule >> > { self :: optional_operator ( state ) . or_else ( | state | { self :: repeat_operator ( state ) } ) . or_else ( | state | { self :: repeat_once_operator ( state ) } ) . or_else ( | state | { self :: repeat_exact ( state ) } ) . or_else ( | state | { self :: repeat_min ( state ) } ) . or_else ( | state | { self :: repeat_max ( state ) } ) . or_else ( | state | { self :: repeat_min_max ( state ) } ) } # [ inline ] # [ allow ( non_snake_case , unused_variables ) ] pub fn positive_predicate_operator ( state : Box < :: pest :: ParserState < Rule >> ) -> :: pest :: ParseResult < Box < :: pest :: ParserState < Rule >> > { state . rule ( Rule :: positive_predicate_operator , | state | { state . match_string ( "&" ) } ) } # [ inline ] # [ allow ( non_snake_case , unused_variables ) ] pub fn negative_predicate_operator ( state : Box < :: pest :: ParserState < Rule >> ) -> :: pest :: ParseResult < Box < :: pest :: ParserState < Rule >> > { state . rule ( Rule :: negative_predicate_operator , | state | { state . match_string ( "!" ) } ) } # [ inline ] # [ allow ( non_snake_case , unused_variables ) ] pub fn sequence_operator ( state : Box < :: pest :: ParserState < Rule >> ) -> :: pest :: ParseResult < Box < :: pest :: ParserState < Rule >> > { state . rule ( Rule :: sequence_operator , | state | { state . match_string ( "~" ) } ) } # [ inline ] # [ allow ( non_snake_case , unused_variables ) ] pub fn choice_operator ( state : Box < :: pest :: ParserState < Rule >> ) -> :: pest :: ParseResult < Box < :: pest :: ParserState < Rule >> > { state . rule ( Rule :: choice_operator , | state | { state . match_string ( "|" ) } ) } # [ inline ] # [ allow ( non_snake_case , unused_variables ) ] pub fn optional_operator ( state : Box < :: pest :: ParserState < Rule >> ) -> :: pest :: ParseResult < Box < :: pest :: ParserState < Rule >> > { state . rule ( Rule :: optional_operator , | state | { state . match_string ( "?" ) } ) } # [ inline ] # [ allow ( non_snake_case , unused_variables ) ] pub fn repeat_operator ( state : Box < :: pest :: ParserState < Rule >> ) -> :: pest :: ParseResult < Box < :: pest :: ParserState < Rule >> > { state . rule ( Rule :: repeat_operator , | state | { state . match_string ( "*" ) } ) } # [ inline ] # [ allow ( non_snake_case , unused_variables ) ] pub fn repeat_once_operator ( state : Box < :: pest :: ParserState < Rule >> ) -> :: pest :: ParseResult < Box < :: pest :: ParserState < Rule >> > { state . rule ( Rule :: repeat_once_operator , | state | { state . match_string ( "+" ) } ) } # [ inline ] # [ allow ( non_snake_case , unused_variables ) ] pub fn repeat_exact ( state : Box < :: pest :: ParserState < Rule >> ) -> :: pest :: ParseResult < Box < :: pest :: ParserState < Rule >> > { state . rule ( Rule :: repeat_exact , | state | { state . sequence ( | state | { self :: opening_brace ( state ) . and_then ( | state | { super :: hidden :: skip ( state ) } ) . and_then ( | state | { self :: number ( state ) } ) . and_then ( | state | { super :: hidden :: skip ( state ) } ) . and_then ( | state | { self :: closing_brace ( state ) } ) } ) } ) } # [ inline ] # [ allow ( non_snake_case , unused_variables ) ] pub fn repeat_min ( state : Box < :: pest :: ParserState < Rule >> ) -> :: pest :: ParseResult < Box < :: pest :: ParserState < Rule >> > { state . rule ( Rule :: repeat_min , | state | { state . sequence ( | state | { self :: opening_brace ( state ) . and_then ( | state | { super :: hidden :: skip ( state ) } ) . and_then ( | state | { self :: number ( state ) } ) . and_then ( | state | { super :: hidden :: skip ( state ) } ) . and_then ( | state | { self :: comma ( state ) } ) . and_then ( | state | { super :: hidden :: skip ( state ) } ) . and_then ( | state | { self :: closing_brace ( state ) } ) } ) } ) } # [ inline ] # [ allow ( non_snake_case , unused_variables ) ] pub fn repeat_max ( state : Box < :: pest :: ParserState < Rule >> ) -> :: pest :: ParseResult < Box < :: pest :: ParserState < Rule >> > { state . rule ( Rule :: repeat_max , | state | { state . sequence ( | state | { self :: opening_brace ( state ) . and_then ( | state | { super :: hidden :: skip ( state ) } ) . and_then ( | state | { self :: comma ( state ) } ) . and_then ( | state | { super :: hidden :: skip ( state ) } ) . and_then ( | state | { self :: number ( state ) } ) . and_then ( | state | { super :: hidden :: skip ( state ) } ) . and_then ( | state | { self :: closing_brace ( state ) } ) } ) } ) } # [ inline ] # [ allow ( non_snake_case , unused_variables ) ] pub fn repeat_min_max ( state : Box < :: pest :: ParserState < Rule >> ) -> :: pest :: ParseResult < Box < :: pest :: ParserState < Rule >> > { state . rule ( Rule :: repeat_min_max , | state | { state . sequence ( | state | { self :: opening_brace ( state ) . and_then ( | state | { super :: hidden :: skip ( state ) } ) . and_then ( | state | { self :: number ( state ) } ) . and_then ( | state | { super :: hidden :: skip ( state ) } ) . and_then ( | state | { self :: comma ( state ) } ) . and_then ( | state | { super :: hidden :: skip ( state ) } ) . and_then ( | state | { self :: number ( state ) } ) . and_then ( | state | { super :: hidden :: skip ( state ) } ) . and_then ( | state | { self :: closing_brace ( state ) } ) } ) } ) } # [ inline ] # [ allow ( non_snake_case , unused_variables ) ] pub fn number ( state : Box < :: pest :: ParserState < Rule >> ) -> :: pest :: ParseResult < Box < :: pest :: ParserState < Rule >> > { state . rule ( Rule :: number , | state | { state . atomic ( :: pest :: Atomicity :: Atomic , | state | { state . sequence ( | state | { state . match_range ( '0' .. '9' ) . and_then ( | state | { state . repeat ( | state | { state . match_range ( '0' .. '9' ) } ) } ) } ) } ) } ) } # [ inline ] # [ allow ( non_snake_case , unused_variables ) ] pub fn integer ( state : Box < :: pest :: ParserState < Rule >> ) -> :: pest :: ParseResult < Box < :: pest :: ParserState < Rule >> > { state . rule ( Rule :: integer , | state | { state . atomic ( :: pest :: Atomicity :: Atomic , | state | { self :: number ( state ) . or_else ( | state | { state . sequence ( | state | { state . match_string ( "-" ) . and_then ( | state | { state . repeat ( | state | { state . match_string ( "0" ) } ) } ) . and_then ( | state | { state . match_range ( '1' .. '9' ) } ) . and_then ( | state | { state . optional ( | state | { self :: number ( state ) } ) } ) } ) } ) } ) } ) } # [ inline ] # [ allow ( non_snake_case , unused_variables ) ] pub fn comma ( state : Box < :: pest :: ParserState < Rule >> ) -> :: pest :: ParseResult < Box < :: pest :: ParserState < Rule >> > { state . rule ( Rule :: comma , | state | { state . match_string ( "," ) } ) } # [ inline ] # [ allow ( non_snake_case , unused_variables ) ] pub fn _push ( state : Box < :: pest :: ParserState < Rule >> ) -> :: pest :: ParseResult < Box < :: pest :: ParserState < Rule >> > { state . rule ( Rule :: _push , | state | { state . sequence ( | state | { state . match_string ( "PUSH" ) . and_then ( | state | { super :: hidden :: skip ( state ) } ) . and_then ( | state | { self :: opening_paren ( state ) } ) . and_then ( | state | { super :: hidden :: skip ( state ) } ) . and_then ( | state | { self :: expression ( state ) } ) . and_then ( | state | { super :: hidden :: skip ( state ) } ) . and_then ( | state | { self :: closing_paren ( state ) } ) } ) } ) } # [ inline ] # [ allow ( non_snake_case , unused_variables ) ] pub fn peek_slice ( state : Box < :: pest :: ParserState < Rule >> ) -> :: pest :: ParseResult < Box < :: pest :: ParserState < Rule >> > { state . rule ( Rule :: peek_slice , | state | { state . sequence ( | state | { state . match_string ( "PEEK" ) . and_then ( | state | { super :: hidden :: skip ( state ) } ) . and_then ( | state | { self :: opening_brack ( state ) } ) . and_then ( | state | { super :: hidden :: skip ( state ) } ) . and_then ( | state | { state . optional ( | state | { self :: integer ( state ) } ) } ) . and_then ( | state | { super :: hidden :: skip ( state ) } ) . and_then ( | state | { self :: range_operator ( state ) } ) . and_then ( | state | { super :: hidden :: skip ( state ) } ) . and_then ( | state | { state . optional ( | state | { self :: integer ( state ) } ) } ) . and_then ( | state | { super :: hidden :: skip ( state ) } ) . and_then ( | state | { self :: closing_brack ( state ) } ) } ) } ) } # [ inline ] # [ allow ( non_snake_case , unused_variables ) ] pub fn identifier ( state : Box < :: pest :: ParserState < Rule >> ) -> :: pest :: ParseResult < Box < :: pest :: ParserState < Rule >> > { state . rule ( Rule :: identifier , | state | { state . atomic ( :: pest :: Atomicity :: Atomic , | state | { state . sequence ( | state | { state . lookahead ( false , | state | { state . match_string ( "PUSH" ) } ) . and_then ( | state | { state . match_string ( "_" ) . or_else ( | state | { self :: alpha ( state ) } ) } ) . and_then ( | state | { state . repeat ( | state | { state . match_string ( "_" ) . or_else ( | state | { self :: alpha_num ( state ) } ) } ) } ) } ) } ) } ) } # [ inline ] # [ allow ( non_snake_case , unused_variables ) ] pub fn alpha ( state : Box < :: pest :: ParserState < Rule >> ) -> :: pest :: ParseResult < Box < :: pest :: ParserState < Rule >> > { state . match_range ( 'a' .. 'z' ) . or_else ( | state | { state . match_range ( 'A' .. 'Z' ) } ) } # [ inline ] # [ allow ( non_snake_case , unused_variables ) ] pub fn alpha_num ( state : Box < :: pest :: ParserState < Rule >> ) -> :: pest :: ParseResult < Box < :: pest :: ParserState < Rule >> > { self :: alpha ( state ) . or_else ( | state | { state . match_range ( '0' .. '9' ) } ) } # [ inline ] # [ allow ( non_snake_case , unused_variables ) ] pub fn string ( state : Box < :: pest :: ParserState < Rule >> ) -> :: pest :: ParseResult < Box < :: pest :: ParserState < Rule >> > { state . atomic ( :: pest :: Atomicity :: CompoundAtomic , | state | { state . rule ( Rule :: string , | state | { state . sequence ( | state | { self :: quote ( state ) . and_then ( | state | { self :: inner_str ( state ) } ) . and_then ( | state | { self :: quote ( state ) } ) } ) } ) } ) } # [ inline ] # [ allow ( non_snake_case , unused_variables ) ] pub fn insensitive_string ( state : Box < :: pest :: ParserState < Rule >> ) -> :: pest :: ParseResult < Box < :: pest :: ParserState < Rule >> > { state . rule ( Rule :: insensitive_string , | state | { state . sequence ( | state | { state . match_string ( "^" ) . and_then ( | state | { super :: hidden :: skip ( state ) } ) . and_then ( | state | { self :: string ( state ) } ) } ) } ) } # [ inline ] # [ allow ( non_snake_case , unused_variables ) ] pub fn range ( state : Box < :: pest :: ParserState < Rule >> ) -> :: pest :: ParseResult < Box < :: pest :: ParserState < Rule >> > { state . rule ( Rule :: range , | state | { state . sequence ( | state | { self :: character ( state ) . and_then ( | state | { super :: hidden :: skip ( state ) } ) . and_then ( | state | { self :: range_operator ( state ) } ) . and_then ( | state | { super :: hidden :: skip ( state ) } ) . and_then ( | state | { self :: character ( state ) } ) } ) } ) } # [ inline ] # [ allow ( non_snake_case , unused_variables ) ] pub fn character ( state : Box < :: pest :: ParserState < Rule >> ) -> :: pest :: ParseResult < Box < :: pest :: ParserState < Rule >> > { state . atomic ( :: pest :: Atomicity :: CompoundAtomic , | state | { state . rule ( Rule :: character , | state | { state . sequence ( | state | { self :: single_quote ( state ) . and_then ( | state | { self :: inner_chr ( state ) } ) . and_then ( | state | { self :: single_quote ( state ) } ) } ) } ) } ) } # [ inline ] # [ allow ( non_snake_case , unused_variables ) ] pub fn inner_str ( state : Box < :: pest :: ParserState < Rule >> ) -> :: pest :: ParseResult < Box < :: pest :: ParserState < Rule >> > { state . rule ( Rule :: inner_str , | state | { state . atomic ( :: pest :: Atomicity :: Atomic , | state | { state . sequence ( | state | { let strings = [ "\"" , "\\" ] ; state . skip_until ( & strings ) . and_then ( | state | { state . optional ( | state | { state . sequence ( | state | { self :: escape ( state ) . and_then ( | state | { self :: inner_str ( state ) } ) } ) } ) } ) } ) } ) } ) } # [ inline ] # [ allow ( non_snake_case , unused_variables ) ] pub fn inner_chr ( state : Box < :: pest :: ParserState < Rule >> ) -> :: pest :: ParseResult < Box < :: pest :: ParserState < Rule >> > { state . rule ( Rule :: inner_chr , | state | { state . atomic ( :: pest :: Atomicity :: Atomic , | state | { self :: escape ( state ) . or_else ( | state | { self :: ANY ( state ) } ) } ) } ) } # [ inline ] # [ allow ( non_snake_case , unused_variables ) ] pub fn escape ( state : Box < :: pest :: ParserState < Rule >> ) -> :: pest :: ParseResult < Box < :: pest :: ParserState < Rule >> > { state . rule ( Rule :: escape , | state | { state . atomic ( :: pest :: Atomicity :: Atomic , | state | { state . sequence ( | state | { state . match_string ( "\\" ) . and_then ( | state | { state . match_string ( "\"" ) . or_else ( | state | { state . match_string ( "\\" ) } ) . or_else ( | state | { state . match_string ( "r" ) } ) . or_else ( | state | { state . match_string ( "n" ) } ) . or_else ( | state | { state . match_string ( "t" ) } ) . or_else ( | state | { state . match_string ( "0" ) } ) . or_else ( | state | { state . match_string ( "'" ) } ) . or_else ( | state | { self :: code ( state ) } ) . or_else ( | state | { self :: unicode ( state ) } ) } ) } ) } ) } ) } # [ inline ] # [ allow ( non_snake_case , unused_variables ) ] pub fn code ( state : Box < :: pest :: ParserState < Rule >> ) -> :: pest :: ParseResult < Box < :: pest :: ParserState < Rule >> > { state . rule ( Rule :: code , | state | { state . atomic ( :: pest :: Atomicity :: Atomic , | state | { state . sequence ( | state | { state . match_string ( "x" ) . and_then ( | state | { self :: hex_digit ( state ) } ) . and_then ( | state | { self :: hex_digit ( state ) } ) } ) } ) } ) } # [ inline ] # [ allow ( non_snake_case , unused_variables ) ] pub fn unicode ( state : Box < :: pest :: ParserState < Rule >> ) -> :: pest :: ParseResult < Box < :: pest :: ParserState < Rule >> > { state . rule ( Rule :: unicode , | state | { state . atomic ( :: pest :: Atomicity :: Atomic , | state | { state . sequence ( | state | { state . match_string ( "u" ) . and_then ( | state | { self :: opening_brace ( state ) } ) . and_then ( | state | { state . sequence ( | state | { self :: hex_digit ( state ) . and_then ( | state | { self :: hex_digit ( state ) } ) . and_then ( | state | { state . optional ( | state | { self :: hex_digit ( state ) } ) } ) . and_then ( | state | { state . optional ( | state | { self :: hex_digit ( state ) } ) } ) . and_then ( | state | { state . optional ( | state | { self :: hex_digit ( state ) } ) } ) . and_then ( | state | { state . optional ( | state | { self :: hex_digit ( state ) } ) } ) } ) } ) . and_then ( | state | { self :: closing_brace ( state ) } ) } ) } ) } ) } # [ inline ] # [ allow ( non_snake_case , unused_variables ) ] pub fn hex_digit ( state : Box < :: pest :: ParserState < Rule >> ) -> :: pest :: ParseResult < Box < :: pest :: ParserState < Rule >> > { state . rule ( Rule :: hex_digit , | state | { state . atomic ( :: pest :: Atomicity :: Atomic , | state | { state . match_range ( '0' .. '9' ) . or_else ( | state | { state . match_range ( 'a' .. 'f' ) } ) . or_else ( | state | { state . match_range ( 'A' .. 'F' ) } ) } ) } ) } # [ inline ] # [ allow ( non_snake_case , unused_variables ) ] pub fn quote ( state : Box < :: pest :: ParserState < Rule >> ) -> :: pest :: ParseResult < Box < :: pest :: ParserState < Rule >> > { state . rule ( Rule :: quote , | state | { state . match_string ( "\"" ) } ) } # [ inline ] # [ allow ( non_snake_case , unused_variables ) ] pub fn single_quote ( state : Box < :: pest :: ParserState < Rule >> ) -> :: pest :: ParseResult < Box < :: pest :: ParserState < Rule >> > { state . rule ( Rule :: single_quote , | state | { state . match_string ( "'" ) } ) } # [ inline ] # [ allow ( non_snake_case , unused_variables ) ] pub fn range_operator ( state : Box < :: pest :: ParserState < Rule >> ) -> :: pest :: ParseResult < Box < :: pest :: ParserState < Rule >> > { state . rule ( Rule :: range_operator , | state | { state . match_string ( ".." ) } ) } # [ inline ] # [ allow ( non_snake_case , unused_variables ) ] pub fn newline ( state : Box < :: pest :: ParserState < Rule >> ) -> :: pest :: ParseResult < Box < :: pest :: ParserState < Rule >> > { state . match_string ( "\n" ) . or_else ( | state | { state . match_string ( "\r\n" ) } ) } # [ inline ] # [ allow ( non_snake_case , unused_variables ) ] pub fn WHITESPACE ( state : Box < :: pest :: ParserState < Rule >> ) -> :: pest :: ParseResult < Box < :: pest :: ParserState < Rule >> > { state . atomic ( :: pest :: Atomicity :: Atomic , | state | { state . match_string ( " " ) . or_else ( | state | { state . match_string ( "\t" ) } ) . or_else ( | state | { self :: newline ( state ) } ) } ) } # [ inline ] # [ allow ( non_snake_case , unused_variables ) ] pub fn block_comment ( state : Box < :: pest :: ParserState < Rule >> ) -> :: pest :: ParseResult < Box < :: pest :: ParserState < Rule >> > { state . sequence ( | state | { state . match_string ( "/*" ) . and_then ( | state | { super :: hidden :: skip ( state ) } ) . and_then ( | state | { state . sequence ( | state | { state . optional ( | state | { self :: block_comment ( state ) . or_else ( | state | { state . sequence ( | state | { state . lookahead ( false , | state | { state . match_string ( "*/" ) } ) . and_then ( | state | { super :: hidden :: skip ( state ) } ) . and_then ( | state | { self :: ANY ( state ) } ) } ) } ) . and_then ( | state | { state . repeat ( | state | { state . sequence ( | state | { super :: hidden :: skip ( state ) . and_then ( | state | { self :: block_comment ( state ) . or_else ( | state | { state . sequence ( | state | { state . lookahead ( false , | state | { state . match_string ( "*/" ) } ) . and_then ( | state | { super :: hidden :: skip ( state ) } ) . and_then ( | state | { self :: ANY ( state ) } ) } ) } ) } ) } ) } ) } ) } ) } ) } ) . and_then ( | state | { super :: hidden :: skip ( state ) } ) . and_then ( | state | { state . match_string ( "*/" ) } ) } ) } # [ inline ] # [ allow ( non_snake_case , unused_variables ) ] pub fn COMMENT ( state : Box < :: pest :: ParserState < Rule >> ) -> :: pest :: ParseResult < Box < :: pest :: ParserState < Rule >> > { state . atomic ( :: pest :: Atomicity :: Atomic , | state | { self :: block_comment ( state ) . or_else ( | state | { state . sequence ( | state | { state . match_string ( "//" ) . and_then ( | state | { state . repeat ( | state | { state . sequence ( | state | { state . lookahead ( false , | state | { self :: newline ( state ) } ) . and_then ( | state | { self :: ANY ( state ) } ) } ) } ) } ) } ) } ) } ) } # [ inline ] # [ allow ( dead_code , non_snake_case , unused_variables ) ] pub fn SOI ( state : Box < :: pest :: ParserState < Rule >> ) -> :: pest :: ParseResult < Box < :: pest :: ParserState < Rule >> > { state . start_of_input ( ) } # [ inline ] # [ allow ( dead_code , non_snake_case , unused_variables ) ] pub fn ANY ( state : Box < :: pest :: ParserState < Rule >> ) -> :: pest :: ParseResult < Box < :: pest :: ParserState < Rule >> > { state . skip ( 1 ) } # [ inline ] # [ allow ( dead_code , non_snake_case , unused_variables ) ] pub fn EOI ( state : Box < :: pest :: ParserState < Rule >> ) -> :: pest :: ParseResult < Box < :: pest :: ParserState < Rule >> > { state . rule ( Rule :: EOI , | state | state . end_of_input ( ) ) } } pub use self :: visible :: * ; } :: pest :: state ( input , | state | { match rule { Rule :: grammar_rules => rules :: grammar_rules ( state ) , Rule :: grammar_rule => rules :: grammar_rule ( state ) , Rule :: assignment_operator => rules :: assignment_operator ( state ) , Rule :: opening_brace => rules :: opening_brace ( state ) , Rule :: closing_brace => rules :: closing_brace ( state ) , Rule :: opening_paren => rules :: opening_paren ( state ) , Rule :: closing_paren => rules :: closing_paren ( state ) , Rule :: opening_brack => rules :: opening_brack ( state ) , Rule :: closing_brack => rules :: closing_brack ( state ) , Rule :: modifier => rules :: modifier ( state ) , Rule :: silent_modifier => rules :: silent_modifier ( state ) , Rule :: atomic_modifier => rules :: atomic_modifier ( state ) , Rule :: compound_atomic_modifier => rules :: compound_atomic_modifier ( state ) , Rule :: non_atomic_modifier => rules :: non_atomic_modifier ( state ) , Rule :: expression => rules :: expression ( state ) , Rule :: term => rules :: term ( state ) , Rule :: node => rules :: node ( state ) , Rule :: terminal => rules :: terminal ( state ) , Rule :: prefix_operator => rules :: prefix_operator ( state ) , Rule :: infix_operator => rules :: infix_operator ( state ) , Rule :: postfix_operator => rules :: postfix_operator ( state ) , Rule :: positive_predicate_operator => rules :: positive_predicate_operator ( state ) , Rule :: negative_predicate_operator => rules :: negative_predicate_operator ( state ) , Rule :: sequence_operator => rules :: sequence_operator ( state ) , Rule :: choice_operator => rules :: choice_operator ( state ) , Rule :: optional_operator => rules :: optional_operator ( state ) , Rule :: repeat_operator => rules :: repeat_operator ( state ) , Rule :: repeat_once_operator => rules :: repeat_once_operator ( state ) , Rule :: repeat_exact => rules :: repeat_exact ( state ) , Rule :: repeat_min => rules :: repeat_min ( state ) , Rule :: repeat_max => rules :: repeat_max ( state ) , Rule :: repeat_min_max => rules :: repeat_min_max ( state ) , Rule :: number => rules :: number ( state ) , Rule :: integer => rules :: integer ( state ) , Rule :: comma => rules :: comma ( state ) , Rule :: _push => rules :: _push ( state ) , Rule :: peek_slice => rules :: peek_slice ( state ) , Rule :: identifier => rules :: identifier ( state ) , Rule :: alpha => rules :: alpha ( state ) , Rule :: alpha_num => rules :: alpha_num ( state ) , Rule :: string => rules :: string ( state ) , Rule :: insensitive_string => rules :: insensitive_string ( state ) , Rule :: range => rules :: range ( state ) , Rule :: character => rules :: character ( state ) , Rule :: inner_str => rules :: inner_str ( state ) , Rule :: inner_chr => rules :: inner_chr ( state ) , Rule :: escape => rules :: escape ( state ) , Rule :: code => rules :: code ( state ) , Rule :: unicode => rules :: unicode ( state ) , Rule :: hex_digit => rules :: hex_digit ( state ) , Rule :: quote => rules :: quote ( state ) , Rule :: single_quote => rules :: single_quote ( state ) , Rule :: range_operator => rules :: range_operator ( state ) , Rule :: newline => rules :: newline ( state ) , Rule :: WHITESPACE => rules :: WHITESPACE ( state ) , Rule :: block_comment => rules :: block_comment ( state ) , Rule :: COMMENT => rules :: COMMENT ( state ) , Rule :: EOI => rules :: EOI ( state ) } } ) } } +# [allow (dead_code , non_camel_case_types , clippy :: upper_case_acronyms)] # [derive (Clone , Copy , Debug , Eq , Hash , Ord , PartialEq , PartialOrd)] pub enum Rule { EOI , grammar_rules , grammar_rule , assignment_operator , opening_brace , closing_brace , opening_paren , closing_paren , opening_brack , closing_brack , modifier , silent_modifier , atomic_modifier , compound_atomic_modifier , non_atomic_modifier , expression , term , node , terminal , prefix_operator , infix_operator , postfix_operator , positive_predicate_operator , negative_predicate_operator , sequence_operator , choice_operator , optional_operator , repeat_operator , repeat_once_operator , repeat_exact , repeat_min , repeat_max , repeat_min_max , number , integer , comma , _push , peek_slice , identifier , alpha , alpha_num , string , insensitive_string , range , character , inner_str , inner_chr , escape , code , unicode , hex_digit , quote , single_quote , range_operator , newline , WHITESPACE , block_comment , COMMENT } # [allow (clippy :: all)] impl :: pest :: Parser < Rule > for PestParser { fn parse < 'i > (rule : Rule , input : & 'i str) -> :: std :: result :: Result < :: pest :: iterators :: Pairs < 'i , Rule > , :: pest :: error :: Error < Rule > > { mod rules { # ! [allow (clippy :: upper_case_acronyms)] pub mod hidden { use super :: super :: Rule ; # [inline] # [allow (dead_code , non_snake_case , unused_variables)] pub fn skip (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { if state . atomicity () == :: pest :: Atomicity :: NonAtomic { state . sequence (| state | { state . repeat (| state | super :: visible :: WHITESPACE (state)) . and_then (| state | { state . repeat (| state | { state . sequence (| state | { super :: visible :: COMMENT (state) . and_then (| state | { state . repeat (| state | super :: visible :: WHITESPACE (state)) }) }) }) }) }) } else { Ok (state) } } } pub mod visible { use super :: super :: Rule ; # [inline] # [allow (non_snake_case , unused_variables)] pub fn grammar_rules (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . sequence (| state | { self :: SOI (state) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { state . sequence (| state | { self :: grammar_rule (state) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { state . sequence (| state | { state . optional (| state | { self :: grammar_rule (state) . and_then (| state | { state . repeat (| state | { state . sequence (| state | { super :: hidden :: skip (state) . and_then (| state | { self :: grammar_rule (state) }) }) }) }) }) }) }) }) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: EOI (state) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn grammar_rule (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: grammar_rule , | state | { state . sequence (| state | { self :: identifier (state) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: assignment_operator (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { state . optional (| state | { self :: modifier (state) }) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: opening_brace (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: expression (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: closing_brace (state) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn assignment_operator (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: assignment_operator , | state | { state . match_string ("=") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn opening_brace (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: opening_brace , | state | { state . match_string ("{") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn closing_brace (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: closing_brace , | state | { state . match_string ("}") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn opening_paren (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: opening_paren , | state | { state . match_string ("(") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn closing_paren (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: closing_paren , | state | { state . match_string (")") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn opening_brack (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: opening_brack , | state | { state . match_string ("[") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn closing_brack (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: closing_brack , | state | { state . match_string ("]") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn modifier (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { self :: silent_modifier (state) . or_else (| state | { self :: atomic_modifier (state) }) . or_else (| state | { self :: compound_atomic_modifier (state) }) . or_else (| state | { self :: non_atomic_modifier (state) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn silent_modifier (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: silent_modifier , | state | { state . match_string ("_") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn atomic_modifier (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: atomic_modifier , | state | { state . match_string ("@") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn compound_atomic_modifier (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: compound_atomic_modifier , | state | { state . match_string ("$") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn non_atomic_modifier (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: non_atomic_modifier , | state | { state . match_string ("!") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn expression (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: expression , | state | { state . sequence (| state | { state . optional (| state | { self :: choice_operator (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: term (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { state . sequence (| state | { state . optional (| state | { state . sequence (| state | { self :: infix_operator (state) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: term (state) }) }) . and_then (| state | { state . repeat (| state | { state . sequence (| state | { super :: hidden :: skip (state) . and_then (| state | { state . sequence (| state | { self :: infix_operator (state) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: term (state) }) }) }) }) }) }) }) }) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn term (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: term , | state | { state . sequence (| state | { state . sequence (| state | { state . optional (| state | { self :: prefix_operator (state) . and_then (| state | { state . repeat (| state | { state . sequence (| state | { super :: hidden :: skip (state) . and_then (| state | { self :: prefix_operator (state) }) }) }) }) }) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: node (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { state . sequence (| state | { state . optional (| state | { self :: postfix_operator (state) . and_then (| state | { state . repeat (| state | { state . sequence (| state | { super :: hidden :: skip (state) . and_then (| state | { self :: postfix_operator (state) }) }) }) }) }) }) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn node (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . sequence (| state | { self :: opening_paren (state) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: expression (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: closing_paren (state) }) }) . or_else (| state | { self :: terminal (state) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn terminal (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { self :: _push (state) . or_else (| state | { self :: peek_slice (state) }) . or_else (| state | { self :: identifier (state) }) . or_else (| state | { self :: string (state) }) . or_else (| state | { self :: insensitive_string (state) }) . or_else (| state | { self :: range (state) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn prefix_operator (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { self :: positive_predicate_operator (state) . or_else (| state | { self :: negative_predicate_operator (state) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn infix_operator (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { self :: sequence_operator (state) . or_else (| state | { self :: choice_operator (state) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn postfix_operator (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { self :: optional_operator (state) . or_else (| state | { self :: repeat_operator (state) }) . or_else (| state | { self :: repeat_once_operator (state) }) . or_else (| state | { self :: repeat_exact (state) }) . or_else (| state | { self :: repeat_min (state) }) . or_else (| state | { self :: repeat_max (state) }) . or_else (| state | { self :: repeat_min_max (state) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn positive_predicate_operator (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: positive_predicate_operator , | state | { state . match_string ("&") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn negative_predicate_operator (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: negative_predicate_operator , | state | { state . match_string ("!") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn sequence_operator (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: sequence_operator , | state | { state . match_string ("~") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn choice_operator (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: choice_operator , | state | { state . match_string ("|") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn optional_operator (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: optional_operator , | state | { state . match_string ("?") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn repeat_operator (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: repeat_operator , | state | { state . match_string ("*") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn repeat_once_operator (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: repeat_once_operator , | state | { state . match_string ("+") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn repeat_exact (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: repeat_exact , | state | { state . sequence (| state | { self :: opening_brace (state) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: number (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: closing_brace (state) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn repeat_min (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: repeat_min , | state | { state . sequence (| state | { self :: opening_brace (state) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: number (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: comma (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: closing_brace (state) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn repeat_max (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: repeat_max , | state | { state . sequence (| state | { self :: opening_brace (state) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: comma (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: number (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: closing_brace (state) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn repeat_min_max (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: repeat_min_max , | state | { state . sequence (| state | { self :: opening_brace (state) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: number (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: comma (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: number (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: closing_brace (state) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn number (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: number , | state | { state . atomic (:: pest :: Atomicity :: Atomic , | state | { state . sequence (| state | { state . match_range ('0' .. '9') . and_then (| state | { state . repeat (| state | { state . match_range ('0' .. '9') }) }) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn integer (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: integer , | state | { state . atomic (:: pest :: Atomicity :: Atomic , | state | { self :: number (state) . or_else (| state | { state . sequence (| state | { state . match_string ("-") . and_then (| state | { state . repeat (| state | { state . match_string ("0") }) }) . and_then (| state | { state . match_range ('1' .. '9') }) . and_then (| state | { state . optional (| state | { self :: number (state) }) }) }) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn comma (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: comma , | state | { state . match_string (",") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn _push (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: _push , | state | { state . sequence (| state | { state . match_string ("PUSH") . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: opening_paren (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: expression (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: closing_paren (state) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn peek_slice (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: peek_slice , | state | { state . sequence (| state | { state . match_string ("PEEK") . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: opening_brack (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { state . optional (| state | { self :: integer (state) }) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: range_operator (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { state . optional (| state | { self :: integer (state) }) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: closing_brack (state) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn identifier (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: identifier , | state | { state . atomic (:: pest :: Atomicity :: Atomic , | state | { state . sequence (| state | { state . lookahead (false , | state | { state . match_string ("PUSH") }) . and_then (| state | { state . match_string ("_") . or_else (| state | { self :: alpha (state) }) }) . and_then (| state | { state . repeat (| state | { state . match_string ("_") . or_else (| state | { self :: alpha_num (state) }) }) }) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn alpha (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . match_range ('a' .. 'z') . or_else (| state | { state . match_range ('A' .. 'Z') }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn alpha_num (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { self :: alpha (state) . or_else (| state | { state . match_range ('0' .. '9') }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn string (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . atomic (:: pest :: Atomicity :: CompoundAtomic , | state | { state . rule (Rule :: string , | state | { state . sequence (| state | { self :: quote (state) . and_then (| state | { self :: inner_str (state) }) . and_then (| state | { self :: quote (state) }) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn insensitive_string (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: insensitive_string , | state | { state . sequence (| state | { state . match_string ("^") . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: string (state) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn range (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: range , | state | { state . sequence (| state | { self :: character (state) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: range_operator (state) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: character (state) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn character (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . atomic (:: pest :: Atomicity :: CompoundAtomic , | state | { state . rule (Rule :: character , | state | { state . sequence (| state | { self :: single_quote (state) . and_then (| state | { self :: inner_chr (state) }) . and_then (| state | { self :: single_quote (state) }) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn inner_str (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: inner_str , | state | { state . atomic (:: pest :: Atomicity :: Atomic , | state | { state . sequence (| state | { let strings = ["\"" , "\\"] ; state . skip_until (& strings) . and_then (| state | { state . optional (| state | { state . sequence (| state | { self :: escape (state) . and_then (| state | { self :: inner_str (state) }) }) }) }) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn inner_chr (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: inner_chr , | state | { state . atomic (:: pest :: Atomicity :: Atomic , | state | { self :: escape (state) . or_else (| state | { self :: ANY (state) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn escape (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: escape , | state | { state . atomic (:: pest :: Atomicity :: Atomic , | state | { state . sequence (| state | { state . match_string ("\\") . and_then (| state | { state . match_string ("\"") . or_else (| state | { state . match_string ("\\") }) . or_else (| state | { state . match_string ("r") }) . or_else (| state | { state . match_string ("n") }) . or_else (| state | { state . match_string ("t") }) . or_else (| state | { state . match_string ("0") }) . or_else (| state | { state . match_string ("'") }) . or_else (| state | { self :: code (state) }) . or_else (| state | { self :: unicode (state) }) }) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn code (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: code , | state | { state . atomic (:: pest :: Atomicity :: Atomic , | state | { state . sequence (| state | { state . match_string ("x") . and_then (| state | { self :: hex_digit (state) }) . and_then (| state | { self :: hex_digit (state) }) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn unicode (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: unicode , | state | { state . atomic (:: pest :: Atomicity :: Atomic , | state | { state . sequence (| state | { state . match_string ("u") . and_then (| state | { self :: opening_brace (state) }) . and_then (| state | { state . sequence (| state | { self :: hex_digit (state) . and_then (| state | { self :: hex_digit (state) }) . and_then (| state | { state . optional (| state | { self :: hex_digit (state) }) }) . and_then (| state | { state . optional (| state | { self :: hex_digit (state) }) }) . and_then (| state | { state . optional (| state | { self :: hex_digit (state) }) }) . and_then (| state | { state . optional (| state | { self :: hex_digit (state) }) }) }) }) . and_then (| state | { self :: closing_brace (state) }) }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn hex_digit (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: hex_digit , | state | { state . atomic (:: pest :: Atomicity :: Atomic , | state | { state . match_range ('0' .. '9') . or_else (| state | { state . match_range ('a' .. 'f') }) . or_else (| state | { state . match_range ('A' .. 'F') }) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn quote (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: quote , | state | { state . match_string ("\"") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn single_quote (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: single_quote , | state | { state . match_string ("'") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn range_operator (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: range_operator , | state | { state . match_string ("..") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn newline (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . match_string ("\n") . or_else (| state | { state . match_string ("\r\n") }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn WHITESPACE (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . atomic (:: pest :: Atomicity :: Atomic , | state | { state . match_string (" ") . or_else (| state | { state . match_string ("\t") }) . or_else (| state | { self :: newline (state) }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn block_comment (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . sequence (| state | { state . match_string ("/*") . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { state . sequence (| state | { state . optional (| state | { self :: block_comment (state) . or_else (| state | { state . sequence (| state | { state . lookahead (false , | state | { state . match_string ("*/") }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: ANY (state) }) }) }) . and_then (| state | { state . repeat (| state | { state . sequence (| state | { super :: hidden :: skip (state) . and_then (| state | { self :: block_comment (state) . or_else (| state | { state . sequence (| state | { state . lookahead (false , | state | { state . match_string ("*/") }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { self :: ANY (state) }) }) }) }) }) }) }) }) }) }) . and_then (| state | { super :: hidden :: skip (state) }) . and_then (| state | { state . match_string ("*/") }) }) } # [inline] # [allow (non_snake_case , unused_variables)] pub fn COMMENT (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . atomic (:: pest :: Atomicity :: Atomic , | state | { self :: block_comment (state) . or_else (| state | { state . sequence (| state | { state . match_string ("//") . and_then (| state | { state . repeat (| state | { state . sequence (| state | { state . lookahead (false , | state | { self :: newline (state) }) . and_then (| state | { self :: ANY (state) }) }) }) }) }) }) }) } # [inline] # [allow (dead_code , non_snake_case , unused_variables)] pub fn ANY (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . skip (1) } # [inline] # [allow (dead_code , non_snake_case , unused_variables)] pub fn EOI (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . rule (Rule :: EOI , | state | state . end_of_input ()) } # [inline] # [allow (dead_code , non_snake_case , unused_variables)] pub fn SOI (state : :: std :: boxed :: Box < :: pest :: ParserState < Rule >>) -> :: pest :: ParseResult < :: std :: boxed :: Box < :: pest :: ParserState < Rule >> > { state . start_of_input () } } pub use self :: visible :: * ; } :: pest :: state (input , | state | { match rule { Rule :: grammar_rules => rules :: grammar_rules (state) , Rule :: grammar_rule => rules :: grammar_rule (state) , Rule :: assignment_operator => rules :: assignment_operator (state) , Rule :: opening_brace => rules :: opening_brace (state) , Rule :: closing_brace => rules :: closing_brace (state) , Rule :: opening_paren => rules :: opening_paren (state) , Rule :: closing_paren => rules :: closing_paren (state) , Rule :: opening_brack => rules :: opening_brack (state) , Rule :: closing_brack => rules :: closing_brack (state) , Rule :: modifier => rules :: modifier (state) , Rule :: silent_modifier => rules :: silent_modifier (state) , Rule :: atomic_modifier => rules :: atomic_modifier (state) , Rule :: compound_atomic_modifier => rules :: compound_atomic_modifier (state) , Rule :: non_atomic_modifier => rules :: non_atomic_modifier (state) , Rule :: expression => rules :: expression (state) , Rule :: term => rules :: term (state) , Rule :: node => rules :: node (state) , Rule :: terminal => rules :: terminal (state) , Rule :: prefix_operator => rules :: prefix_operator (state) , Rule :: infix_operator => rules :: infix_operator (state) , Rule :: postfix_operator => rules :: postfix_operator (state) , Rule :: positive_predicate_operator => rules :: positive_predicate_operator (state) , Rule :: negative_predicate_operator => rules :: negative_predicate_operator (state) , Rule :: sequence_operator => rules :: sequence_operator (state) , Rule :: choice_operator => rules :: choice_operator (state) , Rule :: optional_operator => rules :: optional_operator (state) , Rule :: repeat_operator => rules :: repeat_operator (state) , Rule :: repeat_once_operator => rules :: repeat_once_operator (state) , Rule :: repeat_exact => rules :: repeat_exact (state) , Rule :: repeat_min => rules :: repeat_min (state) , Rule :: repeat_max => rules :: repeat_max (state) , Rule :: repeat_min_max => rules :: repeat_min_max (state) , Rule :: number => rules :: number (state) , Rule :: integer => rules :: integer (state) , Rule :: comma => rules :: comma (state) , Rule :: _push => rules :: _push (state) , Rule :: peek_slice => rules :: peek_slice (state) , Rule :: identifier => rules :: identifier (state) , Rule :: alpha => rules :: alpha (state) , Rule :: alpha_num => rules :: alpha_num (state) , Rule :: string => rules :: string (state) , Rule :: insensitive_string => rules :: insensitive_string (state) , Rule :: range => rules :: range (state) , Rule :: character => rules :: character (state) , Rule :: inner_str => rules :: inner_str (state) , Rule :: inner_chr => rules :: inner_chr (state) , Rule :: escape => rules :: escape (state) , Rule :: code => rules :: code (state) , Rule :: unicode => rules :: unicode (state) , Rule :: hex_digit => rules :: hex_digit (state) , Rule :: quote => rules :: quote (state) , Rule :: single_quote => rules :: single_quote (state) , Rule :: range_operator => rules :: range_operator (state) , Rule :: newline => rules :: newline (state) , Rule :: WHITESPACE => rules :: WHITESPACE (state) , Rule :: block_comment => rules :: block_comment (state) , Rule :: COMMENT => rules :: COMMENT (state) , Rule :: EOI => rules :: EOI (state) } }) } } diff --git a/vendor/pest_meta/src/lib.rs b/vendor/pest_meta/src/lib.rs index 1f9c5bcb6..4e178be6f 100644 --- a/vendor/pest_meta/src/lib.rs +++ b/vendor/pest_meta/src/lib.rs @@ -7,9 +7,7 @@ // option. All files in the project carrying such notice may not be copied, // modified, or distributed except according to those terms. -#![allow(clippy::range_plus_one)] - -extern crate maplit; +extern crate once_cell; #[cfg(test)] #[macro_use] extern crate pest; @@ -30,18 +28,19 @@ where { result.unwrap_or_else(|e| { panic!( - "grammar error\n\n".to_owned() - + &e.into_iter() - .map(|error| format!("{}", error)) - .collect::>() - .join("\n\n") + "grammar error\n\n{}", + &e.into_iter() + .map(|error| format!("{}", error)) + .collect::>() + .join("\n\n") ) }) } #[doc(hidden)] pub static UNICODE_PROPERTY_NAMES: &[&str] = &[ - /* BINARY */ "ALPHABETIC", + /* BINARY */ + "ALPHABETIC", "BIDI_CONTROL", "CASE_IGNORABLE", "CASED", @@ -93,7 +92,8 @@ pub static UNICODE_PROPERTY_NAMES: &[&str] = &[ "WHITE_SPACE", "XID_CONTINUE", "XID_START", - /* CATEGORY */ "CASED_LETTER", + /* CATEGORY */ + "CASED_LETTER", "CLOSE_PUNCTUATION", "CONNECTOR_PUNCTUATION", "CONTROL", diff --git a/vendor/pest_meta/src/optimizer/concatenator.rs b/vendor/pest_meta/src/optimizer/concatenator.rs index e0aab7bc1..31d3aa531 100644 --- a/vendor/pest_meta/src/optimizer/concatenator.rs +++ b/vendor/pest_meta/src/optimizer/concatenator.rs @@ -7,28 +7,27 @@ // option. All files in the project carrying such notice may not be copied, // modified, or distributed except according to those terms. -use ast::*; +use crate::ast::*; pub fn concatenate(rule: Rule) -> Rule { - match rule { - Rule { name, ty, expr } => Rule { - name, - 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), - (Expr::Insens(lhs), Expr::Insens(rhs)) => Expr::Insens(lhs + &rhs), - (lhs, rhs) => Expr::Seq(Box::new(lhs), Box::new(rhs)), - }, - expr => expr, - } - } else { - expr + let Rule { name, ty, expr } = rule; + Rule { + name, + 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), + (Expr::Insens(lhs), Expr::Insens(rhs)) => Expr::Insens(lhs + &rhs), + (lhs, rhs) => Expr::Seq(Box::new(lhs), Box::new(rhs)), + }, + expr => expr, } - }), - }, + } else { + expr + } + }), } } diff --git a/vendor/pest_meta/src/optimizer/factorizer.rs b/vendor/pest_meta/src/optimizer/factorizer.rs index 236289e14..5481870bf 100644 --- a/vendor/pest_meta/src/optimizer/factorizer.rs +++ b/vendor/pest_meta/src/optimizer/factorizer.rs @@ -7,32 +7,45 @@ // option. All files in the project carrying such notice may not be copied, // modified, or distributed except according to those terms. -use ast::*; +use crate::ast::*; pub fn factor(rule: Rule) -> Rule { - match rule { - Rule { name, ty, expr } => 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)) => { - if l1 == l2 { - Expr::Seq(l1, Box::new(Expr::Choice(r1, r2))) - } else { - Expr::Choice( - Box::new(Expr::Seq(l1, r1)), - Box::new(Expr::Seq(l2, r2)), - ) - } + let Rule { name, ty, expr } = 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)) => { + if l1 == l2 { + Expr::Seq(l1, Box::new(Expr::Choice(r1, r2))) + } else { + Expr::Choice(Box::new(Expr::Seq(l1, r1)), Box::new(Expr::Seq(l2, r2))) } - (lhs, rhs) => Expr::Choice(Box::new(lhs), Box::new(rhs)), - }, - expr => expr, - } - }), - }, + } + // Converts `(rule ~ rest) | rule` to `rule ~ rest?`, avoiding trying to match `rule` twice. + (Expr::Seq(l1, l2), r) => { + if *l1 == r { + Expr::Seq(l1, Box::new(Expr::Opt(l2))) + } else { + Expr::Choice(Box::new(Expr::Seq(l1, l2)), Box::new(r)) + } + } + // Converts `rule | (rule ~ rest)` to `rule` since `(rule ~ rest)` + // will never match if `rule` didn't. + (l, Expr::Seq(r1, r2)) => { + if l == *r1 { + l + } else { + Expr::Choice(Box::new(l), Box::new(Expr::Seq(r1, r2))) + } + } + (lhs, rhs) => Expr::Choice(Box::new(lhs), Box::new(rhs)), + }, + expr => expr, + } + }), } } diff --git a/vendor/pest_meta/src/optimizer/lister.rs b/vendor/pest_meta/src/optimizer/lister.rs new file mode 100644 index 000000000..e19885032 --- /dev/null +++ b/vendor/pest_meta/src/optimizer/lister.rs @@ -0,0 +1,42 @@ +// pest. The Elegant Parser +// Copyright (c) 2018 DragoČ™ Tiselice +// +// Licensed under the Apache License, Version 2.0 +// or the MIT +// license , at your +// option. All files in the project carrying such notice may not be copied, +// modified, or distributed except according to those terms. + +use crate::ast::*; + +pub fn list(rule: Rule) -> Rule { + let Rule { name, ty, expr } = 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) => { + let l = *l; + match l { + Expr::Seq(l1, l2) => { + // Converts `(rule ~ rest)* ~ rule` to `rule ~ (rest ~ rule)*`, + // avoiding matching the last `rule` twice. + if l1 == r { + Expr::Seq(l1, Box::new(Expr::Rep(Box::new(Expr::Seq(l2, r))))) + } else { + Expr::Seq(Box::new(Expr::Rep(Box::new(Expr::Seq(l1, l2)))), r) + } + } + expr => Expr::Seq(Box::new(Expr::Rep(Box::new(expr))), r), + } + } + expr => Expr::Seq(Box::new(expr), r), + }, + expr => expr, + } + }), + } +} diff --git a/vendor/pest_meta/src/optimizer/mod.rs b/vendor/pest_meta/src/optimizer/mod.rs index 7013c43f9..e0cbdb0de 100644 --- a/vendor/pest_meta/src/optimizer/mod.rs +++ b/vendor/pest_meta/src/optimizer/mod.rs @@ -7,7 +7,7 @@ // option. All files in the project carrying such notice may not be copied, // modified, or distributed except according to those terms. -use ast::*; +use crate::ast::*; use std::collections::HashMap; #[cfg(test)] @@ -20,6 +20,7 @@ macro_rules! box_tree { mod concatenator; mod factorizer; +mod lister; mod restorer; mod rotater; mod skipper; @@ -33,6 +34,7 @@ pub fn optimize(rules: Vec) -> Vec { .map(unroller::unroll) .map(concatenator::concatenate) .map(factorizer::factor) + .map(lister::list) .map(rule_to_optimized_rule) .collect(); @@ -279,7 +281,7 @@ mod tests { #[test] fn rotate() { let rules = { - use ast::Expr::*; + use crate::ast::Expr::*; vec![Rule { name: "rule".to_owned(), ty: RuleType::Normal, @@ -293,7 +295,7 @@ mod tests { }] }; let rotated = { - use optimizer::OptimizedExpr::*; + use crate::optimizer::OptimizedExpr::*; vec![OptimizedRule { name: "rule".to_owned(), ty: RuleType::Normal, @@ -313,7 +315,7 @@ mod tests { #[test] fn skip() { let rules = { - use ast::Expr::*; + use crate::ast::Expr::*; vec![Rule { name: "rule".to_owned(), ty: RuleType::Atomic, @@ -335,7 +337,7 @@ mod tests { #[test] fn concat_strings() { let rules = { - use ast::Expr::*; + use crate::ast::Expr::*; vec![Rule { name: "rule".to_owned(), ty: RuleType::Atomic, @@ -362,7 +364,7 @@ mod tests { expr: Expr::RepExact(Box::new(Expr::Ident(String::from("a"))), 3), }]; let unrolled = { - use optimizer::OptimizedExpr::*; + use crate::optimizer::OptimizedExpr::*; vec![OptimizedRule { name: "rule".to_owned(), ty: RuleType::Atomic, @@ -384,7 +386,7 @@ mod tests { expr: Expr::RepMax(Box::new(Expr::Str("a".to_owned())), 3), }]; let unrolled = { - use optimizer::OptimizedExpr::*; + use crate::optimizer::OptimizedExpr::*; vec![OptimizedRule { name: "rule".to_owned(), ty: RuleType::Atomic, @@ -406,7 +408,7 @@ mod tests { expr: Expr::RepMin(Box::new(Expr::Str("a".to_owned())), 2), }]; let unrolled = { - use optimizer::OptimizedExpr::*; + use crate::optimizer::OptimizedExpr::*; vec![OptimizedRule { name: "rule".to_owned(), ty: RuleType::Atomic, @@ -428,7 +430,7 @@ mod tests { expr: Expr::RepMinMax(Box::new(Expr::Str("a".to_owned())), 2, 3), }]; let unrolled = { - use optimizer::OptimizedExpr::*; + use crate::optimizer::OptimizedExpr::*; vec![OptimizedRule { name: "rule".to_owned(), ty: RuleType::Atomic, @@ -452,7 +454,7 @@ mod tests { #[test] fn concat_insensitive_strings() { let rules = { - use ast::Expr::*; + use crate::ast::Expr::*; vec![Rule { name: "rule".to_owned(), ty: RuleType::Atomic, @@ -474,7 +476,7 @@ mod tests { #[test] fn long_common_sequence() { let rules = { - use ast::Expr::*; + use crate::ast::Expr::*; vec![Rule { name: "rule".to_owned(), ty: RuleType::Silent, @@ -491,7 +493,7 @@ mod tests { }] }; let optimized = { - use optimizer::OptimizedExpr::*; + use crate::optimizer::OptimizedExpr::*; vec![OptimizedRule { name: "rule".to_owned(), ty: RuleType::Silent, @@ -507,4 +509,82 @@ mod tests { assert_eq!(optimize(rules), optimized); } + + #[test] + fn short_common_sequence() { + let rules = { + use crate::ast::Expr::*; + vec![Rule { + name: "rule".to_owned(), + ty: RuleType::Silent, + expr: box_tree!(Choice( + Seq(Ident(String::from("a")), Ident(String::from("b"))), + Ident(String::from("a")) + )), + }] + }; + let optimized = { + use crate::optimizer::OptimizedExpr::*; + vec![OptimizedRule { + name: "rule".to_owned(), + ty: RuleType::Silent, + expr: box_tree!(Seq(Ident(String::from("a")), Opt(Ident(String::from("b"))))), + }] + }; + + assert_eq!(optimize(rules), optimized); + } + + #[test] + fn impossible_common_sequence() { + let rules = { + use crate::ast::Expr::*; + vec![Rule { + name: "rule".to_owned(), + ty: RuleType::Silent, + expr: box_tree!(Choice( + Ident(String::from("a")), + Seq(Ident(String::from("a")), Ident(String::from("b"))) + )), + }] + }; + let optimized = { + use crate::optimizer::OptimizedExpr::*; + vec![OptimizedRule { + name: "rule".to_owned(), + ty: RuleType::Silent, + expr: box_tree!(Ident(String::from("a"))), + }] + }; + + assert_eq!(optimize(rules), optimized); + } + + #[test] + fn lister() { + let rules = { + use crate::ast::Expr::*; + vec![Rule { + name: "rule".to_owned(), + ty: RuleType::Silent, + expr: box_tree!(Seq( + Rep(Seq(Ident(String::from("a")), Ident(String::from("b")))), + Ident(String::from("a")) + )), + }] + }; + let optimized = { + use crate::optimizer::OptimizedExpr::*; + vec![OptimizedRule { + name: "rule".to_owned(), + ty: RuleType::Silent, + expr: box_tree!(Seq( + Ident(String::from("a")), + Rep(Seq(Ident(String::from("b")), Ident(String::from("a")))) + )), + }] + }; + + assert_eq!(optimize(rules), optimized); + } } diff --git a/vendor/pest_meta/src/optimizer/restorer.rs b/vendor/pest_meta/src/optimizer/restorer.rs index 34a710eab..e128e03f1 100644 --- a/vendor/pest_meta/src/optimizer/restorer.rs +++ b/vendor/pest_meta/src/optimizer/restorer.rs @@ -8,19 +8,15 @@ // modified, or distributed except according to those terms. use std::collections::HashMap; -use optimizer::*; +use crate::optimizer::*; pub fn restore_on_err( rule: OptimizedRule, rules: &HashMap, ) -> OptimizedRule { - match rule { - OptimizedRule { name, ty, expr } => { - let expr = expr.map_bottom_up(|expr| wrap_branching_exprs(expr, rules)); - - OptimizedRule { name, ty, expr } - } - } + let OptimizedRule { name, ty, expr } = rule; + let expr = expr.map_bottom_up(|expr| wrap_branching_exprs(expr, rules)); + OptimizedRule { name, ty, expr } } fn wrap_branching_exprs( @@ -96,7 +92,7 @@ fn child_modifies_state( #[cfg(test)] mod tests { use super::*; - use optimizer::OptimizedExpr::*; + use crate::optimizer::OptimizedExpr::*; #[test] fn restore_no_stack_children() { diff --git a/vendor/pest_meta/src/optimizer/rotater.rs b/vendor/pest_meta/src/optimizer/rotater.rs index 3588738ad..7a7d8fba4 100644 --- a/vendor/pest_meta/src/optimizer/rotater.rs +++ b/vendor/pest_meta/src/optimizer/rotater.rs @@ -7,7 +7,7 @@ // option. All files in the project carrying such notice may not be copied, // modified, or distributed except according to those terms. -use ast::*; +use crate::ast::*; pub fn rotate(rule: Rule) -> Rule { fn rotate_internal(expr: Expr) -> Expr { @@ -35,11 +35,10 @@ pub fn rotate(rule: Rule) -> Rule { } } - match rule { - Rule { name, ty, expr } => Rule { - name, - ty, - expr: expr.map_top_down(rotate_internal), - }, + let Rule { name, ty, expr } = rule; + Rule { + name, + ty, + expr: expr.map_top_down(rotate_internal), } } diff --git a/vendor/pest_meta/src/optimizer/skipper.rs b/vendor/pest_meta/src/optimizer/skipper.rs index f55edc06f..40bc5a16f 100644 --- a/vendor/pest_meta/src/optimizer/skipper.rs +++ b/vendor/pest_meta/src/optimizer/skipper.rs @@ -7,7 +7,7 @@ // option. All files in the project carrying such notice may not be copied, // modified, or distributed except according to those terms. -use ast::*; +use crate::ast::*; pub fn skip(rule: Rule) -> Rule { fn populate_choices(expr: Expr, mut choices: Vec) -> Option { @@ -28,30 +28,29 @@ pub fn skip(rule: Rule) -> Rule { } } - match rule { - Rule { name, ty, expr } => Rule { - name, - 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.clone() { - if let (Expr::NegPred(expr), Expr::Ident(ident)) = (*lhs, *rhs) { - if ident == "ANY" { - if let Some(expr) = populate_choices(*expr, vec![]) { - return expr; - } + let Rule { name, ty, expr } = rule; + Rule { + name, + 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) { + if ident == "ANY" { + if let Some(expr) = populate_choices(*expr, vec![]) { + return expr; } } } - }; + } + }; - expr - }) - } else { expr - }, + }) + } else { + expr }, } } diff --git a/vendor/pest_meta/src/optimizer/unroller.rs b/vendor/pest_meta/src/optimizer/unroller.rs index fff17336d..e3c360d90 100644 --- a/vendor/pest_meta/src/optimizer/unroller.rs +++ b/vendor/pest_meta/src/optimizer/unroller.rs @@ -7,61 +7,60 @@ // option. All files in the project carrying such notice may not be copied, // modified, or distributed except according to those terms. -use ast::*; +use crate::ast::*; pub fn unroll(rule: Rule) -> Rule { - match rule { - Rule { name, ty, expr } => Rule { - name, - ty, - expr: expr.map_bottom_up(|expr| match expr { - Expr::RepOnce(expr) => Expr::Seq(expr.clone(), Box::new(Expr::Rep(expr))), - Expr::RepExact(expr, num) => (1..num + 1) - .map(|_| *expr.clone()) - .rev() - .fold(None, |rep, expr| match rep { - None => Some(expr), - Some(rep) => Some(Expr::Seq(Box::new(expr), Box::new(rep))), - }) - .unwrap(), - Expr::RepMin(expr, min) => (1..min + 2) - .map(|i| { - if i <= min { - *expr.clone() - } else { - Expr::Rep(expr.clone()) - } - }) - .rev() - .fold(None, |rep, expr| match rep { - None => Some(expr), - Some(rep) => Some(Expr::Seq(Box::new(expr), Box::new(rep))), - }) - .unwrap(), - Expr::RepMax(expr, max) => (1..max + 1) - .map(|_| Expr::Opt(expr.clone())) - .rev() - .fold(None, |rep, expr| match rep { - None => Some(expr), - Some(rep) => Some(Expr::Seq(Box::new(expr), Box::new(rep))), - }) - .unwrap(), - Expr::RepMinMax(expr, min, max) => (1..max + 1) - .map(|i| { - if i <= min { - *expr.clone() - } else { - Expr::Opt(expr.clone()) - } - }) - .rev() - .fold(None, |rep, expr| match rep { - None => Some(expr), - Some(rep) => Some(Expr::Seq(Box::new(expr), Box::new(rep))), - }) - .unwrap(), - expr => expr, - }), - }, + let Rule { name, ty, expr } = rule; + Rule { + name, + ty, + expr: expr.map_bottom_up(|expr| match expr { + Expr::RepOnce(expr) => Expr::Seq(expr.clone(), Box::new(Expr::Rep(expr))), + Expr::RepExact(expr, num) => (1..num + 1) + .map(|_| *expr.clone()) + .rev() + .fold(None, |rep, expr| match rep { + None => Some(expr), + Some(rep) => Some(Expr::Seq(Box::new(expr), Box::new(rep))), + }) + .unwrap(), + Expr::RepMin(expr, min) => (1..min + 2) + .map(|i| { + if i <= min { + *expr.clone() + } else { + Expr::Rep(expr.clone()) + } + }) + .rev() + .fold(None, |rep, expr| match rep { + None => Some(expr), + Some(rep) => Some(Expr::Seq(Box::new(expr), Box::new(rep))), + }) + .unwrap(), + Expr::RepMax(expr, max) => (1..max + 1) + .map(|_| Expr::Opt(expr.clone())) + .rev() + .fold(None, |rep, expr| match rep { + None => Some(expr), + Some(rep) => Some(Expr::Seq(Box::new(expr), Box::new(rep))), + }) + .unwrap(), + Expr::RepMinMax(expr, min, max) => (1..max + 1) + .map(|i| { + if i <= min { + *expr.clone() + } else { + Expr::Opt(expr.clone()) + } + }) + .rev() + .fold(None, |rep, expr| match rep { + None => Some(expr), + Some(rep) => Some(Expr::Seq(Box::new(expr), Box::new(rep))), + }) + .unwrap(), + expr => expr, + }), } } diff --git a/vendor/pest_meta/src/parser.rs b/vendor/pest_meta/src/parser.rs index 5f6f3b374..72abd810d 100644 --- a/vendor/pest_meta/src/parser.rs +++ b/vendor/pest_meta/src/parser.rs @@ -15,10 +15,14 @@ use pest::iterators::{Pair, Pairs}; use pest::prec_climber::{Assoc, Operator, PrecClimber}; use pest::{Parser, Span}; -use ast::{Expr, Rule as AstRule, RuleType}; -use validator; +use crate::ast::{Expr, Rule as AstRule, RuleType}; +use crate::validator; -include!("grammar.rs"); +mod grammar { + include!("grammar.rs"); +} + +pub use self::grammar::*; pub fn parse(rule: Rule, data: &str) -> Result, Error> { PestParser::parse(rule, data) @@ -125,13 +129,9 @@ pub enum ParserExpr<'i> { } fn convert_rule(rule: ParserRule) -> AstRule { - match rule { - ParserRule { name, ty, node, .. } => { - let expr = convert_node(node); - - AstRule { name, ty, expr } - } - } + let ParserRule { name, ty, node, .. } = rule; + let expr = convert_node(node); + AstRule { name, ty, expr } } fn convert_node(node: ParserNode) -> Expr { @@ -174,9 +174,7 @@ pub fn consume_rules(pairs: Pairs) -> Result, Vec } } -fn consume_rules_with_spans<'i>( - pairs: Pairs<'i, Rule>, -) -> Result>, Vec>> { +fn consume_rules_with_spans(pairs: Pairs) -> Result, Vec>> { let climber = PrecClimber::new(vec![ Operator::new(Rule::choice_operator, Assoc::Left), Operator::new(Rule::sequence_operator, Assoc::Left), @@ -206,7 +204,13 @@ fn consume_rules_with_spans<'i>( pairs.next().unwrap(); // opening_brace - let node = consume_expr(pairs.next().unwrap().into_inner().peekable(), &climber)?; + // skip initial infix operators + let mut inner_nodes = pairs.next().unwrap().into_inner().peekable(); + if inner_nodes.peek().unwrap().as_rule() == Rule::choice_operator { + inner_nodes.next().unwrap(); + } + + let node = consume_expr(inner_nodes, &climber)?; Ok(ParserRule { name, @@ -617,6 +621,8 @@ fn unescape(string: &str) -> Option { #[cfg(test)] mod tests { + use std::convert::TryInto; + use super::super::unwrap_or_report; use super::*; @@ -1073,7 +1079,7 @@ mod tests { parser: PestParser, input: "a = {}", rule: Rule::grammar_rules, - positives: vec![Rule::term], + positives: vec![Rule::expression], negatives: vec![], pos: 5 }; @@ -1091,6 +1097,18 @@ mod tests { }; } + #[test] + fn incorrect_prefix() { + fails_with! { + parser: PestParser, + input: "a = { ~ b}", + rule: Rule::grammar_rules, + positives: vec![Rule::expression], + negatives: vec![], + pos: 6 + }; + } + #[test] fn wrong_op() { fails_with! { @@ -1228,7 +1246,7 @@ mod tests { let pairs = PestParser::parse(Rule::grammar_rules, input).unwrap(); let ast = consume_rules_with_spans(pairs).unwrap(); - let ast: Vec<_> = ast.into_iter().map(|rule| convert_rule(rule)).collect(); + let ast: Vec<_> = ast.into_iter().map(convert_rule).collect(); assert_eq!( ast, @@ -1266,7 +1284,7 @@ mod tests { let pairs = PestParser::parse(Rule::grammar_rules, input).unwrap(); let ast = consume_rules_with_spans(pairs).unwrap(); - let ast: Vec<_> = ast.into_iter().map(|rule| convert_rule(rule)).collect(); + let ast: Vec<_> = ast.into_iter().map(convert_rule).collect(); assert_eq!( ast, @@ -1485,4 +1503,45 @@ mod tests { assert_eq!(unescape(string), None); } + + #[test] + fn handles_deep_nesting() { + let sample1 = include_str!(concat!( + env!("CARGO_MANIFEST_DIR"), + "/resources/test/fuzzsample1.grammar" + )); + let sample2 = include_str!(concat!( + env!("CARGO_MANIFEST_DIR"), + "/resources/test/fuzzsample2.grammar" + )); + let sample3 = include_str!(concat!( + env!("CARGO_MANIFEST_DIR"), + "/resources/test/fuzzsample3.grammar" + )); + let sample4 = include_str!(concat!( + env!("CARGO_MANIFEST_DIR"), + "/resources/test/fuzzsample4.grammar" + )); + let sample5 = include_str!(concat!( + env!("CARGO_MANIFEST_DIR"), + "/resources/test/fuzzsample5.grammar" + )); + const ERROR: &str = "call limit reached"; + pest::set_call_limit(Some(5_000usize.try_into().unwrap())); + let s1 = crate::parser::parse(crate::parser::Rule::grammar_rules, sample1); + assert!(s1.is_err()); + assert_eq!(s1.unwrap_err().variant.message(), ERROR); + let s2 = crate::parser::parse(crate::parser::Rule::grammar_rules, sample2); + assert!(s2.is_err()); + assert_eq!(s2.unwrap_err().variant.message(), ERROR); + let s3 = crate::parser::parse(crate::parser::Rule::grammar_rules, sample3); + assert!(s3.is_err()); + assert_eq!(s3.unwrap_err().variant.message(), ERROR); + let s4 = crate::parser::parse(crate::parser::Rule::grammar_rules, sample4); + assert!(s4.is_err()); + assert_eq!(s4.unwrap_err().variant.message(), ERROR); + let s5 = crate::parser::parse(crate::parser::Rule::grammar_rules, sample5); + assert!(s5.is_err()); + assert_eq!(s5.unwrap_err().variant.message(), ERROR); + } } diff --git a/vendor/pest_meta/src/validator.rs b/vendor/pest_meta/src/validator.rs index a358dbeec..5448c3bcd 100644 --- a/vendor/pest_meta/src/validator.rs +++ b/vendor/pest_meta/src/validator.rs @@ -7,105 +7,67 @@ // option. All files in the project carrying such notice may not be copied, // modified, or distributed except according to those terms. +use once_cell::sync::Lazy; use std::collections::{HashMap, HashSet}; use pest::error::{Error, ErrorVariant, InputLocation}; use pest::iterators::Pairs; use pest::Span; -use parser::{ParserExpr, ParserNode, ParserRule, Rule}; -use UNICODE_PROPERTY_NAMES; - -#[allow(clippy::needless_pass_by_value)] -pub fn validate_pairs<'i>(pairs: Pairs<'i, Rule>) -> Result, Vec>> { - let mut rust_keywords = HashSet::new(); - rust_keywords.insert("abstract"); - rust_keywords.insert("alignof"); - rust_keywords.insert("as"); - rust_keywords.insert("become"); - rust_keywords.insert("box"); - rust_keywords.insert("break"); - rust_keywords.insert("const"); - rust_keywords.insert("continue"); - rust_keywords.insert("crate"); - rust_keywords.insert("do"); - rust_keywords.insert("else"); - rust_keywords.insert("enum"); - rust_keywords.insert("extern"); - rust_keywords.insert("false"); - rust_keywords.insert("final"); - rust_keywords.insert("fn"); - rust_keywords.insert("for"); - rust_keywords.insert("if"); - rust_keywords.insert("impl"); - rust_keywords.insert("in"); - rust_keywords.insert("let"); - rust_keywords.insert("loop"); - rust_keywords.insert("macro"); - rust_keywords.insert("match"); - rust_keywords.insert("mod"); - rust_keywords.insert("move"); - rust_keywords.insert("mut"); - rust_keywords.insert("offsetof"); - rust_keywords.insert("override"); - rust_keywords.insert("priv"); - rust_keywords.insert("proc"); - rust_keywords.insert("pure"); - rust_keywords.insert("pub"); - rust_keywords.insert("ref"); - rust_keywords.insert("return"); - rust_keywords.insert("Self"); - rust_keywords.insert("self"); - rust_keywords.insert("sizeof"); - rust_keywords.insert("static"); - rust_keywords.insert("struct"); - rust_keywords.insert("super"); - rust_keywords.insert("trait"); - rust_keywords.insert("true"); - rust_keywords.insert("type"); - rust_keywords.insert("typeof"); - rust_keywords.insert("unsafe"); - rust_keywords.insert("unsized"); - rust_keywords.insert("use"); - rust_keywords.insert("virtual"); - rust_keywords.insert("where"); - rust_keywords.insert("while"); - rust_keywords.insert("yield"); - - let mut pest_keywords = HashSet::new(); - pest_keywords.insert("_"); - pest_keywords.insert("ANY"); - pest_keywords.insert("DROP"); - pest_keywords.insert("EOI"); - pest_keywords.insert("PEEK"); - pest_keywords.insert("PEEK_ALL"); - pest_keywords.insert("POP"); - pest_keywords.insert("POP_ALL"); - pest_keywords.insert("PUSH"); - pest_keywords.insert("SOI"); - - let mut builtins = HashSet::new(); - builtins.insert("ANY"); - builtins.insert("DROP"); - builtins.insert("EOI"); - builtins.insert("PEEK"); - builtins.insert("PEEK_ALL"); - builtins.insert("POP"); - builtins.insert("POP_ALL"); - builtins.insert("SOI"); - builtins.insert("ASCII_DIGIT"); - builtins.insert("ASCII_NONZERO_DIGIT"); - builtins.insert("ASCII_BIN_DIGIT"); - builtins.insert("ASCII_OCT_DIGIT"); - builtins.insert("ASCII_HEX_DIGIT"); - builtins.insert("ASCII_ALPHA_LOWER"); - builtins.insert("ASCII_ALPHA_UPPER"); - builtins.insert("ASCII_ALPHA"); - builtins.insert("ASCII_ALPHANUMERIC"); - builtins.insert("ASCII"); - builtins.insert("NEWLINE"); - builtins.extend(UNICODE_PROPERTY_NAMES); - +use crate::parser::{ParserExpr, ParserNode, ParserRule, Rule}; +use crate::UNICODE_PROPERTY_NAMES; + +static RUST_KEYWORDS: Lazy> = Lazy::new(|| { + [ + "abstract", "alignof", "as", "become", "box", "break", "const", "continue", "crate", "do", + "else", "enum", "extern", "false", "final", "fn", "for", "if", "impl", "in", "let", "loop", + "macro", "match", "mod", "move", "mut", "offsetof", "override", "priv", "proc", "pure", + "pub", "ref", "return", "Self", "self", "sizeof", "static", "struct", "super", "trait", + "true", "type", "typeof", "unsafe", "unsized", "use", "virtual", "where", "while", "yield", + ] + .iter() + .cloned() + .collect() +}); + +static PEST_KEYWORDS: Lazy> = Lazy::new(|| { + [ + "_", "ANY", "DROP", "EOI", "PEEK", "PEEK_ALL", "POP", "POP_ALL", "PUSH", "SOI", + ] + .iter() + .cloned() + .collect() +}); + +static BUILTINS: Lazy> = Lazy::new(|| { + [ + "ANY", + "DROP", + "EOI", + "PEEK", + "PEEK_ALL", + "POP", + "POP_ALL", + "SOI", + "ASCII_DIGIT", + "ASCII_NONZERO_DIGIT", + "ASCII_BIN_DIGIT", + "ASCII_OCT_DIGIT", + "ASCII_HEX_DIGIT", + "ASCII_ALPHA_LOWER", + "ASCII_ALPHA_UPPER", + "ASCII_ALPHA", + "ASCII_ALPHANUMERIC", + "ASCII", + "NEWLINE", + ] + .iter() + .cloned() + .chain(UNICODE_PROPERTY_NAMES.iter().cloned()) + .collect::>() +}); + +pub fn validate_pairs(pairs: Pairs) -> Result, Vec>> { let definitions: Vec<_> = pairs .clone() .filter(|pair| pair.as_rule() == Rule::grammar_rule) @@ -125,10 +87,10 @@ pub fn validate_pairs<'i>(pairs: Pairs<'i, Rule>) -> Result, Vec(pairs: Pairs<'i, Rule>) -> Result, Vec( - definitions: &Vec>, - rust_keywords: &HashSet<&str>, -) -> Vec> { +#[allow(clippy::ptr_arg)] +pub fn validate_rust_keywords(definitions: &Vec) -> Vec> { let mut errors = vec![]; for definition in definitions { let name = definition.as_str(); - if rust_keywords.contains(name) { + if RUST_KEYWORDS.contains(name) { errors.push(Error::new_from_span( ErrorVariant::CustomError { message: format!("{} is a rust keyword", name), }, - definition.clone(), + *definition, )) } } @@ -165,22 +124,19 @@ pub fn validate_rust_keywords<'i>( errors } -#[allow(clippy::implicit_hasher, clippy::ptr_arg)] -pub fn validate_pest_keywords<'i>( - definitions: &Vec>, - pest_keywords: &HashSet<&str>, -) -> Vec> { +#[allow(clippy::ptr_arg)] +pub fn validate_pest_keywords(definitions: &Vec) -> Vec> { let mut errors = vec![]; for definition in definitions { let name = definition.as_str(); - if pest_keywords.contains(name) { + if PEST_KEYWORDS.contains(name) { errors.push(Error::new_from_span( ErrorVariant::CustomError { message: format!("{} is a pest keyword", name), }, - definition.clone(), + *definition, )) } } @@ -189,7 +145,7 @@ pub fn validate_pest_keywords<'i>( } #[allow(clippy::ptr_arg)] -pub fn validate_already_defined<'i>(definitions: &Vec>) -> Vec> { +pub fn validate_already_defined(definitions: &Vec) -> Vec> { let mut errors = vec![]; let mut defined = HashSet::new(); @@ -201,7 +157,7 @@ pub fn validate_already_defined<'i>(definitions: &Vec>) -> Vec(definitions: &Vec>) -> Vec( definitions: &Vec>, called_rules: &Vec>, - builtins: &HashSet<&str>, ) -> Vec> { let mut errors = vec![]; let definitions: HashSet<_> = definitions.iter().map(|span| span.as_str()).collect(); @@ -223,12 +178,12 @@ pub fn validate_undefined<'i>( for rule in called_rules { let name = rule.as_str(); - if !definitions.contains(name) && !builtins.contains(name) { + if !definitions.contains(name) && !BUILTINS.contains(name) { errors.push(Error::new_from_span( ErrorVariant::CustomError { message: format!("rule {} is undefined", name), }, - rule.clone(), + *rule, )) } } @@ -259,7 +214,7 @@ fn is_non_progressing<'i>( trace: &mut Vec, ) -> bool { match *expr { - ParserExpr::Str(ref string) => string == "", + ParserExpr::Str(ref string) => string.is_empty(), ParserExpr::Ident(ref ident) => { if ident == "soi" || ident == "eoi" { return true; @@ -297,7 +252,7 @@ fn is_non_failing<'i>( trace: &mut Vec, ) -> bool { match *expr { - ParserExpr::Str(ref string) => string == "", + ParserExpr::Str(ref string) => string.is_empty(), ParserExpr::Ident(ref ident) => { if !trace.contains(ident) { if let Some(node) = rules.get(ident) { @@ -342,7 +297,7 @@ fn validate_repetition<'a, 'i: 'a>(rules: &'a [ParserRule<'i>]) -> Vec(rules: &'a [ParserRule<'i>]) -> Vec(rules: &'a [ParserRule<'i>]) -> Vec> "expression cannot fail; following choices cannot be reached" .to_owned(), }, - node.span.clone(), + node.span, )) } else { None @@ -419,7 +374,7 @@ fn validate_whitespace_comment<'a, 'i: 'a>(rules: &'a [ParserRule<'i>]) -> Vec(rules: &'a [ParserRule<'i>]) -> Vec(rules: &'a [ParserRule<'i>]) -> HashMap(rules: HashMap>) -> Vec> { fn check_expr<'a, 'i: 'a>( node: &'a ParserNode<'i>, @@ -475,7 +429,7 @@ fn left_recursion<'a, 'i: 'a>(rules: HashMap>) -> Vec chain ) }, - node.span.clone() + node.span )); } @@ -499,22 +453,22 @@ fn left_recursion<'a, 'i: 'a>(rules: HashMap>) -> Vec } } ParserExpr::Choice(ref lhs, ref rhs) => { - check_expr(&lhs, rules, trace).or_else(|| check_expr(&rhs, rules, trace)) + check_expr(lhs, rules, trace).or_else(|| check_expr(rhs, rules, trace)) } - ParserExpr::Rep(ref node) => check_expr(&node, rules, trace), - ParserExpr::RepOnce(ref node) => check_expr(&node, rules, trace), - ParserExpr::Opt(ref node) => check_expr(&node, rules, trace), - ParserExpr::PosPred(ref node) => check_expr(&node, rules, trace), - ParserExpr::NegPred(ref node) => check_expr(&node, rules, trace), - ParserExpr::Push(ref node) => check_expr(&node, rules, trace), + ParserExpr::Rep(ref node) => check_expr(node, rules, trace), + ParserExpr::RepOnce(ref node) => check_expr(node, rules, trace), + ParserExpr::Opt(ref node) => check_expr(node, rules, trace), + ParserExpr::PosPred(ref node) => check_expr(node, rules, trace), + ParserExpr::NegPred(ref node) => check_expr(node, rules, trace), + ParserExpr::Push(ref node) => check_expr(node, rules, trace), _ => None, } } let mut errors = vec![]; - for (ref name, ref node) in &rules { - let name = (*name).clone(); + for (name, node) in &rules { + let name = name.clone(); if let Some(error) = check_expr(node, &rules, &mut vec![name]) { errors.push(error); -- cgit v1.2.3