From bfe7ca33bd869c6a0cc6f9c44a504e223e27bfd9 Mon Sep 17 00:00:00 2001 From: Alek Ratzloff Date: Sat, 1 Apr 2023 22:34:35 -0700 Subject: [PATCH] Initial commit * Parser, compiler, objects, and VM base implementations * Stuff will print out, functions called, etc * There are probably plenty of bugs but this is a good starting point to start committing changes into git Signed-off-by: Alek Ratzloff --- .gitignore | 1 + Cargo.lock | 765 +++ Cargo.toml | 14 + build.rs | 6 + examples/hello.np | 3 + src/compile/compiler.rs | 138 + src/compile/const_table.rs | 25 + src/compile/mod.rs | 4 + src/compile/scope.rs | 79 + src/compile/thunk.rs | 52 + src/main.rs | 93 + src/obj/builtin_fun.rs | 137 + src/obj/builtins.rs | 55 + src/obj/int.rs | 53 + src/obj/mod.rs | 73 + src/obj/none.rs | 39 + src/obj/str.rs | 53 + src/obj/user_fun.rs | 50 + src/syn/ast.rs | 72 + src/syn/mod.rs | 69 + src/syn/parser.lalrpop | 62 + src/syn/parser.rs | 11540 +++++++++++++++++++++++++++++++++++ src/vm/frame.rs | 190 + src/vm/inst.rs | 32 + src/vm/mod.rs | 246 + src/vm/name.rs | 2 + 26 files changed, 13853 insertions(+) create mode 100644 .gitignore create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 build.rs create mode 100644 examples/hello.np create mode 100644 src/compile/compiler.rs create mode 100644 src/compile/const_table.rs create mode 100644 src/compile/mod.rs create mode 100644 src/compile/scope.rs create mode 100644 src/compile/thunk.rs create mode 100644 src/main.rs create mode 100644 src/obj/builtin_fun.rs create mode 100644 src/obj/builtins.rs create mode 100644 src/obj/int.rs create mode 100644 src/obj/mod.rs create mode 100644 src/obj/none.rs create mode 100644 src/obj/str.rs create mode 100644 src/obj/user_fun.rs create mode 100644 src/syn/ast.rs create mode 100644 src/syn/mod.rs create mode 100644 src/syn/parser.lalrpop create mode 100644 src/syn/parser.rs create mode 100644 src/vm/frame.rs create mode 100644 src/vm/inst.rs create mode 100644 src/vm/mod.rs create mode 100644 src/vm/name.rs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..0a4de56 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,765 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "aho-corasick" +version = "0.7.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" +dependencies = [ + "memchr", +] + +[[package]] +name = "ansi_term" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" +dependencies = [ + "winapi", +] + +[[package]] +name = "ascii-canvas" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8824ecca2e851cec16968d54a01dd372ef8f95b244fb84b84e70128be347c3c6" +dependencies = [ + "term", +] + +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi 0.1.19", + "libc", + "winapi", +] + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "bit-set" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e11e16035ea35e4e5997b393eacbf6f63983188f7a2ad25bfb13465f5ad59de" +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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "cc" +version = "1.0.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "clap" +version = "2.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" +dependencies = [ + "ansi_term", + "atty", + "bitflags", + "strsim", + "textwrap", + "unicode-width", + "vec_map", +] + +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" + +[[package]] +name = "diff" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e25ea47919b1560c4e3b7fe0aaab9becf5b84a10325ddf7db0f0ba5e1026499" + +[[package]] +name = "dirs-next" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1" +dependencies = [ + "cfg-if", + "dirs-sys-next", +] + +[[package]] +name = "dirs-sys-next" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" +dependencies = [ + "libc", + "redox_users", + "winapi", +] + +[[package]] +name = "either" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" + +[[package]] +name = "ena" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7402b94a93c24e742487327a7cd839dc9d36fec9de9fb25b09f2dae459f36c3" +dependencies = [ + "log", +] + +[[package]] +name = "errno" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50d6a0976c999d473fe89ad888d5a284e55366d9dc9038b1ba2aa15128c4afa0" +dependencies = [ + "errno-dragonfly", + "libc", + "windows-sys", +] + +[[package]] +name = "errno-dragonfly" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "fixedbitset" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" + +[[package]] +name = "gc" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3edaac0f5832202ebc99520cb77c932248010c4645d20be1dc62d6579f5b3752" +dependencies = [ + "gc_derive", +] + +[[package]] +name = "gc_derive" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60df8444f094ff7885631d80e78eb7d88c3c2361a98daaabb06256e4500db941" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "getrandom" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d39cd93900197114fa1fcb7ae84ca742095eed9442088988ae74fa744e930e77" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "hashbrown" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" + +[[package]] +name = "heck" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "hermit-abi" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +dependencies = [ + "libc", +] + +[[package]] +name = "hermit-abi" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" + +[[package]] +name = "indexmap" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282a6247722caba404c065016bbfa522806e51714c34f5dfc3e4a3a46fcb4223" +dependencies = [ + "autocfg", + "hashbrown", +] + +[[package]] +name = "instant" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "io-lifetimes" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09270fd4fa1111bc614ed2246c7ef56239a3063d5be0d1ec3b589c505d400aeb" +dependencies = [ + "hermit-abi 0.3.1", + "libc", + "windows-sys", +] + +[[package]] +name = "is-terminal" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "256017f749ab3117e93acb91063009e1f1bb56d03965b14c2c8df4eb02c524d8" +dependencies = [ + "hermit-abi 0.3.1", + "io-lifetimes", + "rustix", + "windows-sys", +] + +[[package]] +name = "itertools" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9a9d19fa1e79b6215ff29b9d6880b706147f16e9b1dbb1e4e5947b5b02bc5e3" +dependencies = [ + "either", +] + +[[package]] +name = "lalrpop" +version = "0.19.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f34313ec00c2eb5c3c87ca6732ea02dcf3af99c3ff7a8fb622ffb99c9d860a87" +dependencies = [ + "ascii-canvas", + "bit-set", + "diff", + "ena", + "is-terminal", + "itertools", + "lalrpop-util", + "petgraph", + "pico-args", + "regex", + "regex-syntax", + "string_cache", + "term", + "tiny-keccak", + "unicode-xid", +] + +[[package]] +name = "lalrpop-util" +version = "0.19.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5c1f7869c94d214466c5fd432dfed12c379fd87786768d36455892d46b18edd" +dependencies = [ + "regex", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.140" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c" + +[[package]] +name = "linux-raw-sys" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d59d8c75012853d2e872fb56bc8a2e53718e2cafe1a4c823143141c6d90c322f" + +[[package]] +name = "lock_api" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88943dd7ef4a2e5a4bfa2753aaab3013e34ce2533d1996fb18ef591e315e2b3b" +dependencies = [ + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "memchr" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" + +[[package]] +name = "new_debug_unreachable" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54" + +[[package]] +name = "not-python" +version = "0.1.0" +dependencies = [ + "gc", + "lalrpop", + "lalrpop-util", + "regex", + "structopt", +] + +[[package]] +name = "parking_lot" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" +dependencies = [ + "instant", + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216" +dependencies = [ + "cfg-if", + "instant", + "libc", + "redox_syscall", + "smallvec", + "winapi", +] + +[[package]] +name = "petgraph" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4dd7d28ee937e54fe3080c91faa1c3a46c06de6252988a7f4592ba2310ef22a4" +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 = "precomputed-hash" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" + +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + +[[package]] +name = "proc-macro2" +version = "1.0.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "quote" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "864d3e96a899863136fc6e99f3d7cae289dafe43bf2c5ac19b70df7210c0a145" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "redox_syscall" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff" +dependencies = [ + "bitflags", +] + +[[package]] +name = "redox_users" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64" +dependencies = [ + "getrandom", + "redox_syscall", +] + +[[package]] +name = "regex" +version = "1.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.6.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" + +[[package]] +name = "rustix" +version = "0.37.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e78cc525325c06b4a7ff02db283472f3c042b7ff0c391f96c6d5ac6f4f91b75" +dependencies = [ + "bitflags", + "errno", + "io-lifetimes", + "libc", + "linux-raw-sys", + "windows-sys", +] + +[[package]] +name = "rustversion" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2cc38e8fa666e2de3c4aba7edeb5ffc5246c1c2ed0e3d17e560aeeba736b23f" + +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + +[[package]] +name = "siphasher" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a86232ab60fa71287d7f2ddae4a7073f6b7aac33631c3015abb556f08c6d0a3e" + +[[package]] +name = "smallvec" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83" + +[[package]] +name = "string_cache" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33994d0838dc2d152d17a62adf608a869b5e846b65b389af7f3dbc1de45c5b26" +dependencies = [ + "lazy_static", + "new_debug_unreachable", + "parking_lot", + "phf_shared", + "precomputed-hash", +] + +[[package]] +name = "strsim" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" + +[[package]] +name = "structopt" +version = "0.3.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c6b5c64445ba8094a6ab0c3cd2ad323e07171012d9c98b0b15651daf1787a10" +dependencies = [ + "clap", + "lazy_static", + "structopt-derive", +] + +[[package]] +name = "structopt-derive" +version = "0.4.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcb5ae327f9cc13b68763b5749770cb9e048a99bd9dfdfa58d0cf05d5f64afe0" +dependencies = [ + "heck", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "syn" +version = "1.0.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a65b3f4ffa0092e9887669db0eae07941f023991ab58ea44da8fe8e2d511c6b" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "synstructure" +version = "0.12.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "unicode-xid", +] + +[[package]] +name = "term" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c59df8ac95d96ff9bede18eb7300b0fda5e5d8d90960e76f8e14ae765eedbf1f" +dependencies = [ + "dirs-next", + "rustversion", + "winapi", +] + +[[package]] +name = "textwrap" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" +dependencies = [ + "unicode-width", +] + +[[package]] +name = "tiny-keccak" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" +dependencies = [ + "crunchy", +] + +[[package]] +name = "unicode-segmentation" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e8820f5d777f6224dc4be3632222971ac30164d4a258d595640799554ebfd99" + +[[package]] +name = "unicode-width" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" + +[[package]] +name = "unicode-xid" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" + +[[package]] +name = "vec_map" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "wasi" +version = "0.10.2+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-sys" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" + +[[package]] +name = "windows_i686_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" + +[[package]] +name = "windows_i686_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..edf9593 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "not-python" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[build-dependencies] +lalrpop = "0.19.9" + +[dependencies] +lalrpop-util = { version = "0.19.9", features = ["lexer"] } +gc = { version = "0.4", features = ["derive", "nightly"] } +regex = "1" +structopt = "0.3.26" \ No newline at end of file diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..3afe285 --- /dev/null +++ b/build.rs @@ -0,0 +1,6 @@ +fn main() -> Result<(), Box> { + lalrpop::Configuration::new() + .generate_in_source_tree() + .process()?; + Ok(()) +} diff --git a/examples/hello.np b/examples/hello.np new file mode 100644 index 0000000..673ecd7 --- /dev/null +++ b/examples/hello.np @@ -0,0 +1,3 @@ +println(123); +println(None); +println("hell world"); diff --git a/src/compile/compiler.rs b/src/compile/compiler.rs new file mode 100644 index 0000000..e2a62c9 --- /dev/null +++ b/src/compile/compiler.rs @@ -0,0 +1,138 @@ +use crate::compile::{scope::GlobalScope, thunk::Thunk}; +use crate::obj::prelude::*; +use crate::obj::ObjPtr; +use crate::syn::ast::*; +use crate::vm::inst::Inst; + +pub struct Compiler { + scope: GlobalScope, +} + +impl Compiler { + pub fn new() -> Self { + Self { + scope: Default::default(), + } + } + + /// Gets the global scope. + pub fn scope(&self) -> &GlobalScope { + &self.scope + } + + /// Gets the global scope, mutably. + pub fn scope_mut(&mut self) -> &mut GlobalScope { + &mut self.scope + } + + /// Compile the given list of AST statements, returning the body. + pub fn compile_stmts(&mut self, stmts: &Vec) -> Vec { + self.gather_names(stmts); + let mut thunks = Vec::new(); + for stmt in stmts { + thunks.push(self.emit_stmt(stmt)); + } + Thunk::List(thunks).flatten() + } + + fn emit_stmt(&mut self, stmt: &SpStmt) -> Thunk { + match stmt.inner() { + Stmt::Assign(_lhs_expr, _expr) => todo!(), + Stmt::Expr(expr) => { + let mut thunk = self.emit_expr(expr); + thunk.push(Inst::Pop); + thunk + } + Stmt::If { .. } => todo!(), + Stmt::Def { .. } => todo!(), + Stmt::Import { .. } => todo!(), + } + } + + fn emit_expr(&mut self, expr: &SpExpr) -> Thunk { + match expr.inner() { + Expr::Call(expr, args) => { + let mut thunk = Vec::with_capacity(args.len() + 1); + thunk.push(self.emit_expr(expr)); + thunk.extend(args.iter().map(|arg| self.emit_expr(arg))); + let mut thunk = Thunk::List(thunk); + thunk.push(Inst::Call(args.len())); + thunk + } + Expr::Get(expr, name) => { + let mut thunk = self.emit_expr(expr); + thunk.push(Inst::GetAttr(name.clone())); + thunk + } + Expr::Atom(atom) => self.emit_atom(atom), + } + } + + fn emit_atom(&mut self, atom: &SpAtom) -> Thunk { + match atom.inner() { + Atom::Int(i) => Thunk::Block(vec![Inst::Push(ObjPtr::new(Int::new(*i)))]), + Atom::Float(_) => todo!(), // Thunk::Block(vec![Inst::Push(Gc::new(Float::new(*f)))]), + Atom::Str(s) => Thunk::Block(vec![Inst::Push(ObjPtr::new(Str::new(s.clone())))]), + Atom::Sym(_) => todo!(), + Atom::Name(n) => { + // Look up the symbol first. It may already exist. + // If it doesn't exist, create it. It may be created + // dynamically. + let name = self + .scope() + .lookup_scoped(n) + .unwrap_or_else(|| self.scope_mut().insert_local(n)); + Thunk::Block(vec![Inst::Load(name)]) + } + } + } + + /// Gather all names from the list of statements and add them to the scope. + fn gather_names(&mut self, stmts: &Vec) { + for stmt in stmts { + match stmt.inner() { + Stmt::Assign(lhs, _) => match lhs { + AssignLhs::Name(name) => { + self.scope_mut().insert_local(name); + } + AssignLhs::Complex(expr, _) => self.gather_expr_names(expr.inner()), + }, + Stmt::Def { name, .. } => { + self.scope_mut().insert_local(name); + } + Stmt::Expr(expr) => { + // Get the names of the variables used in this expr + self.gather_expr_names(expr.inner()); + } + Stmt::If { .. } => { + todo!() + } + Stmt::Import { .. } => { + todo!() + } + } + } + } + + /// Gather the names used inside of an expression, recursively. + fn gather_expr_names(&mut self, expr: &Expr) { + match expr { + Expr::Call(fun, args) => { + self.gather_expr_names(fun.inner()); + for arg in args { + self.gather_expr_names(arg.inner()); + } + } + Expr::Get(head, _) => { + self.gather_expr_names(head.inner()); + } + Expr::Atom(atom) => match atom.inner() { + Atom::Name(name) => { + self.scope_mut().insert_local(name); + } + // TODO symbols + _ => { /* no-op on non-names */ } + }, + } + } +} diff --git a/src/compile/const_table.rs b/src/compile/const_table.rs new file mode 100644 index 0000000..6986293 --- /dev/null +++ b/src/compile/const_table.rs @@ -0,0 +1,25 @@ +use std::any::{Any, TypeId}; +use std::collections::BTreeMap; + +type ConstId = usize; + +#[derive(Debug, Default)] +pub struct ConstTable { + tables: BTreeMap>>, +} + +impl ConstTable { + /// Registers a type of constant. This should be done before anything of a + /// given type is added. + pub fn register_type(&mut self) { + let type_id = TypeId::of::(); + assert!( + !self.tables.contains_key(&type_id), + "type {} already registered in const table", + std::any::type_name::() + ); + self.tables.insert(type_id, Default::default()); + } + + pub fn insert(&mut self) {} +} diff --git a/src/compile/mod.rs b/src/compile/mod.rs new file mode 100644 index 0000000..4aa27c4 --- /dev/null +++ b/src/compile/mod.rs @@ -0,0 +1,4 @@ +pub mod compiler; +//pub mod const_table; +pub mod scope; +pub mod thunk; diff --git a/src/compile/scope.rs b/src/compile/scope.rs new file mode 100644 index 0000000..82ad376 --- /dev/null +++ b/src/compile/scope.rs @@ -0,0 +1,79 @@ +use crate::vm::name::Name; +use std::collections::BTreeMap; + +pub type LocalScope = BTreeMap; + +#[derive(Debug, Default)] +pub struct GlobalScope { + names: Vec, + scopes: Vec, +} + +impl GlobalScope { + pub fn push(&mut self, local: LocalScope) { + self.scopes.push(local); + } + + pub fn pop(&mut self) -> Option { + self.scopes.pop() + } + + pub fn lookup_scoped(&self, name: &str) -> Option { + self.scopes + .iter() + .filter_map(|names| { + names + .iter() + .find(|(_, s)| s.as_str() == name) + .map(|(n, _)| *n) + }) + .next() + } + + pub fn lookup_local(&self, name: &str) -> Option { + self.scopes.last().and_then(|names| { + names + .iter() + .find(|(_, s)| s.as_str() == name) + .map(|(n, _)| *n) + }) + } + + pub fn insert_local(&mut self, name: impl ToString) -> Name { + let name = name.to_string(); + if let Some(local) = self.lookup_local(&name) { + local + } else { + let next = Name(self.names.len()); + self.names.push(name.clone()); + let top = self.scopes.last_mut().expect("no scope"); + top.insert(next, name); + next + } + } +} + +#[test] +fn test_global_scope_insert() { + let mut scope = GlobalScope::default(); + scope.push(Default::default()); + assert_eq!(scope.insert_local("zero"), Name(0)); + assert_eq!(scope.insert_local("zero"), Name(0)); + assert_eq!(scope.insert_local("one"), Name(1)); + assert_eq!(scope.insert_local("zero"), Name(0)); + assert_eq!(scope.insert_local("one"), Name(1)); + scope.push(Default::default()); + assert_eq!(scope.insert_local("zero"), Name(2)); + assert_eq!(scope.insert_local("one"), Name(3)); + assert_eq!(scope.insert_local("zero"), Name(2)); + assert_eq!(scope.insert_local("one"), Name(3)); + scope.push(Default::default()); + assert_eq!(scope.insert_local("zero"), Name(4)); + assert_eq!(scope.insert_local("one"), Name(5)); + scope.pop().unwrap(); + assert_eq!(scope.insert_local("zero"), Name(2)); + assert_eq!(scope.insert_local("one"), Name(3)); + scope.pop().unwrap(); + assert_eq!(scope.insert_local("zero"), Name(0)); + assert_eq!(scope.insert_local("one"), Name(1)); +} diff --git a/src/compile/thunk.rs b/src/compile/thunk.rs new file mode 100644 index 0000000..ede8107 --- /dev/null +++ b/src/compile/thunk.rs @@ -0,0 +1,52 @@ +use crate::vm::inst::Inst; + +pub enum Thunk { + Block(Vec), + List(Vec), + /* + IfElse { + cond: Box, + if_true: Box, + if_false: Box, + }, + */ +} + +impl Thunk { + pub fn flatten(self) -> Vec { + use Thunk::*; + match self { + Block(block) => block, + List(list) => list.into_iter().flat_map(|thunk| thunk.flatten()).collect(), + /* + IfElse { .. } => { + todo!("flatten if/else") + } + */ + } + } + + pub fn push(&mut self, inst: Inst) { + use Thunk::*; + match self { + Block(block) => { + block.push(inst); + } + List(list) => { + if let Some(Block(last)) = list.last_mut() { + // if this is a block, then push the inst to the end of the + // block instead of creating a new element + last.push(inst); + } else { + // otherwise, push a new list block + list.push(Block(vec![inst])); + } + } /* + IfElse { .. } => { + // replace this with a List type, with *self as the first element + todo!() + } + */ + } + } +} diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..d53dd62 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,93 @@ +#![feature(lazy_cell)] +mod compile; +mod obj; +mod syn; +mod vm; + +use std::io::Read; +use std::path::PathBuf; +use structopt::StructOpt; +use vm::inst::Inst; + +use crate::obj::prelude::*; +use crate::vm::frame::{Frame, UserFrame}; + +#[derive(Debug, StructOpt)] +struct Opt { + #[structopt(name = "PATH", parse(from_os_str))] + path: Option, +} + +type Result> = std::result::Result; + +fn main() -> Result { + let opt = Opt::from_args(); + + let (text, _path) = if let Some(path) = opt.path.as_ref() { + (std::fs::read_to_string(path)?, path.display().to_string()) + } else { + let mut input = String::new(); + std::io::stdin().read_to_string(&mut input)?; + (input, "".to_string()) + }; + + let stmts = syn::parser::FileParser::new().parse(&text).unwrap(); + //println!("{:#?}", stmts); + let builtin_names: &[(&str, ObjPtr)] = &[("None", ObjPtr::clone(&NONE_INST))]; + + let (mut exec_body, scope) = { + let mut compiler = compile::compiler::Compiler::new(); + compiler.scope_mut().push(Default::default()); + + // add builtin function names + for (name, _ptr) in BUILTIN_FUNS { + compiler.scope_mut().insert_local(name); + } + + for (name, _ptr) in builtin_names { + compiler.scope_mut().insert_local(name); + } + + let exec_body = compiler.compile_stmts(&stmts); + let scope = compiler.scope_mut().pop().unwrap(); + (exec_body, scope) + }; + + // XXX + // Push the return statement to the end of the body since this doesn't get + // added otherwise. + exec_body.push(Inst::Push(ObjPtr::new(Int::new(0)))); + exec_body.push(Inst::Return); + + //println!("{:#?}", exec_body); + + let locals: Vec<_> = scope.keys().copied().collect(); + let main_fun: ObjPtr<_> = UserFun::new(None, vec![], locals, exec_body).into(); + + // Add the __main__ value + let mut main_frame = UserFrame::new(main_fun.clone(), vec![], 0); + // Add builtin functions + for (name, ptr) in BUILTIN_FUNS { + let (opaque_name, _) = scope.iter().find(|(_, v)| v == name).unwrap(); + main_frame.locals_mut().insert( + *opaque_name, + Some(ObjPtr::new(BuiltinFun::new(name.to_string(), *ptr))), + ); + } + // Add builtin values + for (name, ptr) in builtin_names { + let (opaque_name, _) = scope.iter().find(|(_, v)| v == name).unwrap(); + main_frame + .locals_mut() + .insert(*opaque_name, Some(ObjPtr::clone(ptr))); + } + //main_frame.locals_mut().insert(main_name, main_fun); + + let mut vm = crate::vm::Vm::new(); + vm.frames_mut().push(Frame::User(main_frame)); + + // Start 'er up + vm.resume(); + + Ok(()) +} diff --git a/src/obj/builtin_fun.rs b/src/obj/builtin_fun.rs new file mode 100644 index 0000000..f755fbd --- /dev/null +++ b/src/obj/builtin_fun.rs @@ -0,0 +1,137 @@ +use std::fmt; + +use crate::vm::frame::Frame; +use crate::{obj::prelude::*, vm::Vm}; + +pub type BuiltinFunPtr = fn(BuiltinFunVm, Vec, BuiltinFunState) -> BuiltinFunResult; + +#[macro_export] +macro_rules! builtin_fun { + ($name:expr, $ptr:expr) => { + $crate::obj::builtin_fun::BuiltinFun::new($name.into(), $ptr) + }; +} + +#[macro_export] +macro_rules! builtin_fun_ptr { + ($($tt:tt)+) => { $crate::obj::ObjPtr::new(builtin_fun!($($tt)+)) }; +} + +pub use builtin_fun; +pub use builtin_fun_ptr; + +/// A result from a builtin function. +#[derive(Debug)] +pub enum BuiltinFunResult { + /// Return the given optional object. + Return(Option), + /// Yield function execution to the given stack frame. + Yield(Frame), +} + +/// A builtin function may be resumed after it's done calling a user-defined +/// function. This enum determines what the function execution context is. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum BuiltinFunState { + /// This function is being called for the first time. + Begin, + /// This function is being resumed after yielding control to some other function. + Resume(usize), +} + +impl BuiltinFunState { + pub fn next(&self) -> Self { + match self { + BuiltinFunState::Begin => BuiltinFunState::Resume(0), + BuiltinFunState::Resume(n) => BuiltinFunState::Resume(n + 1), + } + } +} + +/// This is a wrapper structure around the VM that provides an API to a +/// `BuiltinFun` function call. +/// +/// It has some extra checks that prevent the VM being used in a weird/unexpected way. +pub struct BuiltinFunVm<'vm> { + vm: &'vm mut Vm, + last_sp: usize, +} + +impl<'vm> BuiltinFunVm<'vm> { + pub fn new(vm: &'vm mut Vm, last_sp: usize) -> Self { + Self { vm, last_sp } + } + + pub fn stack(&self) -> &Vec { + self.vm.stack() + } + + pub fn make_frame(&self, fun: ObjPtr, args: Vec) -> Option { + self.vm.make_frame(fun, args) + } + + pub fn push_stack(&mut self, value: ObjPtr) { + self.vm.push_stack(value); + } + + pub fn pop_stack(&mut self) -> Option { + if self.stack().len() <= self.last_sp { + panic!("Tried to underflow stack in BuiltinFun call "); + } + self.pop_stack_unchecked() + } + + pub fn pop_stack_unchecked(&mut self) -> Option { + self.vm.pop_stack() + } +} + +pub struct BuiltinFun { + name: String, + fun: BuiltinFunPtr, + attrs: AttrsPtr, +} + +impl fmt::Debug for BuiltinFun { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BuiltinFun") + .field("name", &self.name) + .field( + "fun", + &format!( + "", + (&self.fun as *const _) as usize + ), + ) + .field("attrs", &self.attrs) + .finish() + } +} + +impl BuiltinFun { + pub fn new(name: String, fun: BuiltinFunPtr) -> Self { + Self { + name, + fun, + attrs: Default::default(), + } + } + + pub fn fun(&self) -> BuiltinFunPtr { + self.fun + } + + pub fn name(&self) -> &String { + &self.name + } +} + +impl Obj for BuiltinFun { + fn attrs(&self) -> AttrsPtr { + AttrsPtr::clone(&self.attrs) + } + + fn as_any(&self) -> &(dyn std::any::Any + 'static) { + self + } +} diff --git a/src/obj/builtins.rs b/src/obj/builtins.rs new file mode 100644 index 0000000..787b711 --- /dev/null +++ b/src/obj/builtins.rs @@ -0,0 +1,55 @@ +//! Builtin functions and objects. +use crate::obj::prelude::*; + +pub const BUILTIN_FUNS: &[(&str, BuiltinFunPtr)] = &[ + // + ("println", println), + ("print", print), +]; + +fn println(vm: BuiltinFunVm, args: Vec, state: BuiltinFunState) -> BuiltinFunResult { + do_print(vm, args, state, "\n") +} + +fn print(vm: BuiltinFunVm, args: Vec, state: BuiltinFunState) -> BuiltinFunResult { + do_print(vm, args, state, "") +} + +/// Shared logic of `print` and `println`. +/// It can append a string to the end of whatever is being printed. +fn do_print( + mut vm: BuiltinFunVm, + args: Vec, + state: BuiltinFunState, + end: &str, +) -> BuiltinFunResult { + const POST_CALL_STR: BuiltinFunState = BuiltinFunState::Resume(0); + + if state == BuiltinFunState::Begin { + if args.len() == 0 { + println!(); + return BuiltinFunResult::Return(None); + } else if args.len() != 1 { + todo!("Throw exception: arity error"); + } + + let arg = ObjPtr::clone(&args[0]); + let str_fun = arg.get("__str__").expect("No __str__ function?"); + let frame = vm + .make_frame(str_fun, vec![arg]) + .expect("__str__ attr was not a function?"); + BuiltinFunResult::Yield(frame) + } else if state == POST_CALL_STR { + // Get return value, cast it as an `Any`, and then downcast to a string. + let result = vm.pop_stack().expect("No return value from __str__?"); + let result_any = result.as_any(); + if let Some(value) = result_any.downcast_ref::() { + print!("{}{}", value.value(), end); + } else { + todo!("Throw exception: __str__ function didn't return a Str?"); + } + BuiltinFunResult::Return(None) + } else { + panic!("unexpected state: {state:?}"); + } +} diff --git a/src/obj/int.rs b/src/obj/int.rs new file mode 100644 index 0000000..3f372a8 --- /dev/null +++ b/src/obj/int.rs @@ -0,0 +1,53 @@ +use crate::obj::prelude::*; +use std::{any::Any, sync::LazyLock}; + +pub type IntValue = i64; + +static INT_ATTRS: LazyLock = LazyLock::new(|| { + attrs_ptr! { + // + "__str__" => builtin_fun_ptr!("__str__", |_vm, args, _state| { + if args.len() != 1 { + todo!("Throw exception: arity error"); + } + let arg_any = &args[0].as_any(); + let obj = arg_any.downcast_ref::().expect("Int.__str__ did not receive Int?"); + + BuiltinFunResult::Return(Some(ObjPtr::new(Str::new(obj.value().to_string())))) + }), + } +}); + +#[derive(Debug, Clone)] +pub struct Int { + attrs: AttrsPtr, + value: IntValue, +} + +impl Int { + pub fn new(value: IntValue) -> Self { + let attrs = AttrsPtr::clone(&INT_ATTRS); + // TODO intern + Int { attrs, value } + } + + pub fn value(&self) -> IntValue { + self.value + } +} + +impl Obj for Int { + fn attrs(&self) -> AttrsPtr { + AttrsPtr::clone(&self.attrs) + } + + fn as_any(&self) -> &(dyn Any + 'static) { + self + } +} + +impl ToString for Int { + fn to_string(&self) -> String { + format!("{}", self.value()) + } +} diff --git a/src/obj/mod.rs b/src/obj/mod.rs new file mode 100644 index 0000000..404a352 --- /dev/null +++ b/src/obj/mod.rs @@ -0,0 +1,73 @@ +pub mod builtin_fun; +pub mod builtins; +pub mod int; +pub mod none; +pub mod str; +pub mod user_fun; + +pub mod prelude { + // Module types + pub use super::{builtin_fun::*, int::*, none::*, str::*, user_fun::*}; + // Local types + pub use super::{Attrs, AttrsPtr, Obj, ObjPtr}; + // Macros + pub use super::{attrs, attrs_ptr}; + // Builtins + pub use super::builtins::*; +} + +use std::any::Any; +use std::collections::HashMap; +use std::fmt::Debug; +use std::sync::{Arc, RwLock}; + +// Macro definitions + +#[macro_export] +macro_rules! attrs { + ($($key:expr => $value:expr),* $(,)?) => {{ + let mut __attrs = $crate::obj::Attrs::new(); + $( + __attrs.insert($key.into(), $value); + )* + __attrs + }}; +} + +#[macro_export] +macro_rules! attrs_ptr { + ($($tt:tt)*) => {{ + $crate::obj::AttrsPtr::new( + std::sync::RwLock::new( + attrs! { + $($tt)* + } + ) + ) + }}; +} + +pub use attrs; +pub use attrs_ptr; + +pub type ObjPtr = Arc; +pub type Attrs = HashMap; +pub type AttrsPtr = Arc>; + +pub trait Obj: Debug + Sync + Send { + fn attrs(&self) -> AttrsPtr; + + fn as_any(&self) -> &(dyn Any + 'static); + + fn get(&self, key: &str) -> Option { + let attrs_ptr = self.attrs(); + let attrs = attrs_ptr.read().unwrap(); + attrs.get(key).cloned() + } + + fn set(&mut self, key: String, value: ObjPtr) -> Option { + let attrs_ptr = self.attrs(); + let mut attrs = attrs_ptr.write().unwrap(); + attrs.insert(key, value) + } +} diff --git a/src/obj/none.rs b/src/obj/none.rs new file mode 100644 index 0000000..61a8ebe --- /dev/null +++ b/src/obj/none.rs @@ -0,0 +1,39 @@ +use crate::obj::prelude::*; +use std::{any::Any, sync::LazyLock}; + +pub static NONE_INST: LazyLock = LazyLock::new(|| ObjPtr::new(None::new())); +static NONE_STR: LazyLock = LazyLock::new(|| ObjPtr::new(Str::new("None"))); + +static NONE_ATTRS: LazyLock = LazyLock::new(|| { + attrs_ptr! { + // + "__str__" => builtin_fun_ptr!("__str__", |_vm, args, _state| { + if args.len() != 1 { + todo!("Throw exception: arity error"); + } + BuiltinFunResult::Return(Some(ObjPtr::clone(&NONE_STR))) + }), + } +}); + +#[derive(Debug)] +pub struct None { + attrs: AttrsPtr, +} + +impl None { + fn new() -> Self { + let attrs = AttrsPtr::clone(&NONE_ATTRS); + Self { attrs } + } +} + +impl Obj for None { + fn attrs(&self) -> AttrsPtr { + AttrsPtr::clone(&self.attrs) + } + + fn as_any(&self) -> &(dyn Any + 'static) { + self + } +} diff --git a/src/obj/str.rs b/src/obj/str.rs new file mode 100644 index 0000000..fdfe13c --- /dev/null +++ b/src/obj/str.rs @@ -0,0 +1,53 @@ +use crate::obj::prelude::*; +use std::{any::Any, sync::LazyLock}; + +pub type StrValue = String; + +static STR_ATTRS: LazyLock = LazyLock::new(|| { + attrs_ptr! { + // + "__str__" => builtin_fun_ptr!("__str__", |_vm, mut args, _state| { + if args.len() != 1 { + todo!("Throw exception: arity error"); + } + BuiltinFunResult::Return(Some(args.pop().unwrap())) + }), + } +}); + +#[derive(Debug, Clone)] +pub struct Str { + attrs: AttrsPtr, + value: StrValue, +} + +impl Str { + pub fn new(value: impl Into) -> Self { + let attrs = AttrsPtr::clone(&STR_ATTRS); + // TODO intern + Str { + attrs, + value: value.into(), + } + } + + pub fn value(&self) -> &StrValue { + &self.value + } +} + +impl Obj for Str { + fn attrs(&self) -> AttrsPtr { + AttrsPtr::clone(&self.attrs) + } + + fn as_any(&self) -> &(dyn Any + 'static) { + self + } +} + +impl ToString for Str { + fn to_string(&self) -> String { + self.value().clone() + } +} diff --git a/src/obj/user_fun.rs b/src/obj/user_fun.rs new file mode 100644 index 0000000..6a470ff --- /dev/null +++ b/src/obj/user_fun.rs @@ -0,0 +1,50 @@ +use crate::obj::prelude::*; +use crate::vm::{inst::Inst, name::Name}; + +#[derive(Debug)] +pub struct UserFun { + name: Option, + params: Vec, + locals: Vec, + body: Vec, + attrs: AttrsPtr, +} + +impl UserFun { + pub fn new(name: Option, params: Vec, locals: Vec, body: Vec) -> Self { + Self { + name, + params, + locals, + body, + attrs: Default::default(), + } + } + + /// Returns the name of this function, `None` if it is anonymous. + pub fn name(&self) -> Option { + self.name + } + + pub fn params(&self) -> &Vec { + &self.params + } + + pub fn locals(&self) -> &Vec { + &self.locals + } + + pub fn body(&self) -> &Vec { + &self.body + } +} + +impl Obj for UserFun { + fn attrs(&self) -> AttrsPtr { + AttrsPtr::clone(&self.attrs) + } + + fn as_any(&self) -> &(dyn std::any::Any + 'static) { + self + } +} diff --git a/src/syn/ast.rs b/src/syn/ast.rs new file mode 100644 index 0000000..082fd05 --- /dev/null +++ b/src/syn/ast.rs @@ -0,0 +1,72 @@ +use crate::syn::Spanned; + +#[derive(Debug, Clone)] +pub enum Stmt { + Assign(AssignLhs, Expr), + Expr(SpExpr), + If { + if_true: SpCondExpr, + elseif: Vec, + else_expr: Option, + }, + Def { + name: String, + params: Vec, + body: Vec, + }, + Import { + target: String, + from: Option, + }, +} + +#[derive(Debug, Clone)] +pub enum AssignLhs { + /// A simple assignment. + /// + /// `x = foo` + Name(String), + + /// A more complex assignment. + /// + /// `x().bar = foo` + Complex(SpExpr, String), +} + +pub type SpStmt = Spanned; + +#[derive(Debug, Clone)] +pub struct CondExpr { + pub cond: SpExpr, + pub expr: SpExpr, +} + +pub type SpCondExpr = Spanned; + +#[derive(Debug, Clone)] +pub struct Param { + pub name: String, + pub ty: Option, +} + +pub type SpParam = Spanned; + +#[derive(Debug, Clone)] +pub enum Expr { + Call(Box, Vec), + Get(Box, String), + Atom(SpAtom), +} + +pub type SpExpr = Spanned; + +#[derive(Debug, Clone)] +pub enum Atom { + Int(i64), + Float(f64), + Str(String), + Sym(String), + Name(String), +} + +pub type SpAtom = Spanned; diff --git a/src/syn/mod.rs b/src/syn/mod.rs new file mode 100644 index 0000000..c87afda --- /dev/null +++ b/src/syn/mod.rs @@ -0,0 +1,69 @@ +// TODO - remove this when we start working on the syntax again +#![allow(unused)] + +pub mod ast; +pub mod parser; + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub struct Span { + start: usize, + end: usize, +} + +impl Span { + pub fn new(start: usize, end: usize) -> Self { + Self { start, end } + } + + pub fn start(&self) -> usize { + self.start + } + + pub fn end(&self) -> usize { + self.end + } +} + +#[derive(Debug, Clone)] +pub struct Spanned { + span: Span, + inner: T, +} + +impl Spanned { + pub fn new(span: Span, inner: T) -> Self { + Self { span, inner } + } + + pub fn span(&self) -> &Span { + &self.span + } + + pub fn inner(&self) -> &T { + &self.inner + } + + pub fn into_inner(self) -> T { + self.inner + } + + pub fn split(self) -> (Span, T) { + (self.span, self.inner) + } +} + +pub(self) fn unescape(s: impl ToString) -> String { + const REPLACE: &[(&str, &str)] = &[ + (r"\\", r"\"), + ("\\n", "\n"), + ("\\t", "\t"), + ("\\r", "\r"), + ("\\\"", "\""), + ("\\\'", "\'"), + ]; + let mut s = s.to_string(); + for (old, new) in REPLACE { + s = s.replace(old, new); + } + s +} diff --git a/src/syn/parser.lalrpop b/src/syn/parser.lalrpop new file mode 100644 index 0000000..37a77c9 --- /dev/null +++ b/src/syn/parser.lalrpop @@ -0,0 +1,62 @@ +use std::str::FromStr; +use crate::syn::{Span, Spanned, unescape}; +use crate::syn::ast::*; + + +grammar; + +Spanned: Spanned = { + => Spanned::new(Span::new(start, end), inner), +}; + +pub File: Vec = { + ";")*> => { + if let Some(tail) = tail { + head.push(tail); + } + head + }, +} + +pub SpStmt = Spanned; + +pub Stmt: Stmt = { + => Stmt::Expr(<>), +} + +pub SpExpr = Spanned; + +pub Expr: Expr = { + "(" ",")*> ")" => { + let argv = match last { + Some(expr) => { + argv.push(expr); + argv + } + None => argv, + }; + Expr::Call(Box::new(fun), argv) + }, + => Expr::Atom(atom), + "(" ")" => expr, +}; + + +pub SpAtom = Spanned; + +pub Atom: Atom = { + => Atom::Str(s), + => Atom::Int(n), + => Atom::Name(name), +}; + +Int: i64 = => i64::from_str(s).unwrap(); +Str: String = { + // NOTE - doing 1 .. s.len() - 1 is safe because these are ascii characters + // and will always be one byte + => unescape(&s[1..s.len() - 1]), + => unescape(&s[1..s.len() - 1]), +} +Name: String = { + => s.to_string(), +} \ No newline at end of file diff --git a/src/syn/parser.rs b/src/syn/parser.rs new file mode 100644 index 0000000..d6866e0 --- /dev/null +++ b/src/syn/parser.rs @@ -0,0 +1,11540 @@ +// auto-generated: "lalrpop 0.19.9" +// sha3: 9f2f643359fa262b9e763802a5a6af68d8022e5e2da5a7822efcb3749ed1b711 +use std::str::FromStr; +use crate::syn::{Span, Spanned, unescape}; +use crate::syn::ast::*; +#[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__Atom { + #![allow(non_snake_case, non_camel_case_types, unused_mut, unused_variables, unused_imports, unused_parens, clippy::all)] + + use std::str::FromStr; + use crate::syn::{Span, Spanned, unescape}; + use crate::syn::ast::*; + #[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(Spanned), + Variant2(alloc::vec::Vec>), + Variant3(Spanned), + Variant4(alloc::vec::Vec>), + Variant5(usize), + Variant6(Atom), + Variant7(Expr), + Variant8(Vec), + Variant9(i64), + Variant10(String), + Variant11(Spanned), + Variant12(core::option::Option>), + Variant13(core::option::Option>), + Variant14(Stmt), + } + const __ACTION: &[i8] = &[ + // State 0 + 0, 0, 0, 0, 6, 7, 8, 9, + // State 1 + 0, 0, 0, 0, 0, 0, 0, 0, + // State 2 + 0, 0, 0, 0, 0, 0, 0, 0, + // State 3 + 0, 0, 0, 0, 0, 0, 0, 0, + // State 4 + 0, 0, 0, 0, 0, 0, 0, 0, + // State 5 + 0, 0, 0, 0, 0, 0, 0, 0, + // State 6 + 0, 0, 0, 0, 0, 0, 0, 0, + // State 7 + 0, 0, 0, 0, 0, 0, 0, 0, + // State 8 + 0, 0, 0, 0, 0, 0, 0, 0, + ]; + fn __action(state: i8, integer: usize) -> i8 { + __ACTION[(state as usize) * 8 + integer] + } + const __EOF_ACTION: &[i8] = &[ + // State 0 + 0, + // State 1 + -41, + // State 2 + -14, + // State 3 + -15, + // State 4 + -13, + // State 5 + -39, + // State 6 + -40, + // State 7 + -26, + // State 8 + -27, + ]; + fn __goto(state: i8, nt: usize) -> i8 { + match nt { + 8 => 1, + 11 => 2, + 12 => 3, + 22 => 4, + _ => 0, + } + } + fn __expected_tokens(__state: i8) -> alloc::vec::Vec { + const __TERMINAL: &[&str] = &[ + r###""(""###, + r###"")""###, + r###"",""###, + r###"";""###, + r###"r#"\"([^\"\\\\]|\\\\[ntr\"'\\\\])*\""#"###, + r###"r#"'([^\"\\\\]|\\\\[ntr\"'\\\\])*'"#"###, + r###"r#"[0-9]+"#"###, + r###"r#"[a-zA-Z_][a-zA-Z0-9_]*"#"###, + ]; + __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 = Atom; + 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, 8 - 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(4, _) if true => Some(0), + Token(5, _) if true => Some(1), + Token(6, _) if true => Some(2), + Token(7, _) if true => Some(3), + Token(0, _) if true => Some(4), + Token(1, _) if true => Some(5), + Token(2, _) if true => Some(6), + Token(3, _) if true => Some(7), + _ => 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 => match __token { + Token(4, __tok0) | Token(5, __tok0) | Token(6, __tok0) | Token(7, __tok0) | Token(0, __tok0) | Token(1, __tok0) | Token(2, __tok0) | Token(3, __tok0) if true => __Symbol::Variant0(__tok0), + _ => unreachable!(), + }, + _ => unreachable!(), + } + } + pub struct AtomParser { + builder: __lalrpop_util::lexer::MatcherBuilder, + _priv: (), + } + + impl AtomParser { + pub fn new() -> AtomParser { + let __builder = super::__intern_token::new_builder(); + AtomParser { + 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 => { + // __Atom = Atom => ActionFn(6); + let __sym0 = __pop_Variant6(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action6::<>(input, __sym0); + return Some(Ok(__nt)); + } + 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::<(&())>) + } + _ => 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_Variant6< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, Atom, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant6(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant7< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, Expr, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant7(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant11< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, Spanned, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant11(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant1< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, Spanned, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant1(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant3< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, Spanned, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant3(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant14< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, Stmt, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant14(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant10< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, String, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant10(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant8< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, Vec, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant8(__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>, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant2(__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>, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant4(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant12< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, core::option::Option>, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant12(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant13< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, core::option::Option>, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant13(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant9< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, i64, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant9(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant5< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, usize, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant5(__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() + } + } + 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) + { + // ( ",") = SpExpr, "," => ActionFn(27); + assert!(__symbols.len() >= 2); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym1.2.clone(); + let __nt = super::__action27::<>(input, __sym0, __sym1); + __symbols.push((__start, __Symbol::Variant1(__nt), __end)); + (2, 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(25); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); + let __end = __start.clone(); + let __nt = super::__action25::<>(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(26); + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action26::<>(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) + { + // ( ",")+ = SpExpr, "," => ActionFn(41); + assert!(__symbols.len() >= 2); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym1.2.clone(); + let __nt = super::__action41::<>(input, __sym0, __sym1); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (2, 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) + { + // ( ",")+ = ( ",")+, SpExpr, "," => ActionFn(42); + assert!(__symbols.len() >= 3); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant1(__symbols); + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym2.2.clone(); + let __nt = super::__action42::<>(input, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (3, 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) + { + // ( ";") = SpStmt, ";" => ActionFn(34); + assert!(__symbols.len() >= 2); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym1.2.clone(); + let __nt = super::__action34::<>(input, __sym0, __sym1); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (2, 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(32); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); + let __end = __start.clone(); + let __nt = super::__action32::<>(input, &__start, &__end); + __symbols.push((__start, __Symbol::Variant4(__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(33); + let __sym0 = __pop_Variant4(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action33::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant4(__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) + { + // ( ";")+ = SpStmt, ";" => ActionFn(45); + assert!(__symbols.len() >= 2); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym1.2.clone(); + let __nt = super::__action45::<>(input, __sym0, __sym1); + __symbols.push((__start, __Symbol::Variant4(__nt), __end)); + (2, 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) + { + // ( ";")+ = ( ";")+, SpStmt, ";" => ActionFn(46); + assert!(__symbols.len() >= 3); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant3(__symbols); + let __sym0 = __pop_Variant4(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym2.2.clone(); + let __nt = super::__action46::<>(input, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant4(__nt), __end)); + (3, 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) + { + // @L = => ActionFn(40); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); + let __end = __start.clone(); + let __nt = super::__action40::<>(input, &__start, &__end); + __symbols.push((__start, __Symbol::Variant5(__nt), __end)); + (0, 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) + { + // @R = => ActionFn(39); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); + let __end = __start.clone(); + let __nt = super::__action39::<>(input, &__start, &__end); + __symbols.push((__start, __Symbol::Variant5(__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) + { + // Atom = Str => ActionFn(15); + let __sym0 = __pop_Variant10(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action15::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant6(__nt), __end)); + (1, 8) + } + 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) + { + // Atom = Int => ActionFn(16); + let __sym0 = __pop_Variant9(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action16::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant6(__nt), __end)); + (1, 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) + { + // Atom = Name => ActionFn(17); + let __sym0 = __pop_Variant10(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action17::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant6(__nt), __end)); + (1, 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) + { + // Expr = SpExpr, "(", SpExpr, ")" => ActionFn(55); + assert!(__symbols.len() >= 4); + let __sym3 = __pop_Variant0(__symbols); + let __sym2 = __pop_Variant1(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym3.2.clone(); + let __nt = super::__action55::<>(input, __sym0, __sym1, __sym2, __sym3); + __symbols.push((__start, __Symbol::Variant7(__nt), __end)); + (4, 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) + { + // Expr = SpExpr, "(", ")" => ActionFn(56); + assert!(__symbols.len() >= 3); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym2.2.clone(); + let __nt = super::__action56::<>(input, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant7(__nt), __end)); + (3, 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) + { + // Expr = SpExpr, "(", ( ",")+, SpExpr, ")" => ActionFn(57); + assert!(__symbols.len() >= 5); + let __sym4 = __pop_Variant0(__symbols); + let __sym3 = __pop_Variant1(__symbols); + let __sym2 = __pop_Variant2(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym4.2.clone(); + let __nt = super::__action57::<>(input, __sym0, __sym1, __sym2, __sym3, __sym4); + __symbols.push((__start, __Symbol::Variant7(__nt), __end)); + (5, 9) + } + 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) + { + // Expr = SpExpr, "(", ( ",")+, ")" => ActionFn(58); + assert!(__symbols.len() >= 4); + let __sym3 = __pop_Variant0(__symbols); + let __sym2 = __pop_Variant2(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym3.2.clone(); + let __nt = super::__action58::<>(input, __sym0, __sym1, __sym2, __sym3); + __symbols.push((__start, __Symbol::Variant7(__nt), __end)); + (4, 9) + } + 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) + { + // Expr = SpAtom => ActionFn(12); + let __sym0 = __pop_Variant11(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action12::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant7(__nt), __end)); + (1, 9) + } + 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) + { + // Expr = "(", Expr, ")" => ActionFn(13); + assert!(__symbols.len() >= 3); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant7(__symbols); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym2.2.clone(); + let __nt = super::__action13::<>(input, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant7(__nt), __end)); + (3, 9) + } + 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) + { + // File = SpStmt => ActionFn(59); + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action59::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant8(__nt), __end)); + (1, 10) + } + 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) + { + // File = => ActionFn(60); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); + let __end = __start.clone(); + let __nt = super::__action60::<>(input, &__start, &__end); + __symbols.push((__start, __Symbol::Variant8(__nt), __end)); + (0, 10) + } + 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) + { + // File = ( ";")+, SpStmt => ActionFn(61); + assert!(__symbols.len() >= 2); + let __sym1 = __pop_Variant3(__symbols); + let __sym0 = __pop_Variant4(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym1.2.clone(); + let __nt = super::__action61::<>(input, __sym0, __sym1); + __symbols.push((__start, __Symbol::Variant8(__nt), __end)); + (2, 10) + } + 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) + { + // File = ( ";")+ => ActionFn(62); + let __sym0 = __pop_Variant4(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action62::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant8(__nt), __end)); + (1, 10) + } + 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) + { + // Int = r#"[0-9]+"# => ActionFn(18); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action18::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant9(__nt), __end)); + (1, 11) + } + 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) + { + // Name = r#"[a-zA-Z_][a-zA-Z0-9_]*"# => ActionFn(21); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action21::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant10(__nt), __end)); + (1, 12) + } + 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) + { + // SpAtom = Spanned => ActionFn(14); + let __sym0 = __pop_Variant11(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action14::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant11(__nt), __end)); + (1, 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) + { + // SpExpr = Spanned => ActionFn(10); + let __sym0 = __pop_Variant1(__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, 14) + } + 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) + { + // SpExpr? = SpExpr => ActionFn(23); + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action23::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant12(__nt), __end)); + (1, 15) + } + 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) + { + // SpExpr? = => ActionFn(24); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); + let __end = __start.clone(); + let __nt = super::__action24::<>(input, &__start, &__end); + __symbols.push((__start, __Symbol::Variant12(__nt), __end)); + (0, 15) + } + 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) + { + // SpStmt = Spanned => ActionFn(8); + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action8::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (1, 16) + } + 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) + { + // SpStmt? = SpStmt => ActionFn(30); + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action30::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant13(__nt), __end)); + (1, 17) + } + 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) + { + // SpStmt? = => ActionFn(31); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); + let __end = __start.clone(); + let __nt = super::__action31::<>(input, &__start, &__end); + __symbols.push((__start, __Symbol::Variant13(__nt), __end)); + (0, 17) + } + 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) + { + // Spanned = Atom => ActionFn(52); + let __sym0 = __pop_Variant6(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action52::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant11(__nt), __end)); + (1, 18) + } + 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) + { + // Spanned = Expr => ActionFn(53); + let __sym0 = __pop_Variant7(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action53::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant1(__nt), __end)); + (1, 19) + } + 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) + { + // Spanned = Stmt => ActionFn(54); + let __sym0 = __pop_Variant14(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action54::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (1, 20) + } + 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) + { + // Stmt = SpExpr => ActionFn(9); + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action9::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant14(__nt), __end)); + (1, 21) + } + 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) + { + // Str = r#"\"([^\"\\\\]|\\\\[ntr\"'\\\\])*\""# => ActionFn(19); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action19::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant10(__nt), __end)); + (1, 22) + } + 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) + { + // Str = r#"'([^\"\\\\]|\\\\[ntr\"'\\\\])*'"# => ActionFn(20); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action20::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant10(__nt), __end)); + (1, 22) + } + 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(4); + let __sym0 = __pop_Variant7(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action4::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant7(__nt), __end)); + (1, 24) + } + 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) + { + // __File = File => ActionFn(0); + let __sym0 = __pop_Variant8(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action0::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant8(__nt), __end)); + (1, 25) + } + 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) + { + // __SpAtom = SpAtom => ActionFn(5); + let __sym0 = __pop_Variant11(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action5::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant11(__nt), __end)); + (1, 26) + } + 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) + { + // __SpExpr = SpExpr => ActionFn(3); + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action3::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant1(__nt), __end)); + (1, 27) + } + 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) + { + // __SpStmt = SpStmt => ActionFn(1); + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action1::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (1, 28) + } + 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) + { + // __Stmt = Stmt => ActionFn(2); + let __sym0 = __pop_Variant14(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action2::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant14(__nt), __end)); + (1, 29) + } +} +pub use self::__parse__Atom::AtomParser; + +#[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 std::str::FromStr; + use crate::syn::{Span, Spanned, unescape}; + use crate::syn::ast::*; + #[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(Spanned), + Variant2(alloc::vec::Vec>), + Variant3(Spanned), + Variant4(alloc::vec::Vec>), + Variant5(usize), + Variant6(Atom), + Variant7(Expr), + Variant8(Vec), + Variant9(i64), + Variant10(String), + Variant11(Spanned), + Variant12(core::option::Option>), + Variant13(core::option::Option>), + Variant14(Stmt), + } + const __ACTION: &[i8] = &[ + // State 0 + 2, 0, 0, 0, 14, 15, 16, 17, + // State 1 + 2, 0, 0, 0, 14, 15, 16, 17, + // State 2 + 2, 21, 0, 0, 14, 15, 16, 17, + // State 3 + 2, 24, 0, 0, 14, 15, 16, 17, + // State 4 + -35, -35, -35, 0, 0, 0, 0, 0, + // State 5 + -36, 0, 0, 0, 0, 0, 0, 0, + // State 6 + -14, -14, -14, 0, 0, 0, 0, 0, + // State 7 + -15, -15, -15, 0, 0, 0, 0, 0, + // State 8 + -20, -20, -20, 0, 0, 0, 0, 0, + // State 9 + 3, 0, 0, 0, 0, 0, 0, 0, + // State 10 + -28, -28, -28, 0, 0, 0, 0, 0, + // State 11 + -29, -29, -29, 0, 0, 0, 0, 0, + // State 12 + -13, -13, -13, 0, 0, 0, 0, 0, + // State 13 + -39, -39, -39, 0, 0, 0, 0, 0, + // State 14 + -40, -40, -40, 0, 0, 0, 0, 0, + // State 15 + -26, -26, -26, 0, 0, 0, 0, 0, + // State 16 + -27, -27, -27, 0, 0, 0, 0, 0, + // State 17 + -36, 22, 0, 0, 0, 0, 0, 0, + // State 18 + -36, -36, -36, 0, 0, 0, 0, 0, + // State 19 + 3, 25, 26, 0, 0, 0, 0, 0, + // State 20 + -17, -17, -17, 0, 0, 0, 0, 0, + // State 21 + -21, -21, -21, 0, 0, 0, 0, 0, + // State 22 + 3, 27, 28, 0, 0, 0, 0, 0, + // State 23 + -19, -19, -19, 0, 0, 0, 0, 0, + // State 24 + -16, -16, -16, 0, 0, 0, 0, 0, + // State 25 + -4, -4, 0, 0, -4, -4, -4, -4, + // State 26 + -18, -18, -18, 0, 0, 0, 0, 0, + // State 27 + -5, -5, 0, 0, -5, -5, -5, -5, + ]; + fn __action(state: i8, integer: usize) -> i8 { + __ACTION[(state as usize) * 8 + integer] + } + const __EOF_ACTION: &[i8] = &[ + // State 0 + 0, + // State 1 + 0, + // State 2 + 0, + // State 3 + 0, + // State 4 + -35, + // State 5 + -42, + // State 6 + -14, + // State 7 + -15, + // State 8 + -20, + // State 9 + 0, + // State 10 + -28, + // State 11 + 0, + // State 12 + -13, + // State 13 + -39, + // State 14 + -40, + // State 15 + -26, + // State 16 + -27, + // State 17 + 0, + // State 18 + 0, + // State 19 + 0, + // State 20 + -17, + // State 21 + -21, + // State 22 + 0, + // State 23 + -19, + // State 24 + -16, + // State 25 + 0, + // State 26 + -18, + // State 27 + 0, + ]; + fn __goto(state: i8, nt: usize) -> i8 { + match nt { + 2 => 3, + 8 => 4, + 9 => match state { + 1 => 17, + 2..=3 => 18, + _ => 5, + }, + 11 => 6, + 12 => 7, + 13 => 8, + 14 => match state { + 2 => 19, + 3 => 22, + _ => 9, + }, + 18 => 10, + 19 => 11, + 22 => 12, + _ => 0, + } + } + fn __expected_tokens(__state: i8) -> alloc::vec::Vec { + const __TERMINAL: &[&str] = &[ + r###""(""###, + r###"")""###, + r###"",""###, + r###"";""###, + r###"r#"\"([^\"\\\\]|\\\\[ntr\"'\\\\])*\""#"###, + r###"r#"'([^\"\\\\]|\\\\[ntr\"'\\\\])*'"#"###, + r###"r#"[0-9]+"#"###, + r###"r#"[a-zA-Z_][a-zA-Z0-9_]*"#"###, + ]; + __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, 8 - 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(4, _) if true => Some(0), + Token(5, _) if true => Some(1), + Token(6, _) if true => Some(2), + Token(7, _) if true => Some(3), + Token(0, _) if true => Some(4), + Token(1, _) if true => Some(5), + Token(2, _) if true => Some(6), + Token(3, _) if true => Some(7), + _ => 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 => match __token { + Token(4, __tok0) | Token(5, __tok0) | Token(6, __tok0) | Token(7, __tok0) | Token(0, __tok0) | Token(1, __tok0) | Token(2, __tok0) | Token(3, __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 => { + // __Expr = Expr => ActionFn(4); + let __sym0 = __pop_Variant7(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action4::<>(input, __sym0); + return Some(Ok(__nt)); + } + 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::<(&())>) + } + _ => 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_Variant6< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, Atom, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant6(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant7< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, Expr, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant7(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant11< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, Spanned, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant11(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant1< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, Spanned, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant1(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant3< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, Spanned, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant3(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant14< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, Stmt, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant14(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant10< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, String, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant10(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant8< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, Vec, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant8(__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>, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant2(__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>, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant4(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant12< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, core::option::Option>, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant12(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant13< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, core::option::Option>, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant13(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant9< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, i64, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant9(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant5< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, usize, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant5(__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() + } + } + 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) + { + // ( ",") = SpExpr, "," => ActionFn(27); + assert!(__symbols.len() >= 2); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym1.2.clone(); + let __nt = super::__action27::<>(input, __sym0, __sym1); + __symbols.push((__start, __Symbol::Variant1(__nt), __end)); + (2, 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(25); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); + let __end = __start.clone(); + let __nt = super::__action25::<>(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(26); + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action26::<>(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) + { + // ( ",")+ = SpExpr, "," => ActionFn(41); + assert!(__symbols.len() >= 2); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym1.2.clone(); + let __nt = super::__action41::<>(input, __sym0, __sym1); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (2, 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) + { + // ( ",")+ = ( ",")+, SpExpr, "," => ActionFn(42); + assert!(__symbols.len() >= 3); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant1(__symbols); + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym2.2.clone(); + let __nt = super::__action42::<>(input, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (3, 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) + { + // ( ";") = SpStmt, ";" => ActionFn(34); + assert!(__symbols.len() >= 2); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym1.2.clone(); + let __nt = super::__action34::<>(input, __sym0, __sym1); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (2, 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(32); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); + let __end = __start.clone(); + let __nt = super::__action32::<>(input, &__start, &__end); + __symbols.push((__start, __Symbol::Variant4(__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(33); + let __sym0 = __pop_Variant4(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action33::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant4(__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) + { + // ( ";")+ = SpStmt, ";" => ActionFn(45); + assert!(__symbols.len() >= 2); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym1.2.clone(); + let __nt = super::__action45::<>(input, __sym0, __sym1); + __symbols.push((__start, __Symbol::Variant4(__nt), __end)); + (2, 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) + { + // ( ";")+ = ( ";")+, SpStmt, ";" => ActionFn(46); + assert!(__symbols.len() >= 3); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant3(__symbols); + let __sym0 = __pop_Variant4(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym2.2.clone(); + let __nt = super::__action46::<>(input, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant4(__nt), __end)); + (3, 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) + { + // @L = => ActionFn(40); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); + let __end = __start.clone(); + let __nt = super::__action40::<>(input, &__start, &__end); + __symbols.push((__start, __Symbol::Variant5(__nt), __end)); + (0, 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) + { + // @R = => ActionFn(39); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); + let __end = __start.clone(); + let __nt = super::__action39::<>(input, &__start, &__end); + __symbols.push((__start, __Symbol::Variant5(__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) + { + // Atom = Str => ActionFn(15); + let __sym0 = __pop_Variant10(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action15::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant6(__nt), __end)); + (1, 8) + } + 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) + { + // Atom = Int => ActionFn(16); + let __sym0 = __pop_Variant9(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action16::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant6(__nt), __end)); + (1, 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) + { + // Atom = Name => ActionFn(17); + let __sym0 = __pop_Variant10(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action17::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant6(__nt), __end)); + (1, 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) + { + // Expr = SpExpr, "(", SpExpr, ")" => ActionFn(55); + assert!(__symbols.len() >= 4); + let __sym3 = __pop_Variant0(__symbols); + let __sym2 = __pop_Variant1(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym3.2.clone(); + let __nt = super::__action55::<>(input, __sym0, __sym1, __sym2, __sym3); + __symbols.push((__start, __Symbol::Variant7(__nt), __end)); + (4, 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) + { + // Expr = SpExpr, "(", ")" => ActionFn(56); + assert!(__symbols.len() >= 3); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym2.2.clone(); + let __nt = super::__action56::<>(input, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant7(__nt), __end)); + (3, 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) + { + // Expr = SpExpr, "(", ( ",")+, SpExpr, ")" => ActionFn(57); + assert!(__symbols.len() >= 5); + let __sym4 = __pop_Variant0(__symbols); + let __sym3 = __pop_Variant1(__symbols); + let __sym2 = __pop_Variant2(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym4.2.clone(); + let __nt = super::__action57::<>(input, __sym0, __sym1, __sym2, __sym3, __sym4); + __symbols.push((__start, __Symbol::Variant7(__nt), __end)); + (5, 9) + } + 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) + { + // Expr = SpExpr, "(", ( ",")+, ")" => ActionFn(58); + assert!(__symbols.len() >= 4); + let __sym3 = __pop_Variant0(__symbols); + let __sym2 = __pop_Variant2(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym3.2.clone(); + let __nt = super::__action58::<>(input, __sym0, __sym1, __sym2, __sym3); + __symbols.push((__start, __Symbol::Variant7(__nt), __end)); + (4, 9) + } + 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) + { + // Expr = SpAtom => ActionFn(12); + let __sym0 = __pop_Variant11(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action12::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant7(__nt), __end)); + (1, 9) + } + 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) + { + // Expr = "(", Expr, ")" => ActionFn(13); + assert!(__symbols.len() >= 3); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant7(__symbols); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym2.2.clone(); + let __nt = super::__action13::<>(input, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant7(__nt), __end)); + (3, 9) + } + 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) + { + // File = SpStmt => ActionFn(59); + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action59::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant8(__nt), __end)); + (1, 10) + } + 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) + { + // File = => ActionFn(60); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); + let __end = __start.clone(); + let __nt = super::__action60::<>(input, &__start, &__end); + __symbols.push((__start, __Symbol::Variant8(__nt), __end)); + (0, 10) + } + 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) + { + // File = ( ";")+, SpStmt => ActionFn(61); + assert!(__symbols.len() >= 2); + let __sym1 = __pop_Variant3(__symbols); + let __sym0 = __pop_Variant4(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym1.2.clone(); + let __nt = super::__action61::<>(input, __sym0, __sym1); + __symbols.push((__start, __Symbol::Variant8(__nt), __end)); + (2, 10) + } + 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) + { + // File = ( ";")+ => ActionFn(62); + let __sym0 = __pop_Variant4(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action62::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant8(__nt), __end)); + (1, 10) + } + 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) + { + // Int = r#"[0-9]+"# => ActionFn(18); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action18::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant9(__nt), __end)); + (1, 11) + } + 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) + { + // Name = r#"[a-zA-Z_][a-zA-Z0-9_]*"# => ActionFn(21); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action21::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant10(__nt), __end)); + (1, 12) + } + 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) + { + // SpAtom = Spanned => ActionFn(14); + let __sym0 = __pop_Variant11(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action14::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant11(__nt), __end)); + (1, 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) + { + // SpExpr = Spanned => ActionFn(10); + let __sym0 = __pop_Variant1(__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, 14) + } + 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) + { + // SpExpr? = SpExpr => ActionFn(23); + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action23::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant12(__nt), __end)); + (1, 15) + } + 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) + { + // SpExpr? = => ActionFn(24); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); + let __end = __start.clone(); + let __nt = super::__action24::<>(input, &__start, &__end); + __symbols.push((__start, __Symbol::Variant12(__nt), __end)); + (0, 15) + } + 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) + { + // SpStmt = Spanned => ActionFn(8); + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action8::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (1, 16) + } + 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) + { + // SpStmt? = SpStmt => ActionFn(30); + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action30::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant13(__nt), __end)); + (1, 17) + } + 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) + { + // SpStmt? = => ActionFn(31); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); + let __end = __start.clone(); + let __nt = super::__action31::<>(input, &__start, &__end); + __symbols.push((__start, __Symbol::Variant13(__nt), __end)); + (0, 17) + } + 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) + { + // Spanned = Atom => ActionFn(52); + let __sym0 = __pop_Variant6(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action52::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant11(__nt), __end)); + (1, 18) + } + 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) + { + // Spanned = Expr => ActionFn(53); + let __sym0 = __pop_Variant7(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action53::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant1(__nt), __end)); + (1, 19) + } + 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) + { + // Spanned = Stmt => ActionFn(54); + let __sym0 = __pop_Variant14(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action54::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (1, 20) + } + 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) + { + // Stmt = SpExpr => ActionFn(9); + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action9::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant14(__nt), __end)); + (1, 21) + } + 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) + { + // Str = r#"\"([^\"\\\\]|\\\\[ntr\"'\\\\])*\""# => ActionFn(19); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action19::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant10(__nt), __end)); + (1, 22) + } + 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) + { + // Str = r#"'([^\"\\\\]|\\\\[ntr\"'\\\\])*'"# => ActionFn(20); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action20::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant10(__nt), __end)); + (1, 22) + } + 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) + { + // __Atom = Atom => ActionFn(6); + let __sym0 = __pop_Variant6(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action6::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant6(__nt), __end)); + (1, 23) + } + 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) + { + // __File = File => ActionFn(0); + let __sym0 = __pop_Variant8(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action0::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant8(__nt), __end)); + (1, 25) + } + 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) + { + // __SpAtom = SpAtom => ActionFn(5); + let __sym0 = __pop_Variant11(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action5::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant11(__nt), __end)); + (1, 26) + } + 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) + { + // __SpExpr = SpExpr => ActionFn(3); + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action3::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant1(__nt), __end)); + (1, 27) + } + 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) + { + // __SpStmt = SpStmt => ActionFn(1); + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action1::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (1, 28) + } + 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) + { + // __Stmt = Stmt => ActionFn(2); + let __sym0 = __pop_Variant14(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action2::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant14(__nt), __end)); + (1, 29) + } +} +pub use self::__parse__Expr::ExprParser; + +#[cfg_attr(rustfmt, rustfmt_skip)] +mod __parse__File { + #![allow(non_snake_case, non_camel_case_types, unused_mut, unused_variables, unused_imports, unused_parens, clippy::all)] + + use std::str::FromStr; + use crate::syn::{Span, Spanned, unescape}; + use crate::syn::ast::*; + #[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(Spanned), + Variant2(alloc::vec::Vec>), + Variant3(Spanned), + Variant4(alloc::vec::Vec>), + Variant5(usize), + Variant6(Atom), + Variant7(Expr), + Variant8(Vec), + Variant9(i64), + Variant10(String), + Variant11(Spanned), + Variant12(core::option::Option>), + Variant13(core::option::Option>), + Variant14(Stmt), + } + const __ACTION: &[i8] = &[ + // State 0 + 3, 0, 0, 0, 19, 20, 21, 22, + // State 1 + 3, 0, 0, 0, 19, 20, 21, 22, + // State 2 + 3, 0, 0, 0, 19, 20, 21, 22, + // State 3 + 3, 29, 0, 0, 19, 20, 21, 22, + // State 4 + 3, 32, 0, 0, 19, 20, 21, 22, + // State 5 + -35, -35, -35, -35, 0, 0, 0, 0, + // State 6 + -36, -36, -36, -36, 0, 0, 0, 0, + // State 7 + 0, 0, 0, 0, 0, 0, 0, 0, + // State 8 + -14, -14, -14, -14, 0, 0, 0, 0, + // State 9 + -15, -15, -15, -15, 0, 0, 0, 0, + // State 10 + -20, -20, -20, -20, 0, 0, 0, 0, + // State 11 + 4, 0, 0, -38, 0, 0, 0, 0, + // State 12 + 0, 0, 0, 24, 0, 0, 0, 0, + // State 13 + -28, -28, -28, -28, 0, 0, 0, 0, + // State 14 + -29, -29, -29, -29, 0, 0, 0, 0, + // State 15 + 0, 0, 0, -32, 0, 0, 0, 0, + // State 16 + 0, 0, 0, -37, 0, 0, 0, 0, + // State 17 + -13, -13, -13, -13, 0, 0, 0, 0, + // State 18 + -39, -39, -39, -39, 0, 0, 0, 0, + // State 19 + -40, -40, -40, -40, 0, 0, 0, 0, + // State 20 + -26, -26, -26, -26, 0, 0, 0, 0, + // State 21 + -27, -27, -27, -27, 0, 0, 0, 0, + // State 22 + 0, 0, 0, 27, 0, 0, 0, 0, + // State 23 + -9, 0, 0, 0, -9, -9, -9, -9, + // State 24 + -36, 30, 0, 0, 0, 0, 0, 0, + // State 25 + 4, 0, 0, 0, 0, 0, 0, 0, + // State 26 + -10, 0, 0, 0, -10, -10, -10, -10, + // State 27 + 4, 33, 34, 0, 0, 0, 0, 0, + // State 28 + -17, -17, -17, -17, 0, 0, 0, 0, + // State 29 + -21, -21, -21, -21, 0, 0, 0, 0, + // State 30 + 4, 35, 36, 0, 0, 0, 0, 0, + // State 31 + -19, -19, -19, -19, 0, 0, 0, 0, + // State 32 + -16, -16, -16, -16, 0, 0, 0, 0, + // State 33 + -4, -4, 0, 0, -4, -4, -4, -4, + // State 34 + -18, -18, -18, -18, 0, 0, 0, 0, + // State 35 + -5, -5, 0, 0, -5, -5, -5, -5, + ]; + fn __action(state: i8, integer: usize) -> i8 { + __ACTION[(state as usize) * 8 + integer] + } + const __EOF_ACTION: &[i8] = &[ + // State 0 + -23, + // State 1 + -25, + // State 2 + 0, + // State 3 + 0, + // State 4 + 0, + // State 5 + -35, + // State 6 + -36, + // State 7 + -43, + // State 8 + -14, + // State 9 + -15, + // State 10 + -20, + // State 11 + -38, + // State 12 + -22, + // State 13 + -28, + // State 14 + -29, + // State 15 + -32, + // State 16 + -37, + // State 17 + -13, + // State 18 + -39, + // State 19 + -40, + // State 20 + -26, + // State 21 + -27, + // State 22 + -24, + // State 23 + -9, + // State 24 + 0, + // State 25 + 0, + // State 26 + -10, + // State 27 + 0, + // State 28 + -17, + // State 29 + -21, + // State 30 + 0, + // State 31 + -19, + // State 32 + -16, + // State 33 + 0, + // State 34 + -18, + // State 35 + 0, + ]; + fn __goto(state: i8, nt: usize) -> i8 { + match nt { + 2 => 4, + 5 => 1, + 8 => 5, + 9 => match state { + 2 => 24, + _ => 6, + }, + 10 => 7, + 11 => 8, + 12 => 9, + 13 => 10, + 14 => match state { + 2 => 25, + 3 => 27, + 4 => 30, + _ => 11, + }, + 16 => match state { + 1 => 22, + _ => 12, + }, + 18 => 13, + 19 => 14, + 20 => 15, + 21 => 16, + 22 => 17, + _ => 0, + } + } + fn __expected_tokens(__state: i8) -> alloc::vec::Vec { + const __TERMINAL: &[&str] = &[ + r###""(""###, + r###"")""###, + r###"",""###, + r###"";""###, + r###"r#"\"([^\"\\\\]|\\\\[ntr\"'\\\\])*\""#"###, + r###"r#"'([^\"\\\\]|\\\\[ntr\"'\\\\])*'"#"###, + r###"r#"[0-9]+"#"###, + r###"r#"[a-zA-Z_][a-zA-Z0-9_]*"#"###, + ]; + __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 = Vec; + 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, 8 - 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(4, _) if true => Some(0), + Token(5, _) if true => Some(1), + Token(6, _) if true => Some(2), + Token(7, _) if true => Some(3), + Token(0, _) if true => Some(4), + Token(1, _) if true => Some(5), + Token(2, _) if true => Some(6), + Token(3, _) if true => Some(7), + _ => 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 => match __token { + Token(4, __tok0) | Token(5, __tok0) | Token(6, __tok0) | Token(7, __tok0) | Token(0, __tok0) | Token(1, __tok0) | Token(2, __tok0) | Token(3, __tok0) if true => __Symbol::Variant0(__tok0), + _ => unreachable!(), + }, + _ => unreachable!(), + } + } + pub struct FileParser { + builder: __lalrpop_util::lexer::MatcherBuilder, + _priv: (), + } + + impl FileParser { + pub fn new() -> FileParser { + let __builder = super::__intern_token::new_builder(); + FileParser { + builder: __builder, + _priv: (), + } + } + + #[allow(dead_code)] + pub fn parse< + 'input, + >( + &self, + input: &'input str, + ) -> Result, __lalrpop_util::ParseError, &'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,__lalrpop_util::ParseError, &'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 => { + // __File = File => ActionFn(0); + let __sym0 = __pop_Variant8(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action0::<>(input, __sym0); + return Some(Ok(__nt)); + } + 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::<(&())>) + } + _ => 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_Variant6< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, Atom, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant6(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant7< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, Expr, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant7(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant11< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, Spanned, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant11(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant1< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, Spanned, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant1(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant3< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, Spanned, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant3(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant14< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, Stmt, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant14(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant10< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, String, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant10(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant8< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, Vec, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant8(__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>, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant2(__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>, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant4(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant12< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, core::option::Option>, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant12(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant13< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, core::option::Option>, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant13(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant9< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, i64, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant9(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant5< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, usize, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant5(__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() + } + } + 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) + { + // ( ",") = SpExpr, "," => ActionFn(27); + assert!(__symbols.len() >= 2); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym1.2.clone(); + let __nt = super::__action27::<>(input, __sym0, __sym1); + __symbols.push((__start, __Symbol::Variant1(__nt), __end)); + (2, 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(25); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); + let __end = __start.clone(); + let __nt = super::__action25::<>(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(26); + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action26::<>(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) + { + // ( ",")+ = SpExpr, "," => ActionFn(41); + assert!(__symbols.len() >= 2); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym1.2.clone(); + let __nt = super::__action41::<>(input, __sym0, __sym1); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (2, 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) + { + // ( ",")+ = ( ",")+, SpExpr, "," => ActionFn(42); + assert!(__symbols.len() >= 3); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant1(__symbols); + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym2.2.clone(); + let __nt = super::__action42::<>(input, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (3, 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) + { + // ( ";") = SpStmt, ";" => ActionFn(34); + assert!(__symbols.len() >= 2); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym1.2.clone(); + let __nt = super::__action34::<>(input, __sym0, __sym1); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (2, 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(32); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); + let __end = __start.clone(); + let __nt = super::__action32::<>(input, &__start, &__end); + __symbols.push((__start, __Symbol::Variant4(__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(33); + let __sym0 = __pop_Variant4(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action33::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant4(__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) + { + // ( ";")+ = SpStmt, ";" => ActionFn(45); + assert!(__symbols.len() >= 2); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym1.2.clone(); + let __nt = super::__action45::<>(input, __sym0, __sym1); + __symbols.push((__start, __Symbol::Variant4(__nt), __end)); + (2, 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) + { + // ( ";")+ = ( ";")+, SpStmt, ";" => ActionFn(46); + assert!(__symbols.len() >= 3); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant3(__symbols); + let __sym0 = __pop_Variant4(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym2.2.clone(); + let __nt = super::__action46::<>(input, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant4(__nt), __end)); + (3, 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) + { + // @L = => ActionFn(40); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); + let __end = __start.clone(); + let __nt = super::__action40::<>(input, &__start, &__end); + __symbols.push((__start, __Symbol::Variant5(__nt), __end)); + (0, 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) + { + // @R = => ActionFn(39); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); + let __end = __start.clone(); + let __nt = super::__action39::<>(input, &__start, &__end); + __symbols.push((__start, __Symbol::Variant5(__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) + { + // Atom = Str => ActionFn(15); + let __sym0 = __pop_Variant10(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action15::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant6(__nt), __end)); + (1, 8) + } + 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) + { + // Atom = Int => ActionFn(16); + let __sym0 = __pop_Variant9(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action16::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant6(__nt), __end)); + (1, 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) + { + // Atom = Name => ActionFn(17); + let __sym0 = __pop_Variant10(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action17::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant6(__nt), __end)); + (1, 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) + { + // Expr = SpExpr, "(", SpExpr, ")" => ActionFn(55); + assert!(__symbols.len() >= 4); + let __sym3 = __pop_Variant0(__symbols); + let __sym2 = __pop_Variant1(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym3.2.clone(); + let __nt = super::__action55::<>(input, __sym0, __sym1, __sym2, __sym3); + __symbols.push((__start, __Symbol::Variant7(__nt), __end)); + (4, 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) + { + // Expr = SpExpr, "(", ")" => ActionFn(56); + assert!(__symbols.len() >= 3); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym2.2.clone(); + let __nt = super::__action56::<>(input, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant7(__nt), __end)); + (3, 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) + { + // Expr = SpExpr, "(", ( ",")+, SpExpr, ")" => ActionFn(57); + assert!(__symbols.len() >= 5); + let __sym4 = __pop_Variant0(__symbols); + let __sym3 = __pop_Variant1(__symbols); + let __sym2 = __pop_Variant2(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym4.2.clone(); + let __nt = super::__action57::<>(input, __sym0, __sym1, __sym2, __sym3, __sym4); + __symbols.push((__start, __Symbol::Variant7(__nt), __end)); + (5, 9) + } + 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) + { + // Expr = SpExpr, "(", ( ",")+, ")" => ActionFn(58); + assert!(__symbols.len() >= 4); + let __sym3 = __pop_Variant0(__symbols); + let __sym2 = __pop_Variant2(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym3.2.clone(); + let __nt = super::__action58::<>(input, __sym0, __sym1, __sym2, __sym3); + __symbols.push((__start, __Symbol::Variant7(__nt), __end)); + (4, 9) + } + 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) + { + // Expr = SpAtom => ActionFn(12); + let __sym0 = __pop_Variant11(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action12::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant7(__nt), __end)); + (1, 9) + } + 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) + { + // Expr = "(", Expr, ")" => ActionFn(13); + assert!(__symbols.len() >= 3); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant7(__symbols); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym2.2.clone(); + let __nt = super::__action13::<>(input, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant7(__nt), __end)); + (3, 9) + } + 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) + { + // File = SpStmt => ActionFn(59); + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action59::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant8(__nt), __end)); + (1, 10) + } + 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) + { + // File = => ActionFn(60); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); + let __end = __start.clone(); + let __nt = super::__action60::<>(input, &__start, &__end); + __symbols.push((__start, __Symbol::Variant8(__nt), __end)); + (0, 10) + } + 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) + { + // File = ( ";")+, SpStmt => ActionFn(61); + assert!(__symbols.len() >= 2); + let __sym1 = __pop_Variant3(__symbols); + let __sym0 = __pop_Variant4(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym1.2.clone(); + let __nt = super::__action61::<>(input, __sym0, __sym1); + __symbols.push((__start, __Symbol::Variant8(__nt), __end)); + (2, 10) + } + 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) + { + // File = ( ";")+ => ActionFn(62); + let __sym0 = __pop_Variant4(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action62::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant8(__nt), __end)); + (1, 10) + } + 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) + { + // Int = r#"[0-9]+"# => ActionFn(18); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action18::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant9(__nt), __end)); + (1, 11) + } + 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) + { + // Name = r#"[a-zA-Z_][a-zA-Z0-9_]*"# => ActionFn(21); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action21::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant10(__nt), __end)); + (1, 12) + } + 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) + { + // SpAtom = Spanned => ActionFn(14); + let __sym0 = __pop_Variant11(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action14::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant11(__nt), __end)); + (1, 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) + { + // SpExpr = Spanned => ActionFn(10); + let __sym0 = __pop_Variant1(__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, 14) + } + 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) + { + // SpExpr? = SpExpr => ActionFn(23); + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action23::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant12(__nt), __end)); + (1, 15) + } + 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) + { + // SpExpr? = => ActionFn(24); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); + let __end = __start.clone(); + let __nt = super::__action24::<>(input, &__start, &__end); + __symbols.push((__start, __Symbol::Variant12(__nt), __end)); + (0, 15) + } + 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) + { + // SpStmt = Spanned => ActionFn(8); + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action8::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (1, 16) + } + 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) + { + // SpStmt? = SpStmt => ActionFn(30); + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action30::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant13(__nt), __end)); + (1, 17) + } + 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) + { + // SpStmt? = => ActionFn(31); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); + let __end = __start.clone(); + let __nt = super::__action31::<>(input, &__start, &__end); + __symbols.push((__start, __Symbol::Variant13(__nt), __end)); + (0, 17) + } + 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) + { + // Spanned = Atom => ActionFn(52); + let __sym0 = __pop_Variant6(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action52::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant11(__nt), __end)); + (1, 18) + } + 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) + { + // Spanned = Expr => ActionFn(53); + let __sym0 = __pop_Variant7(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action53::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant1(__nt), __end)); + (1, 19) + } + 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) + { + // Spanned = Stmt => ActionFn(54); + let __sym0 = __pop_Variant14(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action54::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (1, 20) + } + 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) + { + // Stmt = SpExpr => ActionFn(9); + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action9::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant14(__nt), __end)); + (1, 21) + } + 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) + { + // Str = r#"\"([^\"\\\\]|\\\\[ntr\"'\\\\])*\""# => ActionFn(19); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action19::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant10(__nt), __end)); + (1, 22) + } + 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) + { + // Str = r#"'([^\"\\\\]|\\\\[ntr\"'\\\\])*'"# => ActionFn(20); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action20::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant10(__nt), __end)); + (1, 22) + } + 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) + { + // __Atom = Atom => ActionFn(6); + let __sym0 = __pop_Variant6(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action6::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant6(__nt), __end)); + (1, 23) + } + 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(4); + let __sym0 = __pop_Variant7(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action4::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant7(__nt), __end)); + (1, 24) + } + 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) + { + // __SpAtom = SpAtom => ActionFn(5); + let __sym0 = __pop_Variant11(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action5::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant11(__nt), __end)); + (1, 26) + } + 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) + { + // __SpExpr = SpExpr => ActionFn(3); + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action3::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant1(__nt), __end)); + (1, 27) + } + 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) + { + // __SpStmt = SpStmt => ActionFn(1); + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action1::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (1, 28) + } + 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) + { + // __Stmt = Stmt => ActionFn(2); + let __sym0 = __pop_Variant14(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action2::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant14(__nt), __end)); + (1, 29) + } +} +pub use self::__parse__File::FileParser; + +#[cfg_attr(rustfmt, rustfmt_skip)] +mod __parse__SpAtom { + #![allow(non_snake_case, non_camel_case_types, unused_mut, unused_variables, unused_imports, unused_parens, clippy::all)] + + use std::str::FromStr; + use crate::syn::{Span, Spanned, unescape}; + use crate::syn::ast::*; + #[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(Spanned), + Variant2(alloc::vec::Vec>), + Variant3(Spanned), + Variant4(alloc::vec::Vec>), + Variant5(usize), + Variant6(Atom), + Variant7(Expr), + Variant8(Vec), + Variant9(i64), + Variant10(String), + Variant11(Spanned), + Variant12(core::option::Option>), + Variant13(core::option::Option>), + Variant14(Stmt), + } + const __ACTION: &[i8] = &[ + // State 0 + 0, 0, 0, 0, 8, 9, 10, 11, + // State 1 + 0, 0, 0, 0, 0, 0, 0, 0, + // State 2 + 0, 0, 0, 0, 0, 0, 0, 0, + // State 3 + 0, 0, 0, 0, 0, 0, 0, 0, + // State 4 + 0, 0, 0, 0, 0, 0, 0, 0, + // State 5 + 0, 0, 0, 0, 0, 0, 0, 0, + // State 6 + 0, 0, 0, 0, 0, 0, 0, 0, + // State 7 + 0, 0, 0, 0, 0, 0, 0, 0, + // State 8 + 0, 0, 0, 0, 0, 0, 0, 0, + // State 9 + 0, 0, 0, 0, 0, 0, 0, 0, + // State 10 + 0, 0, 0, 0, 0, 0, 0, 0, + ]; + fn __action(state: i8, integer: usize) -> i8 { + __ACTION[(state as usize) * 8 + integer] + } + const __EOF_ACTION: &[i8] = &[ + // State 0 + 0, + // State 1 + -35, + // State 2 + -14, + // State 3 + -15, + // State 4 + -44, + // State 5 + -28, + // State 6 + -13, + // State 7 + -39, + // State 8 + -40, + // State 9 + -26, + // State 10 + -27, + ]; + fn __goto(state: i8, nt: usize) -> i8 { + match nt { + 8 => 1, + 11 => 2, + 12 => 3, + 13 => 4, + 18 => 5, + 22 => 6, + _ => 0, + } + } + fn __expected_tokens(__state: i8) -> alloc::vec::Vec { + const __TERMINAL: &[&str] = &[ + r###""(""###, + r###"")""###, + r###"",""###, + r###"";""###, + r###"r#"\"([^\"\\\\]|\\\\[ntr\"'\\\\])*\""#"###, + r###"r#"'([^\"\\\\]|\\\\[ntr\"'\\\\])*'"#"###, + r###"r#"[0-9]+"#"###, + r###"r#"[a-zA-Z_][a-zA-Z0-9_]*"#"###, + ]; + __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 = Spanned; + 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, 8 - 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(4, _) if true => Some(0), + Token(5, _) if true => Some(1), + Token(6, _) if true => Some(2), + Token(7, _) if true => Some(3), + Token(0, _) if true => Some(4), + Token(1, _) if true => Some(5), + Token(2, _) if true => Some(6), + Token(3, _) if true => Some(7), + _ => 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 => match __token { + Token(4, __tok0) | Token(5, __tok0) | Token(6, __tok0) | Token(7, __tok0) | Token(0, __tok0) | Token(1, __tok0) | Token(2, __tok0) | Token(3, __tok0) if true => __Symbol::Variant0(__tok0), + _ => unreachable!(), + }, + _ => unreachable!(), + } + } + pub struct SpAtomParser { + builder: __lalrpop_util::lexer::MatcherBuilder, + _priv: (), + } + + impl SpAtomParser { + pub fn new() -> SpAtomParser { + let __builder = super::__intern_token::new_builder(); + SpAtomParser { + builder: __builder, + _priv: (), + } + } + + #[allow(dead_code)] + pub fn parse< + 'input, + >( + &self, + input: &'input str, + ) -> Result, __lalrpop_util::ParseError, &'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,__lalrpop_util::ParseError, &'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 => { + // __SpAtom = SpAtom => ActionFn(5); + let __sym0 = __pop_Variant11(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action5::<>(input, __sym0); + return Some(Ok(__nt)); + } + 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::<(&())>) + } + _ => 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_Variant6< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, Atom, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant6(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant7< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, Expr, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant7(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant11< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, Spanned, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant11(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant1< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, Spanned, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant1(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant3< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, Spanned, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant3(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant14< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, Stmt, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant14(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant10< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, String, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant10(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant8< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, Vec, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant8(__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>, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant2(__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>, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant4(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant12< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, core::option::Option>, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant12(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant13< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, core::option::Option>, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant13(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant9< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, i64, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant9(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant5< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, usize, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant5(__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() + } + } + 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) + { + // ( ",") = SpExpr, "," => ActionFn(27); + assert!(__symbols.len() >= 2); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym1.2.clone(); + let __nt = super::__action27::<>(input, __sym0, __sym1); + __symbols.push((__start, __Symbol::Variant1(__nt), __end)); + (2, 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(25); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); + let __end = __start.clone(); + let __nt = super::__action25::<>(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(26); + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action26::<>(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) + { + // ( ",")+ = SpExpr, "," => ActionFn(41); + assert!(__symbols.len() >= 2); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym1.2.clone(); + let __nt = super::__action41::<>(input, __sym0, __sym1); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (2, 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) + { + // ( ",")+ = ( ",")+, SpExpr, "," => ActionFn(42); + assert!(__symbols.len() >= 3); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant1(__symbols); + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym2.2.clone(); + let __nt = super::__action42::<>(input, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (3, 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) + { + // ( ";") = SpStmt, ";" => ActionFn(34); + assert!(__symbols.len() >= 2); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym1.2.clone(); + let __nt = super::__action34::<>(input, __sym0, __sym1); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (2, 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(32); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); + let __end = __start.clone(); + let __nt = super::__action32::<>(input, &__start, &__end); + __symbols.push((__start, __Symbol::Variant4(__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(33); + let __sym0 = __pop_Variant4(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action33::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant4(__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) + { + // ( ";")+ = SpStmt, ";" => ActionFn(45); + assert!(__symbols.len() >= 2); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym1.2.clone(); + let __nt = super::__action45::<>(input, __sym0, __sym1); + __symbols.push((__start, __Symbol::Variant4(__nt), __end)); + (2, 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) + { + // ( ";")+ = ( ";")+, SpStmt, ";" => ActionFn(46); + assert!(__symbols.len() >= 3); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant3(__symbols); + let __sym0 = __pop_Variant4(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym2.2.clone(); + let __nt = super::__action46::<>(input, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant4(__nt), __end)); + (3, 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) + { + // @L = => ActionFn(40); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); + let __end = __start.clone(); + let __nt = super::__action40::<>(input, &__start, &__end); + __symbols.push((__start, __Symbol::Variant5(__nt), __end)); + (0, 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) + { + // @R = => ActionFn(39); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); + let __end = __start.clone(); + let __nt = super::__action39::<>(input, &__start, &__end); + __symbols.push((__start, __Symbol::Variant5(__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) + { + // Atom = Str => ActionFn(15); + let __sym0 = __pop_Variant10(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action15::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant6(__nt), __end)); + (1, 8) + } + 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) + { + // Atom = Int => ActionFn(16); + let __sym0 = __pop_Variant9(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action16::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant6(__nt), __end)); + (1, 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) + { + // Atom = Name => ActionFn(17); + let __sym0 = __pop_Variant10(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action17::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant6(__nt), __end)); + (1, 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) + { + // Expr = SpExpr, "(", SpExpr, ")" => ActionFn(55); + assert!(__symbols.len() >= 4); + let __sym3 = __pop_Variant0(__symbols); + let __sym2 = __pop_Variant1(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym3.2.clone(); + let __nt = super::__action55::<>(input, __sym0, __sym1, __sym2, __sym3); + __symbols.push((__start, __Symbol::Variant7(__nt), __end)); + (4, 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) + { + // Expr = SpExpr, "(", ")" => ActionFn(56); + assert!(__symbols.len() >= 3); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym2.2.clone(); + let __nt = super::__action56::<>(input, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant7(__nt), __end)); + (3, 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) + { + // Expr = SpExpr, "(", ( ",")+, SpExpr, ")" => ActionFn(57); + assert!(__symbols.len() >= 5); + let __sym4 = __pop_Variant0(__symbols); + let __sym3 = __pop_Variant1(__symbols); + let __sym2 = __pop_Variant2(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym4.2.clone(); + let __nt = super::__action57::<>(input, __sym0, __sym1, __sym2, __sym3, __sym4); + __symbols.push((__start, __Symbol::Variant7(__nt), __end)); + (5, 9) + } + 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) + { + // Expr = SpExpr, "(", ( ",")+, ")" => ActionFn(58); + assert!(__symbols.len() >= 4); + let __sym3 = __pop_Variant0(__symbols); + let __sym2 = __pop_Variant2(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym3.2.clone(); + let __nt = super::__action58::<>(input, __sym0, __sym1, __sym2, __sym3); + __symbols.push((__start, __Symbol::Variant7(__nt), __end)); + (4, 9) + } + 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) + { + // Expr = SpAtom => ActionFn(12); + let __sym0 = __pop_Variant11(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action12::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant7(__nt), __end)); + (1, 9) + } + 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) + { + // Expr = "(", Expr, ")" => ActionFn(13); + assert!(__symbols.len() >= 3); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant7(__symbols); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym2.2.clone(); + let __nt = super::__action13::<>(input, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant7(__nt), __end)); + (3, 9) + } + 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) + { + // File = SpStmt => ActionFn(59); + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action59::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant8(__nt), __end)); + (1, 10) + } + 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) + { + // File = => ActionFn(60); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); + let __end = __start.clone(); + let __nt = super::__action60::<>(input, &__start, &__end); + __symbols.push((__start, __Symbol::Variant8(__nt), __end)); + (0, 10) + } + 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) + { + // File = ( ";")+, SpStmt => ActionFn(61); + assert!(__symbols.len() >= 2); + let __sym1 = __pop_Variant3(__symbols); + let __sym0 = __pop_Variant4(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym1.2.clone(); + let __nt = super::__action61::<>(input, __sym0, __sym1); + __symbols.push((__start, __Symbol::Variant8(__nt), __end)); + (2, 10) + } + 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) + { + // File = ( ";")+ => ActionFn(62); + let __sym0 = __pop_Variant4(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action62::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant8(__nt), __end)); + (1, 10) + } + 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) + { + // Int = r#"[0-9]+"# => ActionFn(18); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action18::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant9(__nt), __end)); + (1, 11) + } + 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) + { + // Name = r#"[a-zA-Z_][a-zA-Z0-9_]*"# => ActionFn(21); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action21::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant10(__nt), __end)); + (1, 12) + } + 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) + { + // SpAtom = Spanned => ActionFn(14); + let __sym0 = __pop_Variant11(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action14::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant11(__nt), __end)); + (1, 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) + { + // SpExpr = Spanned => ActionFn(10); + let __sym0 = __pop_Variant1(__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, 14) + } + 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) + { + // SpExpr? = SpExpr => ActionFn(23); + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action23::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant12(__nt), __end)); + (1, 15) + } + 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) + { + // SpExpr? = => ActionFn(24); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); + let __end = __start.clone(); + let __nt = super::__action24::<>(input, &__start, &__end); + __symbols.push((__start, __Symbol::Variant12(__nt), __end)); + (0, 15) + } + 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) + { + // SpStmt = Spanned => ActionFn(8); + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action8::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (1, 16) + } + 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) + { + // SpStmt? = SpStmt => ActionFn(30); + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action30::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant13(__nt), __end)); + (1, 17) + } + 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) + { + // SpStmt? = => ActionFn(31); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); + let __end = __start.clone(); + let __nt = super::__action31::<>(input, &__start, &__end); + __symbols.push((__start, __Symbol::Variant13(__nt), __end)); + (0, 17) + } + 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) + { + // Spanned = Atom => ActionFn(52); + let __sym0 = __pop_Variant6(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action52::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant11(__nt), __end)); + (1, 18) + } + 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) + { + // Spanned = Expr => ActionFn(53); + let __sym0 = __pop_Variant7(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action53::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant1(__nt), __end)); + (1, 19) + } + 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) + { + // Spanned = Stmt => ActionFn(54); + let __sym0 = __pop_Variant14(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action54::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (1, 20) + } + 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) + { + // Stmt = SpExpr => ActionFn(9); + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action9::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant14(__nt), __end)); + (1, 21) + } + 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) + { + // Str = r#"\"([^\"\\\\]|\\\\[ntr\"'\\\\])*\""# => ActionFn(19); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action19::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant10(__nt), __end)); + (1, 22) + } + 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) + { + // Str = r#"'([^\"\\\\]|\\\\[ntr\"'\\\\])*'"# => ActionFn(20); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action20::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant10(__nt), __end)); + (1, 22) + } + 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) + { + // __Atom = Atom => ActionFn(6); + let __sym0 = __pop_Variant6(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action6::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant6(__nt), __end)); + (1, 23) + } + 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(4); + let __sym0 = __pop_Variant7(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action4::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant7(__nt), __end)); + (1, 24) + } + 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) + { + // __File = File => ActionFn(0); + let __sym0 = __pop_Variant8(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action0::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant8(__nt), __end)); + (1, 25) + } + 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) + { + // __SpExpr = SpExpr => ActionFn(3); + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action3::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant1(__nt), __end)); + (1, 27) + } + 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) + { + // __SpStmt = SpStmt => ActionFn(1); + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action1::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (1, 28) + } + 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) + { + // __Stmt = Stmt => ActionFn(2); + let __sym0 = __pop_Variant14(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action2::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant14(__nt), __end)); + (1, 29) + } +} +pub use self::__parse__SpAtom::SpAtomParser; + +#[cfg_attr(rustfmt, rustfmt_skip)] +mod __parse__SpExpr { + #![allow(non_snake_case, non_camel_case_types, unused_mut, unused_variables, unused_imports, unused_parens, clippy::all)] + + use std::str::FromStr; + use crate::syn::{Span, Spanned, unescape}; + use crate::syn::ast::*; + #[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(Spanned), + Variant2(alloc::vec::Vec>), + Variant3(Spanned), + Variant4(alloc::vec::Vec>), + Variant5(usize), + Variant6(Atom), + Variant7(Expr), + Variant8(Vec), + Variant9(i64), + Variant10(String), + Variant11(Spanned), + Variant12(core::option::Option>), + Variant13(core::option::Option>), + Variant14(Stmt), + } + const __ACTION: &[i8] = &[ + // State 0 + 2, 0, 0, 0, 14, 15, 16, 17, + // State 1 + 2, 0, 0, 0, 14, 15, 16, 17, + // State 2 + 2, 21, 0, 0, 14, 15, 16, 17, + // State 3 + 2, 24, 0, 0, 14, 15, 16, 17, + // State 4 + -35, -35, -35, 0, 0, 0, 0, 0, + // State 5 + -36, -36, -36, 0, 0, 0, 0, 0, + // State 6 + -14, -14, -14, 0, 0, 0, 0, 0, + // State 7 + -15, -15, -15, 0, 0, 0, 0, 0, + // State 8 + -20, -20, -20, 0, 0, 0, 0, 0, + // State 9 + 3, 0, 0, 0, 0, 0, 0, 0, + // State 10 + -28, -28, -28, 0, 0, 0, 0, 0, + // State 11 + -29, -29, -29, 0, 0, 0, 0, 0, + // State 12 + -13, -13, -13, 0, 0, 0, 0, 0, + // State 13 + -39, -39, -39, 0, 0, 0, 0, 0, + // State 14 + -40, -40, -40, 0, 0, 0, 0, 0, + // State 15 + -26, -26, -26, 0, 0, 0, 0, 0, + // State 16 + -27, -27, -27, 0, 0, 0, 0, 0, + // State 17 + -36, 22, 0, 0, 0, 0, 0, 0, + // State 18 + 3, 0, 0, 0, 0, 0, 0, 0, + // State 19 + 3, 25, 26, 0, 0, 0, 0, 0, + // State 20 + -17, -17, -17, 0, 0, 0, 0, 0, + // State 21 + -21, -21, -21, 0, 0, 0, 0, 0, + // State 22 + 3, 27, 28, 0, 0, 0, 0, 0, + // State 23 + -19, -19, -19, 0, 0, 0, 0, 0, + // State 24 + -16, -16, -16, 0, 0, 0, 0, 0, + // State 25 + -4, -4, 0, 0, -4, -4, -4, -4, + // State 26 + -18, -18, -18, 0, 0, 0, 0, 0, + // State 27 + -5, -5, 0, 0, -5, -5, -5, -5, + ]; + fn __action(state: i8, integer: usize) -> i8 { + __ACTION[(state as usize) * 8 + integer] + } + const __EOF_ACTION: &[i8] = &[ + // State 0 + 0, + // State 1 + 0, + // State 2 + 0, + // State 3 + 0, + // State 4 + -35, + // State 5 + -36, + // State 6 + -14, + // State 7 + -15, + // State 8 + -20, + // State 9 + -45, + // State 10 + -28, + // State 11 + -29, + // State 12 + -13, + // State 13 + -39, + // State 14 + -40, + // State 15 + -26, + // State 16 + -27, + // State 17 + 0, + // State 18 + 0, + // State 19 + 0, + // State 20 + -17, + // State 21 + -21, + // State 22 + 0, + // State 23 + -19, + // State 24 + -16, + // State 25 + 0, + // State 26 + -18, + // State 27 + 0, + ]; + fn __goto(state: i8, nt: usize) -> i8 { + match nt { + 2 => 3, + 8 => 4, + 9 => match state { + 1 => 17, + _ => 5, + }, + 11 => 6, + 12 => 7, + 13 => 8, + 14 => match state { + 1 => 18, + 2 => 19, + 3 => 22, + _ => 9, + }, + 18 => 10, + 19 => 11, + 22 => 12, + _ => 0, + } + } + fn __expected_tokens(__state: i8) -> alloc::vec::Vec { + const __TERMINAL: &[&str] = &[ + r###""(""###, + r###"")""###, + r###"",""###, + r###"";""###, + r###"r#"\"([^\"\\\\]|\\\\[ntr\"'\\\\])*\""#"###, + r###"r#"'([^\"\\\\]|\\\\[ntr\"'\\\\])*'"#"###, + r###"r#"[0-9]+"#"###, + r###"r#"[a-zA-Z_][a-zA-Z0-9_]*"#"###, + ]; + __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 = Spanned; + 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, 8 - 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(4, _) if true => Some(0), + Token(5, _) if true => Some(1), + Token(6, _) if true => Some(2), + Token(7, _) if true => Some(3), + Token(0, _) if true => Some(4), + Token(1, _) if true => Some(5), + Token(2, _) if true => Some(6), + Token(3, _) if true => Some(7), + _ => 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 => match __token { + Token(4, __tok0) | Token(5, __tok0) | Token(6, __tok0) | Token(7, __tok0) | Token(0, __tok0) | Token(1, __tok0) | Token(2, __tok0) | Token(3, __tok0) if true => __Symbol::Variant0(__tok0), + _ => unreachable!(), + }, + _ => unreachable!(), + } + } + pub struct SpExprParser { + builder: __lalrpop_util::lexer::MatcherBuilder, + _priv: (), + } + + impl SpExprParser { + pub fn new() -> SpExprParser { + let __builder = super::__intern_token::new_builder(); + SpExprParser { + builder: __builder, + _priv: (), + } + } + + #[allow(dead_code)] + pub fn parse< + 'input, + >( + &self, + input: &'input str, + ) -> Result, __lalrpop_util::ParseError, &'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,__lalrpop_util::ParseError, &'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 => { + // __SpExpr = SpExpr => ActionFn(3); + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action3::<>(input, __sym0); + return Some(Ok(__nt)); + } + 45 => { + __reduce45(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) + } + 46 => { + __reduce46(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) + } + _ => 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_Variant6< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, Atom, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant6(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant7< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, Expr, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant7(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant11< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, Spanned, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant11(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant1< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, Spanned, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant1(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant3< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, Spanned, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant3(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant14< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, Stmt, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant14(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant10< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, String, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant10(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant8< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, Vec, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant8(__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>, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant2(__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>, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant4(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant12< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, core::option::Option>, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant12(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant13< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, core::option::Option>, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant13(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant9< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, i64, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant9(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant5< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, usize, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant5(__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() + } + } + 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) + { + // ( ",") = SpExpr, "," => ActionFn(27); + assert!(__symbols.len() >= 2); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym1.2.clone(); + let __nt = super::__action27::<>(input, __sym0, __sym1); + __symbols.push((__start, __Symbol::Variant1(__nt), __end)); + (2, 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(25); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); + let __end = __start.clone(); + let __nt = super::__action25::<>(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(26); + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action26::<>(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) + { + // ( ",")+ = SpExpr, "," => ActionFn(41); + assert!(__symbols.len() >= 2); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym1.2.clone(); + let __nt = super::__action41::<>(input, __sym0, __sym1); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (2, 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) + { + // ( ",")+ = ( ",")+, SpExpr, "," => ActionFn(42); + assert!(__symbols.len() >= 3); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant1(__symbols); + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym2.2.clone(); + let __nt = super::__action42::<>(input, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (3, 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) + { + // ( ";") = SpStmt, ";" => ActionFn(34); + assert!(__symbols.len() >= 2); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym1.2.clone(); + let __nt = super::__action34::<>(input, __sym0, __sym1); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (2, 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(32); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); + let __end = __start.clone(); + let __nt = super::__action32::<>(input, &__start, &__end); + __symbols.push((__start, __Symbol::Variant4(__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(33); + let __sym0 = __pop_Variant4(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action33::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant4(__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) + { + // ( ";")+ = SpStmt, ";" => ActionFn(45); + assert!(__symbols.len() >= 2); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym1.2.clone(); + let __nt = super::__action45::<>(input, __sym0, __sym1); + __symbols.push((__start, __Symbol::Variant4(__nt), __end)); + (2, 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) + { + // ( ";")+ = ( ";")+, SpStmt, ";" => ActionFn(46); + assert!(__symbols.len() >= 3); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant3(__symbols); + let __sym0 = __pop_Variant4(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym2.2.clone(); + let __nt = super::__action46::<>(input, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant4(__nt), __end)); + (3, 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) + { + // @L = => ActionFn(40); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); + let __end = __start.clone(); + let __nt = super::__action40::<>(input, &__start, &__end); + __symbols.push((__start, __Symbol::Variant5(__nt), __end)); + (0, 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) + { + // @R = => ActionFn(39); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); + let __end = __start.clone(); + let __nt = super::__action39::<>(input, &__start, &__end); + __symbols.push((__start, __Symbol::Variant5(__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) + { + // Atom = Str => ActionFn(15); + let __sym0 = __pop_Variant10(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action15::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant6(__nt), __end)); + (1, 8) + } + 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) + { + // Atom = Int => ActionFn(16); + let __sym0 = __pop_Variant9(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action16::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant6(__nt), __end)); + (1, 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) + { + // Atom = Name => ActionFn(17); + let __sym0 = __pop_Variant10(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action17::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant6(__nt), __end)); + (1, 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) + { + // Expr = SpExpr, "(", SpExpr, ")" => ActionFn(55); + assert!(__symbols.len() >= 4); + let __sym3 = __pop_Variant0(__symbols); + let __sym2 = __pop_Variant1(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym3.2.clone(); + let __nt = super::__action55::<>(input, __sym0, __sym1, __sym2, __sym3); + __symbols.push((__start, __Symbol::Variant7(__nt), __end)); + (4, 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) + { + // Expr = SpExpr, "(", ")" => ActionFn(56); + assert!(__symbols.len() >= 3); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym2.2.clone(); + let __nt = super::__action56::<>(input, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant7(__nt), __end)); + (3, 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) + { + // Expr = SpExpr, "(", ( ",")+, SpExpr, ")" => ActionFn(57); + assert!(__symbols.len() >= 5); + let __sym4 = __pop_Variant0(__symbols); + let __sym3 = __pop_Variant1(__symbols); + let __sym2 = __pop_Variant2(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym4.2.clone(); + let __nt = super::__action57::<>(input, __sym0, __sym1, __sym2, __sym3, __sym4); + __symbols.push((__start, __Symbol::Variant7(__nt), __end)); + (5, 9) + } + 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) + { + // Expr = SpExpr, "(", ( ",")+, ")" => ActionFn(58); + assert!(__symbols.len() >= 4); + let __sym3 = __pop_Variant0(__symbols); + let __sym2 = __pop_Variant2(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym3.2.clone(); + let __nt = super::__action58::<>(input, __sym0, __sym1, __sym2, __sym3); + __symbols.push((__start, __Symbol::Variant7(__nt), __end)); + (4, 9) + } + 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) + { + // Expr = SpAtom => ActionFn(12); + let __sym0 = __pop_Variant11(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action12::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant7(__nt), __end)); + (1, 9) + } + 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) + { + // Expr = "(", Expr, ")" => ActionFn(13); + assert!(__symbols.len() >= 3); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant7(__symbols); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym2.2.clone(); + let __nt = super::__action13::<>(input, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant7(__nt), __end)); + (3, 9) + } + 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) + { + // File = SpStmt => ActionFn(59); + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action59::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant8(__nt), __end)); + (1, 10) + } + 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) + { + // File = => ActionFn(60); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); + let __end = __start.clone(); + let __nt = super::__action60::<>(input, &__start, &__end); + __symbols.push((__start, __Symbol::Variant8(__nt), __end)); + (0, 10) + } + 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) + { + // File = ( ";")+, SpStmt => ActionFn(61); + assert!(__symbols.len() >= 2); + let __sym1 = __pop_Variant3(__symbols); + let __sym0 = __pop_Variant4(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym1.2.clone(); + let __nt = super::__action61::<>(input, __sym0, __sym1); + __symbols.push((__start, __Symbol::Variant8(__nt), __end)); + (2, 10) + } + 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) + { + // File = ( ";")+ => ActionFn(62); + let __sym0 = __pop_Variant4(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action62::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant8(__nt), __end)); + (1, 10) + } + 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) + { + // Int = r#"[0-9]+"# => ActionFn(18); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action18::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant9(__nt), __end)); + (1, 11) + } + 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) + { + // Name = r#"[a-zA-Z_][a-zA-Z0-9_]*"# => ActionFn(21); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action21::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant10(__nt), __end)); + (1, 12) + } + 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) + { + // SpAtom = Spanned => ActionFn(14); + let __sym0 = __pop_Variant11(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action14::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant11(__nt), __end)); + (1, 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) + { + // SpExpr = Spanned => ActionFn(10); + let __sym0 = __pop_Variant1(__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, 14) + } + 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) + { + // SpExpr? = SpExpr => ActionFn(23); + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action23::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant12(__nt), __end)); + (1, 15) + } + 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) + { + // SpExpr? = => ActionFn(24); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); + let __end = __start.clone(); + let __nt = super::__action24::<>(input, &__start, &__end); + __symbols.push((__start, __Symbol::Variant12(__nt), __end)); + (0, 15) + } + 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) + { + // SpStmt = Spanned => ActionFn(8); + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action8::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (1, 16) + } + 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) + { + // SpStmt? = SpStmt => ActionFn(30); + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action30::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant13(__nt), __end)); + (1, 17) + } + 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) + { + // SpStmt? = => ActionFn(31); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); + let __end = __start.clone(); + let __nt = super::__action31::<>(input, &__start, &__end); + __symbols.push((__start, __Symbol::Variant13(__nt), __end)); + (0, 17) + } + 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) + { + // Spanned = Atom => ActionFn(52); + let __sym0 = __pop_Variant6(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action52::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant11(__nt), __end)); + (1, 18) + } + 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) + { + // Spanned = Expr => ActionFn(53); + let __sym0 = __pop_Variant7(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action53::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant1(__nt), __end)); + (1, 19) + } + 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) + { + // Spanned = Stmt => ActionFn(54); + let __sym0 = __pop_Variant14(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action54::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (1, 20) + } + 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) + { + // Stmt = SpExpr => ActionFn(9); + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action9::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant14(__nt), __end)); + (1, 21) + } + 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) + { + // Str = r#"\"([^\"\\\\]|\\\\[ntr\"'\\\\])*\""# => ActionFn(19); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action19::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant10(__nt), __end)); + (1, 22) + } + 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) + { + // Str = r#"'([^\"\\\\]|\\\\[ntr\"'\\\\])*'"# => ActionFn(20); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action20::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant10(__nt), __end)); + (1, 22) + } + 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) + { + // __Atom = Atom => ActionFn(6); + let __sym0 = __pop_Variant6(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action6::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant6(__nt), __end)); + (1, 23) + } + 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(4); + let __sym0 = __pop_Variant7(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action4::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant7(__nt), __end)); + (1, 24) + } + 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) + { + // __File = File => ActionFn(0); + let __sym0 = __pop_Variant8(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action0::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant8(__nt), __end)); + (1, 25) + } + 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) + { + // __SpAtom = SpAtom => ActionFn(5); + let __sym0 = __pop_Variant11(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action5::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant11(__nt), __end)); + (1, 26) + } + 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) + { + // __SpStmt = SpStmt => ActionFn(1); + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action1::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (1, 28) + } + 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) + { + // __Stmt = Stmt => ActionFn(2); + let __sym0 = __pop_Variant14(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action2::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant14(__nt), __end)); + (1, 29) + } +} +pub use self::__parse__SpExpr::SpExprParser; + +#[cfg_attr(rustfmt, rustfmt_skip)] +mod __parse__SpStmt { + #![allow(non_snake_case, non_camel_case_types, unused_mut, unused_variables, unused_imports, unused_parens, clippy::all)] + + use std::str::FromStr; + use crate::syn::{Span, Spanned, unescape}; + use crate::syn::ast::*; + #[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(Spanned), + Variant2(alloc::vec::Vec>), + Variant3(Spanned), + Variant4(alloc::vec::Vec>), + Variant5(usize), + Variant6(Atom), + Variant7(Expr), + Variant8(Vec), + Variant9(i64), + Variant10(String), + Variant11(Spanned), + Variant12(core::option::Option>), + Variant13(core::option::Option>), + Variant14(Stmt), + } + const __ACTION: &[i8] = &[ + // State 0 + 2, 0, 0, 0, 17, 18, 19, 20, + // State 1 + 2, 0, 0, 0, 17, 18, 19, 20, + // State 2 + 2, 24, 0, 0, 17, 18, 19, 20, + // State 3 + 2, 27, 0, 0, 17, 18, 19, 20, + // State 4 + -35, -35, -35, 0, 0, 0, 0, 0, + // State 5 + -36, -36, -36, 0, 0, 0, 0, 0, + // State 6 + -14, -14, -14, 0, 0, 0, 0, 0, + // State 7 + -15, -15, -15, 0, 0, 0, 0, 0, + // State 8 + -20, -20, -20, 0, 0, 0, 0, 0, + // State 9 + 3, 0, 0, 0, 0, 0, 0, 0, + // State 10 + 0, 0, 0, 0, 0, 0, 0, 0, + // State 11 + -28, -28, -28, 0, 0, 0, 0, 0, + // State 12 + -29, -29, -29, 0, 0, 0, 0, 0, + // State 13 + 0, 0, 0, 0, 0, 0, 0, 0, + // State 14 + 0, 0, 0, 0, 0, 0, 0, 0, + // State 15 + -13, -13, -13, 0, 0, 0, 0, 0, + // State 16 + -39, -39, -39, 0, 0, 0, 0, 0, + // State 17 + -40, -40, -40, 0, 0, 0, 0, 0, + // State 18 + -26, -26, -26, 0, 0, 0, 0, 0, + // State 19 + -27, -27, -27, 0, 0, 0, 0, 0, + // State 20 + -36, 25, 0, 0, 0, 0, 0, 0, + // State 21 + 3, 0, 0, 0, 0, 0, 0, 0, + // State 22 + 3, 28, 29, 0, 0, 0, 0, 0, + // State 23 + -17, -17, -17, 0, 0, 0, 0, 0, + // State 24 + -21, -21, -21, 0, 0, 0, 0, 0, + // State 25 + 3, 30, 31, 0, 0, 0, 0, 0, + // State 26 + -19, -19, -19, 0, 0, 0, 0, 0, + // State 27 + -16, -16, -16, 0, 0, 0, 0, 0, + // State 28 + -4, -4, 0, 0, -4, -4, -4, -4, + // State 29 + -18, -18, -18, 0, 0, 0, 0, 0, + // State 30 + -5, -5, 0, 0, -5, -5, -5, -5, + ]; + fn __action(state: i8, integer: usize) -> i8 { + __ACTION[(state as usize) * 8 + integer] + } + const __EOF_ACTION: &[i8] = &[ + // State 0 + 0, + // State 1 + 0, + // State 2 + 0, + // State 3 + 0, + // State 4 + -35, + // State 5 + -36, + // State 6 + -14, + // State 7 + -15, + // State 8 + -20, + // State 9 + -38, + // State 10 + -46, + // State 11 + -28, + // State 12 + -29, + // State 13 + -32, + // State 14 + -37, + // State 15 + -13, + // State 16 + -39, + // State 17 + -40, + // State 18 + -26, + // State 19 + -27, + // State 20 + 0, + // State 21 + 0, + // State 22 + 0, + // State 23 + -17, + // State 24 + -21, + // State 25 + 0, + // State 26 + -19, + // State 27 + -16, + // State 28 + 0, + // State 29 + -18, + // State 30 + 0, + ]; + fn __goto(state: i8, nt: usize) -> i8 { + match nt { + 2 => 3, + 8 => 4, + 9 => match state { + 1 => 20, + _ => 5, + }, + 11 => 6, + 12 => 7, + 13 => 8, + 14 => match state { + 1 => 21, + 2 => 22, + 3 => 25, + _ => 9, + }, + 16 => 10, + 18 => 11, + 19 => 12, + 20 => 13, + 21 => 14, + 22 => 15, + _ => 0, + } + } + fn __expected_tokens(__state: i8) -> alloc::vec::Vec { + const __TERMINAL: &[&str] = &[ + r###""(""###, + r###"")""###, + r###"",""###, + r###"";""###, + r###"r#"\"([^\"\\\\]|\\\\[ntr\"'\\\\])*\""#"###, + r###"r#"'([^\"\\\\]|\\\\[ntr\"'\\\\])*'"#"###, + r###"r#"[0-9]+"#"###, + r###"r#"[a-zA-Z_][a-zA-Z0-9_]*"#"###, + ]; + __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 = Spanned; + 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, 8 - 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(4, _) if true => Some(0), + Token(5, _) if true => Some(1), + Token(6, _) if true => Some(2), + Token(7, _) if true => Some(3), + Token(0, _) if true => Some(4), + Token(1, _) if true => Some(5), + Token(2, _) if true => Some(6), + Token(3, _) if true => Some(7), + _ => 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 => match __token { + Token(4, __tok0) | Token(5, __tok0) | Token(6, __tok0) | Token(7, __tok0) | Token(0, __tok0) | Token(1, __tok0) | Token(2, __tok0) | Token(3, __tok0) if true => __Symbol::Variant0(__tok0), + _ => unreachable!(), + }, + _ => unreachable!(), + } + } + pub struct SpStmtParser { + builder: __lalrpop_util::lexer::MatcherBuilder, + _priv: (), + } + + impl SpStmtParser { + pub fn new() -> SpStmtParser { + let __builder = super::__intern_token::new_builder(); + SpStmtParser { + builder: __builder, + _priv: (), + } + } + + #[allow(dead_code)] + pub fn parse< + 'input, + >( + &self, + input: &'input str, + ) -> Result, __lalrpop_util::ParseError, &'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,__lalrpop_util::ParseError, &'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 => { + // __SpStmt = SpStmt => ActionFn(1); + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action1::<>(input, __sym0); + return Some(Ok(__nt)); + } + 46 => { + __reduce46(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) + } + _ => 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_Variant6< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, Atom, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant6(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant7< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, Expr, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant7(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant11< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, Spanned, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant11(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant1< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, Spanned, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant1(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant3< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, Spanned, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant3(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant14< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, Stmt, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant14(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant10< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, String, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant10(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant8< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, Vec, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant8(__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>, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant2(__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>, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant4(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant12< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, core::option::Option>, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant12(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant13< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, core::option::Option>, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant13(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant9< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, i64, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant9(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant5< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, usize, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant5(__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() + } + } + 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) + { + // ( ",") = SpExpr, "," => ActionFn(27); + assert!(__symbols.len() >= 2); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym1.2.clone(); + let __nt = super::__action27::<>(input, __sym0, __sym1); + __symbols.push((__start, __Symbol::Variant1(__nt), __end)); + (2, 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(25); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); + let __end = __start.clone(); + let __nt = super::__action25::<>(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(26); + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action26::<>(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) + { + // ( ",")+ = SpExpr, "," => ActionFn(41); + assert!(__symbols.len() >= 2); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym1.2.clone(); + let __nt = super::__action41::<>(input, __sym0, __sym1); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (2, 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) + { + // ( ",")+ = ( ",")+, SpExpr, "," => ActionFn(42); + assert!(__symbols.len() >= 3); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant1(__symbols); + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym2.2.clone(); + let __nt = super::__action42::<>(input, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (3, 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) + { + // ( ";") = SpStmt, ";" => ActionFn(34); + assert!(__symbols.len() >= 2); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym1.2.clone(); + let __nt = super::__action34::<>(input, __sym0, __sym1); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (2, 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(32); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); + let __end = __start.clone(); + let __nt = super::__action32::<>(input, &__start, &__end); + __symbols.push((__start, __Symbol::Variant4(__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(33); + let __sym0 = __pop_Variant4(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action33::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant4(__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) + { + // ( ";")+ = SpStmt, ";" => ActionFn(45); + assert!(__symbols.len() >= 2); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym1.2.clone(); + let __nt = super::__action45::<>(input, __sym0, __sym1); + __symbols.push((__start, __Symbol::Variant4(__nt), __end)); + (2, 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) + { + // ( ";")+ = ( ";")+, SpStmt, ";" => ActionFn(46); + assert!(__symbols.len() >= 3); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant3(__symbols); + let __sym0 = __pop_Variant4(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym2.2.clone(); + let __nt = super::__action46::<>(input, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant4(__nt), __end)); + (3, 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) + { + // @L = => ActionFn(40); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); + let __end = __start.clone(); + let __nt = super::__action40::<>(input, &__start, &__end); + __symbols.push((__start, __Symbol::Variant5(__nt), __end)); + (0, 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) + { + // @R = => ActionFn(39); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); + let __end = __start.clone(); + let __nt = super::__action39::<>(input, &__start, &__end); + __symbols.push((__start, __Symbol::Variant5(__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) + { + // Atom = Str => ActionFn(15); + let __sym0 = __pop_Variant10(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action15::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant6(__nt), __end)); + (1, 8) + } + 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) + { + // Atom = Int => ActionFn(16); + let __sym0 = __pop_Variant9(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action16::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant6(__nt), __end)); + (1, 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) + { + // Atom = Name => ActionFn(17); + let __sym0 = __pop_Variant10(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action17::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant6(__nt), __end)); + (1, 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) + { + // Expr = SpExpr, "(", SpExpr, ")" => ActionFn(55); + assert!(__symbols.len() >= 4); + let __sym3 = __pop_Variant0(__symbols); + let __sym2 = __pop_Variant1(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym3.2.clone(); + let __nt = super::__action55::<>(input, __sym0, __sym1, __sym2, __sym3); + __symbols.push((__start, __Symbol::Variant7(__nt), __end)); + (4, 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) + { + // Expr = SpExpr, "(", ")" => ActionFn(56); + assert!(__symbols.len() >= 3); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym2.2.clone(); + let __nt = super::__action56::<>(input, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant7(__nt), __end)); + (3, 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) + { + // Expr = SpExpr, "(", ( ",")+, SpExpr, ")" => ActionFn(57); + assert!(__symbols.len() >= 5); + let __sym4 = __pop_Variant0(__symbols); + let __sym3 = __pop_Variant1(__symbols); + let __sym2 = __pop_Variant2(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym4.2.clone(); + let __nt = super::__action57::<>(input, __sym0, __sym1, __sym2, __sym3, __sym4); + __symbols.push((__start, __Symbol::Variant7(__nt), __end)); + (5, 9) + } + 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) + { + // Expr = SpExpr, "(", ( ",")+, ")" => ActionFn(58); + assert!(__symbols.len() >= 4); + let __sym3 = __pop_Variant0(__symbols); + let __sym2 = __pop_Variant2(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym3.2.clone(); + let __nt = super::__action58::<>(input, __sym0, __sym1, __sym2, __sym3); + __symbols.push((__start, __Symbol::Variant7(__nt), __end)); + (4, 9) + } + 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) + { + // Expr = SpAtom => ActionFn(12); + let __sym0 = __pop_Variant11(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action12::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant7(__nt), __end)); + (1, 9) + } + 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) + { + // Expr = "(", Expr, ")" => ActionFn(13); + assert!(__symbols.len() >= 3); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant7(__symbols); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym2.2.clone(); + let __nt = super::__action13::<>(input, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant7(__nt), __end)); + (3, 9) + } + 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) + { + // File = SpStmt => ActionFn(59); + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action59::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant8(__nt), __end)); + (1, 10) + } + 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) + { + // File = => ActionFn(60); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); + let __end = __start.clone(); + let __nt = super::__action60::<>(input, &__start, &__end); + __symbols.push((__start, __Symbol::Variant8(__nt), __end)); + (0, 10) + } + 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) + { + // File = ( ";")+, SpStmt => ActionFn(61); + assert!(__symbols.len() >= 2); + let __sym1 = __pop_Variant3(__symbols); + let __sym0 = __pop_Variant4(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym1.2.clone(); + let __nt = super::__action61::<>(input, __sym0, __sym1); + __symbols.push((__start, __Symbol::Variant8(__nt), __end)); + (2, 10) + } + 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) + { + // File = ( ";")+ => ActionFn(62); + let __sym0 = __pop_Variant4(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action62::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant8(__nt), __end)); + (1, 10) + } + 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) + { + // Int = r#"[0-9]+"# => ActionFn(18); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action18::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant9(__nt), __end)); + (1, 11) + } + 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) + { + // Name = r#"[a-zA-Z_][a-zA-Z0-9_]*"# => ActionFn(21); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action21::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant10(__nt), __end)); + (1, 12) + } + 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) + { + // SpAtom = Spanned => ActionFn(14); + let __sym0 = __pop_Variant11(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action14::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant11(__nt), __end)); + (1, 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) + { + // SpExpr = Spanned => ActionFn(10); + let __sym0 = __pop_Variant1(__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, 14) + } + 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) + { + // SpExpr? = SpExpr => ActionFn(23); + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action23::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant12(__nt), __end)); + (1, 15) + } + 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) + { + // SpExpr? = => ActionFn(24); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); + let __end = __start.clone(); + let __nt = super::__action24::<>(input, &__start, &__end); + __symbols.push((__start, __Symbol::Variant12(__nt), __end)); + (0, 15) + } + 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) + { + // SpStmt = Spanned => ActionFn(8); + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action8::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (1, 16) + } + 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) + { + // SpStmt? = SpStmt => ActionFn(30); + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action30::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant13(__nt), __end)); + (1, 17) + } + 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) + { + // SpStmt? = => ActionFn(31); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); + let __end = __start.clone(); + let __nt = super::__action31::<>(input, &__start, &__end); + __symbols.push((__start, __Symbol::Variant13(__nt), __end)); + (0, 17) + } + 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) + { + // Spanned = Atom => ActionFn(52); + let __sym0 = __pop_Variant6(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action52::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant11(__nt), __end)); + (1, 18) + } + 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) + { + // Spanned = Expr => ActionFn(53); + let __sym0 = __pop_Variant7(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action53::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant1(__nt), __end)); + (1, 19) + } + 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) + { + // Spanned = Stmt => ActionFn(54); + let __sym0 = __pop_Variant14(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action54::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (1, 20) + } + 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) + { + // Stmt = SpExpr => ActionFn(9); + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action9::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant14(__nt), __end)); + (1, 21) + } + 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) + { + // Str = r#"\"([^\"\\\\]|\\\\[ntr\"'\\\\])*\""# => ActionFn(19); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action19::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant10(__nt), __end)); + (1, 22) + } + 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) + { + // Str = r#"'([^\"\\\\]|\\\\[ntr\"'\\\\])*'"# => ActionFn(20); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action20::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant10(__nt), __end)); + (1, 22) + } + 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) + { + // __Atom = Atom => ActionFn(6); + let __sym0 = __pop_Variant6(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action6::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant6(__nt), __end)); + (1, 23) + } + 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(4); + let __sym0 = __pop_Variant7(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action4::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant7(__nt), __end)); + (1, 24) + } + 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) + { + // __File = File => ActionFn(0); + let __sym0 = __pop_Variant8(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action0::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant8(__nt), __end)); + (1, 25) + } + 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) + { + // __SpAtom = SpAtom => ActionFn(5); + let __sym0 = __pop_Variant11(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action5::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant11(__nt), __end)); + (1, 26) + } + 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) + { + // __SpExpr = SpExpr => ActionFn(3); + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action3::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant1(__nt), __end)); + (1, 27) + } + 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) + { + // __Stmt = Stmt => ActionFn(2); + let __sym0 = __pop_Variant14(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action2::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant14(__nt), __end)); + (1, 29) + } +} +pub use self::__parse__SpStmt::SpStmtParser; + +#[cfg_attr(rustfmt, rustfmt_skip)] +mod __parse__Stmt { + #![allow(non_snake_case, non_camel_case_types, unused_mut, unused_variables, unused_imports, unused_parens, clippy::all)] + + use std::str::FromStr; + use crate::syn::{Span, Spanned, unescape}; + use crate::syn::ast::*; + #[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(Spanned), + Variant2(alloc::vec::Vec>), + Variant3(Spanned), + Variant4(alloc::vec::Vec>), + Variant5(usize), + Variant6(Atom), + Variant7(Expr), + Variant8(Vec), + Variant9(i64), + Variant10(String), + Variant11(Spanned), + Variant12(core::option::Option>), + Variant13(core::option::Option>), + Variant14(Stmt), + } + const __ACTION: &[i8] = &[ + // State 0 + 2, 0, 0, 0, 15, 16, 17, 18, + // State 1 + 2, 0, 0, 0, 15, 16, 17, 18, + // State 2 + 2, 22, 0, 0, 15, 16, 17, 18, + // State 3 + 2, 25, 0, 0, 15, 16, 17, 18, + // State 4 + -35, -35, -35, 0, 0, 0, 0, 0, + // State 5 + -36, -36, -36, 0, 0, 0, 0, 0, + // State 6 + -14, -14, -14, 0, 0, 0, 0, 0, + // State 7 + -15, -15, -15, 0, 0, 0, 0, 0, + // State 8 + -20, -20, -20, 0, 0, 0, 0, 0, + // State 9 + 3, 0, 0, 0, 0, 0, 0, 0, + // State 10 + -28, -28, -28, 0, 0, 0, 0, 0, + // State 11 + -29, -29, -29, 0, 0, 0, 0, 0, + // State 12 + 0, 0, 0, 0, 0, 0, 0, 0, + // State 13 + -13, -13, -13, 0, 0, 0, 0, 0, + // State 14 + -39, -39, -39, 0, 0, 0, 0, 0, + // State 15 + -40, -40, -40, 0, 0, 0, 0, 0, + // State 16 + -26, -26, -26, 0, 0, 0, 0, 0, + // State 17 + -27, -27, -27, 0, 0, 0, 0, 0, + // State 18 + -36, 23, 0, 0, 0, 0, 0, 0, + // State 19 + 3, 0, 0, 0, 0, 0, 0, 0, + // State 20 + 3, 26, 27, 0, 0, 0, 0, 0, + // State 21 + -17, -17, -17, 0, 0, 0, 0, 0, + // State 22 + -21, -21, -21, 0, 0, 0, 0, 0, + // State 23 + 3, 28, 29, 0, 0, 0, 0, 0, + // State 24 + -19, -19, -19, 0, 0, 0, 0, 0, + // State 25 + -16, -16, -16, 0, 0, 0, 0, 0, + // State 26 + -4, -4, 0, 0, -4, -4, -4, -4, + // State 27 + -18, -18, -18, 0, 0, 0, 0, 0, + // State 28 + -5, -5, 0, 0, -5, -5, -5, -5, + ]; + fn __action(state: i8, integer: usize) -> i8 { + __ACTION[(state as usize) * 8 + integer] + } + const __EOF_ACTION: &[i8] = &[ + // State 0 + 0, + // State 1 + 0, + // State 2 + 0, + // State 3 + 0, + // State 4 + -35, + // State 5 + -36, + // State 6 + -14, + // State 7 + -15, + // State 8 + -20, + // State 9 + -38, + // State 10 + -28, + // State 11 + -29, + // State 12 + -47, + // State 13 + -13, + // State 14 + -39, + // State 15 + -40, + // State 16 + -26, + // State 17 + -27, + // State 18 + 0, + // State 19 + 0, + // State 20 + 0, + // State 21 + -17, + // State 22 + -21, + // State 23 + 0, + // State 24 + -19, + // State 25 + -16, + // State 26 + 0, + // State 27 + -18, + // State 28 + 0, + ]; + fn __goto(state: i8, nt: usize) -> i8 { + match nt { + 2 => 3, + 8 => 4, + 9 => match state { + 1 => 18, + _ => 5, + }, + 11 => 6, + 12 => 7, + 13 => 8, + 14 => match state { + 1 => 19, + 2 => 20, + 3 => 23, + _ => 9, + }, + 18 => 10, + 19 => 11, + 21 => 12, + 22 => 13, + _ => 0, + } + } + fn __expected_tokens(__state: i8) -> alloc::vec::Vec { + const __TERMINAL: &[&str] = &[ + r###""(""###, + r###"")""###, + r###"",""###, + r###"";""###, + r###"r#"\"([^\"\\\\]|\\\\[ntr\"'\\\\])*\""#"###, + r###"r#"'([^\"\\\\]|\\\\[ntr\"'\\\\])*'"#"###, + r###"r#"[0-9]+"#"###, + r###"r#"[a-zA-Z_][a-zA-Z0-9_]*"#"###, + ]; + __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 = Stmt; + 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, 8 - 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(4, _) if true => Some(0), + Token(5, _) if true => Some(1), + Token(6, _) if true => Some(2), + Token(7, _) if true => Some(3), + Token(0, _) if true => Some(4), + Token(1, _) if true => Some(5), + Token(2, _) if true => Some(6), + Token(3, _) if true => Some(7), + _ => 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 => match __token { + Token(4, __tok0) | Token(5, __tok0) | Token(6, __tok0) | Token(7, __tok0) | Token(0, __tok0) | Token(1, __tok0) | Token(2, __tok0) | Token(3, __tok0) if true => __Symbol::Variant0(__tok0), + _ => unreachable!(), + }, + _ => unreachable!(), + } + } + pub struct StmtParser { + builder: __lalrpop_util::lexer::MatcherBuilder, + _priv: (), + } + + impl StmtParser { + pub fn new() -> StmtParser { + let __builder = super::__intern_token::new_builder(); + StmtParser { + 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 => { + // __Stmt = Stmt => ActionFn(2); + let __sym0 = __pop_Variant14(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action2::<>(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_Variant6< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, Atom, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant6(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant7< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, Expr, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant7(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant11< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, Spanned, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant11(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant1< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, Spanned, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant1(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant3< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, Spanned, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant3(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant14< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, Stmt, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant14(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant10< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, String, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant10(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant8< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, Vec, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant8(__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>, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant2(__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>, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant4(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant12< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, core::option::Option>, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant12(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant13< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, core::option::Option>, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant13(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant9< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, i64, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant9(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant5< + 'input, + >( + __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> + ) -> (usize, usize, usize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant5(__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() + } + } + 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) + { + // ( ",") = SpExpr, "," => ActionFn(27); + assert!(__symbols.len() >= 2); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym1.2.clone(); + let __nt = super::__action27::<>(input, __sym0, __sym1); + __symbols.push((__start, __Symbol::Variant1(__nt), __end)); + (2, 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(25); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); + let __end = __start.clone(); + let __nt = super::__action25::<>(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(26); + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action26::<>(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) + { + // ( ",")+ = SpExpr, "," => ActionFn(41); + assert!(__symbols.len() >= 2); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym1.2.clone(); + let __nt = super::__action41::<>(input, __sym0, __sym1); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (2, 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) + { + // ( ",")+ = ( ",")+, SpExpr, "," => ActionFn(42); + assert!(__symbols.len() >= 3); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant1(__symbols); + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym2.2.clone(); + let __nt = super::__action42::<>(input, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (3, 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) + { + // ( ";") = SpStmt, ";" => ActionFn(34); + assert!(__symbols.len() >= 2); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym1.2.clone(); + let __nt = super::__action34::<>(input, __sym0, __sym1); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (2, 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(32); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); + let __end = __start.clone(); + let __nt = super::__action32::<>(input, &__start, &__end); + __symbols.push((__start, __Symbol::Variant4(__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(33); + let __sym0 = __pop_Variant4(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action33::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant4(__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) + { + // ( ";")+ = SpStmt, ";" => ActionFn(45); + assert!(__symbols.len() >= 2); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym1.2.clone(); + let __nt = super::__action45::<>(input, __sym0, __sym1); + __symbols.push((__start, __Symbol::Variant4(__nt), __end)); + (2, 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) + { + // ( ";")+ = ( ";")+, SpStmt, ";" => ActionFn(46); + assert!(__symbols.len() >= 3); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant3(__symbols); + let __sym0 = __pop_Variant4(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym2.2.clone(); + let __nt = super::__action46::<>(input, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant4(__nt), __end)); + (3, 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) + { + // @L = => ActionFn(40); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); + let __end = __start.clone(); + let __nt = super::__action40::<>(input, &__start, &__end); + __symbols.push((__start, __Symbol::Variant5(__nt), __end)); + (0, 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) + { + // @R = => ActionFn(39); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); + let __end = __start.clone(); + let __nt = super::__action39::<>(input, &__start, &__end); + __symbols.push((__start, __Symbol::Variant5(__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) + { + // Atom = Str => ActionFn(15); + let __sym0 = __pop_Variant10(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action15::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant6(__nt), __end)); + (1, 8) + } + 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) + { + // Atom = Int => ActionFn(16); + let __sym0 = __pop_Variant9(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action16::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant6(__nt), __end)); + (1, 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) + { + // Atom = Name => ActionFn(17); + let __sym0 = __pop_Variant10(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action17::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant6(__nt), __end)); + (1, 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) + { + // Expr = SpExpr, "(", SpExpr, ")" => ActionFn(55); + assert!(__symbols.len() >= 4); + let __sym3 = __pop_Variant0(__symbols); + let __sym2 = __pop_Variant1(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym3.2.clone(); + let __nt = super::__action55::<>(input, __sym0, __sym1, __sym2, __sym3); + __symbols.push((__start, __Symbol::Variant7(__nt), __end)); + (4, 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) + { + // Expr = SpExpr, "(", ")" => ActionFn(56); + assert!(__symbols.len() >= 3); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym2.2.clone(); + let __nt = super::__action56::<>(input, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant7(__nt), __end)); + (3, 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) + { + // Expr = SpExpr, "(", ( ",")+, SpExpr, ")" => ActionFn(57); + assert!(__symbols.len() >= 5); + let __sym4 = __pop_Variant0(__symbols); + let __sym3 = __pop_Variant1(__symbols); + let __sym2 = __pop_Variant2(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym4.2.clone(); + let __nt = super::__action57::<>(input, __sym0, __sym1, __sym2, __sym3, __sym4); + __symbols.push((__start, __Symbol::Variant7(__nt), __end)); + (5, 9) + } + 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) + { + // Expr = SpExpr, "(", ( ",")+, ")" => ActionFn(58); + assert!(__symbols.len() >= 4); + let __sym3 = __pop_Variant0(__symbols); + let __sym2 = __pop_Variant2(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym3.2.clone(); + let __nt = super::__action58::<>(input, __sym0, __sym1, __sym2, __sym3); + __symbols.push((__start, __Symbol::Variant7(__nt), __end)); + (4, 9) + } + 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) + { + // Expr = SpAtom => ActionFn(12); + let __sym0 = __pop_Variant11(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action12::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant7(__nt), __end)); + (1, 9) + } + 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) + { + // Expr = "(", Expr, ")" => ActionFn(13); + assert!(__symbols.len() >= 3); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant7(__symbols); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym2.2.clone(); + let __nt = super::__action13::<>(input, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant7(__nt), __end)); + (3, 9) + } + 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) + { + // File = SpStmt => ActionFn(59); + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action59::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant8(__nt), __end)); + (1, 10) + } + 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) + { + // File = => ActionFn(60); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); + let __end = __start.clone(); + let __nt = super::__action60::<>(input, &__start, &__end); + __symbols.push((__start, __Symbol::Variant8(__nt), __end)); + (0, 10) + } + 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) + { + // File = ( ";")+, SpStmt => ActionFn(61); + assert!(__symbols.len() >= 2); + let __sym1 = __pop_Variant3(__symbols); + let __sym0 = __pop_Variant4(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym1.2.clone(); + let __nt = super::__action61::<>(input, __sym0, __sym1); + __symbols.push((__start, __Symbol::Variant8(__nt), __end)); + (2, 10) + } + 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) + { + // File = ( ";")+ => ActionFn(62); + let __sym0 = __pop_Variant4(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action62::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant8(__nt), __end)); + (1, 10) + } + 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) + { + // Int = r#"[0-9]+"# => ActionFn(18); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action18::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant9(__nt), __end)); + (1, 11) + } + 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) + { + // Name = r#"[a-zA-Z_][a-zA-Z0-9_]*"# => ActionFn(21); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action21::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant10(__nt), __end)); + (1, 12) + } + 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) + { + // SpAtom = Spanned => ActionFn(14); + let __sym0 = __pop_Variant11(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action14::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant11(__nt), __end)); + (1, 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) + { + // SpExpr = Spanned => ActionFn(10); + let __sym0 = __pop_Variant1(__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, 14) + } + 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) + { + // SpExpr? = SpExpr => ActionFn(23); + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action23::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant12(__nt), __end)); + (1, 15) + } + 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) + { + // SpExpr? = => ActionFn(24); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); + let __end = __start.clone(); + let __nt = super::__action24::<>(input, &__start, &__end); + __symbols.push((__start, __Symbol::Variant12(__nt), __end)); + (0, 15) + } + 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) + { + // SpStmt = Spanned => ActionFn(8); + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action8::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (1, 16) + } + 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) + { + // SpStmt? = SpStmt => ActionFn(30); + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action30::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant13(__nt), __end)); + (1, 17) + } + 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) + { + // SpStmt? = => ActionFn(31); + let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); + let __end = __start.clone(); + let __nt = super::__action31::<>(input, &__start, &__end); + __symbols.push((__start, __Symbol::Variant13(__nt), __end)); + (0, 17) + } + 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) + { + // Spanned = Atom => ActionFn(52); + let __sym0 = __pop_Variant6(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action52::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant11(__nt), __end)); + (1, 18) + } + 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) + { + // Spanned = Expr => ActionFn(53); + let __sym0 = __pop_Variant7(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action53::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant1(__nt), __end)); + (1, 19) + } + 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) + { + // Spanned = Stmt => ActionFn(54); + let __sym0 = __pop_Variant14(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action54::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (1, 20) + } + 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) + { + // Stmt = SpExpr => ActionFn(9); + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action9::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant14(__nt), __end)); + (1, 21) + } + 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) + { + // Str = r#"\"([^\"\\\\]|\\\\[ntr\"'\\\\])*\""# => ActionFn(19); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action19::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant10(__nt), __end)); + (1, 22) + } + 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) + { + // Str = r#"'([^\"\\\\]|\\\\[ntr\"'\\\\])*'"# => ActionFn(20); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action20::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant10(__nt), __end)); + (1, 22) + } + 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) + { + // __Atom = Atom => ActionFn(6); + let __sym0 = __pop_Variant6(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action6::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant6(__nt), __end)); + (1, 23) + } + 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(4); + let __sym0 = __pop_Variant7(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action4::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant7(__nt), __end)); + (1, 24) + } + 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) + { + // __File = File => ActionFn(0); + let __sym0 = __pop_Variant8(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action0::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant8(__nt), __end)); + (1, 25) + } + 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) + { + // __SpAtom = SpAtom => ActionFn(5); + let __sym0 = __pop_Variant11(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action5::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant11(__nt), __end)); + (1, 26) + } + 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) + { + // __SpExpr = SpExpr => ActionFn(3); + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action3::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant1(__nt), __end)); + (1, 27) + } + 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) + { + // __SpStmt = SpStmt => ActionFn(1); + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action1::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (1, 28) + } +} +pub use self::__parse__Stmt::StmtParser; +#[cfg_attr(rustfmt, rustfmt_skip)] +mod __intern_token { + #![allow(unused_imports)] + use std::str::FromStr; + use crate::syn::{Span, Spanned, unescape}; + use crate::syn::ast::*; + #[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)] = &[ + ("^(\"([\0-!\\#-\\[\\]-\u{10ffff}]|\\\\[\"'\\\\nrt])*\")", false), + ("^('([\0-!\\#-\\[\\]-\u{10ffff}]|\\\\[\"'\\\\nrt])*')", false), + ("^([0-9]+)", false), + ("^([A-Z_a-z][0-9A-Z_a-z]*)", false), + ("^(\\()", false), + ("^(\\))", false), + ("^(,)", 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, Vec, usize), +) -> Vec +{ + __0 +} + +#[allow(unused_variables)] +fn __action1< + 'input, +>( + input: &'input str, + (_, __0, _): (usize, Spanned, usize), +) -> Spanned +{ + __0 +} + +#[allow(unused_variables)] +fn __action2< + 'input, +>( + input: &'input str, + (_, __0, _): (usize, Stmt, usize), +) -> Stmt +{ + __0 +} + +#[allow(unused_variables)] +fn __action3< + 'input, +>( + input: &'input str, + (_, __0, _): (usize, Spanned, usize), +) -> Spanned +{ + __0 +} + +#[allow(unused_variables)] +fn __action4< + 'input, +>( + input: &'input str, + (_, __0, _): (usize, Expr, usize), +) -> Expr +{ + __0 +} + +#[allow(unused_variables)] +fn __action5< + 'input, +>( + input: &'input str, + (_, __0, _): (usize, Spanned, usize), +) -> Spanned +{ + __0 +} + +#[allow(unused_variables)] +fn __action6< + 'input, +>( + input: &'input str, + (_, __0, _): (usize, Atom, usize), +) -> Atom +{ + __0 +} + +#[allow(unused_variables)] +fn __action7< + 'input, +>( + input: &'input str, + (_, mut head, _): (usize, alloc::vec::Vec>, usize), + (_, tail, _): (usize, core::option::Option>, usize), +) -> Vec +{ + { + if let Some(tail) = tail { + head.push(tail); + } + head + } +} + +#[allow(unused_variables)] +fn __action8< + 'input, +>( + input: &'input str, + (_, __0, _): (usize, Spanned, usize), +) -> Spanned +{ + __0 +} + +#[allow(unused_variables)] +fn __action9< + 'input, +>( + input: &'input str, + (_, __0, _): (usize, Spanned, usize), +) -> Stmt +{ + Stmt::Expr(__0) +} + +#[allow(unused_variables)] +fn __action10< + 'input, +>( + input: &'input str, + (_, __0, _): (usize, Spanned, usize), +) -> Spanned +{ + __0 +} + +#[allow(unused_variables)] +fn __action11< + 'input, +>( + input: &'input str, + (_, fun, _): (usize, Spanned, usize), + (_, _, _): (usize, &'input str, usize), + (_, mut argv, _): (usize, alloc::vec::Vec>, usize), + (_, last, _): (usize, core::option::Option>, usize), + (_, _, _): (usize, &'input str, usize), +) -> Expr +{ + { + let argv = match last { + Some(expr) => { + argv.push(expr); + argv + } + None => argv, + }; + Expr::Call(Box::new(fun), argv) + } +} + +#[allow(unused_variables)] +fn __action12< + 'input, +>( + input: &'input str, + (_, atom, _): (usize, Spanned, usize), +) -> Expr +{ + Expr::Atom(atom) +} + +#[allow(unused_variables)] +fn __action13< + 'input, +>( + input: &'input str, + (_, _, _): (usize, &'input str, usize), + (_, expr, _): (usize, Expr, usize), + (_, _, _): (usize, &'input str, usize), +) -> Expr +{ + expr +} + +#[allow(unused_variables)] +fn __action14< + 'input, +>( + input: &'input str, + (_, __0, _): (usize, Spanned, usize), +) -> Spanned +{ + __0 +} + +#[allow(unused_variables)] +fn __action15< + 'input, +>( + input: &'input str, + (_, s, _): (usize, String, usize), +) -> Atom +{ + Atom::Str(s) +} + +#[allow(unused_variables)] +fn __action16< + 'input, +>( + input: &'input str, + (_, n, _): (usize, i64, usize), +) -> Atom +{ + Atom::Int(n) +} + +#[allow(unused_variables)] +fn __action17< + 'input, +>( + input: &'input str, + (_, name, _): (usize, String, usize), +) -> Atom +{ + Atom::Name(name) +} + +#[allow(unused_variables)] +fn __action18< + 'input, +>( + input: &'input str, + (_, s, _): (usize, &'input str, usize), +) -> i64 +{ + i64::from_str(s).unwrap() +} + +#[allow(unused_variables)] +fn __action19< + 'input, +>( + input: &'input str, + (_, s, _): (usize, &'input str, usize), +) -> String +{ + unescape(&s[1..s.len() - 1]) +} + +#[allow(unused_variables)] +fn __action20< + 'input, +>( + input: &'input str, + (_, s, _): (usize, &'input str, usize), +) -> String +{ + unescape(&s[1..s.len() - 1]) +} + +#[allow(unused_variables)] +fn __action21< + 'input, +>( + input: &'input str, + (_, s, _): (usize, &'input str, usize), +) -> String +{ + s.to_string() +} + +#[allow(unused_variables)] +fn __action22< + 'input, +>( + input: &'input str, + (_, start, _): (usize, usize, usize), + (_, inner, _): (usize, Atom, usize), + (_, end, _): (usize, usize, usize), +) -> Spanned +{ + Spanned::new(Span::new(start, end), inner) +} + +#[allow(unused_variables)] +fn __action23< + 'input, +>( + input: &'input str, + (_, __0, _): (usize, Spanned, usize), +) -> core::option::Option> +{ + Some(__0) +} + +#[allow(unused_variables)] +fn __action24< + 'input, +>( + input: &'input str, + __lookbehind: &usize, + __lookahead: &usize, +) -> core::option::Option> +{ + None +} + +#[allow(unused_variables)] +fn __action25< + 'input, +>( + input: &'input str, + __lookbehind: &usize, + __lookahead: &usize, +) -> alloc::vec::Vec> +{ + alloc::vec![] +} + +#[allow(unused_variables)] +fn __action26< + 'input, +>( + input: &'input str, + (_, v, _): (usize, alloc::vec::Vec>, usize), +) -> alloc::vec::Vec> +{ + v +} + +#[allow(unused_variables)] +fn __action27< + 'input, +>( + input: &'input str, + (_, __0, _): (usize, Spanned, usize), + (_, _, _): (usize, &'input str, usize), +) -> Spanned +{ + __0 +} + +#[allow(unused_variables)] +fn __action28< + 'input, +>( + input: &'input str, + (_, start, _): (usize, usize, usize), + (_, inner, _): (usize, Expr, usize), + (_, end, _): (usize, usize, usize), +) -> Spanned +{ + Spanned::new(Span::new(start, end), inner) +} + +#[allow(unused_variables)] +fn __action29< + 'input, +>( + input: &'input str, + (_, start, _): (usize, usize, usize), + (_, inner, _): (usize, Stmt, usize), + (_, end, _): (usize, usize, usize), +) -> Spanned +{ + Spanned::new(Span::new(start, end), inner) +} + +#[allow(unused_variables)] +fn __action30< + 'input, +>( + input: &'input str, + (_, __0, _): (usize, Spanned, usize), +) -> core::option::Option> +{ + Some(__0) +} + +#[allow(unused_variables)] +fn __action31< + 'input, +>( + input: &'input str, + __lookbehind: &usize, + __lookahead: &usize, +) -> core::option::Option> +{ + None +} + +#[allow(unused_variables)] +fn __action32< + 'input, +>( + input: &'input str, + __lookbehind: &usize, + __lookahead: &usize, +) -> alloc::vec::Vec> +{ + alloc::vec![] +} + +#[allow(unused_variables)] +fn __action33< + 'input, +>( + input: &'input str, + (_, v, _): (usize, alloc::vec::Vec>, usize), +) -> alloc::vec::Vec> +{ + v +} + +#[allow(unused_variables)] +fn __action34< + 'input, +>( + input: &'input str, + (_, __0, _): (usize, Spanned, usize), + (_, _, _): (usize, &'input str, usize), +) -> Spanned +{ + __0 +} + +#[allow(unused_variables)] +fn __action35< + 'input, +>( + input: &'input str, + (_, __0, _): (usize, Spanned, usize), +) -> alloc::vec::Vec> +{ + alloc::vec![__0] +} + +#[allow(unused_variables)] +fn __action36< + 'input, +>( + input: &'input str, + (_, v, _): (usize, alloc::vec::Vec>, usize), + (_, e, _): (usize, Spanned, usize), +) -> alloc::vec::Vec> +{ + { let mut v = v; v.push(e); v } +} + +#[allow(unused_variables)] +fn __action37< + 'input, +>( + input: &'input str, + (_, __0, _): (usize, Spanned, usize), +) -> alloc::vec::Vec> +{ + alloc::vec![__0] +} + +#[allow(unused_variables)] +fn __action38< + 'input, +>( + input: &'input str, + (_, v, _): (usize, alloc::vec::Vec>, usize), + (_, e, _): (usize, Spanned, usize), +) -> alloc::vec::Vec> +{ + { let mut v = v; v.push(e); v } +} + +#[allow(unused_variables)] +fn __action39< + 'input, +>( + input: &'input str, + __lookbehind: &usize, + __lookahead: &usize, +) -> usize +{ + __lookbehind.clone() +} + +#[allow(unused_variables)] +fn __action40< + 'input, +>( + input: &'input str, + __lookbehind: &usize, + __lookahead: &usize, +) -> usize +{ + __lookahead.clone() +} + +#[allow(unused_variables)] +fn __action41< + 'input, +>( + input: &'input str, + __0: (usize, Spanned, usize), + __1: (usize, &'input str, usize), +) -> alloc::vec::Vec> +{ + let __start0 = __0.0.clone(); + let __end0 = __1.2.clone(); + let __temp0 = __action27( + input, + __0, + __1, + ); + let __temp0 = (__start0, __temp0, __end0); + __action37( + input, + __temp0, + ) +} + +#[allow(unused_variables)] +fn __action42< + 'input, +>( + input: &'input str, + __0: (usize, alloc::vec::Vec>, usize), + __1: (usize, Spanned, usize), + __2: (usize, &'input str, usize), +) -> alloc::vec::Vec> +{ + let __start0 = __1.0.clone(); + let __end0 = __2.2.clone(); + let __temp0 = __action27( + input, + __1, + __2, + ); + let __temp0 = (__start0, __temp0, __end0); + __action38( + input, + __0, + __temp0, + ) +} + +#[allow(unused_variables)] +fn __action43< + 'input, +>( + input: &'input str, + __0: (usize, Spanned, 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 = __action25( + input, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action11( + input, + __0, + __1, + __temp0, + __2, + __3, + ) +} + +#[allow(unused_variables)] +fn __action44< + 'input, +>( + input: &'input str, + __0: (usize, Spanned, usize), + __1: (usize, &'input str, usize), + __2: (usize, alloc::vec::Vec>, 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 = __action26( + input, + __2, + ); + let __temp0 = (__start0, __temp0, __end0); + __action11( + input, + __0, + __1, + __temp0, + __3, + __4, + ) +} + +#[allow(unused_variables)] +fn __action45< + 'input, +>( + input: &'input str, + __0: (usize, Spanned, usize), + __1: (usize, &'input str, usize), +) -> alloc::vec::Vec> +{ + let __start0 = __0.0.clone(); + let __end0 = __1.2.clone(); + let __temp0 = __action34( + input, + __0, + __1, + ); + let __temp0 = (__start0, __temp0, __end0); + __action35( + input, + __temp0, + ) +} + +#[allow(unused_variables)] +fn __action46< + 'input, +>( + input: &'input str, + __0: (usize, alloc::vec::Vec>, usize), + __1: (usize, Spanned, usize), + __2: (usize, &'input str, usize), +) -> alloc::vec::Vec> +{ + let __start0 = __1.0.clone(); + let __end0 = __2.2.clone(); + let __temp0 = __action34( + input, + __1, + __2, + ); + let __temp0 = (__start0, __temp0, __end0); + __action36( + input, + __0, + __temp0, + ) +} + +#[allow(unused_variables)] +fn __action47< + 'input, +>( + input: &'input str, + __0: (usize, core::option::Option>, usize), +) -> Vec +{ + let __start0 = __0.0.clone(); + let __end0 = __0.0.clone(); + let __temp0 = __action32( + input, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action7( + input, + __temp0, + __0, + ) +} + +#[allow(unused_variables)] +fn __action48< + 'input, +>( + input: &'input str, + __0: (usize, alloc::vec::Vec>, usize), + __1: (usize, core::option::Option>, usize), +) -> Vec +{ + let __start0 = __0.0.clone(); + let __end0 = __0.2.clone(); + let __temp0 = __action33( + input, + __0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action7( + input, + __temp0, + __1, + ) +} + +#[allow(unused_variables)] +fn __action49< + 'input, +>( + input: &'input str, + __0: (usize, Atom, usize), + __1: (usize, usize, usize), +) -> Spanned +{ + let __start0 = __0.0.clone(); + let __end0 = __0.0.clone(); + let __temp0 = __action40( + input, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action22( + input, + __temp0, + __0, + __1, + ) +} + +#[allow(unused_variables)] +fn __action50< + 'input, +>( + input: &'input str, + __0: (usize, Expr, usize), + __1: (usize, usize, usize), +) -> Spanned +{ + let __start0 = __0.0.clone(); + let __end0 = __0.0.clone(); + let __temp0 = __action40( + input, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action28( + input, + __temp0, + __0, + __1, + ) +} + +#[allow(unused_variables)] +fn __action51< + 'input, +>( + input: &'input str, + __0: (usize, Stmt, usize), + __1: (usize, usize, usize), +) -> Spanned +{ + let __start0 = __0.0.clone(); + let __end0 = __0.0.clone(); + let __temp0 = __action40( + input, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action29( + input, + __temp0, + __0, + __1, + ) +} + +#[allow(unused_variables)] +fn __action52< + 'input, +>( + input: &'input str, + __0: (usize, Atom, usize), +) -> Spanned +{ + let __start0 = __0.2.clone(); + let __end0 = __0.2.clone(); + let __temp0 = __action39( + input, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action49( + input, + __0, + __temp0, + ) +} + +#[allow(unused_variables)] +fn __action53< + 'input, +>( + input: &'input str, + __0: (usize, Expr, usize), +) -> Spanned +{ + let __start0 = __0.2.clone(); + let __end0 = __0.2.clone(); + let __temp0 = __action39( + input, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action50( + input, + __0, + __temp0, + ) +} + +#[allow(unused_variables)] +fn __action54< + 'input, +>( + input: &'input str, + __0: (usize, Stmt, usize), +) -> Spanned +{ + let __start0 = __0.2.clone(); + let __end0 = __0.2.clone(); + let __temp0 = __action39( + input, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action51( + input, + __0, + __temp0, + ) +} + +#[allow(unused_variables)] +fn __action55< + 'input, +>( + input: &'input str, + __0: (usize, Spanned, usize), + __1: (usize, &'input str, usize), + __2: (usize, Spanned, usize), + __3: (usize, &'input str, usize), +) -> Expr +{ + let __start0 = __2.0.clone(); + let __end0 = __2.2.clone(); + let __temp0 = __action23( + input, + __2, + ); + let __temp0 = (__start0, __temp0, __end0); + __action43( + input, + __0, + __1, + __temp0, + __3, + ) +} + +#[allow(unused_variables)] +fn __action56< + 'input, +>( + input: &'input str, + __0: (usize, Spanned, usize), + __1: (usize, &'input str, usize), + __2: (usize, &'input str, usize), +) -> Expr +{ + let __start0 = __1.2.clone(); + let __end0 = __2.0.clone(); + let __temp0 = __action24( + input, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action43( + input, + __0, + __1, + __temp0, + __2, + ) +} + +#[allow(unused_variables)] +fn __action57< + 'input, +>( + input: &'input str, + __0: (usize, Spanned, usize), + __1: (usize, &'input str, usize), + __2: (usize, alloc::vec::Vec>, usize), + __3: (usize, Spanned, usize), + __4: (usize, &'input str, usize), +) -> Expr +{ + let __start0 = __3.0.clone(); + let __end0 = __3.2.clone(); + let __temp0 = __action23( + input, + __3, + ); + let __temp0 = (__start0, __temp0, __end0); + __action44( + input, + __0, + __1, + __2, + __temp0, + __4, + ) +} + +#[allow(unused_variables)] +fn __action58< + 'input, +>( + input: &'input str, + __0: (usize, Spanned, usize), + __1: (usize, &'input str, usize), + __2: (usize, alloc::vec::Vec>, usize), + __3: (usize, &'input str, usize), +) -> Expr +{ + let __start0 = __2.2.clone(); + let __end0 = __3.0.clone(); + let __temp0 = __action24( + input, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action44( + input, + __0, + __1, + __2, + __temp0, + __3, + ) +} + +#[allow(unused_variables)] +fn __action59< + 'input, +>( + input: &'input str, + __0: (usize, Spanned, usize), +) -> Vec +{ + let __start0 = __0.0.clone(); + let __end0 = __0.2.clone(); + let __temp0 = __action30( + input, + __0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action47( + input, + __temp0, + ) +} + +#[allow(unused_variables)] +fn __action60< + 'input, +>( + input: &'input str, + __lookbehind: &usize, + __lookahead: &usize, +) -> Vec +{ + let __start0 = __lookbehind.clone(); + let __end0 = __lookahead.clone(); + let __temp0 = __action31( + input, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action47( + input, + __temp0, + ) +} + +#[allow(unused_variables)] +fn __action61< + 'input, +>( + input: &'input str, + __0: (usize, alloc::vec::Vec>, usize), + __1: (usize, Spanned, usize), +) -> Vec +{ + let __start0 = __1.0.clone(); + let __end0 = __1.2.clone(); + let __temp0 = __action30( + input, + __1, + ); + let __temp0 = (__start0, __temp0, __end0); + __action48( + input, + __0, + __temp0, + ) +} + +#[allow(unused_variables)] +fn __action62< + 'input, +>( + input: &'input str, + __0: (usize, alloc::vec::Vec>, usize), +) -> Vec +{ + let __start0 = __0.2.clone(); + let __end0 = __0.2.clone(); + let __temp0 = __action31( + input, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action48( + input, + __0, + __temp0, + ) +} + +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/src/vm/frame.rs b/src/vm/frame.rs new file mode 100644 index 0000000..b91dedf --- /dev/null +++ b/src/vm/frame.rs @@ -0,0 +1,190 @@ +use std::collections::BTreeMap; + +use crate::{ + obj::{ + builtin_fun::{BuiltinFun, BuiltinFunState}, + user_fun::UserFun, + ObjPtr, + }, + vm::name::Name, +}; + +#[derive(Debug)] +pub enum Frame { + Builtin(BuiltinFrame), + User(UserFrame), +} + +impl Frame { + pub fn last_sp(&self) -> usize { + match self { + Frame::Builtin(frame) => frame.last_sp(), + Frame::User(frame) => frame.last_sp(), + } + } +} + +impl From for Frame { + fn from(other: UserFrame) -> Self { + Self::User(other) + } +} + +impl From for Frame { + fn from(other: BuiltinFrame) -> Self { + Self::Builtin(other) + } +} + +#[derive(Debug)] +pub struct BuiltinFrame { + builtin_fun: ObjPtr, + args: Vec, + last_sp: usize, + state: BuiltinFunState, +} + +impl BuiltinFrame { + pub fn new(builtin_fun: ObjPtr, args: Vec, last_sp: usize) -> Self { + assert!( + builtin_fun.as_any().is::(), + "BuiltinFrame::new got a new object pointer that isn't a BuiltinFun, instead got {builtin_fun:?}" + ); + BuiltinFrame { + builtin_fun, + args, + last_sp, + state: BuiltinFunState::Begin, + } + } + + pub fn builtin_fun(&self) -> &BuiltinFun { + // TODO + // when downcast_ref_unchecked + if let Some(builtin_fun) = self.builtin_fun.as_any().downcast_ref() { + builtin_fun + } else { + // using panic! here so we get formatting + panic!( + "BuiltinFrame::new got a new object that isn't a BuiltinFun, instead got {:?}", + self.builtin_fun, + ); + } + } + + pub fn args(&self) -> &Vec { + &self.args + } + + pub fn state(&self) -> BuiltinFunState { + self.state + } + + pub fn set_state(&mut self, state: BuiltinFunState) { + self.state = state; + } + + pub fn last_sp(&self) -> usize { + self.last_sp + } +} + +pub type FrameLocals = BTreeMap>; + +#[derive(Debug)] +pub struct UserFrame { + user_fun: ObjPtr, + last_sp: usize, + pc: usize, + locals: FrameLocals, +} + +impl UserFrame { + pub fn new(user_fun: ObjPtr, args: Vec, last_sp: usize) -> Self { + assert!( + user_fun.as_any().is::(), + "UserFrame::new got a new object pointer that isn't a UserFun, instead got {user_fun:?}" + ); + + let user_fun_obj: &UserFun = if let Some(user_fun) = user_fun.as_any().downcast_ref() { + user_fun + } else { + // using panic! here so we get formatting + panic!( + "UserFrame::new got a new object that isn't a UserFun, instead got {:?}", + user_fun, + ) + }; + + // Check arity + if user_fun_obj.params().len() != args.len() { + todo!( + "Throw exception: arity error ({} args passed, {} expected)", + args.len(), + user_fun_obj.params().len() + ); + } + + // Create the locals + let mut locals = FrameLocals::new(); + for local in user_fun_obj.locals().iter().copied() { + locals.insert(local, None); + } + + // Set the args + for (param, arg) in user_fun_obj.params().iter().copied().zip(args) { + assert!( + locals.contains_key(¶m), + "param {:?} not found in locals for function with name {:?}", + param, + user_fun_obj.name() + ); + locals.insert(param, Some(arg)); + } + + Self { + user_fun, + last_sp, + pc: 0, + locals, + } + } + + pub fn user_fun(&self) -> &UserFun { + // TODO + // when downcast_ref_unchecked + if let Some(user_fun) = self.user_fun.as_any().downcast_ref() { + user_fun + } else { + // using panic! here so we get formatting + panic!( + "UserFrame::new got a new object that isn't a UserFun, instead got {:?}", + self.user_fun, + ); + } + } + + pub fn last_sp(&self) -> usize { + self.last_sp + } + + pub fn locals(&self) -> &FrameLocals { + &self.locals + } + + pub fn locals_mut(&mut self) -> &mut FrameLocals { + &mut self.locals + } + + pub fn get_inst(&self) -> &crate::vm::inst::Inst { + &self.user_fun().body()[self.pc] + } + + pub fn pc(&self) -> usize { + self.pc + } + + pub fn set_pc(&mut self, pc: usize) { + self.pc = pc; + } +} diff --git a/src/vm/inst.rs b/src/vm/inst.rs new file mode 100644 index 0000000..a74f7f8 --- /dev/null +++ b/src/vm/inst.rs @@ -0,0 +1,32 @@ +use crate::obj::ObjPtr; +use crate::vm::name::Name; + +#[derive(Debug, Clone)] +pub enum Inst { + /// Pushes an object to the stack. + Push(ObjPtr), + + /// Loads a local value in a name and pushes it to the stack. + Load(Name), + + /// Pops the top item off of the stack and stores it in a name. + Store(Name), + + /// Get an attribute from the top item of the stack. + GetAttr(String), + + /// Pops the top item off of the stack, discarding it. + Pop, + + /// Pops the top N function arguments off the stack, and attempt to call the + /// next stack item. + Call(usize), + + /// Exits the current function stack frame and returns control to the + /// calling function. + /// + /// This will take the last value on top of the stack (the return value), + /// resize the stack to its last size (pre-call), and push the return value + /// back to the top of the stack. + Return, +} diff --git a/src/vm/mod.rs b/src/vm/mod.rs new file mode 100644 index 0000000..d5d36f6 --- /dev/null +++ b/src/vm/mod.rs @@ -0,0 +1,246 @@ +pub mod frame; +pub mod inst; +pub mod name; + +use crate::obj::prelude::*; +use crate::vm::frame::{BuiltinFrame, UserFrame}; +use crate::vm::{frame::Frame, inst::Inst, name::Name}; + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum State { + Running, + Stopped, +} + +/// The virtual machine structure. +#[derive(Debug)] +pub struct Vm { + frames: Vec, + state: State, + stack: Vec, +} + +impl Vm { + pub fn new() -> Self { + Self { + frames: Default::default(), + state: State::Stopped, + stack: Default::default(), + } + } + + pub fn state(&self) -> State { + self.state + } + + /// Gets all stack frames. + pub fn frames(&self) -> &Vec { + &self.frames + } + + /// Gets all stack frames, mutably. + pub fn frames_mut(&mut self) -> &mut Vec { + &mut self.frames + } + + /// Gets the currently active stack frame. + pub fn active_frame(&self) -> Option<&Frame> { + self.frames().last() + } + + /// Gets the currently active stack frame. + pub fn active_frame_mut(&mut self) -> Option<&mut Frame> { + self.frames_mut().last_mut() + } + + /// Get the stack. + pub fn stack(&self) -> &Vec { + &self.stack + } + + /// Get the stack, mutably. + pub fn stack_mut(&mut self) -> &mut Vec { + &mut self.stack + } + + /// Push a value to the stack. + pub fn push_stack(&mut self, value: ObjPtr) { + self.stack_mut().push(value); + } + + /// Pop a value from the stack. + pub fn pop_stack(&mut self) -> Option { + self.stack_mut().pop() + } + + /// Loads a given name in the currently executing context. + pub fn load(&self, name: Name) -> Option { + // Search up the stack frame for local variable with the given name + for frame in self.frames() { + match frame { + Frame::User(frame) => { + // Figure out if this frame should hold this local + if let Some(local) = frame.locals().get(&name) { + // Return the found value (regardless of whether it's set or not). + return local.clone(); + } + } + Frame::Builtin(_frame) => continue, + } + } + None + } + + pub fn make_frame(&self, fun: ObjPtr, args: Vec) -> Option { + let fun_any = fun.as_any(); + if fun_any.is::() { + Some(Frame::Builtin(BuiltinFrame::new( + fun, + args, + self.stack().len(), + ))) + } else if fun_any.is::() { + Some(Frame::User(UserFrame::new(fun, args, self.stack().len()))) + } else { + todo!("Throw exception: Tried to call un-callable object: {fun:?}"); + } + } + + /// Execute an instruction, using the given program counter. + /// + /// Returns the address of the next instruction to load. + fn exec_inst(&mut self) { + // don't like this, but this is the consequence of not using a pipeline I think + let frame = match self.active_frame_mut() { + Some(Frame::User(frame)) => frame, + other => panic!("Expected user frame, got {other:?} instead"), + }; + + let inst = frame.get_inst(); + let pc = frame.pc() + 1; + let mut next_frame: Option = None; + let mut pop_frame = false; + + match &inst { + Inst::Push(value) => { + let value = value.clone(); + self.push_stack(value) + } + Inst::Load(name) => { + let name = *name; + if let Some(value) = self.load(name) { + self.push_stack(value); + } else { + todo!("Throw exception: Could not load name {name:?} (is it set?)"); + } + } + Inst::Store(_name) => todo!(), + Inst::GetAttr(_attr) => todo!(), + Inst::Pop => { + self + .pop_stack() + .expect("Inst::Pop executed, but there was no value on top of the stack. This is most likely a bug."); + } + Inst::Call(argc) => { + let argc = *argc; + let stack = self.stack_mut(); + let split_at = stack.len() - argc; + let args = stack.split_off(split_at); + + assert_eq!( + args.len(), + argc, + "Not enough arguments popped in Inst::Call" + ); + + let fun = stack.pop().expect("No function pointer in Inst::Call"); + next_frame = self.make_frame(fun, args); + } + Inst::Return => { + let last_sp = frame.last_sp(); + let return_value = self + .pop_stack() + .expect("Inst::Return expected a value on top of the stack, but it was empty."); + + let _discard = self.stack_mut().split_at(last_sp); + self.push_stack(return_value); + pop_frame = true; + } + } + + // Same as the top - this time update the program counter + let frame = match self.active_frame_mut() { + Some(Frame::User(frame)) => frame, + other => panic!("Expected user frame, got {other:?} instead"), + }; + frame.set_pc(pc); + + // This *shouldn't* happen. But it'd be bad if it did. + assert!(!(next_frame.is_some() && pop_frame)); + + // Set up the next stack frame if that's required + if let Some(frame) = next_frame { + self.frames_mut().push(frame); + } + + // Pop the stack frame + if pop_frame { + self.frames_mut().pop(); + } + } + + /// Resumes execution of the currently running function. + pub fn resume(&mut self) { + self.state = State::Running; + while self.state() == State::Running { + // Get the currently running function, figure out what to do next. + match self.active_frame() { + Some(Frame::User(_)) => { + self.exec_inst(); + } + Some(Frame::Builtin(frame)) => { + let state = frame.state(); + let builtin_fun = frame.builtin_fun(); + let fun_ptr = builtin_fun.fun(); + let fun_name = builtin_fun.name().clone(); + let args = frame.args().clone(); + let last_sp = frame.last_sp(); + // frame is implicitly dropped here + let result = fun_ptr(BuiltinFunVm::new(self, last_sp), args, state); + match result { + BuiltinFunResult::Return(maybe_value) => { + let frame = self + .frames_mut() + .pop() + .expect("Active frame modified by BuiltinFun"); + // Reset the stack size + let _remain = self.stack_mut().split_at(frame.last_sp()); + // Push the value to the stack + if let Some(value) = maybe_value { + self.stack_mut().push(value); + } else { + self.stack_mut().push(ObjPtr::clone(&NONE_INST)); + } + } + BuiltinFunResult::Yield(yield_to) => { + let frame = if let Some(Frame::Builtin(frame)) = self.active_frame_mut() + { + frame + } else { + panic!("Active frame modified by BuiltinFun {fun_name:?}"); + }; + // update builtin function's state for when we resume execution + let state = frame.state(); + frame.set_state(state.next()); + // yield control to the next function + self.frames_mut().push(yield_to); + } + } + } + None => { + self.state = State::Stopped; + } + } + } + } +} diff --git a/src/vm/name.rs b/src/vm/name.rs new file mode 100644 index 0000000..05a2689 --- /dev/null +++ b/src/vm/name.rs @@ -0,0 +1,2 @@ +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] +pub struct Name(pub usize);