From 4f7a3687feed6f867f7729da324e31aaea5e56ed Mon Sep 17 00:00:00 2001 From: Waleed Khan Date: Mon, 25 Jul 2022 20:04:24 -0700 Subject: [PATCH] build(revset): build parser as part of `build.rs` Usually, I avoid using `build.rs` since it potentially makes the build slower and harder to analyze statically. But I've forgotten to manually run `lalrpop` enough that it's easier to add the generation to the build script. --- .editorconfig | 2 +- Cargo.lock | 146 ++ git-branchless/Cargo.toml | 3 + git-branchless/build.rs | 3 + git-branchless/src/revset/grammar.rs | 2625 -------------------------- git-branchless/src/revset/mod.rs | 11 +- git-branchless/src/revset/parser.rs | 8 +- 7 files changed, 161 insertions(+), 2637 deletions(-) create mode 100644 git-branchless/build.rs delete mode 100644 git-branchless/src/revset/grammar.rs diff --git a/.editorconfig b/.editorconfig index bf1ef9cc2..3b3287037 100644 --- a/.editorconfig +++ b/.editorconfig @@ -4,6 +4,6 @@ root = true end_of_line = lf trim_trailing_whitespace = true -[*.rs] +[*.{rs,lalrpop}] indent_style = space indent_size = 4 diff --git a/Cargo.lock b/Cargo.lock index cfb80bec1..68a18354a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -58,6 +58,15 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" +[[package]] +name = "ascii-canvas" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8824ecca2e851cec16968d54a01dd372ef8f95b244fb84b84e70128be347c3c6" +dependencies = [ + "term", +] + [[package]] name = "assert_cmd" version = "2.0.4" @@ -116,6 +125,21 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3a8241f3ebb85c056b509d4327ad0358fbbba6ffb340bf388f26350aeda225b1" +[[package]] +name = "bit-set" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0700ddab506f33b20a03b13996eccd309a48e5ff77d0d95926aa0210fb4e95f1" +dependencies = [ + "bit-vec", +] + +[[package]] +name = "bit-vec" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" + [[package]] name = "bitflags" version = "1.3.2" @@ -486,6 +510,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" + [[package]] name = "csv" version = "1.1.6" @@ -676,6 +706,12 @@ dependencies = [ "zeroize", ] +[[package]] +name = "diff" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8" + [[package]] name = "difflib" version = "0.4.0" @@ -721,6 +757,15 @@ version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f107b87b6afc2a64fd13cac55fe06d6c8859f12d4b14cbcdd2c67d0976781be" +[[package]] +name = "ena" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7402b94a93c24e742487327a7cd839dc9d36fec9de9fb25b09f2dae459f36c3" +dependencies = [ + "log", +] + [[package]] name = "encode_unicode" version = "0.3.6" @@ -889,6 +934,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "fixedbitset" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" + [[package]] name = "fnv" version = "1.0.7" @@ -978,6 +1029,7 @@ dependencies = [ "git-record", "insta", "itertools 0.10.3", + "lalrpop", "lalrpop-util", "lazy_static", "man", @@ -1259,6 +1311,29 @@ version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "078e285eafdfb6c4b434e0d31e8cfcb5115b651496faca5749b88fafd4f23bfd" +[[package]] +name = "lalrpop" +version = "0.19.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b30455341b0e18f276fa64540aff54deafb54c589de6aca68659c63dd2d5d823" +dependencies = [ + "ascii-canvas", + "atty", + "bit-set", + "diff", + "ena", + "itertools 0.10.3", + "lalrpop-util", + "petgraph", + "pico-args", + "regex", + "regex-syntax", + "string_cache", + "term", + "tiny-keccak", + "unicode-xid", +] + [[package]] name = "lalrpop-util" version = "0.19.8" @@ -1425,6 +1500,12 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "new_debug_unreachable" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54" + [[package]] name = "nix" version = "0.19.1" @@ -1672,6 +1753,31 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" +[[package]] +name = "petgraph" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5014253a1331579ce62aa67443b4a658c5e7dd03d4bc6d302b94474888143" +dependencies = [ + "fixedbitset", + "indexmap", +] + +[[package]] +name = "phf_shared" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6796ad771acdc0123d2a88dc428b5e38ef24456743ddb1744ed628f9815c096" +dependencies = [ + "siphasher", +] + +[[package]] +name = "pico-args" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db8bcd96cb740d03149cbad5518db9fd87126a10ab519c011893b1754134c468" + [[package]] name = "pin-project-lite" version = "0.2.9" @@ -1736,6 +1842,12 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" +[[package]] +name = "precomputed-hash" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" + [[package]] name = "predicates" version = "2.1.1" @@ -2264,6 +2376,12 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2e24979f63a11545f5f2c60141afe249d4f19f84581ea2138065e400941d83d3" +[[package]] +name = "siphasher" +version = "0.3.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de" + [[package]] name = "skim" version = "0.9.4" @@ -2384,6 +2502,19 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "213701ba3370744dcd1a12960caa4843b3d68b4d1c0a5d575e0d65b2ee9d16c0" +[[package]] +name = "string_cache" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "213494b7a2b503146286049378ce02b482200519accc31872ee8be91fa820a08" +dependencies = [ + "new_debug_unreachable", + "once_cell", + "parking_lot 0.12.1", + "phf_shared", + "precomputed-hash", +] + [[package]] name = "strsim" version = "0.8.0" @@ -2600,6 +2731,15 @@ dependencies = [ "chrono", ] +[[package]] +name = "tiny-keccak" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" +dependencies = [ + "crunchy", +] + [[package]] name = "tinytemplate" version = "1.2.1" @@ -2776,6 +2916,12 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" +[[package]] +name = "unicode-xid" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "957e51f3646910546462e67d5f7599b9e4fb8acdd304b087a6494730f9eebf04" + [[package]] name = "url" version = "2.2.2" diff --git a/git-branchless/Cargo.toml b/git-branchless/Cargo.toml index e7a1d8b04..2dd8fbc67 100644 --- a/git-branchless/Cargo.toml +++ b/git-branchless/Cargo.toml @@ -57,6 +57,9 @@ insta = "1.16.0" portable-pty = "0.7.0" vt100 = "0.15.1" +[build-dependencies] +lalrpop = "0.19.8" + [package.metadata.release] pre-release-replacements = [ { file = "../CHANGELOG.md", search = "Unreleased", replace = "{{version}}", min = 1 }, diff --git a/git-branchless/build.rs b/git-branchless/build.rs new file mode 100644 index 000000000..ca5c2836d --- /dev/null +++ b/git-branchless/build.rs @@ -0,0 +1,3 @@ +fn main() { + lalrpop::process_root().unwrap(); +} diff --git a/git-branchless/src/revset/grammar.rs b/git-branchless/src/revset/grammar.rs deleted file mode 100644 index 760bb3410..000000000 --- a/git-branchless/src/revset/grammar.rs +++ /dev/null @@ -1,2625 +0,0 @@ -// auto-generated: "lalrpop 0.19.8" -// sha3: e4697a13cd51d01c3f8513c46ecd4c697164148fc6db6c2ec19f26b577ecd66e -use super::ast::Expr; -#[allow(unused_extern_crates)] -extern crate lalrpop_util as __lalrpop_util; -#[allow(unused_imports)] -use self::__lalrpop_util::state_machine as __state_machine; -extern crate core; -extern crate alloc; - -#[cfg_attr(rustfmt, rustfmt_skip)] -mod __parse__Expr { - #![allow(non_snake_case, non_camel_case_types, unused_mut, unused_variables, unused_imports, unused_parens, clippy::all)] - - use super::super::ast::Expr; - #[allow(unused_extern_crates)] - extern crate lalrpop_util as __lalrpop_util; - #[allow(unused_imports)] - use self::__lalrpop_util::state_machine as __state_machine; - extern crate core; - extern crate alloc; - use self::__lalrpop_util::lexer::Token; - #[allow(dead_code)] - pub(crate) enum __Symbol<'input> - { - Variant0(&'input str), - Variant1(&'static str), - Variant2(alloc::vec::Vec<&'static str>), - Variant3((Expr, &'input str)), - Variant4(alloc::vec::Vec<(Expr, &'input str)>), - Variant5(Expr), - Variant6(core::option::Option), - Variant7(String), - } - const __ACTION: &[i8] = &[ - // State 0 - 0, 0, 7, 0, 0, 0, 0, 0, 0, 22, 0, 0, 0, 0, 23, 24, - // State 1 - 0, 0, 7, 0, 0, 0, 0, 0, 0, 22, 0, 0, 0, 0, 23, 24, - // State 2 - -32, -32, 0, -32, -32, -32, -32, -32, -32, 28, 29, -32, -32, -32, 0, 0, - // State 3 - -39, -39, 0, -39, -39, -39, -39, 30, 31, 0, 0, -39, -39, -39, 0, 0, - // State 4 - 32, 33, 0, -41, -41, -41, 34, 0, 0, 0, 0, 35, -41, -41, 0, 0, - // State 5 - 0, 0, 0, -25, 36, -25, 0, 0, 0, 0, 0, 0, 37, 38, 0, 0, - // State 6 - 0, 0, 7, 0, 0, 0, 0, 0, 0, 22, 0, 0, 0, 0, 23, 24, - // State 7 - -33, -33, 0, -33, -33, -33, -33, -33, -33, 28, 29, -33, -33, -33, 0, 0, - // State 8 - 0, 0, 7, 0, 0, 0, 0, 0, 0, 22, 0, 0, 0, 0, 23, 24, - // State 9 - 0, 0, 7, 0, 0, 0, 0, 0, 0, 22, 0, 0, 0, 0, 23, 24, - // State 10 - 0, 0, 7, 0, 0, 0, 0, 0, 0, 22, 0, 0, 0, 0, 23, 24, - // State 11 - 0, 0, 7, 43, 0, 0, 0, 0, 0, 22, 0, 0, 0, 0, 23, 24, - // State 12 - -38, -38, 0, -38, -38, -38, -38, 30, 31, 0, 0, -38, -38, -38, 0, 0, - // State 13 - 32, 33, 0, -40, -40, -40, 34, 0, 0, 0, 0, 35, -40, -40, 0, 0, - // State 14 - 0, 0, 7, 46, 0, 0, 0, 0, 0, 22, 0, 0, 0, 0, 23, 24, - // State 15 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - // State 16 - -34, -34, 0, -34, -34, -34, -34, -34, -34, 0, 0, -34, -34, -34, 0, 0, - // State 17 - -37, -37, 0, -37, -37, -37, -37, -37, -37, 0, 0, -37, -37, -37, 0, 0, - // State 18 - 0, 0, -9, 0, 0, 0, 0, 0, 0, -9, 0, 0, 0, 0, -9, -9, - // State 19 - -48, -48, 12, -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, -48, 0, 0, - // State 20 - -26, -26, 0, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, 0, 0, - // State 21 - 0, 0, -46, 0, 0, 0, 0, 0, 0, -46, 0, 0, 0, 0, -46, -46, - // State 22 - -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, 0, 0, - // State 23 - -49, -49, 0, -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, 0, 0, - // State 24 - -35, -35, 0, -35, -35, -35, -35, -35, -35, 0, 0, -35, -35, -35, 0, 0, - // State 25 - 0, 0, -10, 0, 0, 0, 0, 0, 0, -10, 0, 0, 0, 0, -10, -10, - // State 26 - -4, -4, 0, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, 0, 0, - // State 27 - -44, -44, 0, -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, 0, 0, - // State 28 - -45, -45, 0, -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, 0, 0, - // State 29 - 0, 0, -17, 0, 0, 0, 0, 0, 0, -17, 0, 0, 0, 0, -17, -17, - // State 30 - 0, 0, -16, 0, 0, 0, 0, 0, 0, -16, 0, 0, 0, 0, -16, -16, - // State 31 - 0, 0, -21, 0, 0, 0, 0, 0, 0, -21, 0, 0, 0, 0, -21, -21, - // State 32 - 0, 0, -18, 0, 0, 0, 0, 0, 0, -18, 0, 0, 0, 0, -18, -18, - // State 33 - 0, 0, -20, 0, 0, 0, 0, 0, 0, -20, 0, 0, 0, 0, -20, -20, - // State 34 - 0, 0, -19, 0, 0, 0, 0, 0, 0, -19, 0, 0, 0, 0, -19, -19, - // State 35 - 0, 0, -23, 0, 0, 0, 0, 0, 0, -23, 0, 0, 0, 0, -23, -23, - // State 36 - 0, 0, -24, 0, 0, 0, 0, 0, 0, -24, 0, 0, 0, 0, -24, -24, - // State 37 - 0, 0, -22, 0, 0, 0, 0, 0, 0, -22, 0, 0, 0, 0, -22, -22, - // State 38 - 0, 0, 0, 44, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - // State 39 - -5, -5, 0, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, 0, 0, - // State 40 - -36, -36, 0, -36, -36, -36, -36, -36, -36, 0, 0, -36, -36, -36, 0, 0, - // State 41 - 0, 0, 0, 47, 0, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - // State 42 - -28, -28, 0, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, 0, 0, - // State 43 - -31, -31, 0, -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, 0, 0, - // State 44 - 0, 0, 0, 49, 0, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - // State 45 - -30, -30, 0, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, 0, 0, - // State 46 - -27, -27, 0, -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, 0, 0, - // State 47 - 0, 0, -14, -14, 0, 0, 0, 0, 0, -14, 0, 0, 0, 0, -14, -14, - // State 48 - -29, -29, 0, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, 0, 0, - // State 49 - 0, 0, -15, -15, 0, 0, 0, 0, 0, -15, 0, 0, 0, 0, -15, -15, - ]; - fn __action(state: i8, integer: usize) -> i8 { - __ACTION[(state as usize) * 16 + integer] - } - const __EOF_ACTION: &[i8] = &[ - // State 0 - 0, - // State 1 - 0, - // State 2 - -32, - // State 3 - -39, - // State 4 - -41, - // State 5 - -25, - // State 6 - 0, - // State 7 - -33, - // State 8 - 0, - // State 9 - 0, - // State 10 - 0, - // State 11 - 0, - // State 12 - -38, - // State 13 - -40, - // State 14 - 0, - // State 15 - -50, - // State 16 - -34, - // State 17 - -37, - // State 18 - 0, - // State 19 - -48, - // State 20 - -26, - // State 21 - 0, - // State 22 - -47, - // State 23 - -49, - // State 24 - -35, - // State 25 - 0, - // State 26 - -4, - // State 27 - -44, - // State 28 - -45, - // State 29 - 0, - // State 30 - 0, - // State 31 - 0, - // State 32 - 0, - // State 33 - 0, - // State 34 - 0, - // State 35 - 0, - // State 36 - 0, - // State 37 - 0, - // State 38 - 0, - // State 39 - -5, - // State 40 - -36, - // State 41 - 0, - // State 42 - -28, - // State 43 - -31, - // State 44 - 0, - // State 45 - -30, - // State 46 - -27, - // State 47 - 0, - // State 48 - -29, - // State 49 - 0, - ]; - fn __goto(state: i8, nt: usize) -> i8 { - match nt { - 2 => 7, - 5 => 1, - 8 => 14, - 9 => 8, - 10 => 9, - 11 => 10, - 12 => match state { - 6 => 38, - 11 => 41, - 14 => 44, - _ => 15, - }, - 13 => 2, - 14 => match state { - 1 => 24, - _ => 16, - }, - 15 => match state { - 8 => 40, - _ => 17, - }, - 16 => match state { - 9 => 12, - _ => 3, - }, - 17 => match state { - 10 => 13, - _ => 4, - }, - 18 => 5, - 20 => match state { - 7 => 39, - _ => 26, - }, - 21 => match state { - 1 => 25, - _ => 18, - }, - 22 => 19, - 23 => 20, - _ => 0, - } - } - fn __expected_tokens(__state: i8) -> alloc::vec::Vec { - const __TERMINAL: &[&str] = &[ - r###""%""###, - r###""&""###, - r###""(""###, - r###"")""###, - r###""+""###, - r###"",""###, - r###""-""###, - r###""..""###, - r###"":""###, - r###""::""###, - r###""^""###, - r###""and""###, - r###""or""###, - r###""|""###, - r###"r#"[a-zA-Z0-9/_$@.-]+"#"###, - r###"r#"\\x22([^\\x22\\x5c]|\\x5c.)*\\x22"#"###, - ]; - __TERMINAL.iter().enumerate().filter_map(|(index, terminal)| { - let next_state = __action(__state, index); - if next_state == 0 { - None - } else { - Some(alloc::string::ToString::to_string(terminal)) - } - }).collect() - } - pub(crate) struct __StateMachine<'input> - where - { - input: &'input str, - __phantom: core::marker::PhantomData<(&'input ())>, - } - impl<'input> __state_machine::ParserDefinition for __StateMachine<'input> - where - { - type Location = usize; - type Error = &'static str; - type Token = Token<'input>; - type TokenIndex = usize; - type Symbol = __Symbol<'input>; - type Success = Expr; - type StateIndex = i8; - type Action = i8; - type ReduceIndex = i8; - type NonterminalIndex = usize; - - #[inline] - fn start_location(&self) -> Self::Location { - Default::default() - } - - #[inline] - fn start_state(&self) -> Self::StateIndex { - 0 - } - - #[inline] - fn token_to_index(&self, token: &Self::Token) -> Option { - __token_to_integer(token, core::marker::PhantomData::<(&())>) - } - - #[inline] - fn action(&self, state: i8, integer: usize) -> i8 { - __action(state, integer) - } - - #[inline] - fn error_action(&self, state: i8) -> i8 { - __action(state, 16 - 1) - } - - #[inline] - fn eof_action(&self, state: i8) -> i8 { - __EOF_ACTION[state as usize] - } - - #[inline] - fn goto(&self, state: i8, nt: usize) -> i8 { - __goto(state, nt) - } - - fn token_to_symbol(&self, token_index: usize, token: Self::Token) -> Self::Symbol { - __token_to_symbol(token_index, token, core::marker::PhantomData::<(&())>) - } - - fn expected_tokens(&self, state: i8) -> alloc::vec::Vec { - __expected_tokens(state) - } - - #[inline] - fn uses_error_recovery(&self) -> bool { - false - } - - #[inline] - fn error_recovery_symbol( - &self, - recovery: __state_machine::ErrorRecovery, - ) -> Self::Symbol { - panic!("error recovery not enabled for this grammar") - } - - fn reduce( - &mut self, - action: i8, - start_location: Option<&Self::Location>, - states: &mut alloc::vec::Vec, - symbols: &mut alloc::vec::Vec<__state_machine::SymbolTriple>, - ) -> Option<__state_machine::ParseResult> { - __reduce( - self.input, - action, - start_location, - states, - symbols, - core::marker::PhantomData::<(&())>, - ) - } - - fn simulate_reduce(&self, action: i8) -> __state_machine::SimulatedReduce { - panic!("error recovery not enabled for this grammar") - } - } - fn __token_to_integer< - 'input, - >( - __token: &Token<'input>, - _: core::marker::PhantomData<(&'input ())>, - ) -> Option - { - match *__token { - Token(2, _) if true => Some(0), - Token(3, _) if true => Some(1), - Token(4, _) if true => Some(2), - Token(5, _) if true => Some(3), - Token(6, _) if true => Some(4), - Token(7, _) if true => Some(5), - Token(8, _) if true => Some(6), - Token(9, _) if true => Some(7), - Token(10, _) if true => Some(8), - Token(11, _) if true => Some(9), - Token(12, _) if true => Some(10), - Token(13, _) if true => Some(11), - Token(14, _) if true => Some(12), - Token(15, _) if true => Some(13), - Token(0, _) if true => Some(14), - Token(1, _) if true => Some(15), - _ => None, - } - } - fn __token_to_symbol< - 'input, - >( - __token_index: usize, - __token: Token<'input>, - _: core::marker::PhantomData<(&'input ())>, - ) -> __Symbol<'input> - { - match __token_index { - 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 => match __token { - Token(2, __tok0) | Token(3, __tok0) | Token(4, __tok0) | Token(5, __tok0) | Token(6, __tok0) | Token(7, __tok0) | Token(8, __tok0) | Token(9, __tok0) | Token(10, __tok0) | Token(11, __tok0) | Token(12, __tok0) | Token(13, __tok0) | Token(14, __tok0) | Token(15, __tok0) | Token(0, __tok0) | Token(1, __tok0) if true => __Symbol::Variant0(__tok0), - _ => unreachable!(), - }, - _ => unreachable!(), - } - } - pub struct ExprParser { - builder: __lalrpop_util::lexer::MatcherBuilder, - _priv: (), - } - - impl ExprParser { - pub fn new() -> ExprParser { - let __builder = super::__intern_token::new_builder(); - ExprParser { - builder: __builder, - _priv: (), - } - } - - #[allow(dead_code)] - pub fn parse< - 'input, - >( - &self, - input: &'input str, - ) -> Result, &'static str>> - { - let mut __tokens = self.builder.matcher(input); - __state_machine::Parser::drive( - __StateMachine { - input, - __phantom: core::marker::PhantomData::<(&())>, - }, - __tokens, - ) - } - } - pub(crate) fn __reduce< - 'input, - >( - input: &'input str, - __action: i8, - __lookahead_start: Option<&usize>, - __states: &mut alloc::vec::Vec, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> Option, &'static str>>> - { - let (__pop_states, __nonterminal) = match __action { - 0 => { - __reduce0(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 1 => { - __reduce1(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 2 => { - __reduce2(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 3 => { - __reduce3(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 4 => { - __reduce4(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 5 => { - __reduce5(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 6 => { - __reduce6(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 7 => { - __reduce7(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 8 => { - __reduce8(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 9 => { - __reduce9(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 10 => { - __reduce10(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 11 => { - __reduce11(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 12 => { - __reduce12(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 13 => { - __reduce13(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 14 => { - __reduce14(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 15 => { - __reduce15(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 16 => { - __reduce16(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 17 => { - __reduce17(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 18 => { - __reduce18(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 19 => { - __reduce19(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 20 => { - __reduce20(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 21 => { - __reduce21(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 22 => { - __reduce22(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 23 => { - __reduce23(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 24 => { - __reduce24(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 25 => { - __reduce25(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 26 => { - __reduce26(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 27 => { - __reduce27(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 28 => { - __reduce28(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 29 => { - __reduce29(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 30 => { - __reduce30(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 31 => { - __reduce31(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 32 => { - __reduce32(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 33 => { - __reduce33(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 34 => { - __reduce34(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 35 => { - __reduce35(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 36 => { - __reduce36(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 37 => { - __reduce37(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 38 => { - __reduce38(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 39 => { - __reduce39(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 40 => { - __reduce40(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 41 => { - __reduce41(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 42 => { - __reduce42(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 43 => { - __reduce43(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 44 => { - __reduce44(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 45 => { - __reduce45(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 46 => { - __reduce46(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 47 => { - __reduce47(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 48 => { - __reduce48(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 49 => { - // __Expr = Expr => ActionFn(0); - let __sym0 = __pop_Variant5(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym0.2.clone(); - let __nt = super::__action0::<>(input, __sym0); - return Some(Ok(__nt)); - } - _ => panic!("invalid action code {}", __action) - }; - let __states_len = __states.len(); - __states.truncate(__states_len - __pop_states); - let __state = *__states.last().unwrap(); - let __next_state = __goto(__state, __nonterminal); - __states.push(__next_state); - None - } - #[inline(never)] - fn __symbol_type_mismatch() -> ! { - panic!("symbol type mismatch") - } - fn __pop_Variant3< - 'input, - >( - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> - ) -> (usize, (Expr, &'input str), usize) - { - match __symbols.pop() { - Some((__l, __Symbol::Variant3(__v), __r)) => (__l, __v, __r), - _ => __symbol_type_mismatch() - } - } - fn __pop_Variant5< - 'input, - >( - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> - ) -> (usize, Expr, usize) - { - match __symbols.pop() { - Some((__l, __Symbol::Variant5(__v), __r)) => (__l, __v, __r), - _ => __symbol_type_mismatch() - } - } - fn __pop_Variant7< - 'input, - >( - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> - ) -> (usize, String, usize) - { - match __symbols.pop() { - Some((__l, __Symbol::Variant7(__v), __r)) => (__l, __v, __r), - _ => __symbol_type_mismatch() - } - } - fn __pop_Variant4< - 'input, - >( - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> - ) -> (usize, alloc::vec::Vec<(Expr, &'input str)>, usize) - { - match __symbols.pop() { - Some((__l, __Symbol::Variant4(__v), __r)) => (__l, __v, __r), - _ => __symbol_type_mismatch() - } - } - fn __pop_Variant2< - 'input, - >( - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> - ) -> (usize, alloc::vec::Vec<&'static str>, usize) - { - match __symbols.pop() { - Some((__l, __Symbol::Variant2(__v), __r)) => (__l, __v, __r), - _ => __symbol_type_mismatch() - } - } - fn __pop_Variant6< - 'input, - >( - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> - ) -> (usize, core::option::Option, usize) - { - match __symbols.pop() { - Some((__l, __Symbol::Variant6(__v), __r)) => (__l, __v, __r), - _ => __symbol_type_mismatch() - } - } - fn __pop_Variant0< - 'input, - >( - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> - ) -> (usize, &'input str, usize) - { - match __symbols.pop() { - Some((__l, __Symbol::Variant0(__v), __r)) => (__l, __v, __r), - _ => __symbol_type_mismatch() - } - } - fn __pop_Variant1< - 'input, - >( - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> - ) -> (usize, &'static str, usize) - { - match __symbols.pop() { - Some((__l, __Symbol::Variant1(__v), __r)) => (__l, __v, __r), - _ => __symbol_type_mismatch() - } - } - pub(crate) fn __reduce0< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // () = Postfix => ActionFn(35); - let __sym0 = __pop_Variant1(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym0.2.clone(); - let __nt = super::__action35::<>(input, __sym0); - __symbols.push((__start, __Symbol::Variant1(__nt), __end)); - (1, 0) - } - pub(crate) fn __reduce1< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // ()* = => ActionFn(33); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); - let __nt = super::__action33::<>(input, &__start, &__end); - __symbols.push((__start, __Symbol::Variant2(__nt), __end)); - (0, 1) - } - pub(crate) fn __reduce2< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // ()* = ()+ => ActionFn(34); - let __sym0 = __pop_Variant2(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym0.2.clone(); - let __nt = super::__action34::<>(input, __sym0); - __symbols.push((__start, __Symbol::Variant2(__nt), __end)); - (1, 1) - } - pub(crate) fn __reduce3< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // ()+ = Postfix => ActionFn(45); - let __sym0 = __pop_Variant1(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym0.2.clone(); - let __nt = super::__action45::<>(input, __sym0); - __symbols.push((__start, __Symbol::Variant2(__nt), __end)); - (1, 2) - } - pub(crate) fn __reduce4< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // ()+ = ()+, Postfix => ActionFn(46); - assert!(__symbols.len() >= 2); - let __sym1 = __pop_Variant1(__symbols); - let __sym0 = __pop_Variant2(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym1.2.clone(); - let __nt = super::__action46::<>(input, __sym0, __sym1); - __symbols.push((__start, __Symbol::Variant2(__nt), __end)); - (2, 2) - } - pub(crate) fn __reduce5< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // () = Prefix => ActionFn(38); - let __sym0 = __pop_Variant1(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym0.2.clone(); - let __nt = super::__action38::<>(input, __sym0); - __symbols.push((__start, __Symbol::Variant1(__nt), __end)); - (1, 3) - } - pub(crate) fn __reduce6< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // ()* = => ActionFn(36); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); - let __nt = super::__action36::<>(input, &__start, &__end); - __symbols.push((__start, __Symbol::Variant2(__nt), __end)); - (0, 4) - } - pub(crate) fn __reduce7< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // ()* = ()+ => ActionFn(37); - let __sym0 = __pop_Variant2(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym0.2.clone(); - let __nt = super::__action37::<>(input, __sym0); - __symbols.push((__start, __Symbol::Variant2(__nt), __end)); - (1, 4) - } - pub(crate) fn __reduce8< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // ()+ = Prefix => ActionFn(49); - let __sym0 = __pop_Variant1(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym0.2.clone(); - let __nt = super::__action49::<>(input, __sym0); - __symbols.push((__start, __Symbol::Variant2(__nt), __end)); - (1, 5) - } - pub(crate) fn __reduce9< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // ()+ = ()+, Prefix => ActionFn(50); - assert!(__symbols.len() >= 2); - let __sym1 = __pop_Variant1(__symbols); - let __sym0 = __pop_Variant2(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym1.2.clone(); - let __nt = super::__action50::<>(input, __sym0, __sym1); - __symbols.push((__start, __Symbol::Variant2(__nt), __end)); - (2, 5) - } - pub(crate) fn __reduce10< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // (Expr ",") = Expr, "," => ActionFn(32); - assert!(__symbols.len() >= 2); - let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant5(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym1.2.clone(); - let __nt = super::__action32::<>(input, __sym0, __sym1); - __symbols.push((__start, __Symbol::Variant3(__nt), __end)); - (2, 6) - } - pub(crate) fn __reduce11< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // (Expr ",")* = => ActionFn(30); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); - let __nt = super::__action30::<>(input, &__start, &__end); - __symbols.push((__start, __Symbol::Variant4(__nt), __end)); - (0, 7) - } - pub(crate) fn __reduce12< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // (Expr ",")* = (Expr ",")+ => ActionFn(31); - let __sym0 = __pop_Variant4(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym0.2.clone(); - let __nt = super::__action31::<>(input, __sym0); - __symbols.push((__start, __Symbol::Variant4(__nt), __end)); - (1, 7) - } - pub(crate) fn __reduce13< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // (Expr ",")+ = Expr, "," => ActionFn(53); - assert!(__symbols.len() >= 2); - let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant5(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym1.2.clone(); - let __nt = super::__action53::<>(input, __sym0, __sym1); - __symbols.push((__start, __Symbol::Variant4(__nt), __end)); - (2, 8) - } - pub(crate) fn __reduce14< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // (Expr ",")+ = (Expr ",")+, Expr, "," => ActionFn(54); - assert!(__symbols.len() >= 3); - let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant5(__symbols); - let __sym0 = __pop_Variant4(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym2.2.clone(); - let __nt = super::__action54::<>(input, __sym0, __sym1, __sym2); - __symbols.push((__start, __Symbol::Variant4(__nt), __end)); - (3, 8) - } - pub(crate) fn __reduce15< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // BinOp1 = ":" => ActionFn(15); - let __sym0 = __pop_Variant0(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym0.2.clone(); - let __nt = super::__action15::<>(input, __sym0); - __symbols.push((__start, __Symbol::Variant1(__nt), __end)); - (1, 9) - } - pub(crate) fn __reduce16< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // BinOp1 = ".." => ActionFn(16); - let __sym0 = __pop_Variant0(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym0.2.clone(); - let __nt = super::__action16::<>(input, __sym0); - __symbols.push((__start, __Symbol::Variant1(__nt), __end)); - (1, 9) - } - pub(crate) fn __reduce17< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // BinOp2 = "&" => ActionFn(9); - let __sym0 = __pop_Variant0(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym0.2.clone(); - let __nt = super::__action9::<>(input, __sym0); - __symbols.push((__start, __Symbol::Variant1(__nt), __end)); - (1, 10) - } - pub(crate) fn __reduce18< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // BinOp2 = "and" => ActionFn(10); - let __sym0 = __pop_Variant0(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym0.2.clone(); - let __nt = super::__action10::<>(input, __sym0); - __symbols.push((__start, __Symbol::Variant1(__nt), __end)); - (1, 10) - } - pub(crate) fn __reduce19< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // BinOp2 = "-" => ActionFn(11); - let __sym0 = __pop_Variant0(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym0.2.clone(); - let __nt = super::__action11::<>(input, __sym0); - __symbols.push((__start, __Symbol::Variant1(__nt), __end)); - (1, 10) - } - pub(crate) fn __reduce20< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // BinOp2 = "%" => ActionFn(12); - let __sym0 = __pop_Variant0(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym0.2.clone(); - let __nt = super::__action12::<>(input, __sym0); - __symbols.push((__start, __Symbol::Variant1(__nt), __end)); - (1, 10) - } - pub(crate) fn __reduce21< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // BinOp3 = "|" => ActionFn(4); - let __sym0 = __pop_Variant0(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym0.2.clone(); - let __nt = super::__action4::<>(input, __sym0); - __symbols.push((__start, __Symbol::Variant1(__nt), __end)); - (1, 11) - } - pub(crate) fn __reduce22< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // BinOp3 = "+" => ActionFn(5); - let __sym0 = __pop_Variant0(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym0.2.clone(); - let __nt = super::__action5::<>(input, __sym0); - __symbols.push((__start, __Symbol::Variant1(__nt), __end)); - (1, 11) - } - pub(crate) fn __reduce23< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // BinOp3 = "or" => ActionFn(6); - let __sym0 = __pop_Variant0(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym0.2.clone(); - let __nt = super::__action6::<>(input, __sym0); - __symbols.push((__start, __Symbol::Variant1(__nt), __end)); - (1, 11) - } - pub(crate) fn __reduce24< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // Expr = Expr4 => ActionFn(1); - let __sym0 = __pop_Variant5(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym0.2.clone(); - let __nt = super::__action1::<>(input, __sym0); - __symbols.push((__start, __Symbol::Variant5(__nt), __end)); - (1, 12) - } - pub(crate) fn __reduce25< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // Expr0 = Symbol2 => ActionFn(19); - let __sym0 = __pop_Variant7(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym0.2.clone(); - let __nt = super::__action19::<>(input, __sym0); - __symbols.push((__start, __Symbol::Variant5(__nt), __end)); - (1, 13) - } - pub(crate) fn __reduce26< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // Expr0 = Symbol1, "(", Expr, ")" => ActionFn(57); - assert!(__symbols.len() >= 4); - let __sym3 = __pop_Variant0(__symbols); - let __sym2 = __pop_Variant5(__symbols); - let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant7(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym3.2.clone(); - let __nt = super::__action57::<>(input, __sym0, __sym1, __sym2, __sym3); - __symbols.push((__start, __Symbol::Variant5(__nt), __end)); - (4, 13) - } - pub(crate) fn __reduce27< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // Expr0 = Symbol1, "(", ")" => ActionFn(58); - assert!(__symbols.len() >= 3); - let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant7(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym2.2.clone(); - let __nt = super::__action58::<>(input, __sym0, __sym1, __sym2); - __symbols.push((__start, __Symbol::Variant5(__nt), __end)); - (3, 13) - } - pub(crate) fn __reduce28< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // Expr0 = Symbol1, "(", (Expr ",")+, Expr, ")" => ActionFn(59); - assert!(__symbols.len() >= 5); - let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant5(__symbols); - let __sym2 = __pop_Variant4(__symbols); - let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant7(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym4.2.clone(); - let __nt = super::__action59::<>(input, __sym0, __sym1, __sym2, __sym3, __sym4); - __symbols.push((__start, __Symbol::Variant5(__nt), __end)); - (5, 13) - } - pub(crate) fn __reduce29< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // Expr0 = Symbol1, "(", (Expr ",")+, ")" => ActionFn(60); - assert!(__symbols.len() >= 4); - let __sym3 = __pop_Variant0(__symbols); - let __sym2 = __pop_Variant4(__symbols); - let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant7(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym3.2.clone(); - let __nt = super::__action60::<>(input, __sym0, __sym1, __sym2, __sym3); - __symbols.push((__start, __Symbol::Variant5(__nt), __end)); - (4, 13) - } - pub(crate) fn __reduce30< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // Expr0 = "(", Expr, ")" => ActionFn(21); - assert!(__symbols.len() >= 3); - let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant5(__symbols); - let __sym0 = __pop_Variant0(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym2.2.clone(); - let __nt = super::__action21::<>(input, __sym0, __sym1, __sym2); - __symbols.push((__start, __Symbol::Variant5(__nt), __end)); - (3, 13) - } - pub(crate) fn __reduce31< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // Expr1 = Expr0 => ActionFn(47); - let __sym0 = __pop_Variant5(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym0.2.clone(); - let __nt = super::__action47::<>(input, __sym0); - __symbols.push((__start, __Symbol::Variant5(__nt), __end)); - (1, 14) - } - pub(crate) fn __reduce32< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // Expr1 = Expr0, ()+ => ActionFn(48); - assert!(__symbols.len() >= 2); - let __sym1 = __pop_Variant2(__symbols); - let __sym0 = __pop_Variant5(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym1.2.clone(); - let __nt = super::__action48::<>(input, __sym0, __sym1); - __symbols.push((__start, __Symbol::Variant5(__nt), __end)); - (2, 14) - } - pub(crate) fn __reduce33< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // Expr15 = Expr1 => ActionFn(51); - let __sym0 = __pop_Variant5(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym0.2.clone(); - let __nt = super::__action51::<>(input, __sym0); - __symbols.push((__start, __Symbol::Variant5(__nt), __end)); - (1, 15) - } - pub(crate) fn __reduce34< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // Expr15 = ()+, Expr1 => ActionFn(52); - assert!(__symbols.len() >= 2); - let __sym1 = __pop_Variant5(__symbols); - let __sym0 = __pop_Variant2(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym1.2.clone(); - let __nt = super::__action52::<>(input, __sym0, __sym1); - __symbols.push((__start, __Symbol::Variant5(__nt), __end)); - (2, 15) - } - pub(crate) fn __reduce35< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // Expr2 = Expr2, BinOp1, Expr15 => ActionFn(13); - assert!(__symbols.len() >= 3); - let __sym2 = __pop_Variant5(__symbols); - let __sym1 = __pop_Variant1(__symbols); - let __sym0 = __pop_Variant5(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym2.2.clone(); - let __nt = super::__action13::<>(input, __sym0, __sym1, __sym2); - __symbols.push((__start, __Symbol::Variant5(__nt), __end)); - (3, 16) - } - pub(crate) fn __reduce36< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // Expr2 = Expr15 => ActionFn(14); - let __sym0 = __pop_Variant5(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym0.2.clone(); - let __nt = super::__action14::<>(input, __sym0); - __symbols.push((__start, __Symbol::Variant5(__nt), __end)); - (1, 16) - } - pub(crate) fn __reduce37< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // Expr3 = Expr3, BinOp2, Expr2 => ActionFn(7); - assert!(__symbols.len() >= 3); - let __sym2 = __pop_Variant5(__symbols); - let __sym1 = __pop_Variant1(__symbols); - let __sym0 = __pop_Variant5(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym2.2.clone(); - let __nt = super::__action7::<>(input, __sym0, __sym1, __sym2); - __symbols.push((__start, __Symbol::Variant5(__nt), __end)); - (3, 17) - } - pub(crate) fn __reduce38< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // Expr3 = Expr2 => ActionFn(8); - let __sym0 = __pop_Variant5(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym0.2.clone(); - let __nt = super::__action8::<>(input, __sym0); - __symbols.push((__start, __Symbol::Variant5(__nt), __end)); - (1, 17) - } - pub(crate) fn __reduce39< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // Expr4 = Expr4, BinOp3, Expr3 => ActionFn(2); - assert!(__symbols.len() >= 3); - let __sym2 = __pop_Variant5(__symbols); - let __sym1 = __pop_Variant1(__symbols); - let __sym0 = __pop_Variant5(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym2.2.clone(); - let __nt = super::__action2::<>(input, __sym0, __sym1, __sym2); - __symbols.push((__start, __Symbol::Variant5(__nt), __end)); - (3, 18) - } - pub(crate) fn __reduce40< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // Expr4 = Expr3 => ActionFn(3); - let __sym0 = __pop_Variant5(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym0.2.clone(); - let __nt = super::__action3::<>(input, __sym0); - __symbols.push((__start, __Symbol::Variant5(__nt), __end)); - (1, 18) - } - pub(crate) fn __reduce41< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // Expr? = Expr => ActionFn(28); - let __sym0 = __pop_Variant5(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym0.2.clone(); - let __nt = super::__action28::<>(input, __sym0); - __symbols.push((__start, __Symbol::Variant6(__nt), __end)); - (1, 19) - } - pub(crate) fn __reduce42< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // Expr? = => ActionFn(29); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); - let __end = __start.clone(); - let __nt = super::__action29::<>(input, &__start, &__end); - __symbols.push((__start, __Symbol::Variant6(__nt), __end)); - (0, 19) - } - pub(crate) fn __reduce43< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // Postfix = "::" => ActionFn(23); - let __sym0 = __pop_Variant0(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym0.2.clone(); - let __nt = super::__action23::<>(input, __sym0); - __symbols.push((__start, __Symbol::Variant1(__nt), __end)); - (1, 20) - } - pub(crate) fn __reduce44< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // Postfix = "^" => ActionFn(24); - let __sym0 = __pop_Variant0(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym0.2.clone(); - let __nt = super::__action24::<>(input, __sym0); - __symbols.push((__start, __Symbol::Variant1(__nt), __end)); - (1, 20) - } - pub(crate) fn __reduce45< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // Prefix = "::" => ActionFn(22); - let __sym0 = __pop_Variant0(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym0.2.clone(); - let __nt = super::__action22::<>(input, __sym0); - __symbols.push((__start, __Symbol::Variant1(__nt), __end)); - (1, 21) - } - pub(crate) fn __reduce46< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // Symbol1 = r#"[a-zA-Z0-9/_$@.-]+"# => ActionFn(27); - let __sym0 = __pop_Variant0(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym0.2.clone(); - let __nt = super::__action27::<>(input, __sym0); - __symbols.push((__start, __Symbol::Variant7(__nt), __end)); - (1, 22) - } - pub(crate) fn __reduce47< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // Symbol2 = Symbol1 => ActionFn(25); - let __sym0 = __pop_Variant7(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym0.2.clone(); - let __nt = super::__action25::<>(input, __sym0); - __symbols.push((__start, __Symbol::Variant7(__nt), __end)); - (1, 23) - } - pub(crate) fn __reduce48< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // Symbol2 = r#"\\x22([^\\x22\\x5c]|\\x5c.)*\\x22"# => ActionFn(26); - let __sym0 = __pop_Variant0(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym0.2.clone(); - let __nt = super::__action26::<>(input, __sym0); - __symbols.push((__start, __Symbol::Variant7(__nt), __end)); - (1, 23) - } -} -pub use self::__parse__Expr::ExprParser; -#[cfg_attr(rustfmt, rustfmt_skip)] -mod __intern_token { - #![allow(unused_imports)] - use super::super::ast::Expr; - #[allow(unused_extern_crates)] - extern crate lalrpop_util as __lalrpop_util; - #[allow(unused_imports)] - use self::__lalrpop_util::state_machine as __state_machine; - extern crate core; - extern crate alloc; - pub fn new_builder() -> __lalrpop_util::lexer::MatcherBuilder { - let __strs: &[(&str, bool)] = &[ - ("^([\\$\\--9@-Z_a-z]+)", false), - ("^(\"([\u{0}-!\\#-\\[\\]-\u{10ffff}]|\\\\[\u{0}-\t\u{b}-\u{10ffff}])*\")", false), - ("^(%)", false), - ("^(\\&)", false), - ("^(\\()", false), - ("^(\\))", false), - ("^(\\+)", false), - ("^(,)", false), - ("^(\\-)", false), - ("^(\\.\\.)", false), - ("^(:)", false), - ("^(::)", false), - ("^(\\^)", false), - ("^(and)", false), - ("^(or)", false), - ("^(\\|)", false), - (r"^(\s*)", true), - ]; - __lalrpop_util::lexer::MatcherBuilder::new(__strs.iter().copied()).unwrap() - } -} -pub(crate) use self::__lalrpop_util::lexer::Token; - -#[allow(unused_variables)] -fn __action0< - 'input, ->( - input: &'input str, - (_, __0, _): (usize, Expr, usize), -) -> Expr -{ - __0 -} - -#[allow(unused_variables)] -fn __action1< - 'input, ->( - input: &'input str, - (_, __0, _): (usize, Expr, usize), -) -> Expr -{ - __0 -} - -#[allow(unused_variables)] -fn __action2< - 'input, ->( - input: &'input str, - (_, a, _): (usize, Expr, usize), - (_, op, _): (usize, &'static str, usize), - (_, b, _): (usize, Expr, usize), -) -> Expr -{ - Expr::Fn(op.into(), vec![a, b]) -} - -#[allow(unused_variables)] -fn __action3< - 'input, ->( - input: &'input str, - (_, __0, _): (usize, Expr, usize), -) -> Expr -{ - __0 -} - -#[allow(unused_variables)] -fn __action4< - 'input, ->( - input: &'input str, - (_, __0, _): (usize, &'input str, usize), -) -> &'static str -{ - "union" -} - -#[allow(unused_variables)] -fn __action5< - 'input, ->( - input: &'input str, - (_, __0, _): (usize, &'input str, usize), -) -> &'static str -{ - "union" -} - -#[allow(unused_variables)] -fn __action6< - 'input, ->( - input: &'input str, - (_, __0, _): (usize, &'input str, usize), -) -> &'static str -{ - "union" -} - -#[allow(unused_variables)] -fn __action7< - 'input, ->( - input: &'input str, - (_, a, _): (usize, Expr, usize), - (_, op, _): (usize, &'static str, usize), - (_, b, _): (usize, Expr, usize), -) -> Expr -{ - Expr::Fn(op.into(), vec![a, b]) -} - -#[allow(unused_variables)] -fn __action8< - 'input, ->( - input: &'input str, - (_, __0, _): (usize, Expr, usize), -) -> Expr -{ - __0 -} - -#[allow(unused_variables)] -fn __action9< - 'input, ->( - input: &'input str, - (_, __0, _): (usize, &'input str, usize), -) -> &'static str -{ - "intersection" -} - -#[allow(unused_variables)] -fn __action10< - 'input, ->( - input: &'input str, - (_, __0, _): (usize, &'input str, usize), -) -> &'static str -{ - "intersection" -} - -#[allow(unused_variables)] -fn __action11< - 'input, ->( - input: &'input str, - (_, __0, _): (usize, &'input str, usize), -) -> &'static str -{ - "difference" -} - -#[allow(unused_variables)] -fn __action12< - 'input, ->( - input: &'input str, - (_, __0, _): (usize, &'input str, usize), -) -> &'static str -{ - "only" -} - -#[allow(unused_variables)] -fn __action13< - 'input, ->( - input: &'input str, - (_, a, _): (usize, Expr, usize), - (_, op, _): (usize, &'static str, usize), - (_, b, _): (usize, Expr, usize), -) -> Expr -{ - Expr::Fn(op.into(), vec![a, b]) -} - -#[allow(unused_variables)] -fn __action14< - 'input, ->( - input: &'input str, - (_, __0, _): (usize, Expr, usize), -) -> Expr -{ - __0 -} - -#[allow(unused_variables)] -fn __action15< - 'input, ->( - input: &'input str, - (_, __0, _): (usize, &'input str, usize), -) -> &'static str -{ - "range" -} - -#[allow(unused_variables)] -fn __action16< - 'input, ->( - input: &'input str, - (_, __0, _): (usize, &'input str, usize), -) -> &'static str -{ - "range" -} - -#[allow(unused_variables)] -fn __action17< - 'input, ->( - input: &'input str, - (_, pre, _): (usize, alloc::vec::Vec<&'static str>, usize), - (_, e, _): (usize, Expr, usize), -) -> Expr -{ - { - let mut e = e; - for v in pre { e = Expr::Fn(v.into(), vec![e]); } - e - } -} - -#[allow(unused_variables)] -fn __action18< - 'input, ->( - input: &'input str, - (_, e, _): (usize, Expr, usize), - (_, post, _): (usize, alloc::vec::Vec<&'static str>, usize), -) -> Expr -{ - { - let mut e = e; - for v in post { e = Expr::Fn(v.into(), vec![e]); } - e - } -} - -#[allow(unused_variables)] -fn __action19< - 'input, ->( - input: &'input str, - (_, __0, _): (usize, String, usize), -) -> Expr -{ - Expr::Name(__0) -} - -#[allow(unused_variables)] -fn __action20< - 'input, ->( - input: &'input str, - (_, f, _): (usize, String, usize), - (_, _, _): (usize, &'input str, usize), - (_, args, _): (usize, alloc::vec::Vec<(Expr, &'input str)>, usize), - (_, last, _): (usize, core::option::Option, usize), - (_, _, _): (usize, &'input str, usize), -) -> Expr -{ - { - // Function call. - let mut arg_list: Vec = args.into_iter().map(|(e, _)| e).collect(); - if let Some(last_arg) = last { arg_list.push(last_arg); } - Expr::Fn(f.into(), arg_list) - } -} - -#[allow(unused_variables)] -fn __action21< - 'input, ->( - input: &'input str, - (_, _, _): (usize, &'input str, usize), - (_, __0, _): (usize, Expr, usize), - (_, _, _): (usize, &'input str, usize), -) -> Expr -{ - __0 -} - -#[allow(unused_variables)] -fn __action22< - 'input, ->( - input: &'input str, - (_, __0, _): (usize, &'input str, usize), -) -> &'static str -{ - "ancestors" -} - -#[allow(unused_variables)] -fn __action23< - 'input, ->( - input: &'input str, - (_, __0, _): (usize, &'input str, usize), -) -> &'static str -{ - "descendants" -} - -#[allow(unused_variables)] -fn __action24< - 'input, ->( - input: &'input str, - (_, __0, _): (usize, &'input str, usize), -) -> &'static str -{ - "parents" -} - -#[allow(unused_variables)] -fn __action25< - 'input, ->( - input: &'input str, - (_, __0, _): (usize, String, usize), -) -> String -{ - __0 -} - -#[allow(unused_variables)] -fn __action26< - 'input, ->( - input: &'input str, - (_, escaped, _): (usize, &'input str, usize), -) -> String -{ - { - // Escaped string. - let mut result = String::with_capacity(escaped.len()); - let mut prev = '_'; - for ch in escaped[1..escaped.len()-1].chars() { - match (prev, ch) { - ('\\', 'n') => result.push('\n'), - ('\\', _) => result.push(ch), - (_, '\\') => (), - (_, _) => result.push(ch), - } - prev = ch; - } - result - } -} - -#[allow(unused_variables)] -fn __action27< - 'input, ->( - input: &'input str, - (_, __0, _): (usize, &'input str, usize), -) -> String -{ - __0.to_string() -} - -#[allow(unused_variables)] -fn __action28< - 'input, ->( - input: &'input str, - (_, __0, _): (usize, Expr, usize), -) -> core::option::Option -{ - Some(__0) -} - -#[allow(unused_variables)] -fn __action29< - 'input, ->( - input: &'input str, - __lookbehind: &usize, - __lookahead: &usize, -) -> core::option::Option -{ - None -} - -#[allow(unused_variables)] -fn __action30< - 'input, ->( - input: &'input str, - __lookbehind: &usize, - __lookahead: &usize, -) -> alloc::vec::Vec<(Expr, &'input str)> -{ - alloc::vec![] -} - -#[allow(unused_variables)] -fn __action31< - 'input, ->( - input: &'input str, - (_, v, _): (usize, alloc::vec::Vec<(Expr, &'input str)>, usize), -) -> alloc::vec::Vec<(Expr, &'input str)> -{ - v -} - -#[allow(unused_variables)] -fn __action32< - 'input, ->( - input: &'input str, - (_, __0, _): (usize, Expr, usize), - (_, __1, _): (usize, &'input str, usize), -) -> (Expr, &'input str) -{ - (__0, __1) -} - -#[allow(unused_variables)] -fn __action33< - 'input, ->( - input: &'input str, - __lookbehind: &usize, - __lookahead: &usize, -) -> alloc::vec::Vec<&'static str> -{ - alloc::vec![] -} - -#[allow(unused_variables)] -fn __action34< - 'input, ->( - input: &'input str, - (_, v, _): (usize, alloc::vec::Vec<&'static str>, usize), -) -> alloc::vec::Vec<&'static str> -{ - v -} - -#[allow(unused_variables)] -fn __action35< - 'input, ->( - input: &'input str, - (_, __0, _): (usize, &'static str, usize), -) -> &'static str -{ - __0 -} - -#[allow(unused_variables)] -fn __action36< - 'input, ->( - input: &'input str, - __lookbehind: &usize, - __lookahead: &usize, -) -> alloc::vec::Vec<&'static str> -{ - alloc::vec![] -} - -#[allow(unused_variables)] -fn __action37< - 'input, ->( - input: &'input str, - (_, v, _): (usize, alloc::vec::Vec<&'static str>, usize), -) -> alloc::vec::Vec<&'static str> -{ - v -} - -#[allow(unused_variables)] -fn __action38< - 'input, ->( - input: &'input str, - (_, __0, _): (usize, &'static str, usize), -) -> &'static str -{ - __0 -} - -#[allow(unused_variables)] -fn __action39< - 'input, ->( - input: &'input str, - (_, __0, _): (usize, &'static str, usize), -) -> alloc::vec::Vec<&'static str> -{ - alloc::vec![__0] -} - -#[allow(unused_variables)] -fn __action40< - 'input, ->( - input: &'input str, - (_, v, _): (usize, alloc::vec::Vec<&'static str>, usize), - (_, e, _): (usize, &'static str, usize), -) -> alloc::vec::Vec<&'static str> -{ - { let mut v = v; v.push(e); v } -} - -#[allow(unused_variables)] -fn __action41< - 'input, ->( - input: &'input str, - (_, __0, _): (usize, &'static str, usize), -) -> alloc::vec::Vec<&'static str> -{ - alloc::vec![__0] -} - -#[allow(unused_variables)] -fn __action42< - 'input, ->( - input: &'input str, - (_, v, _): (usize, alloc::vec::Vec<&'static str>, usize), - (_, e, _): (usize, &'static str, usize), -) -> alloc::vec::Vec<&'static str> -{ - { let mut v = v; v.push(e); v } -} - -#[allow(unused_variables)] -fn __action43< - 'input, ->( - input: &'input str, - (_, __0, _): (usize, (Expr, &'input str), usize), -) -> alloc::vec::Vec<(Expr, &'input str)> -{ - alloc::vec![__0] -} - -#[allow(unused_variables)] -fn __action44< - 'input, ->( - input: &'input str, - (_, v, _): (usize, alloc::vec::Vec<(Expr, &'input str)>, usize), - (_, e, _): (usize, (Expr, &'input str), usize), -) -> alloc::vec::Vec<(Expr, &'input str)> -{ - { let mut v = v; v.push(e); v } -} - -#[allow(unused_variables)] -fn __action45< - 'input, ->( - input: &'input str, - __0: (usize, &'static str, usize), -) -> alloc::vec::Vec<&'static str> -{ - let __start0 = __0.0.clone(); - let __end0 = __0.2.clone(); - let __temp0 = __action35( - input, - __0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action41( - input, - __temp0, - ) -} - -#[allow(unused_variables)] -fn __action46< - 'input, ->( - input: &'input str, - __0: (usize, alloc::vec::Vec<&'static str>, usize), - __1: (usize, &'static str, usize), -) -> alloc::vec::Vec<&'static str> -{ - let __start0 = __1.0.clone(); - let __end0 = __1.2.clone(); - let __temp0 = __action35( - input, - __1, - ); - let __temp0 = (__start0, __temp0, __end0); - __action42( - input, - __0, - __temp0, - ) -} - -#[allow(unused_variables)] -fn __action47< - 'input, ->( - input: &'input str, - __0: (usize, Expr, usize), -) -> Expr -{ - let __start0 = __0.2.clone(); - let __end0 = __0.2.clone(); - let __temp0 = __action33( - input, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action18( - input, - __0, - __temp0, - ) -} - -#[allow(unused_variables)] -fn __action48< - 'input, ->( - input: &'input str, - __0: (usize, Expr, usize), - __1: (usize, alloc::vec::Vec<&'static str>, usize), -) -> Expr -{ - let __start0 = __1.0.clone(); - let __end0 = __1.2.clone(); - let __temp0 = __action34( - input, - __1, - ); - let __temp0 = (__start0, __temp0, __end0); - __action18( - input, - __0, - __temp0, - ) -} - -#[allow(unused_variables)] -fn __action49< - 'input, ->( - input: &'input str, - __0: (usize, &'static str, usize), -) -> alloc::vec::Vec<&'static str> -{ - let __start0 = __0.0.clone(); - let __end0 = __0.2.clone(); - let __temp0 = __action38( - input, - __0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action39( - input, - __temp0, - ) -} - -#[allow(unused_variables)] -fn __action50< - 'input, ->( - input: &'input str, - __0: (usize, alloc::vec::Vec<&'static str>, usize), - __1: (usize, &'static str, usize), -) -> alloc::vec::Vec<&'static str> -{ - let __start0 = __1.0.clone(); - let __end0 = __1.2.clone(); - let __temp0 = __action38( - input, - __1, - ); - let __temp0 = (__start0, __temp0, __end0); - __action40( - input, - __0, - __temp0, - ) -} - -#[allow(unused_variables)] -fn __action51< - 'input, ->( - input: &'input str, - __0: (usize, Expr, usize), -) -> Expr -{ - let __start0 = __0.0.clone(); - let __end0 = __0.0.clone(); - let __temp0 = __action36( - input, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action17( - input, - __temp0, - __0, - ) -} - -#[allow(unused_variables)] -fn __action52< - 'input, ->( - input: &'input str, - __0: (usize, alloc::vec::Vec<&'static str>, usize), - __1: (usize, Expr, usize), -) -> Expr -{ - let __start0 = __0.0.clone(); - let __end0 = __0.2.clone(); - let __temp0 = __action37( - input, - __0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action17( - input, - __temp0, - __1, - ) -} - -#[allow(unused_variables)] -fn __action53< - 'input, ->( - input: &'input str, - __0: (usize, Expr, usize), - __1: (usize, &'input str, usize), -) -> alloc::vec::Vec<(Expr, &'input str)> -{ - let __start0 = __0.0.clone(); - let __end0 = __1.2.clone(); - let __temp0 = __action32( - input, - __0, - __1, - ); - let __temp0 = (__start0, __temp0, __end0); - __action43( - input, - __temp0, - ) -} - -#[allow(unused_variables)] -fn __action54< - 'input, ->( - input: &'input str, - __0: (usize, alloc::vec::Vec<(Expr, &'input str)>, usize), - __1: (usize, Expr, usize), - __2: (usize, &'input str, usize), -) -> alloc::vec::Vec<(Expr, &'input str)> -{ - let __start0 = __1.0.clone(); - let __end0 = __2.2.clone(); - let __temp0 = __action32( - input, - __1, - __2, - ); - let __temp0 = (__start0, __temp0, __end0); - __action44( - input, - __0, - __temp0, - ) -} - -#[allow(unused_variables)] -fn __action55< - 'input, ->( - input: &'input str, - __0: (usize, String, usize), - __1: (usize, &'input str, usize), - __2: (usize, core::option::Option, usize), - __3: (usize, &'input str, usize), -) -> Expr -{ - let __start0 = __1.2.clone(); - let __end0 = __2.0.clone(); - let __temp0 = __action30( - input, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action20( - input, - __0, - __1, - __temp0, - __2, - __3, - ) -} - -#[allow(unused_variables)] -fn __action56< - 'input, ->( - input: &'input str, - __0: (usize, String, usize), - __1: (usize, &'input str, usize), - __2: (usize, alloc::vec::Vec<(Expr, &'input str)>, usize), - __3: (usize, core::option::Option, usize), - __4: (usize, &'input str, usize), -) -> Expr -{ - let __start0 = __2.0.clone(); - let __end0 = __2.2.clone(); - let __temp0 = __action31( - input, - __2, - ); - let __temp0 = (__start0, __temp0, __end0); - __action20( - input, - __0, - __1, - __temp0, - __3, - __4, - ) -} - -#[allow(unused_variables)] -fn __action57< - 'input, ->( - input: &'input str, - __0: (usize, String, usize), - __1: (usize, &'input str, usize), - __2: (usize, Expr, usize), - __3: (usize, &'input str, usize), -) -> Expr -{ - let __start0 = __2.0.clone(); - let __end0 = __2.2.clone(); - let __temp0 = __action28( - input, - __2, - ); - let __temp0 = (__start0, __temp0, __end0); - __action55( - input, - __0, - __1, - __temp0, - __3, - ) -} - -#[allow(unused_variables)] -fn __action58< - 'input, ->( - input: &'input str, - __0: (usize, String, usize), - __1: (usize, &'input str, usize), - __2: (usize, &'input str, usize), -) -> Expr -{ - let __start0 = __1.2.clone(); - let __end0 = __2.0.clone(); - let __temp0 = __action29( - input, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action55( - input, - __0, - __1, - __temp0, - __2, - ) -} - -#[allow(unused_variables)] -fn __action59< - 'input, ->( - input: &'input str, - __0: (usize, String, usize), - __1: (usize, &'input str, usize), - __2: (usize, alloc::vec::Vec<(Expr, &'input str)>, usize), - __3: (usize, Expr, usize), - __4: (usize, &'input str, usize), -) -> Expr -{ - let __start0 = __3.0.clone(); - let __end0 = __3.2.clone(); - let __temp0 = __action28( - input, - __3, - ); - let __temp0 = (__start0, __temp0, __end0); - __action56( - input, - __0, - __1, - __2, - __temp0, - __4, - ) -} - -#[allow(unused_variables)] -fn __action60< - 'input, ->( - input: &'input str, - __0: (usize, String, usize), - __1: (usize, &'input str, usize), - __2: (usize, alloc::vec::Vec<(Expr, &'input str)>, usize), - __3: (usize, &'input str, usize), -) -> Expr -{ - let __start0 = __2.2.clone(); - let __end0 = __3.0.clone(); - let __temp0 = __action29( - input, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action56( - input, - __0, - __1, - __2, - __temp0, - __3, - ) -} - -pub trait __ToTriple<'input, > -{ - fn to_triple(value: Self) -> Result<(usize,Token<'input>,usize), __lalrpop_util::ParseError, &'static str>>; -} - -impl<'input, > __ToTriple<'input, > for (usize, Token<'input>, usize) -{ - fn to_triple(value: Self) -> Result<(usize,Token<'input>,usize), __lalrpop_util::ParseError, &'static str>> { - Ok(value) - } -} -impl<'input, > __ToTriple<'input, > for Result<(usize, Token<'input>, usize), &'static str> -{ - fn to_triple(value: Self) -> Result<(usize,Token<'input>,usize), __lalrpop_util::ParseError, &'static str>> { - match value { - Ok(v) => Ok(v), - Err(error) => Err(__lalrpop_util::ParseError::User { error }), - } - } -} diff --git a/git-branchless/src/revset/mod.rs b/git-branchless/src/revset/mod.rs index c953a0bee..143e6ee04 100644 --- a/git-branchless/src/revset/mod.rs +++ b/git-branchless/src/revset/mod.rs @@ -6,11 +6,14 @@ mod eval; mod parser; mod resolve; -#[rustfmt::skip] -#[allow(clippy::all, clippy::as_conversions)] -mod grammar; - pub use ast::Expr; pub use eval::eval; pub use parser::parse; pub use resolve::resolve_commits; + +use lalrpop_util::lalrpop_mod; +lalrpop_mod!( + #[allow(clippy::all, clippy::as_conversions)] + grammar, + "/revset/grammar.rs" +); diff --git a/git-branchless/src/revset/parser.rs b/git-branchless/src/revset/parser.rs index 141777616..370b89491 100644 --- a/git-branchless/src/revset/parser.rs +++ b/git-branchless/src/revset/parser.rs @@ -12,13 +12,7 @@ pub enum ParseError { /// Parse a string representing a revset expression into an [Expr]. /// -/// To update the grammar, make a change to `grammar.lalrpop`, then run -/// -/// ```text -/// lalrpop path/to/grammar.lalrpop -/// ``` -/// -/// to regenerate the source file. +/// To update the grammar, modify `grammar.lalrpop`. #[instrument] pub fn parse(s: &str) -> Result { ExprParser::new()