diff --git a/Cargo.lock b/Cargo.lock index b7449de..58b35f8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -65,17 +65,25 @@ dependencies = [ "rustc-demangle", ] +[[package]] +name = "base64" +version = "0.21.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9" + [[package]] name = "bidir" version = "0.1.0" dependencies = [ "anyhow", + "contracts", "dashmap", "env_logger", "im", "lalrpop", "lalrpop-util", "lazy_static", + "leptos_reactive", "rustyline", "test-log", "trace", @@ -119,6 +127,12 @@ dependencies = [ "typenum", ] +[[package]] +name = "bumpalo" +version = "3.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" + [[package]] name = "cc" version = "1.0.83" @@ -145,6 +159,17 @@ dependencies = [ "winapi", ] +[[package]] +name = "contracts" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1d1429e3bd78171c65aa010eabcdf8f863ba3254728dbfb0ad4b1545beac15c" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "crunchy" version = "0.2.2" @@ -277,6 +302,95 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" +[[package]] +name = "futures" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da0290714b38af9b4a7b094b8a37086d1b4e61f2df9122c3cad2577669145335" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff4dd66668b557604244583e3e1e1eada8c5c2e96a6d0d6653ede395b78bbacb" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb1d22c66e66d9d72e1758f0bd7d4fd0bee04cad842ee34587d68c07e45d088c" + +[[package]] +name = "futures-executor" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f4fb8693db0cf099eadcca0efe2a5a22e4550f98ed16aba6c48700da29597bc" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8bf34a163b5c4c52d0478a4d757da8fb65cabef42ba90515efee0f6f9fa45aaa" + +[[package]] +name = "futures-macro" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53b153fd91e4b0147f4aced87be237c98248656bb01050b96bf3ee89220a8ddb" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.38", +] + +[[package]] +name = "futures-sink" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e36d3378ee38c2a36ad710c5d30c2911d752cb941c00c72dbabfb786a7970817" + +[[package]] +name = "futures-task" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "efd193069b0ddadc69c46389b740bbccdd97203899b48d09c5f7969591d6bae2" + +[[package]] +name = "futures-util" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a19526d624e703a3179b3d322efec918b6246ea0fa51d41124525f00f1cc8104" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + [[package]] name = "getrandom" version = "0.2.10" @@ -371,6 +485,15 @@ version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" +[[package]] +name = "js-sys" +version = "0.3.65" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54c0c35952f67de54bb584e9fd912b3023117cbafc0a77d8f3dee1fb5f572fe8" +dependencies = [ + "wasm-bindgen", +] + [[package]] name = "lalrpop" version = "0.20.0" @@ -409,6 +532,29 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +[[package]] +name = "leptos_reactive" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282e84ae3e3eb30ab1eb1c881bfeea8a3cb6d6c683dc99f26f2f69ee240b148d" +dependencies = [ + "base64", + "cfg-if", + "futures", + "indexmap", + "paste", + "pin-project", + "rustc-hash", + "self_cell", + "serde", + "serde-wasm-bindgen", + "serde_json", + "slotmap", + "thiserror", + "tracing", + "wasm-bindgen-futures", +] + [[package]] name = "libc" version = "0.2.149" @@ -552,6 +698,12 @@ dependencies = [ "windows-targets", ] +[[package]] +name = "paste" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" + [[package]] name = "petgraph" version = "0.6.4" @@ -577,12 +729,38 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5be167a7af36ee22fe3115051bc51f6e6c7054c9348e28deb4f49bd6f705a315" +[[package]] +name = "pin-project" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fda4ed1c6c173e3fc7a83629421152e01d7b1f9b7f65fb301e490e8cfc656422" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.38", +] + [[package]] name = "pin-project-lite" version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + [[package]] name = "powerfmt" version = "0.2.0" @@ -714,6 +892,12 @@ version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + [[package]] name = "rustix" version = "0.38.21" @@ -768,6 +952,12 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" +[[package]] +name = "self_cell" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e388332cd64eb80cd595a00941baf513caffae8dce9cfd0467fc9c66397dade6" + [[package]] name = "serde" version = "1.0.192" @@ -777,6 +967,17 @@ dependencies = [ "serde_derive", ] +[[package]] +name = "serde-wasm-bindgen" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3b143e2833c57ab9ad3ea280d21fd34e285a42837aeb0ee301f4f41890fa00e" +dependencies = [ + "js-sys", + "serde", + "wasm-bindgen", +] + [[package]] name = "serde_derive" version = "1.0.192" @@ -824,6 +1025,25 @@ dependencies = [ "typenum", ] +[[package]] +name = "slab" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" +dependencies = [ + "autocfg", +] + +[[package]] +name = "slotmap" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1e08e261d0e8f5c43123b7adf3e4ca1690d655377ac93a03b2c9d3e98de1342" +dependencies = [ + "serde", + "version_check", +] + [[package]] name = "smallvec" version = "1.11.1" @@ -1110,6 +1330,82 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "wasm-bindgen" +version = "0.2.88" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7daec296f25a1bae309c0cd5c29c4b260e510e6d813c286b19eaadf409d40fce" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.88" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e397f4664c0e4e428e8313a469aaa58310d302159845980fd23b0f22a847f217" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn 2.0.38", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9afec9963e3d0994cac82455b2b3502b81a7f40f9a0d32181f7528d9f4b43e02" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.88" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5961017b3b08ad5f3fe39f1e79877f8ee7c23c5e5fd5eb80de95abc41f1f16b2" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.88" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c5353b8dab669f5e10f5bd76df26a9360c748f054f862ff5f3f8aae0c7fb3907" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.38", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.88" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d046c5d029ba91a1ed14da14dca44b68bf2f124cfbaf741c54151fdb3e0750b" + +[[package]] +name = "web-sys" +version = "0.3.65" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5db499c5f66323272151db0e666cd34f78617522fb0c1604d31a27c50c206a85" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + [[package]] name = "winapi" version = "0.3.9" diff --git a/bidir/Cargo.toml b/bidir/Cargo.toml index be76e5c..80a2052 100644 --- a/bidir/Cargo.toml +++ b/bidir/Cargo.toml @@ -7,11 +7,13 @@ edition = "2021" [dependencies] anyhow = { version = "1.0.75", features = ["backtrace"] } +contracts = { version = "0.6.3" } dashmap = "5.5.3" env_logger = "0.10.0" im = "15.1.0" lalrpop-util = { version = "0.20.0", features = ["lexer", "regex", "unicode"] } lazy_static = "1.4.0" +leptos_reactive = "0.5.2" rustyline = "12.0.0" trace = "0.1.7" tracing = "0.1.40" diff --git a/bidir/src/bidir.rs b/bidir/src/bidir.rs index 1726594..88543a1 100644 --- a/bidir/src/bidir.rs +++ b/bidir/src/bidir.rs @@ -2,7 +2,7 @@ use anyhow::{bail, Result}; use crate::data::{Context, ContextEntry, FreeVar, Monotype, Term, Type}; use crate::gensym::gensym_existential; -use crate::DEPTH; + // Figure 8. Applying a context, as a substitution, to a type @@ -121,7 +121,7 @@ pub fn instantiate_left( Ok(new_ctx) } - Type::Existential(b) => todo!(), + Type::Existential(_b) => todo!(), Type::Unit => todo!(), Type::Var(_) => todo!(), @@ -164,7 +164,7 @@ pub fn instantiate_right( let aug_b = ty_b.subst(beta, &Type::Existential(ex_b.to_owned())); let out_ctx = instantiate_right(&aug_ctx, &aug_b, a)?; - let (before, after) = out_ctx + let (before, _after) = out_ctx .split_by( |entry| matches!(entry, ContextEntry::Marker(m) if *m == ex_b), ) @@ -208,11 +208,11 @@ pub fn typecheck(ctx: &Context, term: &Term, ty: &Type) -> Result { (Term::Unit, Type::Unit) => Ok(ctx.clone()), // ∀I rule - (e, Type::Polytype(x, tyA)) => todo!(), + (_e, Type::Polytype(_x, _tyA)) => todo!(), // →I rule - (Term::Lam(x, e), Type::Arrow(ty_a, ty_b)) => { - let mut aug_ctx = ctx.clone(); + (Term::Lam(_x, _e), Type::Arrow(_ty_a, _ty_b)) => { + let _aug_ctx = ctx.clone(); todo!() } diff --git a/bidir/src/bidir_debruijn.rs b/bidir/src/bidir_debruijn.rs index c0b3334..aade19b 100644 --- a/bidir/src/bidir_debruijn.rs +++ b/bidir/src/bidir_debruijn.rs @@ -1,22 +1,25 @@ use anyhow::{bail, Result}; -use crate::data_debruijn::{Context, Term, Type}; +use crate::data_debruijn::{Context, ContextIndex, ContextItem, Term, Type}; +use crate::DEPTH; // Figure 8. Applying a context, as a substitution, to a type +#[trace] pub fn app_ctx(ctx: &Context, ty: &Type) -> Result { match ty { Type::Unit => Ok(Type::Unit), Type::Var(s) => Ok(Type::Var(s.clone())), - Type::Existential(a) => match ctx.lookup_existential(a) { - Some((_, Some(m))) => Ok(m.into_poly()), - Some((_, None)) => Ok(Type::Existential(a.clone())), - None => bail!("existential variable {a} doesn't exist in context"), + Type::Existential(a) => match ctx.get_existential(a) { + Some(Some(m)) => Ok(m.into_poly()), + Some(None) => Ok(Type::Existential(a.clone())), + None => bail!("existential variable {a:?} doesn't exist in context"), }, - Type::Polytype(a, t) => { - Ok(Type::Polytype(a.clone(), Box::new(app_ctx(ctx, t)?))) + Type::Polytype(t) => { + let t = app_ctx(ctx, t)?; + Ok(Type::Polytype(Box::new(t))) } Type::Arrow(a, b) => Ok(Type::Arrow( @@ -26,14 +29,198 @@ pub fn app_ctx(ctx: &Context, ty: &Type) -> Result { } } +// Figure 9. Algorithmic subtyping + +/// Under input context Γ , type A is a subtype of B, with output context ∆ +pub fn subtype(ctx: &Context, left: &Type, right: &Type) -> Result { + match (left, right) { + // <:Unit rule + (Type::Unit, Type::Unit) => Ok(ctx.clone()), + + // <:Var rule + (Type::Var(x), Type::Var(y)) if x == y && ctx.get_type(x).is_some() => { + Ok(ctx.clone()) + } + + // <:Exvar rule + (Type::Existential(x), Type::Existential(y)) + if x == y && ctx.get_existential(x).is_some() => + { + Ok(ctx.clone()) + } + + // <:InstantiateL + (Type::Existential(a) , ty_a) if ctx.get_existential(a).is_some() => { + instantiate_left(ctx, a, ty_a) + } + + (Type::Unit, Type::Var(_)) => todo!(), + (Type::Unit, Type::Existential(_)) => todo!(), + (Type::Unit, Type::Polytype(_)) => todo!(), + (Type::Unit, Type::Arrow(_, _)) => todo!(), + (Type::Var(_), Type::Unit) => todo!(), + (Type::Var(_), Type::Var(_)) => todo!(), + (Type::Var(_), Type::Existential(_)) => todo!(), + (Type::Var(_), Type::Polytype(_)) => todo!(), + (Type::Var(_), Type::Arrow(_, _)) => todo!(), + (Type::Existential(_), Type::Unit) => todo!(), + (Type::Existential(_), Type::Var(_)) => todo!(), + (Type::Existential(_), Type::Existential(_)) => todo!(), + (Type::Existential(_), Type::Polytype(_)) => todo!(), + (Type::Existential(_), Type::Arrow(_, _)) => todo!(), + (Type::Polytype(_), Type::Unit) => todo!(), + (Type::Polytype(_), Type::Var(_)) => todo!(), + (Type::Polytype(_), Type::Existential(_)) => todo!(), + (Type::Polytype(_), Type::Polytype(_)) => todo!(), + (Type::Polytype(_), Type::Arrow(_, _)) => todo!(), + (Type::Arrow(_, _), Type::Unit) => todo!(), + (Type::Arrow(_, _), Type::Var(_)) => todo!(), + (Type::Arrow(_, _), Type::Existential(_)) => todo!(), + (Type::Arrow(_, _), Type::Polytype(_)) => todo!(), + (Type::Arrow(_, _), Type::Arrow(_, _)) => todo!(), + + _ => bail!("subtyping relation failed between {left:?} and {right:?} (ctx = {ctx:?})"), + } +} + +// Figure 10. Instantiation + +pub fn instantiate_left( + ctx: &Context, + a: &ContextIndex, + ty_a: &Type, +) -> Result { + match ty_a { + // InstLReach rule + Type::Existential(b) + if ctx.get_existential(a).is_some() + && ctx.get_existential(b).is_some() => + { + todo!() + } + + Type::Existential(_b) => todo!(), + Type::Unit => todo!(), + Type::Var(_) => todo!(), + Type::Polytype(_) => todo!(), + Type::Arrow(_, _) => todo!(), + } +} + +// Figure 11. Algorithmic typing + +#[trace] +pub fn typecheck(ctx: &Context, term: &Term, ty: &Type) -> Result { + match (term, ty) { + // 1I rule + (Term::Unit, Type::Unit) => Ok(ctx.clone()), + + // ∀I rule + (_e, Type::Polytype(_t)) => todo!(), + + // →I rule + (Term::Lam(_e), Type::Arrow(_ty_a, _ty_b)) => { + todo!() + } + + // Sub rule + (term, ty) => { + println!("SUB RULE: {term:?} || {ty:?} ({ctx:?})"); + let (ty_a, ctx_theta) = synthesize(ctx, term)?; + let a = app_ctx(&ctx_theta, &ty_a)?; + let b = app_ctx(&ctx_theta, ty)?; + let ctx_delta = subtype(&ctx_theta, &a, &b)?; + Ok(ctx_delta) + } + } +} + +#[trace] pub fn synthesize(ctx: &Context, term: &Term) -> Result<(Type, Context)> { match term { // 1I⇒ rule Term::Unit => Ok((Type::Unit, ctx.clone())), - Term::Var(_) => todo!(), - Term::Lam(_) => todo!(), - Term::App(_, _) => todo!(), + // Var rule + Term::Var(index) => { + let ty = match ctx.get_type(index) { + Some(v) => v, + None => bail!("invalid index {index:?}, context: {ctx:?}"), + }; + Ok((ty, ctx.clone())) + } + + // →E rule + Term::App(e1, e2) => { + let (ty_a, ctx_theta) = synthesize(ctx, e1)?; + let app_a = app_ctx(&ctx_theta, &ty_a)?; + let (ty_c, ctx_delta) = app_synthesize(&ctx_theta, &app_a, &e2)?; + Ok((ty_c, ctx_delta)) + } + + // →I⇒' rule + Term::Lam(e) => { + let (aug_ctx, marker_idx) = ctx.add(ContextItem::Marker); + let (aug_ctx, ex_a_idx) = aug_ctx.add(ContextItem::ExistentialVar); + let (aug_ctx, ex_b_idx) = aug_ctx.add(ContextItem::ExistentialVar); + + let ex_a = Type::Existential(ex_a_idx.clone()); + let ex_b = Type::Existential(ex_b_idx.clone()); + let (aug_ctx, _annot_idx) = + aug_ctx.add(ContextItem::TermAnnot(ex_a.clone())); + + let wtf_ctx = typecheck(&aug_ctx, &e, &ex_b)?; + + let (before_marker, after_marker) = wtf_ctx.split_at(&marker_idx); + println!("Splitting: {:?}", wtf_ctx); + let mut tau = + app_ctx(&after_marker, &Type::Arrow(Box::new(ex_a), Box::new(ex_b)))?; + + let (final_ctx, gen_idx) = before_marker.add(ContextItem::ExistentialVar); + + for index in after_marker.unsolved_existentials() { + tau = tau.subst(&index, Type::Var(gen_idx.clone())); + } + + Ok((Type::Polytype(Box::new(tau)), final_ctx)) + } + Term::Annot(_, _) => todo!(), } } + +pub fn app_synthesize( + _ctx: &Context, + fun_ty: &Type, + term: &Term, +) -> Result<(Type, Context)> { + match (fun_ty, term) { + (Type::Unit, Term::Unit) => todo!(), + (Type::Unit, Term::Var(_)) => todo!(), + (Type::Unit, Term::Lam(_)) => todo!(), + (Type::Unit, Term::App(_, _)) => todo!(), + (Type::Unit, Term::Annot(_, _)) => todo!(), + (Type::Var(_), Term::Unit) => todo!(), + (Type::Var(_), Term::Var(_)) => todo!(), + (Type::Var(_), Term::Lam(_)) => todo!(), + (Type::Var(_), Term::App(_, _)) => todo!(), + (Type::Var(_), Term::Annot(_, _)) => todo!(), + (Type::Existential(_), Term::Unit) => todo!(), + (Type::Existential(_), Term::Var(_)) => todo!(), + (Type::Existential(_), Term::Lam(_)) => todo!(), + (Type::Existential(_), Term::App(_, _)) => todo!(), + (Type::Existential(_), Term::Annot(_, _)) => todo!(), + (Type::Polytype(_), Term::Unit) => todo!(), + (Type::Polytype(_), Term::Var(_)) => todo!(), + (Type::Polytype(_), Term::Lam(_)) => todo!(), + (Type::Polytype(_), Term::App(_, _)) => todo!(), + (Type::Polytype(_), Term::Annot(_, _)) => todo!(), + (Type::Arrow(_, _), Term::Unit) => todo!(), + (Type::Arrow(_, _), Term::Var(_)) => todo!(), + (Type::Arrow(_, _), Term::Lam(_)) => todo!(), + (Type::Arrow(_, _), Term::App(_, _)) => todo!(), + (Type::Arrow(_, _), Term::Annot(_, _)) => todo!(), + + _ => bail!("trying to appSynthesize with a non-function type"), + } +} diff --git a/bidir/src/convert_data.rs b/bidir/src/convert_data.rs deleted file mode 100644 index 9c31d8a..0000000 --- a/bidir/src/convert_data.rs +++ /dev/null @@ -1,57 +0,0 @@ -use crate::DEPTH; -use crate::{data, data_debruijn, gensym::gensym_type}; - -pub fn convert_term(term: &data::Term) -> data_debruijn::Term { - fn convert_term_with_context( - ctx: &data::Context, - term: &data::Term, - ) -> data_debruijn::Term { - match term { - data::Term::Unit => data_debruijn::Term::Unit, - - data::Term::Var(name) => { - let (idx, _) = ctx.lookup_type(name).unwrap(); - let ctx_len = ctx.0.len(); - data_debruijn::Term::Var(ctx_len - 1 - idx) - } - - data::Term::Lam(arg, body) => { - let ty = gensym_type(); - let ctx2 = ctx.add(vec![data::ContextEntry::TermAnnot( - arg.to_owned(), - data::Type::Var(ty.clone()), - )]); - let body = convert_term_with_context(&ctx2, body); - data_debruijn::Term::Lam(Box::new(body)) - } - - data::Term::App(func, arg) => { - let func = convert_term_with_context(ctx, &func); - let arg = convert_term_with_context(ctx, &arg); - data_debruijn::Term::App(Box::new(func), Box::new(arg)) - } - - data::Term::Annot(term, ty) => { - let term = convert_term_with_context(ctx, &term); - let ty = convert_ty_with_context(ctx, &ty); - data_debruijn::Term::Annot(Box::new(term), ty) - } - } - } - - fn convert_ty_with_context( - ctx: &data::Context, - ty: &data::Type, - ) -> data_debruijn::Type { - match ty { - data::Type::Unit => data_debruijn::Type::Unit, - - data::Type::Var(_) => todo!(), - data::Type::Existential(_) => todo!(), - data::Type::Polytype(_, _) => todo!(), - data::Type::Arrow(_, _) => todo!(), - } - } - - convert_term_with_context(&data::Context::default(), term) -} diff --git a/bidir/src/data_debruijn.rs b/bidir/src/data_debruijn.rs index 26a17a6..082052d 100644 --- a/bidir/src/data_debruijn.rs +++ b/bidir/src/data_debruijn.rs @@ -1,9 +1,12 @@ -use std::{fmt, hash::Hash}; +use std::{ + cell::RefCell, + fmt::{self}, + rc::Rc, +}; -use anyhow::{bail, Result}; -use im::{HashSet, Vector}; +use im::Vector; -use crate::gensym::gensym_existential; +use crate::{data, gensym::gensym_type}; /// A lambda calculus term. #[derive(Clone)] @@ -13,7 +16,7 @@ pub enum Term { /// Variable, with a reference into the context. /// The entry pointed to by this index MUST be a TypeVar. - Var(usize), + Var(ContextIndex), /// Lambda abstraction. Lam(Box), @@ -29,7 +32,7 @@ impl fmt::Debug for Term { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { Self::Unit => write!(f, "unit"), - Self::Var(arg0) => write!(f, "{}", arg0), + Self::Var(arg0) => write!(f, "{:?}", arg0), Self::Lam(arg1) => write!(f, "(λ.{:?})", arg1), Self::App(arg0, arg1) => write!(f, "({:?} · {:?})", arg0, arg1), Self::Annot(arg0, arg1) => write!(f, "({:?} : {:?})", arg0, arg1), @@ -40,8 +43,8 @@ impl fmt::Debug for Term { #[derive(Clone)] pub enum Type { Unit, - Var(usize), - Existential(usize), + Var(ContextIndex), + Existential(ContextIndex), Polytype(Box), Arrow(Box, Box), } @@ -50,8 +53,8 @@ impl fmt::Debug for Type { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { Self::Unit => write!(f, "𝟙"), - Self::Var(arg0) => write!(f, "{}", arg0), - Self::Existential(arg0) => write!(f, "{}", arg0), + Self::Var(arg0) => write!(f, "{:?}", arg0), + Self::Existential(arg0) => write!(f, "{:?}", arg0), Self::Polytype(arg1) => write!(f, "(∀.{:?})", arg1), Self::Arrow(arg0, arg1) => write!(f, "({:?} -> {:?})", arg0, arg1), } @@ -65,8 +68,8 @@ impl Type { pub fn try_into_mono(&self) -> Option { match self { Type::Unit => Some(Monotype::Unit), - Type::Var(x) => Some(Monotype::Var(*x)), - Type::Existential(x) => Some(Monotype::Existential(*x)), + Type::Var(x) => Some(Monotype::Var(x.clone())), + Type::Existential(x) => Some(Monotype::Existential(x.clone())), // Polytypes cannot be converted to monotypes Type::Polytype(_) => None, @@ -126,13 +129,23 @@ impl Type { // ), // } // } + + pub fn subst(&self, _before: &ContextIndex, _after: Type) -> Type { + match self { + Type::Unit => Type::Unit, + Type::Var(_) => todo!(), + Type::Existential(_) => todo!(), + Type::Polytype(_) => todo!(), + Type::Arrow(_, _) => todo!(), + } + } } #[derive(Clone)] pub enum Monotype { Unit, - Var(usize), - Existential(usize), + Var(ContextIndex), + Existential(ContextIndex), Arrow(Box, Box), } @@ -140,8 +153,8 @@ impl fmt::Debug for Monotype { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { Self::Unit => write!(f, "𝟙"), - Self::Var(arg0) => write!(f, "{}", arg0), - Self::Existential(arg0) => write!(f, "{}", arg0), + Self::Var(arg0) => write!(f, "{:?}", arg0), + Self::Existential(arg0) => write!(f, "{:?}", arg0), Self::Arrow(arg0, arg1) => write!(f, "({arg0:?} -> {arg1:?})"), } } @@ -160,24 +173,25 @@ impl Monotype { } } +#[derive(Debug, Clone)] +pub enum ContextItem { + TypeVar, + TermAnnot(Type), + ExistentialVar, + ExistentialSolved(Monotype), + Marker, +} + #[derive(Clone)] -pub enum ContextEntry { - TypeVar(String), - TermAnnot(String, Type), - ExistentialVar(String), - ExistentialSolved(String, Monotype), - Marker(String), +pub struct ContextEntry { + item: ContextItem, + index_from_start: usize, + index_from_end: usize, } impl fmt::Debug for ContextEntry { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self { - Self::TypeVar(arg0) => write!(f, "{}", arg0), - Self::TermAnnot(arg0, arg1) => write!(f, "{} : {:?}", arg0, arg1), - Self::ExistentialVar(arg0) => write!(f, "{}", arg0), - Self::ExistentialSolved(arg0, arg1) => write!(f, "{} ≔ {:?}", arg0, arg1), - Self::Marker(arg0) => write!(f, "▶{}", arg0), - } + write!(f, "{:?}", self.item) } } @@ -189,159 +203,222 @@ pub enum CompleteContextEntry { Marker(String), } -#[derive(Clone, Default)] -pub struct Context(pub(crate) Vector); +#[derive(Debug, Clone)] +pub struct Context { + vector: Vector>>, + len: Rc>, + // len: ReadSignal, + // set_len: WriteSignal, +} -impl fmt::Debug for Context { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.write_str("Γ")?; - for rule in self.0.iter() { - f.write_str(", ")?; - rule.fmt(f)?; +// impl fmt::Debug for Context { +// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { +// f.write_str("Γ")?; +// for rule in self.vector.iter() { +// f.write_str(", ")?; +// rule.fmt(f)?; +// } +// Ok(()) +// } +// } + +impl Default for Context { + fn default() -> Self { + let vector = Vector::default(); + // let (len, set_len) = create_signal(0); + let len = Rc::new(RefCell::new(0)); + + Context { + vector, + len, + // len, + // set_len, } - Ok(()) } } impl Context { - pub fn add(&self, entries: Vec) -> Context { + pub fn add(&self, item: ContextItem) -> (Context, ContextIndex) { + let context_level = self.vector.len(); let mut new_ctx = self.clone(); - for entry in entries { - new_ctx.0.push_back(entry); - } - new_ctx + new_ctx.vector.push_back(Rc::new(RefCell::new(ContextEntry { + item, + index_from_end: 0, + index_from_start: self.vector.len(), + }))); + + let context_length = Rc::new(RefCell::new(new_ctx.vector.len())); + // let context_length = self.len.clone(); + // { + // *context_length.borrow_mut() += 1; + // } + + // let context_index = + // create_memo(move |_| context_length.get() - context_level); + let idx = ContextIndex { + context_level, + context_length, + // context_index, + }; + (new_ctx, idx) } - /// Looks up a polytype by name, also returning an index - pub fn lookup_type(&self, name: impl AsRef) -> Option<(usize, Type)> { - self - .0 - .iter() - .enumerate() - .find_map(|(i, entry)| match entry { - ContextEntry::TermAnnot(n, t) if n == name.as_ref() => { - Some((i, t.clone())) - } - _ => None, - }) + pub fn get<'a>(&'a self, index: &ContextIndex) -> Option { + let entry = self.vector.get(index.context_level)?; + let entry = entry.borrow(); + Some(entry.item.clone()) } - #[inline] - pub fn has_type(&self, name: impl AsRef) -> bool { - self.lookup_type(name).is_some() - } - - /// Looks up an existential variable by name - /// - Returns Some(Some(t)) if solved - /// - Returns Some(None) if exists but unsolved - /// - Returns None if not found - pub fn lookup_existential( + pub fn get_existential( &self, - name: impl AsRef, - ) -> Option<(usize, Option)> { - self - .0 - .iter() - .enumerate() - .find_map(|(i, entry)| match entry { - ContextEntry::ExistentialVar(n) if n == name.as_ref() => { - Some((i, None)) - } - ContextEntry::ExistentialSolved(n, t) if n == name.as_ref() => { - Some((i, Some(t.clone()))) - } - _ => None, - }) + index: &ContextIndex, + ) -> Option> { + let item = self.get(index)?; + + match item { + ContextItem::ExistentialSolved(t) => Some(Some(t.clone())), + ContextItem::ExistentialVar => Some(None), + _ => None, + } } - #[inline] - pub fn has_existential(&self, name: impl AsRef) -> bool { - self.lookup_existential(name).is_some() + pub fn get_type(&self, index: &ContextIndex) -> Option { + let item = self.get(index)?; + + match item { + ContextItem::TermAnnot(t) => Some(t.clone()), + _ => None, + } } - /// Returns a list of names of unsolved existentials - pub fn unsolved_existentials(&self) -> HashSet { - let mut unsolved = HashSet::new(); - - for entry in self.0.iter() { - match entry { - ContextEntry::ExistentialVar(n) => { - unsolved.insert(n.clone()); + pub fn unsolved_existentials(&self) -> Vec { + let mut unsolved = Vec::new(); + let context_length = self.len.clone(); + for (context_level, entry) in self.vector.iter().enumerate() { + match entry.borrow().item { + ContextItem::ExistentialVar => { + let index = ContextIndex { + context_length: context_length.clone(), + context_level, + }; + unsolved.push(index) } _ => {} } } - unsolved } - /// Returns (before, after) - pub fn split_by

(&self, p: P) -> Option<(Context, Context)> - where - P: Fn(&ContextEntry) -> bool, - { + /// Splits the context + pub fn split_at(&self, index: &ContextIndex) -> (Context, Context) { let (before, after) = { - let idx = self.0.iter().position(p)?; - self.0.clone().split_at(idx) + // let idx = self.vector.iter().position(p)?; + self.vector.clone().split_at(index.context_level) }; - Some((Context(before), Context(after))) + let before_len = Rc::new(RefCell::new(before.len())); + let after_len = Rc::new(RefCell::new(after.len())); + + ( + Context { + vector: before, + len: before_len, + }, + Context { + vector: after, + len: after_len, + }, + ) } - - pub fn unsplit( - left: &Context, - center: ContextEntry, - right: &Context, - ) -> Context { - let mut res = left.clone(); - res.0.push_back(center); - res.0.extend(right.0.clone().into_iter()); - res - } - - // pub fn split_existential_function(&self, var: &str) -> Result<(String, String, Context)> { - // let mut ctx = self.clone(); - // let idx = match ctx.lookup_existential(var) { - // Some((idx, _)) => idx, - // None => bail!("wtf?"), - // }; - - // let ex_a1_s = gensym_existential(); - // let ex_a2_s = gensym_existential(); - // ctx.0[idx] = ContextEntry::ExistentialSolved( - // var.to_owned(), - // Monotype::Arrow( - // Box::new(Monotype::Existential(ex_a1_s.to_owned())), - // Box::new(Monotype::Existential(ex_a2_s.to_owned())), - // ), - // ); - // ctx - // .0 - // .insert(idx, ContextEntry::ExistentialVar(ex_a1_s.to_owned())); - // ctx - // .0 - // .insert(idx, ContextEntry::ExistentialVar(ex_a2_s.to_owned())); - - // Ok((ex_a1_s, ex_a2_s, ctx)) - // } } /// An index into the context. +#[derive(Clone, PartialEq, Eq)] pub struct ContextIndex { - context_length: usize, - context_index: usize, + context_length: Rc>, + // context_length: ReadSignal, + // context_index: Memo, context_level: usize, } -impl ContextIndex { - /// Bump an index, creating a new one when entering a new context level - /// - /// This should ensure the index is still referring to the same context entry. - pub fn bump(&self) -> Self { - ContextIndex { - context_length: self.context_length + 1, - context_index: self.context_index + 1, - context_level: self.context_level, - } +impl fmt::Debug for ContextIndex { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "#{}", self.context_index()) } } + +impl ContextIndex { + pub fn context_index(&self) -> usize { + *self.context_length.borrow() - self.context_level + } +} + +/* Convert */ + +pub fn convert_term(term: &data::Term) -> Term { + fn convert_term_with_context( + ctx: &data::Context, + ctx2: &Context, + term: &data::Term, + ) -> Term { + match term { + data::Term::Unit => Term::Unit, + + data::Term::Var(name) => { + let (idx, _) = ctx.lookup_type(name).unwrap(); + + let _len = ctx2.len.clone(); + // let context_index = create_memo(move |_| len.get() - idx); + let index = ContextIndex { + context_length: ctx2.len.clone(), + context_level: idx, + // context_index, + }; + Term::Var(index) + } + + data::Term::Lam(arg, body) => { + let ty = gensym_type(); + let aug_ctx = ctx.add(vec![data::ContextEntry::TermAnnot( + arg.to_owned(), + data::Type::Var(ty.clone()), + )]); + let body = convert_term_with_context(&aug_ctx, ctx2, body); + Term::Lam(Box::new(body)) + } + + data::Term::App(func, arg) => { + let func = convert_term_with_context(ctx, ctx2, &func); + let arg = convert_term_with_context(ctx, ctx2, &arg); + Term::App(Box::new(func), Box::new(arg)) + } + + data::Term::Annot(term, ty) => { + let term = convert_term_with_context(ctx, ctx2, &term); + let ty = convert_ty_with_context(ctx, ctx2, &ty); + Term::Annot(Box::new(term), ty) + } + } + } + + fn convert_ty_with_context( + _ctx: &data::Context, + _ctx2: &Context, + ty: &data::Type, + ) -> Type { + match ty { + data::Type::Unit => Type::Unit, + + data::Type::Var(_) => todo!(), + data::Type::Existential(_) => todo!(), + data::Type::Polytype(_, _) => todo!(), + data::Type::Arrow(_, _) => todo!(), + } + } + + convert_term_with_context( + &data::Context::default(), + &Context::default(), + term, + ) +} diff --git a/bidir/src/gensym.rs b/bidir/src/gensym.rs index 3c7f9af..4c10691 100644 --- a/bidir/src/gensym.rs +++ b/bidir/src/gensym.rs @@ -1,5 +1,5 @@ use dashmap::DashMap; -use lazy_static::lazy_static; + thread_local! { static CTRMAP: DashMap<&'static str, usize> = DashMap::new(); diff --git a/bidir/src/lib.rs b/bidir/src/lib.rs index 7e0681e..0f7dbcb 100644 --- a/bidir/src/lib.rs +++ b/bidir/src/lib.rs @@ -1,4 +1,6 @@ #[macro_use] +extern crate contracts; +#[macro_use] extern crate tracing; #[macro_use] extern crate trace; @@ -9,8 +11,6 @@ pub mod abstract_data; pub mod bidir; pub mod data; -pub mod convert_data; - pub mod bidir_debruijn; pub mod data_debruijn; diff --git a/bidir/src/main.rs b/bidir/src/main.rs index caab26b..8a0141c 100644 --- a/bidir/src/main.rs +++ b/bidir/src/main.rs @@ -1,8 +1,8 @@ use anyhow::Result; use bidir::{ - bidir::{app_ctx, synthesize}, - convert_data::convert_term, - data::Context, + bidir_debruijn::{app_ctx, synthesize}, + data_debruijn::convert_term, + data_debruijn::Context, parser::TermParser, }; use rustyline::{Config, DefaultEditor}; @@ -30,11 +30,11 @@ fn main() -> Result<()> { }; println!("parsed: {:?}", parsed_term); - let ctx = Context::default(); let converted_term = convert_term(&parsed_term); println!("converted: {converted_term:?}"); - let (ty, out_ctx) = match synthesize(&ctx, &parsed_term) { + let ctx = Context::default(); + let (ty, out_ctx) = match synthesize(&ctx, &converted_term) { Ok(v) => v, Err(err) => { eprintln!("typecheck error: {err}"); diff --git a/bidir/src/tests.rs b/bidir/src/tests.rs index 3925a8c..94e0553 100644 --- a/bidir/src/tests.rs +++ b/bidir/src/tests.rs @@ -2,9 +2,8 @@ use anyhow::{bail, Result}; use crate::{ bidir_debruijn::{app_ctx, synthesize}, - convert_data::convert_term, data_debruijn::Context, - data_debruijn::Term, + data_debruijn::{convert_term, Term}, parser::TermParser, }; @@ -16,12 +15,11 @@ fn term_of(str: &'static str) -> Result { } #[test] -fn test_id() -> Result<()> { +fn test_id_only() -> Result<()> { let id = term_of(r"\x.x")?; let ctx = Context::default(); let (ty, out_ctx) = synthesize(&ctx, &id)?; bail!("Synthesized: {:?} (context = {:?})", ty, out_ctx); - Ok(()) } diff --git a/out.rs b/out.rs new file mode 100644 index 0000000..f178d86 --- /dev/null +++ b/out.rs @@ -0,0 +1,8759 @@ +#![feature(prelude_import)] +#[prelude_import] +use std::prelude::rust_2021::*; +#[macro_use] +extern crate std; +#[macro_use] +extern crate contracts; +#[macro_use] +extern crate tracing; +#[macro_use] +extern crate trace; + +use lalrpop_util::lalrpop_mod; + +pub mod abstract_data { + + + + + + + pub trait Data { + fn synthesize() {} + } +} +pub mod bidir { + use anyhow::{bail, Result}; + use crate::data::{Context, ContextEntry, FreeVar, Monotype, Term, Type}; + use crate::gensym::gensym_existential; + pub fn app_ctx(ctx: &Context, ty: &Type) -> Result { + match ty { + Type::Unit => Ok(Type::Unit), + Type::Var(s) => Ok(Type::Var(s.clone())), + Type::Existential(a) => + match ctx.lookup_existential(a) { + Some((_, Some(m))) => Ok(m.into_poly()), + Some((_, None)) => Ok(Type::Existential(a.clone())), + None => + return ::anyhow::__private::Err({ + let error = + ::anyhow::__private::format_err(format_args!("existential variable {0} doesn\'t exist in context", + a)); + error + }), + }, + Type::Polytype(a, t) => { + Ok(Type::Polytype(a.clone(), Box::new(app_ctx(ctx, t)?))) + } + Type::Arrow(a, b) => + Ok(Type::Arrow(Box::new(app_ctx(ctx, a)?), + Box::new(app_ctx(ctx, b)?))), + } + } + /// Under input context Γ , type A is a subtype of B, with output context ∆ + pub fn subtype(ctx: &Context, left: &Type, right: &Type) + -> Result { + match (left, right) { + (Type::Unit, Type::Unit) => Ok(ctx.clone()), + (Type::Var(x), Type::Var(y)) if + x == y && ctx.lookup_type(x).is_some() => Ok(ctx.clone()), + (Type::Existential(x), Type::Existential(y)) if + x == y && ctx.lookup_existential(x).is_some() => { + Ok(ctx.clone()) + } + (Type::Existential(a), ty_a) if + !ty_a.free_vars().contains(&FreeVar::Existential(a.to_string())) + && ctx.lookup_existential(a).is_some() => { + let ctx_delta = instantiate_left(ctx, a, ty_a)?; + Ok(ctx_delta) + } + (ty_a, Type::Existential(a)) if + !ty_a.free_vars().contains(&FreeVar::Existential(a.to_string())) + && ctx.lookup_existential(a).is_some() => { + let ctx_delta = instantiate_right(ctx, ty_a, a)?; + Ok(ctx_delta) + } + (Type::Existential(_), Type::Unit) => + ::core::panicking::panic("not yet implemented"), + (Type::Existential(_), Type::Var(_)) => + ::core::panicking::panic("not yet implemented"), + (Type::Existential(_), Type::Polytype(_, _)) => + ::core::panicking::panic("not yet implemented"), + (Type::Existential(_), Type::Arrow(_, _)) => + ::core::panicking::panic("not yet implemented"), + (Type::Polytype(_, _), Type::Unit) => + ::core::panicking::panic("not yet implemented"), + (Type::Polytype(_, _), Type::Var(_)) => + ::core::panicking::panic("not yet implemented"), + (Type::Polytype(_, _), Type::Existential(_)) => + ::core::panicking::panic("not yet implemented"), + (Type::Polytype(_, _), Type::Polytype(_, _)) => + ::core::panicking::panic("not yet implemented"), + (Type::Polytype(_, _), Type::Arrow(_, _)) => + ::core::panicking::panic("not yet implemented"), + (Type::Arrow(_, _), Type::Unit) => + ::core::panicking::panic("not yet implemented"), + (Type::Arrow(_, _), Type::Var(_)) => + ::core::panicking::panic("not yet implemented"), + (Type::Arrow(_, _), Type::Existential(_)) => + ::core::panicking::panic("not yet implemented"), + (Type::Arrow(_, _), Type::Polytype(_, _)) => + ::core::panicking::panic("not yet implemented"), + (Type::Arrow(_, _), Type::Arrow(_, _)) => + ::core::panicking::panic("not yet implemented"), + _ => + return ::anyhow::__private::Err({ + let error = + ::anyhow::__private::format_err(format_args!("subtyping relation failed between {0:?} and {1:?} (ctx = {2:?})", + left, right, ctx)); + error + }), + } + } + pub fn instantiate_left(ctx: &Context, a: &str, ty_a: &Type) + -> Result { + match ty_a { + Type::Existential(b) if + ctx.has_existential(a) && ctx.has_existential(b) => { + let mut new_ctx = ctx.clone(); + { + let b_entry = + new_ctx.0.iter_mut().find(|entry| + match entry { + ContextEntry::ExistentialVar(x) if x == b => true, + _ => false, + }).expect("should exist"); + *b_entry = + ContextEntry::ExistentialSolved(b.to_owned(), + Monotype::Existential(a.to_owned())); + } + Ok(new_ctx) + } + Type::Existential(_b) => + ::core::panicking::panic("not yet implemented"), + Type::Unit => ::core::panicking::panic("not yet implemented"), + Type::Var(_) => ::core::panicking::panic("not yet implemented"), + Type::Polytype(_, _) => + ::core::panicking::panic("not yet implemented"), + Type::Arrow(_, _) => + ::core::panicking::panic("not yet implemented"), + } + } + pub fn instantiate_right(ctx: &Context, ty_a: &Type, a: &str) + -> Result { + match ty_a { + Type::Arrow(ty_a1, ty_a2) if ctx.has_existential(a) => { + { + ::std::io::_print(format_args!("original ctx: {0:?}\n", + ctx)); + }; + let (ex_a1_s, ex_a2_s, ctx_gamma_aug) = + ctx.split_existential_function(a)?; + let ctx_theta = + instantiate_left(&ctx_gamma_aug, &ex_a1_s, &ty_a1)?; + let ty_a2_aug = app_ctx(&ctx_theta, &ty_a2)?; + let ctx_delta = + instantiate_right(&ctx_theta, &ty_a2_aug, &ex_a2_s)?; + Ok(ctx_delta) + } + Type::Polytype(beta, ty_b) if ctx.has_existential(a) => { + let ex_b = gensym_existential(); + let aug_ctx = + ctx.add(<[_]>::into_vec(#[rustc_box] ::alloc::boxed::Box::new([ContextEntry::Marker(ex_b.to_owned()), + ContextEntry::ExistentialVar(ex_b.to_owned())]))); + let aug_b = + ty_b.subst(beta, &Type::Existential(ex_b.to_owned())); + let out_ctx = instantiate_right(&aug_ctx, &aug_b, a)?; + let (before, _after) = + out_ctx.split_by(|entry| + match entry { + ContextEntry::Marker(m) if *m == ex_b => true, + _ => false, + }).unwrap(); + Ok(before) + } + ty_a if ty_a.is_mono() && ctx.has_existential(a) => { + let (before, after) = + ctx.split_by(|entry| + match entry { + ContextEntry::ExistentialVar(n) if n == a => true, + _ => false, + }).unwrap(); + let ty_a_mono = ty_a.into_mono().unwrap(); + Ok(Context::unsplit(&before, + ContextEntry::ExistentialSolved(a.to_owned(), ty_a_mono), + &after)) + } + Type::Unit => ::core::panicking::panic("not yet implemented"), + Type::Var(_) => ::core::panicking::panic("not yet implemented"), + Type::Existential(_) => + ::core::panicking::panic("not yet implemented"), + _ => ::core::panicking::panic("not yet implemented"), + } + } + pub fn typecheck(ctx: &Context, term: &Term, ty: &Type) + -> Result { + match (term, ty) { + (Term::Unit, Type::Unit) => Ok(ctx.clone()), + (_e, Type::Polytype(_x, _tyA)) => + ::core::panicking::panic("not yet implemented"), + (Term::Lam(_x, _e), Type::Arrow(_ty_a, _ty_b)) => { + let _aug_ctx = ctx.clone(); + ::core::panicking::panic("not yet implemented") + } + (term, ty) => { + let (ty_a, ctx_theta) = synthesize(ctx, term)?; + let a = app_ctx(&ctx_theta, &ty_a)?; + let b = app_ctx(&ctx_theta, ty)?; + let ctx_delta = subtype(&ctx_theta, &a, &b)?; + Ok(ctx_delta) + } + } + } + pub fn synthesize(ctx: &Context, term: &Term) -> Result<(Type, Context)> { + match term { + Term::Var(name) if ctx.has_type(name) => { + let (_, ty) = ctx.lookup_type(name).unwrap(); + Ok((ty, ctx.clone())) + } + Term::Var(name) => + return ::anyhow::__private::Err({ + let error = + ::anyhow::__private::format_err(format_args!("could not find name {0}", + name)); + error + }), + Term::Unit => Ok((Type::Unit, ctx.clone())), + Term::Annot(e, ty_a) => { + let ctx_delta = typecheck(ctx, &e, ty_a)?; + Ok((ty_a.clone(), ctx_delta)) + } + Term::Lam(x, e) => { + let ex_a_s = gensym_existential(); + let ex_b_s = gensym_existential(); + let ex_gen = + { + let res = + ::alloc::fmt::format(format_args!("{0}*", ex_a_s)); + res + }; + let ex_a = Type::Existential(ex_a_s.clone()); + let ex_b = Type::Existential(ex_b_s.clone()); + let aug_ctx = + ctx.add(<[_]>::into_vec(#[rustc_box] ::alloc::boxed::Box::new([ContextEntry::Marker(ex_a_s.clone()), + ContextEntry::ExistentialVar(ex_a_s.clone()), + ContextEntry::ExistentialVar(ex_b_s.clone()), + ContextEntry::TermAnnot(x.clone(), ex_a.clone())]))); + let wtf_ctx = typecheck(&aug_ctx, &e, &ex_b)?; + { + use ::tracing::__macro_support::Callsite as _; + static __CALLSITE: ::tracing::callsite::DefaultCallsite = + { + static META: ::tracing::Metadata<'static> = + { + ::tracing_core::metadata::Metadata::new("event bidir/src/bidir.rs:270", + "bidir::bidir", ::tracing::Level::INFO, + ::core::option::Option::Some("bidir/src/bidir.rs"), + ::core::option::Option::Some(270u32), + ::core::option::Option::Some("bidir::bidir"), + ::tracing_core::field::FieldSet::new(&["message"], + ::tracing_core::callsite::Identifier(&__CALLSITE)), + ::tracing::metadata::Kind::EVENT) + }; + ::tracing::callsite::DefaultCallsite::new(&META) + }; + let enabled = + ::tracing::Level::INFO <= + ::tracing::level_filters::STATIC_MAX_LEVEL && + ::tracing::Level::INFO <= + ::tracing::level_filters::LevelFilter::current() && + { + let interest = __CALLSITE.interest(); + !interest.is_never() && + ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(), + interest) + }; + if enabled { + (|value_set: ::tracing::field::ValueSet| + { + let meta = __CALLSITE.metadata(); + ::tracing::Event::dispatch(meta, &value_set); + ; + })({ + #[allow(unused_imports)] + use ::tracing::field::{debug, display, Value}; + let mut iter = __CALLSITE.metadata().fields().iter(); + __CALLSITE.metadata().fields().value_set(&[(&::core::iter::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"), + ::core::option::Option::Some(&format_args!("WTF CTX {0:?}", + wtf_ctx) as &dyn Value))]) + }); + } else { ; } + }; + let (before_marker, after_marker) = + wtf_ctx.split_by(|entry| + match entry { + ContextEntry::Marker(m) if *m == ex_a_s => true, + _ => false, + }).unwrap(); + { + use ::tracing::__macro_support::Callsite as _; + static __CALLSITE: ::tracing::callsite::DefaultCallsite = + { + static META: ::tracing::Metadata<'static> = + { + ::tracing_core::metadata::Metadata::new("event bidir/src/bidir.rs:279", + "bidir::bidir", ::tracing::Level::INFO, + ::core::option::Option::Some("bidir/src/bidir.rs"), + ::core::option::Option::Some(279u32), + ::core::option::Option::Some("bidir::bidir"), + ::tracing_core::field::FieldSet::new(&["message"], + ::tracing_core::callsite::Identifier(&__CALLSITE)), + ::tracing::metadata::Kind::EVENT) + }; + ::tracing::callsite::DefaultCallsite::new(&META) + }; + let enabled = + ::tracing::Level::INFO <= + ::tracing::level_filters::STATIC_MAX_LEVEL && + ::tracing::Level::INFO <= + ::tracing::level_filters::LevelFilter::current() && + { + let interest = __CALLSITE.interest(); + !interest.is_never() && + ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(), + interest) + }; + if enabled { + (|value_set: ::tracing::field::ValueSet| + { + let meta = __CALLSITE.metadata(); + ::tracing::Event::dispatch(meta, &value_set); + ; + })({ + #[allow(unused_imports)] + use ::tracing::field::{debug, display, Value}; + let mut iter = __CALLSITE.metadata().fields().iter(); + __CALLSITE.metadata().fields().value_set(&[(&::core::iter::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"), + ::core::option::Option::Some(&format_args!("Unsolved: {0:?}", + after_marker.unsolved_existentials()) as &dyn Value))]) + }); + } else { ; } + }; + let mut tau = + app_ctx(&after_marker, + &Type::Arrow(Box::new(ex_a), Box::new(ex_b)))?; + for name in after_marker.unsolved_existentials() { + { + use ::tracing::__macro_support::Callsite as _; + static __CALLSITE: ::tracing::callsite::DefaultCallsite = + { + static META: ::tracing::Metadata<'static> = + { + ::tracing_core::metadata::Metadata::new("event bidir/src/bidir.rs:284", + "bidir::bidir", ::tracing::Level::WARN, + ::core::option::Option::Some("bidir/src/bidir.rs"), + ::core::option::Option::Some(284u32), + ::core::option::Option::Some("bidir::bidir"), + ::tracing_core::field::FieldSet::new(&["message"], + ::tracing_core::callsite::Identifier(&__CALLSITE)), + ::tracing::metadata::Kind::EVENT) + }; + ::tracing::callsite::DefaultCallsite::new(&META) + }; + let enabled = + ::tracing::Level::WARN <= + ::tracing::level_filters::STATIC_MAX_LEVEL && + ::tracing::Level::WARN <= + ::tracing::level_filters::LevelFilter::current() && + { + let interest = __CALLSITE.interest(); + !interest.is_never() && + ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(), + interest) + }; + if enabled { + (|value_set: ::tracing::field::ValueSet| + { + let meta = __CALLSITE.metadata(); + ::tracing::Event::dispatch(meta, &value_set); + ; + })({ + #[allow(unused_imports)] + use ::tracing::field::{debug, display, Value}; + let mut iter = __CALLSITE.metadata().fields().iter(); + __CALLSITE.metadata().fields().value_set(&[(&::core::iter::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"), + ::core::option::Option::Some(&format_args!("substituting {0:?} looking for {1}", + tau, name) as &dyn Value))]) + }); + } else { ; } + }; + tau = tau.subst(&name, &Type::Var(ex_gen.clone())); + } + Ok((Type::Polytype(ex_gen, Box::new(tau)), before_marker)) + } + Term::App(e1, e2) => { + let (ty_a, ctx_theta) = synthesize(ctx, e1)?; + let app_a = app_ctx(&ctx_theta, &ty_a)?; + let (ty_c, ctx_delta) = + app_synthesize(&ctx_theta, &app_a, &e2)?; + Ok((ty_c, ctx_delta)) + } + } + } + pub fn app_synthesize(ctx: &Context, fun_ty: &Type, term: &Term) + -> Result<(Type, Context)> { + match (fun_ty, term) { + (Type::Arrow(ty_a, ty_c), e) => { + let out_ctx = typecheck(ctx, e, ty_a)?; + Ok((*ty_c.clone(), out_ctx)) + } + (Type::Polytype(a, ty_a), e) => { + let ex_s = gensym_existential(); + let ex = ContextEntry::ExistentialVar(ex_s.clone()); + let aug_ctx = + ctx.add(<[_]>::into_vec(#[rustc_box] ::alloc::boxed::Box::new([ex.clone()]))); + let aug_ty = ty_a.subst(&a, &Type::Existential(ex_s)); + let (ty, ctx_delta) = app_synthesize(&aug_ctx, &aug_ty, e)?; + Ok((ty, ctx_delta)) + } + (Type::Existential(a), e) if ctx.has_existential(a) => { + let (ex_a1_s, ex_a2_s, ctx_gamma_aug) = + ctx.split_existential_function(a)?; + let ex_a1 = Type::Existential(ex_a1_s.clone()); + let ctx_delta = typecheck(&ctx_gamma_aug, e, &ex_a1)?; + let ex_a2 = Type::Existential(ex_a2_s.clone()); + Ok((ex_a2, ctx_delta)) + } + _ => + return ::anyhow::__private::Err({ + let error = + ::anyhow::__private::format_err(format_args!("trying to appSynthesize with a non-function type")); + error + }), + } + } +} +pub mod data { + use std::{fmt, hash::Hash}; + use anyhow::{bail, Result}; + use im::{HashSet, Vector}; + use crate::gensym::gensym_existential; + pub enum Term { + Unit, + Var(String), + Lam(String, Box), + App(Box, Box), + Annot(Box, Type), + } + #[automatically_derived] + impl ::core::clone::Clone for Term { + #[inline] + fn clone(&self) -> Term { + match self { + Term::Unit => Term::Unit, + Term::Var(__self_0) => + Term::Var(::core::clone::Clone::clone(__self_0)), + Term::Lam(__self_0, __self_1) => + Term::Lam(::core::clone::Clone::clone(__self_0), + ::core::clone::Clone::clone(__self_1)), + Term::App(__self_0, __self_1) => + Term::App(::core::clone::Clone::clone(__self_0), + ::core::clone::Clone::clone(__self_1)), + Term::Annot(__self_0, __self_1) => + Term::Annot(::core::clone::Clone::clone(__self_0), + ::core::clone::Clone::clone(__self_1)), + } + } + } + impl fmt::Debug for Term { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + Self::Unit => f.write_fmt(format_args!("unit")), + Self::Var(arg0) => f.write_fmt(format_args!("{0}", arg0)), + Self::Lam(arg0, arg1) => + f.write_fmt(format_args!("(λ{0}.{1:?})", arg0, arg1)), + Self::App(arg0, arg1) => + f.write_fmt(format_args!("({0:?} · {1:?})", arg0, arg1)), + Self::Annot(arg0, arg1) => + f.write_fmt(format_args!("({0:?} : {1:?})", arg0, arg1)), + } + } + } + pub enum Type { + Unit, + Var(String), + Existential(String), + Polytype(String, Box), + Arrow(Box, Box), + } + #[automatically_derived] + impl ::core::clone::Clone for Type { + #[inline] + fn clone(&self) -> Type { + match self { + Type::Unit => Type::Unit, + Type::Var(__self_0) => + Type::Var(::core::clone::Clone::clone(__self_0)), + Type::Existential(__self_0) => + Type::Existential(::core::clone::Clone::clone(__self_0)), + Type::Polytype(__self_0, __self_1) => + Type::Polytype(::core::clone::Clone::clone(__self_0), + ::core::clone::Clone::clone(__self_1)), + Type::Arrow(__self_0, __self_1) => + Type::Arrow(::core::clone::Clone::clone(__self_0), + ::core::clone::Clone::clone(__self_1)), + } + } + } + impl fmt::Debug for Type { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + Self::Unit => f.write_fmt(format_args!("𝟙")), + Self::Var(arg0) => f.write_fmt(format_args!("{0}", arg0)), + Self::Existential(arg0) => + f.write_fmt(format_args!("{0}", arg0)), + Self::Polytype(arg0, arg1) => + f.write_fmt(format_args!("(∀ {0} . {1:?})", arg0, arg1)), + Self::Arrow(arg0, arg1) => + f.write_fmt(format_args!("({0:?} -> {1:?})", arg0, arg1)), + } + } + } + impl Type { + pub fn into_mono(&self) -> Option { + match self { + Type::Unit => Some(Monotype::Unit), + Type::Var(x) => Some(Monotype::Var(x.clone())), + Type::Existential(x) => + Some(Monotype::Existential(x.clone())), + Type::Polytype(_, _) => None, + Type::Arrow(a, b) => + Some(Monotype::Arrow(Box::new(a.into_mono()?), + Box::new(b.into_mono()?))), + } + } + #[inline] + pub fn is_mono(&self) -> bool { self.into_mono().is_some() } + } + pub enum FreeVar { Var(String), Existential(String), } + #[automatically_derived] + impl ::core::fmt::Debug for FreeVar { + fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { + match self { + FreeVar::Var(__self_0) => + ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Var", + &__self_0), + FreeVar::Existential(__self_0) => + ::core::fmt::Formatter::debug_tuple_field1_finish(f, + "Existential", &__self_0), + } + } + } + #[automatically_derived] + impl ::core::clone::Clone for FreeVar { + #[inline] + fn clone(&self) -> FreeVar { + match self { + FreeVar::Var(__self_0) => + FreeVar::Var(::core::clone::Clone::clone(__self_0)), + FreeVar::Existential(__self_0) => + FreeVar::Existential(::core::clone::Clone::clone(__self_0)), + } + } + } + #[automatically_derived] + impl ::core::marker::StructuralPartialEq for FreeVar { } + #[automatically_derived] + impl ::core::cmp::PartialEq for FreeVar { + #[inline] + fn eq(&self, other: &FreeVar) -> bool { + let __self_tag = ::core::intrinsics::discriminant_value(self); + let __arg1_tag = ::core::intrinsics::discriminant_value(other); + __self_tag == __arg1_tag && + match (self, other) { + (FreeVar::Var(__self_0), FreeVar::Var(__arg1_0)) => + *__self_0 == *__arg1_0, + (FreeVar::Existential(__self_0), + FreeVar::Existential(__arg1_0)) => *__self_0 == *__arg1_0, + _ => unsafe { ::core::intrinsics::unreachable() } + } + } + } + #[automatically_derived] + impl ::core::marker::StructuralEq for FreeVar { } + #[automatically_derived] + impl ::core::cmp::Eq for FreeVar { + #[inline] + #[doc(hidden)] + #[no_coverage] + fn assert_receiver_is_total_eq(&self) -> () { + let _: ::core::cmp::AssertParamIsEq; + } + } + #[automatically_derived] + impl ::core::hash::Hash for FreeVar { + #[inline] + fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () { + let __self_tag = ::core::intrinsics::discriminant_value(self); + ::core::hash::Hash::hash(&__self_tag, state); + match self { + FreeVar::Var(__self_0) => + ::core::hash::Hash::hash(__self_0, state), + FreeVar::Existential(__self_0) => + ::core::hash::Hash::hash(__self_0, state), + } + } + } + impl Type { + pub fn free_vars(&self) -> HashSet { + fn free_vars_with_context(ctx: &Context, ty: &Type) + -> HashSet { + match ty { + Type::Unit => HashSet::default(), + Type::Var(x) if ctx.lookup_type(x).is_some() => + HashSet::default(), + Type::Var(x) => + [FreeVar::Var(x.to_owned())].into_iter().collect(), + Type::Existential(x) if ctx.lookup_existential(x).is_some() + => { + HashSet::default() + } + Type::Existential(x) => { + [FreeVar::Existential(x.to_owned())].into_iter().collect() + } + Type::Polytype(x, ty_a) => { + let new_ctx = + ctx.add(<[_]>::into_vec(#[rustc_box] ::alloc::boxed::Box::new([ContextEntry::ExistentialVar(x.to_owned())]))); + free_vars_with_context(&new_ctx, &ty_a) + } + Type::Arrow(ty_a, ty_b) => { + let a_vars = free_vars_with_context(&ctx, &ty_a); + let b_vars = free_vars_with_context(&ctx, &ty_b); + a_vars.union(b_vars) + } + } + } + free_vars_with_context(&Context::default(), self) + } + pub fn subst(&self, var: &str, replacement: &Type) -> Type { + match self { + Type::Unit => Type::Unit, + Type::Var(n) if n == var => replacement.clone(), + Type::Var(n) => Type::Var(n.clone()), + Type::Existential(s) if s == var => replacement.clone(), + Type::Existential(s) => Type::Existential(s.clone()), + Type::Polytype(a, t) => { + Type::Polytype(a.clone(), + Box::new(t.subst(var, replacement))) + } + Type::Arrow(a, b) => + Type::Arrow(Box::new(a.subst(var, replacement)), + Box::new(b.subst(var, replacement))), + } + } + } + pub enum Monotype { + Unit, + Var(String), + Existential(String), + Arrow(Box, Box), + } + #[automatically_derived] + impl ::core::clone::Clone for Monotype { + #[inline] + fn clone(&self) -> Monotype { + match self { + Monotype::Unit => Monotype::Unit, + Monotype::Var(__self_0) => + Monotype::Var(::core::clone::Clone::clone(__self_0)), + Monotype::Existential(__self_0) => + Monotype::Existential(::core::clone::Clone::clone(__self_0)), + Monotype::Arrow(__self_0, __self_1) => + Monotype::Arrow(::core::clone::Clone::clone(__self_0), + ::core::clone::Clone::clone(__self_1)), + } + } + } + impl fmt::Debug for Monotype { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + Self::Unit => f.write_fmt(format_args!("𝟙")), + Self::Var(arg0) => f.write_fmt(format_args!("{0}", arg0)), + Self::Existential(arg0) => + f.write_fmt(format_args!("{0}", arg0)), + Self::Arrow(arg0, arg1) => + f.write_fmt(format_args!("({0:?} -> {1:?})", arg0, arg1)), + } + } + } + impl Monotype { + pub fn into_poly(&self) -> Type { + match self { + Monotype::Unit => Type::Unit, + Monotype::Var(x) => Type::Var(x.clone()), + Monotype::Existential(x) => Type::Existential(x.clone()), + Monotype::Arrow(a, b) => { + Type::Arrow(Box::new(a.into_poly()), + Box::new(b.into_poly())) + } + } + } + } + pub enum ContextEntry { + TypeVar(String), + TermAnnot(String, Type), + ExistentialVar(String), + ExistentialSolved(String, Monotype), + Marker(String), + } + #[automatically_derived] + impl ::core::clone::Clone for ContextEntry { + #[inline] + fn clone(&self) -> ContextEntry { + match self { + ContextEntry::TypeVar(__self_0) => + ContextEntry::TypeVar(::core::clone::Clone::clone(__self_0)), + ContextEntry::TermAnnot(__self_0, __self_1) => + ContextEntry::TermAnnot(::core::clone::Clone::clone(__self_0), + ::core::clone::Clone::clone(__self_1)), + ContextEntry::ExistentialVar(__self_0) => + ContextEntry::ExistentialVar(::core::clone::Clone::clone(__self_0)), + ContextEntry::ExistentialSolved(__self_0, __self_1) => + ContextEntry::ExistentialSolved(::core::clone::Clone::clone(__self_0), + ::core::clone::Clone::clone(__self_1)), + ContextEntry::Marker(__self_0) => + ContextEntry::Marker(::core::clone::Clone::clone(__self_0)), + } + } + } + impl fmt::Debug for ContextEntry { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + Self::TypeVar(arg0) => f.write_fmt(format_args!("{0}", arg0)), + Self::TermAnnot(arg0, arg1) => + f.write_fmt(format_args!("{0} : {1:?}", arg0, arg1)), + Self::ExistentialVar(arg0) => + f.write_fmt(format_args!("{0}", arg0)), + Self::ExistentialSolved(arg0, arg1) => + f.write_fmt(format_args!("{0} ≔ {1:?}", arg0, arg1)), + Self::Marker(arg0) => + f.write_fmt(format_args!("▶{0}", arg0)), + } + } + } + pub enum CompleteContextEntry { + TypeVar(String), + TermAnnot(String, Type), + ExistentialSolved(String, Monotype), + Marker(String), + } + #[automatically_derived] + impl ::core::fmt::Debug for CompleteContextEntry { + fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { + match self { + CompleteContextEntry::TypeVar(__self_0) => + ::core::fmt::Formatter::debug_tuple_field1_finish(f, + "TypeVar", &__self_0), + CompleteContextEntry::TermAnnot(__self_0, __self_1) => + ::core::fmt::Formatter::debug_tuple_field2_finish(f, + "TermAnnot", __self_0, &__self_1), + CompleteContextEntry::ExistentialSolved(__self_0, __self_1) => + ::core::fmt::Formatter::debug_tuple_field2_finish(f, + "ExistentialSolved", __self_0, &__self_1), + CompleteContextEntry::Marker(__self_0) => + ::core::fmt::Formatter::debug_tuple_field1_finish(f, + "Marker", &__self_0), + } + } + } + #[automatically_derived] + impl ::core::clone::Clone for CompleteContextEntry { + #[inline] + fn clone(&self) -> CompleteContextEntry { + match self { + CompleteContextEntry::TypeVar(__self_0) => + CompleteContextEntry::TypeVar(::core::clone::Clone::clone(__self_0)), + CompleteContextEntry::TermAnnot(__self_0, __self_1) => + CompleteContextEntry::TermAnnot(::core::clone::Clone::clone(__self_0), + ::core::clone::Clone::clone(__self_1)), + CompleteContextEntry::ExistentialSolved(__self_0, __self_1) => + CompleteContextEntry::ExistentialSolved(::core::clone::Clone::clone(__self_0), + ::core::clone::Clone::clone(__self_1)), + CompleteContextEntry::Marker(__self_0) => + CompleteContextEntry::Marker(::core::clone::Clone::clone(__self_0)), + } + } + } + pub struct Context(pub(crate) Vector); + #[automatically_derived] + impl ::core::clone::Clone for Context { + #[inline] + fn clone(&self) -> Context { + Context(::core::clone::Clone::clone(&self.0)) + } + } + #[automatically_derived] + impl ::core::default::Default for Context { + #[inline] + fn default() -> Context { + Context(::core::default::Default::default()) + } + } + impl fmt::Debug for Context { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str("Γ")?; + for rule in self.0.iter() { f.write_str(", ")?; rule.fmt(f)?; } + Ok(()) + } + } + impl Context { + pub fn add(&self, entries: Vec) -> Context { + let mut new_ctx = self.clone(); + for entry in entries { new_ctx.0.push_back(entry); } + new_ctx + } + /// Looks up a polytype by name, also returning an index + pub fn lookup_type(&self, name: impl AsRef) + -> Option<(usize, Type)> { + self.0.iter().enumerate().find_map(|(i, entry)| + match entry { + ContextEntry::TermAnnot(n, t) if n == name.as_ref() => { + Some((i, t.clone())) + } + _ => None, + }) + } + #[inline] + pub fn has_type(&self, name: impl AsRef) -> bool { + self.lookup_type(name).is_some() + } + /// Looks up an existential variable by name + /// - Returns Some(Some(t)) if solved + /// - Returns Some(None) if exists but unsolved + /// - Returns None if not found + pub fn lookup_existential(&self, name: impl AsRef) + -> Option<(usize, Option)> { + self.0.iter().enumerate().find_map(|(i, entry)| + match entry { + ContextEntry::ExistentialVar(n) if n == name.as_ref() => { + Some((i, None)) + } + ContextEntry::ExistentialSolved(n, t) if n == name.as_ref() + => { + Some((i, Some(t.clone()))) + } + _ => None, + }) + } + #[inline] + pub fn has_existential(&self, name: impl AsRef) -> bool { + self.lookup_existential(name).is_some() + } + /// Returns a list of names of unsolved existentials + pub fn unsolved_existentials(&self) -> HashSet { + let mut unsolved = HashSet::new(); + for entry in self.0.iter() { + match entry { + ContextEntry::ExistentialVar(n) => { + unsolved.insert(n.clone()); + } + _ => {} + } + } + unsolved + } + /// Returns (before, after) + pub fn split_by

(&self, p: P) -> Option<(Context, Context)> where + P: Fn(&ContextEntry) -> bool { + let (before, after) = + { + let idx = self.0.iter().position(p)?; + self.0.clone().split_at(idx) + }; + Some((Context(before), Context(after))) + } + pub fn unsplit(left: &Context, center: ContextEntry, right: &Context) + -> Context { + let mut res = left.clone(); + res.0.push_back(center); + res.0.extend(right.0.clone().into_iter()); + res + } + pub fn split_existential_function(&self, var: &str) + -> Result<(String, String, Context)> { + let mut ctx = self.clone(); + let idx = + match ctx.lookup_existential(var) { + Some((idx, _)) => idx, + None => + return ::anyhow::__private::Err({ + let error = + ::anyhow::__private::format_err(format_args!("wtf?")); + error + }), + }; + let ex_a1_s = gensym_existential(); + let ex_a2_s = gensym_existential(); + ctx.0[idx] = + ContextEntry::ExistentialSolved(var.to_owned(), + Monotype::Arrow(Box::new(Monotype::Existential(ex_a1_s.to_owned())), + Box::new(Monotype::Existential(ex_a2_s.to_owned())))); + ctx.0.insert(idx, + ContextEntry::ExistentialVar(ex_a1_s.to_owned())); + ctx.0.insert(idx, + ContextEntry::ExistentialVar(ex_a2_s.to_owned())); + Ok((ex_a1_s, ex_a2_s, ctx)) + } + } +} +pub mod convert_data {} +pub mod bidir_debruijn { + use anyhow::{bail, Result}; + use crate::data_debruijn::{ + Context, ContextEntry, ContextIndex, Term, Type, + }; + use crate::DEPTH; + pub fn app_ctx(ctx: &Context, ty: &Type) -> Result { + { + ::std::io::_print(format_args!("{0:3$}[+] Entering app_ctx(ctx = {1:?}, ty = {2:?})\n", + "", ctx, ty, DEPTH.with(|d| d.get()))); + }; + DEPTH.with(|d| d.set(d.get() + 1)); + let fn_return_value = + { + match ty { + Type::Unit => Ok(Type::Unit), + Type::Var(s) => Ok(Type::Var(s.clone())), + Type::Existential(a) => + match ctx.get_existential(a) { + Some(Some(m)) => Ok(m.into_poly()), + Some(None) => Ok(Type::Existential(a.clone())), + None => + return ::anyhow::__private::Err({ + let error = + ::anyhow::__private::format_err(format_args!("existential variable {0:?} doesn\'t exist in context", + a)); + error + }), + }, + Type::Polytype(t) => { + let t = app_ctx(ctx, t)?; + Ok(Type::Polytype(Box::new(t))) + } + Type::Arrow(a, b) => + Ok(Type::Arrow(Box::new(app_ctx(ctx, a)?), + Box::new(app_ctx(ctx, b)?))), + } + }; + DEPTH.with(|d| d.set(d.get() - 1)); + { + ::std::io::_print(format_args!("{0:2$}[-] Exiting app_ctx = {1:?}\n", + "", fn_return_value, DEPTH.with(|d| d.get()))); + }; + fn_return_value + } + /// Under input context Γ , type A is a subtype of B, with output context ∆ + pub fn subtype(ctx: &Context, left: &Type, right: &Type) + -> Result { + match (left, right) { + (Type::Unit, Type::Unit) => Ok(ctx.clone()), + (Type::Var(x), Type::Var(y)) if + x == y && ctx.get_type(x).is_some() => { + Ok(ctx.clone()) + } + (Type::Existential(x), Type::Existential(y)) if + x == y && ctx.get_existential(x).is_some() => { + Ok(ctx.clone()) + } + (Type::Existential(a), ty_a) if ctx.get_existential(a).is_some() + => { + instantiate_left(ctx, a, ty_a) + } + (Type::Unit, Type::Var(_)) => + ::core::panicking::panic("not yet implemented"), + (Type::Unit, Type::Existential(_)) => + ::core::panicking::panic("not yet implemented"), + (Type::Unit, Type::Polytype(_)) => + ::core::panicking::panic("not yet implemented"), + (Type::Unit, Type::Arrow(_, _)) => + ::core::panicking::panic("not yet implemented"), + (Type::Var(_), Type::Unit) => + ::core::panicking::panic("not yet implemented"), + (Type::Var(_), Type::Var(_)) => + ::core::panicking::panic("not yet implemented"), + (Type::Var(_), Type::Existential(_)) => + ::core::panicking::panic("not yet implemented"), + (Type::Var(_), Type::Polytype(_)) => + ::core::panicking::panic("not yet implemented"), + (Type::Var(_), Type::Arrow(_, _)) => + ::core::panicking::panic("not yet implemented"), + (Type::Existential(_), Type::Unit) => + ::core::panicking::panic("not yet implemented"), + (Type::Existential(_), Type::Var(_)) => + ::core::panicking::panic("not yet implemented"), + (Type::Existential(_), Type::Existential(_)) => + ::core::panicking::panic("not yet implemented"), + (Type::Existential(_), Type::Polytype(_)) => + ::core::panicking::panic("not yet implemented"), + (Type::Existential(_), Type::Arrow(_, _)) => + ::core::panicking::panic("not yet implemented"), + (Type::Polytype(_), Type::Unit) => + ::core::panicking::panic("not yet implemented"), + (Type::Polytype(_), Type::Var(_)) => + ::core::panicking::panic("not yet implemented"), + (Type::Polytype(_), Type::Existential(_)) => + ::core::panicking::panic("not yet implemented"), + (Type::Polytype(_), Type::Polytype(_)) => + ::core::panicking::panic("not yet implemented"), + (Type::Polytype(_), Type::Arrow(_, _)) => + ::core::panicking::panic("not yet implemented"), + (Type::Arrow(_, _), Type::Unit) => + ::core::panicking::panic("not yet implemented"), + (Type::Arrow(_, _), Type::Var(_)) => + ::core::panicking::panic("not yet implemented"), + (Type::Arrow(_, _), Type::Existential(_)) => + ::core::panicking::panic("not yet implemented"), + (Type::Arrow(_, _), Type::Polytype(_)) => + ::core::panicking::panic("not yet implemented"), + (Type::Arrow(_, _), Type::Arrow(_, _)) => + ::core::panicking::panic("not yet implemented"), + _ => + return ::anyhow::__private::Err({ + let error = + ::anyhow::__private::format_err(format_args!("subtyping relation failed between {0:?} and {1:?} (ctx = {2:?})", + left, right, ctx)); + error + }), + } + } + pub fn instantiate_left(ctx: &Context, a: &ContextIndex, ty_a: &Type) + -> Result { + match ty_a { + Type::Existential(b) if + ctx.get_existential(a).is_some() && + ctx.get_existential(b).is_some() => { + ::core::panicking::panic("not yet implemented") + } + Type::Existential(_b) => + ::core::panicking::panic("not yet implemented"), + Type::Unit => ::core::panicking::panic("not yet implemented"), + Type::Var(_) => ::core::panicking::panic("not yet implemented"), + Type::Polytype(_) => + ::core::panicking::panic("not yet implemented"), + Type::Arrow(_, _) => + ::core::panicking::panic("not yet implemented"), + } + } + pub fn typecheck(ctx: &Context, term: &Term, ty: &Type) + -> Result { + { + ::std::io::_print(format_args!("{0:4$}[+] Entering typecheck(ctx = {1:?}, term = {2:?}, ty = {3:?})\n", + "", ctx, term, ty, DEPTH.with(|d| d.get()))); + }; + DEPTH.with(|d| d.set(d.get() + 1)); + let fn_return_value = + { + match (term, ty) { + (Term::Unit, Type::Unit) => Ok(ctx.clone()), + (_e, Type::Polytype(_t)) => + ::core::panicking::panic("not yet implemented"), + (Term::Lam(_e), Type::Arrow(_ty_a, _ty_b)) => { + ::core::panicking::panic("not yet implemented") + } + (term, ty) => { + { + ::std::io::_print(format_args!("SUB RULE: {0:?} || {1:?} ({2:?})\n", + term, ty, ctx)); + }; + let (ty_a, ctx_theta) = synthesize(ctx, term)?; + let a = app_ctx(&ctx_theta, &ty_a)?; + let b = app_ctx(&ctx_theta, ty)?; + let ctx_delta = subtype(&ctx_theta, &a, &b)?; + Ok(ctx_delta) + } + } + }; + DEPTH.with(|d| d.set(d.get() - 1)); + { + ::std::io::_print(format_args!("{0:2$}[-] Exiting typecheck = {1:?}\n", + "", fn_return_value, DEPTH.with(|d| d.get()))); + }; + fn_return_value + } + pub fn synthesize(ctx: &Context, term: &Term) -> Result<(Type, Context)> { + { + ::std::io::_print(format_args!("{0:3$}[+] Entering synthesize(ctx = {1:?}, term = {2:?})\n", + "", ctx, term, DEPTH.with(|d| d.get()))); + }; + DEPTH.with(|d| d.set(d.get() + 1)); + let fn_return_value = + { + match term { + Term::Unit => Ok((Type::Unit, ctx.clone())), + Term::Var(index) => { + let ty = + match ctx.get_type(index) { + Some(v) => v, + None => + return ::anyhow::__private::Err({ + let error = + ::anyhow::__private::format_err(format_args!("invalid index {0:?}, context: {1:?}", + index, ctx)); + error + }), + }; + Ok((ty, ctx.clone())) + } + Term::App(e1, e2) => { + let (ty_a, ctx_theta) = synthesize(ctx, e1)?; + let app_a = app_ctx(&ctx_theta, &ty_a)?; + let (ty_c, ctx_delta) = + app_synthesize(&ctx_theta, &app_a, &e2)?; + Ok((ty_c, ctx_delta)) + } + Term::Lam(e) => { + let (aug_ctx, marker_idx) = ctx.add(ContextEntry::Marker); + let (aug_ctx, ex_a_idx) = + aug_ctx.add(ContextEntry::ExistentialVar); + let (aug_ctx, ex_b_idx) = + aug_ctx.add(ContextEntry::ExistentialVar); + let ex_a = Type::Existential(ex_a_idx.clone()); + let ex_b = Type::Existential(ex_b_idx.clone()); + let (aug_ctx, _annot_idx) = + aug_ctx.add(ContextEntry::TermAnnot(ex_a.clone())); + let wtf_ctx = typecheck(&aug_ctx, &e, &ex_b)?; + let (before_marker, after_marker) = + wtf_ctx.split_at(&marker_idx); + { + ::std::io::_print(format_args!("Splitting: {0:?}\n", + wtf_ctx)); + }; + let mut tau = + app_ctx(&after_marker, + &Type::Arrow(Box::new(ex_a), Box::new(ex_b)))?; + let (final_ctx, gen_idx) = + before_marker.add(ContextEntry::ExistentialVar); + for index in after_marker.unsolved_existentials() { + tau = tau.subst(&index, Type::Var(gen_idx.clone())); + } + Ok((Type::Polytype(Box::new(tau)), final_ctx)) + } + Term::Annot(_, _) => + ::core::panicking::panic("not yet implemented"), + } + }; + DEPTH.with(|d| d.set(d.get() - 1)); + { + ::std::io::_print(format_args!("{0:2$}[-] Exiting synthesize = {1:?}\n", + "", fn_return_value, DEPTH.with(|d| d.get()))); + }; + fn_return_value + } + pub fn app_synthesize(_ctx: &Context, fun_ty: &Type, term: &Term) + -> Result<(Type, Context)> { + match (fun_ty, term) { + (Type::Unit, Term::Unit) => + ::core::panicking::panic("not yet implemented"), + (Type::Unit, Term::Var(_)) => + ::core::panicking::panic("not yet implemented"), + (Type::Unit, Term::Lam(_)) => + ::core::panicking::panic("not yet implemented"), + (Type::Unit, Term::App(_, _)) => + ::core::panicking::panic("not yet implemented"), + (Type::Unit, Term::Annot(_, _)) => + ::core::panicking::panic("not yet implemented"), + (Type::Var(_), Term::Unit) => + ::core::panicking::panic("not yet implemented"), + (Type::Var(_), Term::Var(_)) => + ::core::panicking::panic("not yet implemented"), + (Type::Var(_), Term::Lam(_)) => + ::core::panicking::panic("not yet implemented"), + (Type::Var(_), Term::App(_, _)) => + ::core::panicking::panic("not yet implemented"), + (Type::Var(_), Term::Annot(_, _)) => + ::core::panicking::panic("not yet implemented"), + (Type::Existential(_), Term::Unit) => + ::core::panicking::panic("not yet implemented"), + (Type::Existential(_), Term::Var(_)) => + ::core::panicking::panic("not yet implemented"), + (Type::Existential(_), Term::Lam(_)) => + ::core::panicking::panic("not yet implemented"), + (Type::Existential(_), Term::App(_, _)) => + ::core::panicking::panic("not yet implemented"), + (Type::Existential(_), Term::Annot(_, _)) => + ::core::panicking::panic("not yet implemented"), + (Type::Polytype(_), Term::Unit) => + ::core::panicking::panic("not yet implemented"), + (Type::Polytype(_), Term::Var(_)) => + ::core::panicking::panic("not yet implemented"), + (Type::Polytype(_), Term::Lam(_)) => + ::core::panicking::panic("not yet implemented"), + (Type::Polytype(_), Term::App(_, _)) => + ::core::panicking::panic("not yet implemented"), + (Type::Polytype(_), Term::Annot(_, _)) => + ::core::panicking::panic("not yet implemented"), + (Type::Arrow(_, _), Term::Unit) => + ::core::panicking::panic("not yet implemented"), + (Type::Arrow(_, _), Term::Var(_)) => + ::core::panicking::panic("not yet implemented"), + (Type::Arrow(_, _), Term::Lam(_)) => + ::core::panicking::panic("not yet implemented"), + (Type::Arrow(_, _), Term::App(_, _)) => + ::core::panicking::panic("not yet implemented"), + (Type::Arrow(_, _), Term::Annot(_, _)) => + ::core::panicking::panic("not yet implemented"), + _ => + return ::anyhow::__private::Err({ + let error = + ::anyhow::__private::format_err(format_args!("trying to appSynthesize with a non-function type")); + error + }), + } + } +} +pub mod data_debruijn { + use std::{ + cell::RefCell, fmt::self, + rc::Rc, + }; + use im::Vector; + use crate::{data, gensym::gensym_type}; + /// A lambda calculus term. + pub enum Term { + + /// Unit type + Unit, + + /// Variable, with a reference into the context. + /// The entry pointed to by this index MUST be a TypeVar. + Var(ContextIndex), + + /// Lambda abstraction. + Lam(Box), + + /// Lambda application. + App(Box, Box), + + /// Type annotation + Annot(Box, Type), + } + #[automatically_derived] + impl ::core::clone::Clone for Term { + #[inline] + fn clone(&self) -> Term { + match self { + Term::Unit => Term::Unit, + Term::Var(__self_0) => + Term::Var(::core::clone::Clone::clone(__self_0)), + Term::Lam(__self_0) => + Term::Lam(::core::clone::Clone::clone(__self_0)), + Term::App(__self_0, __self_1) => + Term::App(::core::clone::Clone::clone(__self_0), + ::core::clone::Clone::clone(__self_1)), + Term::Annot(__self_0, __self_1) => + Term::Annot(::core::clone::Clone::clone(__self_0), + ::core::clone::Clone::clone(__self_1)), + } + } + } + impl fmt::Debug for Term { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + Self::Unit => f.write_fmt(format_args!("unit")), + Self::Var(arg0) => f.write_fmt(format_args!("{0:?}", arg0)), + Self::Lam(arg1) => + f.write_fmt(format_args!("(λ.{0:?})", arg1)), + Self::App(arg0, arg1) => + f.write_fmt(format_args!("({0:?} · {1:?})", arg0, arg1)), + Self::Annot(arg0, arg1) => + f.write_fmt(format_args!("({0:?} : {1:?})", arg0, arg1)), + } + } + } + pub enum Type { + Unit, + Var(ContextIndex), + Existential(ContextIndex), + Polytype(Box), + Arrow(Box, Box), + } + #[automatically_derived] + impl ::core::clone::Clone for Type { + #[inline] + fn clone(&self) -> Type { + match self { + Type::Unit => Type::Unit, + Type::Var(__self_0) => + Type::Var(::core::clone::Clone::clone(__self_0)), + Type::Existential(__self_0) => + Type::Existential(::core::clone::Clone::clone(__self_0)), + Type::Polytype(__self_0) => + Type::Polytype(::core::clone::Clone::clone(__self_0)), + Type::Arrow(__self_0, __self_1) => + Type::Arrow(::core::clone::Clone::clone(__self_0), + ::core::clone::Clone::clone(__self_1)), + } + } + } + impl fmt::Debug for Type { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + Self::Unit => f.write_fmt(format_args!("𝟙")), + Self::Var(arg0) => f.write_fmt(format_args!("{0:?}", arg0)), + Self::Existential(arg0) => + f.write_fmt(format_args!("{0:?}", arg0)), + Self::Polytype(arg1) => + f.write_fmt(format_args!("(∀.{0:?})", arg1)), + Self::Arrow(arg0, arg1) => + f.write_fmt(format_args!("({0:?} -> {1:?})", arg0, arg1)), + } + } + } + impl Type { + /// Attempt to turn this polytype into a monotype. + /// + /// This fails if any sub-expression of this type contains a polytype expression. + pub fn try_into_mono(&self) -> Option { + match self { + Type::Unit => Some(Monotype::Unit), + Type::Var(x) => Some(Monotype::Var(x.clone())), + Type::Existential(x) => + Some(Monotype::Existential(x.clone())), + Type::Polytype(_) => None, + Type::Arrow(a, b) => + Some(Monotype::Arrow(Box::new(a.try_into_mono()?), + Box::new(b.try_into_mono()?))), + } + } + #[inline] + pub fn is_mono(&self) -> bool { self.try_into_mono().is_some() } + } + impl Type { + pub fn subst(&self, _before: &ContextIndex, _after: Type) -> Type { + match self { + Type::Unit => Type::Unit, + Type::Var(_) => + ::core::panicking::panic("not yet implemented"), + Type::Existential(_) => + ::core::panicking::panic("not yet implemented"), + Type::Polytype(_) => + ::core::panicking::panic("not yet implemented"), + Type::Arrow(_, _) => + ::core::panicking::panic("not yet implemented"), + } + } + } + pub enum Monotype { + Unit, + Var(ContextIndex), + Existential(ContextIndex), + Arrow(Box, Box), + } + #[automatically_derived] + impl ::core::clone::Clone for Monotype { + #[inline] + fn clone(&self) -> Monotype { + match self { + Monotype::Unit => Monotype::Unit, + Monotype::Var(__self_0) => + Monotype::Var(::core::clone::Clone::clone(__self_0)), + Monotype::Existential(__self_0) => + Monotype::Existential(::core::clone::Clone::clone(__self_0)), + Monotype::Arrow(__self_0, __self_1) => + Monotype::Arrow(::core::clone::Clone::clone(__self_0), + ::core::clone::Clone::clone(__self_1)), + } + } + } + impl fmt::Debug for Monotype { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + Self::Unit => f.write_fmt(format_args!("𝟙")), + Self::Var(arg0) => f.write_fmt(format_args!("{0:?}", arg0)), + Self::Existential(arg0) => + f.write_fmt(format_args!("{0:?}", arg0)), + Self::Arrow(arg0, arg1) => + f.write_fmt(format_args!("({0:?} -> {1:?})", arg0, arg1)), + } + } + } + impl Monotype { + pub fn into_poly(&self) -> Type { + match self { + Monotype::Unit => Type::Unit, + Monotype::Var(x) => Type::Var(x.clone()), + Monotype::Existential(x) => Type::Existential(x.clone()), + Monotype::Arrow(a, b) => { + Type::Arrow(Box::new(a.into_poly()), + Box::new(b.into_poly())) + } + } + } + } + pub enum ContextEntry { + TypeVar, + TermAnnot(Type), + ExistentialVar, + ExistentialSolved(Monotype), + Marker, + } + #[automatically_derived] + impl ::core::fmt::Debug for ContextEntry { + fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { + match self { + ContextEntry::TypeVar => + ::core::fmt::Formatter::write_str(f, "TypeVar"), + ContextEntry::TermAnnot(__self_0) => + ::core::fmt::Formatter::debug_tuple_field1_finish(f, + "TermAnnot", &__self_0), + ContextEntry::ExistentialVar => + ::core::fmt::Formatter::write_str(f, "ExistentialVar"), + ContextEntry::ExistentialSolved(__self_0) => + ::core::fmt::Formatter::debug_tuple_field1_finish(f, + "ExistentialSolved", &__self_0), + ContextEntry::Marker => + ::core::fmt::Formatter::write_str(f, "Marker"), + } + } + } + #[automatically_derived] + impl ::core::clone::Clone for ContextEntry { + #[inline] + fn clone(&self) -> ContextEntry { + match self { + ContextEntry::TypeVar => ContextEntry::TypeVar, + ContextEntry::TermAnnot(__self_0) => + ContextEntry::TermAnnot(::core::clone::Clone::clone(__self_0)), + ContextEntry::ExistentialVar => ContextEntry::ExistentialVar, + ContextEntry::ExistentialSolved(__self_0) => + ContextEntry::ExistentialSolved(::core::clone::Clone::clone(__self_0)), + ContextEntry::Marker => ContextEntry::Marker, + } + } + } + pub enum CompleteContextEntry { + TypeVar(String), + TermAnnot(String, Type), + ExistentialSolved(String, Monotype), + Marker(String), + } + #[automatically_derived] + impl ::core::fmt::Debug for CompleteContextEntry { + fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { + match self { + CompleteContextEntry::TypeVar(__self_0) => + ::core::fmt::Formatter::debug_tuple_field1_finish(f, + "TypeVar", &__self_0), + CompleteContextEntry::TermAnnot(__self_0, __self_1) => + ::core::fmt::Formatter::debug_tuple_field2_finish(f, + "TermAnnot", __self_0, &__self_1), + CompleteContextEntry::ExistentialSolved(__self_0, __self_1) => + ::core::fmt::Formatter::debug_tuple_field2_finish(f, + "ExistentialSolved", __self_0, &__self_1), + CompleteContextEntry::Marker(__self_0) => + ::core::fmt::Formatter::debug_tuple_field1_finish(f, + "Marker", &__self_0), + } + } + } + #[automatically_derived] + impl ::core::clone::Clone for CompleteContextEntry { + #[inline] + fn clone(&self) -> CompleteContextEntry { + match self { + CompleteContextEntry::TypeVar(__self_0) => + CompleteContextEntry::TypeVar(::core::clone::Clone::clone(__self_0)), + CompleteContextEntry::TermAnnot(__self_0, __self_1) => + CompleteContextEntry::TermAnnot(::core::clone::Clone::clone(__self_0), + ::core::clone::Clone::clone(__self_1)), + CompleteContextEntry::ExistentialSolved(__self_0, __self_1) => + CompleteContextEntry::ExistentialSolved(::core::clone::Clone::clone(__self_0), + ::core::clone::Clone::clone(__self_1)), + CompleteContextEntry::Marker(__self_0) => + CompleteContextEntry::Marker(::core::clone::Clone::clone(__self_0)), + } + } + } + pub struct Context { + vector: Vector, + len: Rc>, + } + #[automatically_derived] + impl ::core::fmt::Debug for Context { + fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { + ::core::fmt::Formatter::debug_struct_field2_finish(f, "Context", + "vector", &self.vector, "len", &&self.len) + } + } + #[automatically_derived] + impl ::core::clone::Clone for Context { + #[inline] + fn clone(&self) -> Context { + Context { + vector: ::core::clone::Clone::clone(&self.vector), + len: ::core::clone::Clone::clone(&self.len), + } + } + } + impl Default for Context { + fn default() -> Self { + let vector = Vector::default(); + let len = Rc::new(RefCell::new(0)); + Context { vector, len } + } + } + impl Context { + #[doc = "# Contracts"] + #[doc = + "Invariant: `{ let b = self.vector.len() == * self.len.borrow() ; b }`"] + #[doc = ""] + pub fn add(&self, entry: ContextEntry) -> (Context, ContextIndex) { + if !{ let b = self.vector.len() == *self.len.borrow(); b } { + { + ::core::panicking::panic_display(&"Invariant of add violated: { let b = self.vector.len() == * self.len.borrow() ; b }"); + } + }; + #[allow(unused_mut)] + let mut run = + |this: &Self, entry: ContextEntry| -> (Context, ContextIndex) + { + let context_level = this.vector.len(); + let mut new_ctx = this.clone(); + new_ctx.vector.push_back(entry); + let context_length = this.len.clone(); + { *context_length.borrow_mut() += 1; } + let idx = ContextIndex { context_level, context_length }; + (new_ctx, idx) + }; + let ret = run(self, entry); + if !{ let b = self.vector.len() == *self.len.borrow(); b } { + { + ::core::panicking::panic_display(&"Invariant of add violated: { let b = self.vector.len() == * self.len.borrow() ; b }"); + } + }; + ret + } + #[doc = "# Contracts"] + #[doc = + "Invariant: `{ let b = self.vector.len() == * self.len.borrow() ; b }`"] + #[doc = ""] + #[doc = "Pre-condition: `index.context_length == self.len`"] + #[doc = ""] + pub fn get(&self, index: &ContextIndex) -> Option<&ContextEntry> { + if !{ let b = self.vector.len() == *self.len.borrow(); b } { + { + ::core::panicking::panic_display(&"Invariant of get violated: { let b = self.vector.len() == * self.len.borrow() ; b }"); + } + }; + if !(index.context_length == self.len) { + { + ::core::panicking::panic_display(&"Pre-condition of get violated: index.context_length == self.len"); + } + }; + #[allow(unused_mut)] + let mut run = + |this: &Self, index: &ContextIndex| -> Option<&ContextEntry> + { this.vector.get(index.context_level) }; + let ret = run(self, index); + if !{ let b = self.vector.len() == *self.len.borrow(); b } { + { + ::core::panicking::panic_display(&"Invariant of get violated: { let b = self.vector.len() == * self.len.borrow() ; b }"); + } + }; + ret + } + #[doc = "# Contracts"] + #[doc = + "Invariant: `{ let b = self.vector.len() == * self.len.borrow() ; b }`"] + #[doc = ""] + pub fn get_existential(&self, index: &ContextIndex) + -> Option> { + if !{ let b = self.vector.len() == *self.len.borrow(); b } { + { + ::core::panicking::panic_display(&"Invariant of get_existential violated: { let b = self.vector.len() == * self.len.borrow() ; b }"); + } + }; + #[allow(unused_mut)] + let mut run = + |this: &Self, index: &ContextIndex| + -> Option> + { + let entry = this.get(index)?; + match entry { + ContextEntry::ExistentialSolved(t) => Some(Some(t.clone())), + ContextEntry::ExistentialVar => Some(None), + _ => None, + } + }; + let ret = run(self, index); + if !{ let b = self.vector.len() == *self.len.borrow(); b } { + { + ::core::panicking::panic_display(&"Invariant of get_existential violated: { let b = self.vector.len() == * self.len.borrow() ; b }"); + } + }; + ret + } + #[doc = "# Contracts"] + #[doc = + "Invariant: `{ let b = self.vector.len() == * self.len.borrow() ; b }`"] + #[doc = ""] + pub fn get_type(&self, index: &ContextIndex) -> Option { + if !{ let b = self.vector.len() == *self.len.borrow(); b } { + { + ::core::panicking::panic_display(&"Invariant of get_type violated: { let b = self.vector.len() == * self.len.borrow() ; b }"); + } + }; + #[allow(unused_mut)] + let mut run = + |this: &Self, index: &ContextIndex| -> Option + { + let entry = this.get(index)?; + match entry { + ContextEntry::TermAnnot(t) => Some(t.clone()), + _ => None, + } + }; + let ret = run(self, index); + if !{ let b = self.vector.len() == *self.len.borrow(); b } { + { + ::core::panicking::panic_display(&"Invariant of get_type violated: { let b = self.vector.len() == * self.len.borrow() ; b }"); + } + }; + ret + } + #[doc = "# Contracts"] + #[doc = + "Invariant: `{ let b = self.vector.len() == * self.len.borrow() ; b }`"] + #[doc = ""] + pub fn unsolved_existentials(&self) -> Vec { + if !{ let b = self.vector.len() == *self.len.borrow(); b } { + { + ::core::panicking::panic_display(&"Invariant of unsolved_existentials violated: { let b = self.vector.len() == * self.len.borrow() ; b }"); + } + }; + #[allow(unused_mut)] + let mut run = + |this: &Self| -> Vec + { + let mut unsolved = Vec::new(); + let context_length = this.len.clone(); + for (context_level, entry) in this.vector.iter().enumerate() + { + match entry { + ContextEntry::ExistentialVar => { + let index = + ContextIndex { + context_length: context_length.clone(), + context_level, + }; + unsolved.push(index) + } + _ => {} + } + } + unsolved + }; + let ret = run(self); + if !{ let b = self.vector.len() == *self.len.borrow(); b } { + { + ::core::panicking::panic_display(&"Invariant of unsolved_existentials violated: { let b = self.vector.len() == * self.len.borrow() ; b }"); + } + }; + ret + } + #[doc = " Splits the context"] + #[doc = "# Contracts"] + #[doc = + "Invariant: `{ let b = self.vector.len() == * self.len.borrow() ; b }`"] + #[doc = ""] + pub fn split_at(&self, index: &ContextIndex) -> (Context, Context) { + if !{ let b = self.vector.len() == *self.len.borrow(); b } { + { + ::core::panicking::panic_display(&"Invariant of split_at violated: { let b = self.vector.len() == * self.len.borrow() ; b }"); + } + }; + #[allow(unused_mut)] + let mut run = + |this: &Self, index: &ContextIndex| -> (Context, Context) + { + let (before, after) = + { this.vector.clone().split_at(index.context_level) }; + let before_len = Rc::new(RefCell::new(before.len())); + let after_len = Rc::new(RefCell::new(after.len())); + (Context { vector: before, len: before_len }, + Context { vector: after, len: after_len }) + }; + let ret = run(self, index); + if !{ let b = self.vector.len() == *self.len.borrow(); b } { + { + ::core::panicking::panic_display(&"Invariant of split_at violated: { let b = self.vector.len() == * self.len.borrow() ; b }"); + } + }; + ret + } + } + /// An index into the context. + pub struct ContextIndex { + context_length: Rc>, + context_level: usize, + } + #[automatically_derived] + impl ::core::clone::Clone for ContextIndex { + #[inline] + fn clone(&self) -> ContextIndex { + ContextIndex { + context_length: ::core::clone::Clone::clone(&self.context_length), + context_level: ::core::clone::Clone::clone(&self.context_level), + } + } + } + #[automatically_derived] + impl ::core::marker::StructuralPartialEq for ContextIndex { } + #[automatically_derived] + impl ::core::cmp::PartialEq for ContextIndex { + #[inline] + fn eq(&self, other: &ContextIndex) -> bool { + self.context_length == other.context_length && + self.context_level == other.context_level + } + } + #[automatically_derived] + impl ::core::marker::StructuralEq for ContextIndex { } + #[automatically_derived] + impl ::core::cmp::Eq for ContextIndex { + #[inline] + #[doc(hidden)] + #[no_coverage] + fn assert_receiver_is_total_eq(&self) -> () { + let _: ::core::cmp::AssertParamIsEq>>; + let _: ::core::cmp::AssertParamIsEq; + } + } + impl fmt::Debug for ContextIndex { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.write_fmt(format_args!("#{0}", self.context_index())) + } + } + impl ContextIndex { + pub fn context_index(&self) -> usize { + *self.context_length.borrow() - self.context_level + } + } + pub fn convert_term(term: &data::Term) -> Term { + fn convert_term_with_context(ctx: &data::Context, ctx2: &Context, + term: &data::Term) -> Term { + match term { + data::Term::Unit => Term::Unit, + data::Term::Var(name) => { + let (idx, _) = ctx.lookup_type(name).unwrap(); + let _len = ctx2.len.clone(); + let index = + ContextIndex { + context_length: ctx2.len.clone(), + context_level: idx, + }; + Term::Var(index) + } + data::Term::Lam(arg, body) => { + let ty = gensym_type(); + let aug_ctx = + ctx.add(<[_]>::into_vec(#[rustc_box] ::alloc::boxed::Box::new([data::ContextEntry::TermAnnot(arg.to_owned(), + data::Type::Var(ty.clone()))]))); + let body = convert_term_with_context(&aug_ctx, ctx2, body); + Term::Lam(Box::new(body)) + } + data::Term::App(func, arg) => { + let func = convert_term_with_context(ctx, ctx2, &func); + let arg = convert_term_with_context(ctx, ctx2, &arg); + Term::App(Box::new(func), Box::new(arg)) + } + data::Term::Annot(term, ty) => { + let term = convert_term_with_context(ctx, ctx2, &term); + let ty = convert_ty_with_context(ctx, ctx2, &ty); + Term::Annot(Box::new(term), ty) + } + } + } + fn convert_ty_with_context(_ctx: &data::Context, _ctx2: &Context, + ty: &data::Type) -> Type { + match ty { + data::Type::Unit => Type::Unit, + data::Type::Var(_) => + ::core::panicking::panic("not yet implemented"), + data::Type::Existential(_) => + ::core::panicking::panic("not yet implemented"), + data::Type::Polytype(_, _) => + ::core::panicking::panic("not yet implemented"), + data::Type::Arrow(_, _) => + ::core::panicking::panic("not yet implemented"), + } + } + convert_term_with_context(&data::Context::default(), + &Context::default(), term) + } +} +mod gensym { + use dashmap::DashMap; + const CTRMAP: ::std::thread::LocalKey> = + { + #[inline] + fn __init() -> DashMap<&'static str, usize> { DashMap::new() } + #[inline] + unsafe fn __getit(init: + ::std::option::Option<&mut ::std::option::Option>>) + -> + ::std::option::Option<&'static DashMap<&'static str, + usize>> { + #[thread_local] + static __KEY: + ::std::thread::local_impl::Key> + = + ::std::thread::local_impl::Key::>::new(); + + #[allow(unused_unsafe)] + unsafe { + __KEY.get(move || + { + if let ::std::option::Option::Some(init) = init { + if let ::std::option::Option::Some(value) = init.take() { + return value; + } else if true { + { + ::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}", + format_args!("missing default value"))); + }; + } + } + __init() + }) + } + } + unsafe { ::std::thread::LocalKey::new(__getit) } + }; + const EXISTENTIALS: [&'static str; 24] = + ["α", "β", "γ", "δ", "ε", "ζ", "η", "θ", "ι", "κ", "λ", + "μ", "ν", "ξ", "ο", "π", "ρ", "σ", "τ", "υ", "φ", + "χ", "ψ", "ω"]; + const TYPEVARS: [&'static str; 26] = + ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", + "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]; + pub fn gensym_existential() -> String { + let result = idx("existential"); + { + let res = + ::alloc::fmt::format(format_args!("{0}\u{{302}}", + EXISTENTIALS[result])); + res + } + } + pub fn gensym_type() -> String { + let result = idx("existential"); + { + let res = + ::alloc::fmt::format(format_args!("{0}\u{{302}}", + TYPEVARS[result])); + res + } + } + fn idx(ty: &'static str) -> usize { + CTRMAP.with(|ctrmap| + { + let mut g = ctrmap.entry(ty).or_insert(0); + let ctr = *g; + *g += 1; + ctr + }) + } +} +#[rustfmt::skip] +#[allow(clippy :: extra_unused_lifetimes)] +#[allow(clippy :: needless_lifetimes)] +#[allow(clippy :: let_unit_value)] +#[allow(clippy :: just_underscores_and_digits)] +pub mod parser { + use crate::data::*; + #[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; + #[rustfmt::skip] + #[allow(non_snake_case, non_camel_case_types, unused_mut, + unused_variables, unused_imports, unused_parens, clippy :: all)] + mod __parse__Ident { + use crate::data::*; + #[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(String), + Variant2(Term), + Variant3(Type), + } + const __ACTION: &[i8] = + &[0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; + fn __action(state: i8, integer: usize) -> i8 { + __ACTION[(state as usize) * 11 + integer] + } + const __EOF_ACTION: &[i8] = &[0, -22, -2]; + fn __goto(state: i8, nt: usize) -> i8 { match nt { 1 => 1, _ => 0, } } + const __TERMINAL: &[&str] = + &[r###""(""###, r###""()""###, r###"")""###, r###""->""###, + r###"".""###, r###"":""###, r###""\\""###, + r###""forall""###, r###""λ""###, r###"r#"[A-Za-z_]+"#"###, + r###"r#"\\^[A-Za-z_]+"#"###]; + fn __expected_tokens(__state: i8) + -> alloc::vec::Vec { + __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() + } + fn __expected_tokens_from_states<'input>(__states: &[i8], + _: core::marker::PhantomData<(&'input ())>) + -> alloc::vec::Vec { + __TERMINAL.iter().enumerate().filter_map(|(index, terminal)| + { + if __accepts(None, __states, Some(index), + core::marker::PhantomData::<(&())>) { + Some(alloc::string::ToString::to_string(terminal)) + } else { None } + }).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 = String; + 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, 11 - 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) + } + fn expected_tokens_from_states(&self, states: &[i8]) + -> alloc::vec::Vec { + __expected_tokens_from_states(states, + core::marker::PhantomData::<(&())>) + } + #[inline] + fn uses_error_recovery(&self) -> bool { false } + #[inline] + fn error_recovery_symbol(&self, + recovery: __state_machine::ErrorRecovery) + -> Self::Symbol { + { + ::core::panicking::panic_fmt(format_args!("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 { + __simulate_reduce(action, core::marker::PhantomData::<(&())>) + } + } + fn __token_to_integer<'input>(__token: &Token<'input>, + _: core::marker::PhantomData<(&'input ())>) -> Option { + match *__token { + Token(2, _) if true => Some(0), + Token(3, _) if true => Some(1), + Token(4, _) if true => Some(2), + Token(5, _) if true => Some(3), + Token(6, _) if true => Some(4), + Token(7, _) if true => Some(5), + Token(8, _) if true => Some(6), + Token(9, _) if true => Some(7), + Token(10, _) if true => Some(8), + Token(0, _) if true => Some(9), + Token(1, _) if true => Some(10), + _ => None, + } + } + fn __token_to_symbol<'input>(__token_index: usize, + __token: Token<'input>, + _: core::marker::PhantomData<(&'input ())>) -> __Symbol<'input> { + match __token_index { + 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 => + match __token { + Token(2, __tok0) | Token(3, __tok0) | Token(4, __tok0) | + Token(5, __tok0) | Token(6, __tok0) | Token(7, __tok0) | + Token(8, __tok0) | Token(9, __tok0) | Token(10, __tok0) | + Token(0, __tok0) | Token(1, __tok0) if true => + __Symbol::Variant0(__tok0), + _ => + ::core::panicking::panic("internal error: entered unreachable code"), + }, + _ => + ::core::panicking::panic("internal error: entered unreachable code"), + } + } + fn __simulate_reduce<'input>(__reduce_index: i8, + _: core::marker::PhantomData<(&'input ())>) + -> __state_machine::SimulatedReduce<__StateMachine<'input>> { + match __reduce_index { + 0 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 0, + } + } + 1 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 1, + } + } + 2 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 2, + nonterminal_produced: 2, + } + } + 3 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 2, + } + } + 4 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 3, + } + } + 5 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 3, + nonterminal_produced: 3, + } + } + 6 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 3, + } + } + 7 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 4, + nonterminal_produced: 4, + } + } + 8 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 4, + nonterminal_produced: 4, + } + } + 9 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 4, + } + } + 10 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 3, + nonterminal_produced: 5, + } + } + 11 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 5, + } + } + 12 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 6, + } + } + 13 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 3, + nonterminal_produced: 7, + } + } + 14 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 7, + } + } + 15 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 8, + } + } + 16 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 3, + nonterminal_produced: 8, + } + } + 17 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 8, + } + } + 18 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 8, + } + } + 19 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 4, + nonterminal_produced: 8, + } + } + 20 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 9, + } + } + 21 => __state_machine::SimulatedReduce::Accept, + 22 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 11, + } + } + 23 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 12, + } + } + 24 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 13, + } + } + 25 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 14, + } + } + 26 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 15, + } + } + 27 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 16, + } + } + _ => { + ::core::panicking::panic_fmt(format_args!("invalid reduction index {0}", + __reduce_index)); + } + } + } + pub struct IdentParser { + builder: __lalrpop_util::lexer::MatcherBuilder, + _priv: (), + } + impl IdentParser { + pub fn new() -> IdentParser { + let __builder = super::__intern_token::new_builder(); + IdentParser { 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) + } + } + fn __accepts<'input>(__error_state: Option, __states: &[i8], + __opt_integer: Option, + _: core::marker::PhantomData<(&'input ())>) -> bool { + let mut __states = __states.to_vec(); + __states.extend(__error_state); + loop { + let mut __states_len = __states.len(); + let __top = __states[__states_len - 1]; + let __action = + match __opt_integer { + None => __EOF_ACTION[__top as usize], + Some(__integer) => __action(__top, __integer), + }; + if __action == 0 { return false; } + if __action > 0 { return true; } + let (__to_pop, __nt) = + match __simulate_reduce(-(__action + 1), + core::marker::PhantomData::<(&())>) { + __state_machine::SimulatedReduce::Reduce { + states_to_pop, nonterminal_produced } => + (states_to_pop, nonterminal_produced), + __state_machine::SimulatedReduce::Accept => return true, + }; + __states_len -= __to_pop; + __states.truncate(__states_len); + let __top = __states[__states_len - 1]; + let __next_state = __goto(__top, __nt); + __states.push(__next_state); + } + } + 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 => { + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action6::<>(input, __sym0); + return Some(Ok(__nt)); + } + 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::<(&())>) + } + _ => { + ::core::panicking::panic_fmt(format_args!("invalid action code {0}", + __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() -> ! { + { + ::core::panicking::panic_fmt(format_args!("symbol type mismatch")); + } + } + fn __pop_Variant1<'input>(__symbols: + &mut alloc::vec::Vec<(usize, __Symbol<'input>, usize)>) + -> (usize, String, usize) { + match __symbols.pop() { + Some((__l, __Symbol::Variant1(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch(), + } + } + fn __pop_Variant2<'input>(__symbols: + &mut alloc::vec::Vec<(usize, __Symbol<'input>, usize)>) + -> (usize, Term, usize) { + match __symbols.pop() { + Some((__l, __Symbol::Variant2(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch(), + } + } + fn __pop_Variant3<'input>(__symbols: + &mut alloc::vec::Vec<(usize, __Symbol<'input>, usize)>) + -> (usize, Type, usize) { + match __symbols.pop() { + Some((__l, __Symbol::Variant3(__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) { + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action26::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant1(__nt), __end)); + (1, 0) + } + pub(crate) fn __reduce1<'input>(input: &'input str, + __lookahead_start: Option<&usize>, + __symbols: &mut alloc::vec::Vec<(usize, __Symbol<'input>, usize)>, + _: core::marker::PhantomData<(&'input ())>) -> (usize, usize) { + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action27::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant1(__nt), __end)); + (1, 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) { + if !(__symbols.len() >= 2) { + ::core::panicking::panic("assertion failed: __symbols.len() >= 2") + }; + let __sym1 = __pop_Variant2(__symbols); + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym1.2; + let __nt = super::__action15::<>(input, __sym0, __sym1); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (2, 2) + } + 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) { + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action16::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (1, 2) + } + pub(crate) fn __reduce4<'input>(input: &'input str, + __lookahead_start: Option<&usize>, + __symbols: &mut alloc::vec::Vec<(usize, __Symbol<'input>, usize)>, + _: core::marker::PhantomData<(&'input ())>) -> (usize, usize) { + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action7::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (1, 3) + } + 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) { + if !(__symbols.len() >= 3) { + ::core::panicking::panic("assertion failed: __symbols.len() >= 3") + }; + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant2(__symbols); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0; + let __end = __sym2.2; + let __nt = super::__action8::<>(input, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (3, 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) { + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action9::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (1, 3) + } + 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) { + if !(__symbols.len() >= 4) { + ::core::panicking::panic("assertion failed: __symbols.len() >= 4") + }; + let __sym3 = __pop_Variant2(__symbols); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant1(__symbols); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0; + let __end = __sym3.2; + let __nt = + super::__action10::<>(input, __sym0, __sym1, __sym2, __sym3); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (4, 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) { + if !(__symbols.len() >= 4) { + ::core::panicking::panic("assertion failed: __symbols.len() >= 4") + }; + let __sym3 = __pop_Variant2(__symbols); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant1(__symbols); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0; + let __end = __sym3.2; + let __nt = + super::__action11::<>(input, __sym0, __sym1, __sym2, __sym3); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (4, 4) + } + 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) { + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action12::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (1, 4) + } + 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) { + if !(__symbols.len() >= 3) { + ::core::panicking::panic("assertion failed: __symbols.len() >= 3") + }; + let __sym2 = __pop_Variant3(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym2.2; + let __nt = super::__action13::<>(input, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (3, 5) + } + 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) { + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action14::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (1, 5) + } + 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) { + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action17::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (1, 6) + } + 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) { + if !(__symbols.len() >= 3) { + ::core::panicking::panic("assertion failed: __symbols.len() >= 3") + }; + let __sym2 = __pop_Variant3(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0; + let __end = __sym2.2; + let __nt = super::__action23::<>(input, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (3, 7) + } + 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) { + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action24::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (1, 7) + } + 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) { + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action18::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (1, 8) + } + 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) { + if !(__symbols.len() >= 3) { + ::core::panicking::panic("assertion failed: __symbols.len() >= 3") + }; + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant3(__symbols); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0; + let __end = __sym2.2; + let __nt = super::__action19::<>(input, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (3, 8) + } + 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) { + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action20::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (1, 8) + } + 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) { + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action21::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (1, 8) + } + 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) { + if !(__symbols.len() >= 4) { + ::core::panicking::panic("assertion failed: __symbols.len() >= 4") + }; + let __sym3 = __pop_Variant3(__symbols); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant1(__symbols); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0; + let __end = __sym3.2; + let __nt = + super::__action22::<>(input, __sym0, __sym1, __sym2, __sym3); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (4, 8) + } + 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) { + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action25::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (1, 9) + } + 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) { + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action3::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (1, 11) + } + pub(crate) fn __reduce23<'input>(input: &'input str, + __lookahead_start: Option<&usize>, + __symbols: &mut alloc::vec::Vec<(usize, __Symbol<'input>, usize)>, + _: core::marker::PhantomData<(&'input ())>) -> (usize, usize) { + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action0::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (1, 12) + } + 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) { + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action1::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (1, 13) + } + 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) { + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action2::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (1, 14) + } + 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) { + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action5::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (1, 15) + } + 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) { + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action4::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (1, 16) + } + } + pub use self::__parse__Ident::IdentParser; + #[rustfmt::skip] + #[allow(non_snake_case, non_camel_case_types, unused_mut, + unused_variables, unused_imports, unused_parens, clippy :: all)] + mod __parse__Term { + use crate::data::*; + #[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(String), + Variant2(Term), + Variant3(Type), + } + const __ACTION: &[i8] = + &[3, 18, 0, 0, 0, 0, 4, 0, 5, 19, 0, 3, 18, 0, 0, 0, 0, 4, 0, 5, + 19, 0, 3, 18, 0, 0, 0, 0, 4, 0, 5, 19, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 8, 28, 0, + 0, 0, 0, 0, 9, 0, 19, 29, 3, 18, -13, 0, 0, 0, 4, 0, 5, 19, + 0, 8, 28, 0, 0, 0, 0, 0, 9, 0, 19, 29, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 19, 0, 3, 18, 0, 0, 0, 0, 4, 0, 5, 19, 0, 3, 18, 0, 0, + 0, 0, 4, 0, 5, 19, 0, 8, 28, 0, 0, 0, 0, 0, 9, 0, 19, 29, 8, + 28, 0, 0, 0, 0, 0, 9, 0, 19, 29, -7, -7, -7, 0, 0, -7, -7, + 0, -7, -7, 0, -10, -10, -10, 0, 0, -10, -10, 0, -10, -10, 0, + -12, -12, -12, 0, 0, -12, -12, 0, -12, -12, 0, -4, -4, -4, + 0, 0, 6, -4, 0, -4, -4, 0, -5, -5, -5, 0, 0, -5, -5, 0, -5, + -5, 0, -2, -2, -2, -2, -2, -2, -2, 0, -2, -2, 0, -3, -3, -3, + 0, 0, 6, -3, 0, -3, -3, 0, 0, 0, 30, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, + 0, 0, 0, -19, -19, -19, -19, 0, -19, -19, 0, -19, -19, 0, + -18, -18, -18, -18, 0, -18, -18, 0, -18, -18, 0, -11, -11, + -11, 0, 0, -11, -11, 0, -11, -11, 0, -15, -15, -15, 12, 0, + -15, -15, 0, -15, -15, 0, -16, -16, -16, -16, 0, -16, -16, + 0, -16, -16, 0, -1, -1, -1, -1, 0, -1, -1, 0, -1, -1, 0, -6, + -6, -6, 0, 0, -6, -6, 0, -6, -6, 0, 0, 0, -21, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 37, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 13, 0, 0, 0, 0, 0, 0, -9, -9, -9, 0, 0, -9, -9, 0, -9, -9, + 0, -8, -8, -8, 0, 0, -8, -8, 0, -8, -8, 0, -14, -14, -14, 0, + 0, -14, -14, 0, -14, -14, 0, -17, -17, -17, -17, 0, -17, + -17, 0, -17, -17, 0, -20, -20, -20, -20, 0, -20, -20, 0, + -20, -20, 0]; + fn __action(state: i8, integer: usize) -> i8 { + __ACTION[(state as usize) * 11 + integer] + } + const __EOF_ACTION: &[i8] = + &[0, -23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -7, -10, -12, -4, -5, + -2, -3, 0, 0, 0, -19, -18, -11, -15, -16, -1, -6, 0, 0, 0, + -9, -8, -14, -17, -20]; + fn __goto(state: i8, nt: usize) -> i8 { + match nt { + 0 => 23, + 1 => + match state { + 3 => 21, + 4 => 22, + 5 | 7 | 11..=12 => 24, + 8 => 32, + _ => 13, + }, + 2 => match state { 2 => 6, _ => 1, }, + 3 => 14, + 4 => match state { 9 => 33, 10 => 34, _ => 15, }, + 5 => match state { 1 | 6 => 19, _ => 16, }, + 6 => 20, + 7 => match state { 7 => 30, 11 => 35, _ => 25, }, + 8 => match state { 12 => 37, _ => 26, }, + 9 => 31, + _ => 0, + } + } + const __TERMINAL: &[&str] = + &[r###""(""###, r###""()""###, r###"")""###, r###""->""###, + r###"".""###, r###"":""###, r###""\\""###, + r###""forall""###, r###""λ""###, r###"r#"[A-Za-z_]+"#"###, + r###"r#"\\^[A-Za-z_]+"#"###]; + fn __expected_tokens(__state: i8) + -> alloc::vec::Vec { + __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() + } + fn __expected_tokens_from_states<'input>(__states: &[i8], + _: core::marker::PhantomData<(&'input ())>) + -> alloc::vec::Vec { + __TERMINAL.iter().enumerate().filter_map(|(index, terminal)| + { + if __accepts(None, __states, Some(index), + core::marker::PhantomData::<(&())>) { + Some(alloc::string::ToString::to_string(terminal)) + } else { None } + }).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 = Term; + 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, 11 - 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) + } + fn expected_tokens_from_states(&self, states: &[i8]) + -> alloc::vec::Vec { + __expected_tokens_from_states(states, + core::marker::PhantomData::<(&())>) + } + #[inline] + fn uses_error_recovery(&self) -> bool { false } + #[inline] + fn error_recovery_symbol(&self, + recovery: __state_machine::ErrorRecovery) + -> Self::Symbol { + { + ::core::panicking::panic_fmt(format_args!("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 { + __simulate_reduce(action, core::marker::PhantomData::<(&())>) + } + } + fn __token_to_integer<'input>(__token: &Token<'input>, + _: core::marker::PhantomData<(&'input ())>) -> Option { + match *__token { + Token(2, _) if true => Some(0), + Token(3, _) if true => Some(1), + Token(4, _) if true => Some(2), + Token(5, _) if true => Some(3), + Token(6, _) if true => Some(4), + Token(7, _) if true => Some(5), + Token(8, _) if true => Some(6), + Token(9, _) if true => Some(7), + Token(10, _) if true => Some(8), + Token(0, _) if true => Some(9), + Token(1, _) if true => Some(10), + _ => None, + } + } + fn __token_to_symbol<'input>(__token_index: usize, + __token: Token<'input>, + _: core::marker::PhantomData<(&'input ())>) -> __Symbol<'input> { + match __token_index { + 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 => + match __token { + Token(2, __tok0) | Token(3, __tok0) | Token(4, __tok0) | + Token(5, __tok0) | Token(6, __tok0) | Token(7, __tok0) | + Token(8, __tok0) | Token(9, __tok0) | Token(10, __tok0) | + Token(0, __tok0) | Token(1, __tok0) if true => + __Symbol::Variant0(__tok0), + _ => + ::core::panicking::panic("internal error: entered unreachable code"), + }, + _ => + ::core::panicking::panic("internal error: entered unreachable code"), + } + } + fn __simulate_reduce<'input>(__reduce_index: i8, + _: core::marker::PhantomData<(&'input ())>) + -> __state_machine::SimulatedReduce<__StateMachine<'input>> { + match __reduce_index { + 0 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 0, + } + } + 1 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 1, + } + } + 2 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 2, + nonterminal_produced: 2, + } + } + 3 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 2, + } + } + 4 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 3, + } + } + 5 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 3, + nonterminal_produced: 3, + } + } + 6 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 3, + } + } + 7 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 4, + nonterminal_produced: 4, + } + } + 8 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 4, + nonterminal_produced: 4, + } + } + 9 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 4, + } + } + 10 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 3, + nonterminal_produced: 5, + } + } + 11 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 5, + } + } + 12 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 6, + } + } + 13 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 3, + nonterminal_produced: 7, + } + } + 14 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 7, + } + } + 15 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 8, + } + } + 16 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 3, + nonterminal_produced: 8, + } + } + 17 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 8, + } + } + 18 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 8, + } + } + 19 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 4, + nonterminal_produced: 8, + } + } + 20 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 9, + } + } + 21 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 10, + } + } + 22 => __state_machine::SimulatedReduce::Accept, + 23 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 12, + } + } + 24 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 13, + } + } + 25 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 14, + } + } + 26 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 15, + } + } + 27 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 16, + } + } + _ => { + ::core::panicking::panic_fmt(format_args!("invalid reduction index {0}", + __reduce_index)); + } + } + } + pub struct TermParser { + builder: __lalrpop_util::lexer::MatcherBuilder, + _priv: (), + } + impl TermParser { + pub fn new() -> TermParser { + let __builder = super::__intern_token::new_builder(); + TermParser { 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) + } + } + fn __accepts<'input>(__error_state: Option, __states: &[i8], + __opt_integer: Option, + _: core::marker::PhantomData<(&'input ())>) -> bool { + let mut __states = __states.to_vec(); + __states.extend(__error_state); + loop { + let mut __states_len = __states.len(); + let __top = __states[__states_len - 1]; + let __action = + match __opt_integer { + None => __EOF_ACTION[__top as usize], + Some(__integer) => __action(__top, __integer), + }; + if __action == 0 { return false; } + if __action > 0 { return true; } + let (__to_pop, __nt) = + match __simulate_reduce(-(__action + 1), + core::marker::PhantomData::<(&())>) { + __state_machine::SimulatedReduce::Reduce { + states_to_pop, nonterminal_produced } => + (states_to_pop, nonterminal_produced), + __state_machine::SimulatedReduce::Accept => return true, + }; + __states_len -= __to_pop; + __states.truncate(__states_len); + let __top = __states[__states_len - 1]; + let __next_state = __goto(__top, __nt); + __states.push(__next_state); + } + } + 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 => { + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action3::<>(input, __sym0); + return Some(Ok(__nt)); + } + 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::<(&())>) + } + _ => { + ::core::panicking::panic_fmt(format_args!("invalid action code {0}", + __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() -> ! { + { + ::core::panicking::panic_fmt(format_args!("symbol type mismatch")); + } + } + fn __pop_Variant1<'input>(__symbols: + &mut alloc::vec::Vec<(usize, __Symbol<'input>, usize)>) + -> (usize, String, usize) { + match __symbols.pop() { + Some((__l, __Symbol::Variant1(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch(), + } + } + fn __pop_Variant2<'input>(__symbols: + &mut alloc::vec::Vec<(usize, __Symbol<'input>, usize)>) + -> (usize, Term, usize) { + match __symbols.pop() { + Some((__l, __Symbol::Variant2(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch(), + } + } + fn __pop_Variant3<'input>(__symbols: + &mut alloc::vec::Vec<(usize, __Symbol<'input>, usize)>) + -> (usize, Type, usize) { + match __symbols.pop() { + Some((__l, __Symbol::Variant3(__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) { + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action26::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant1(__nt), __end)); + (1, 0) + } + pub(crate) fn __reduce1<'input>(input: &'input str, + __lookahead_start: Option<&usize>, + __symbols: &mut alloc::vec::Vec<(usize, __Symbol<'input>, usize)>, + _: core::marker::PhantomData<(&'input ())>) -> (usize, usize) { + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action27::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant1(__nt), __end)); + (1, 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) { + if !(__symbols.len() >= 2) { + ::core::panicking::panic("assertion failed: __symbols.len() >= 2") + }; + let __sym1 = __pop_Variant2(__symbols); + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym1.2; + let __nt = super::__action15::<>(input, __sym0, __sym1); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (2, 2) + } + 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) { + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action16::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (1, 2) + } + pub(crate) fn __reduce4<'input>(input: &'input str, + __lookahead_start: Option<&usize>, + __symbols: &mut alloc::vec::Vec<(usize, __Symbol<'input>, usize)>, + _: core::marker::PhantomData<(&'input ())>) -> (usize, usize) { + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action7::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (1, 3) + } + 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) { + if !(__symbols.len() >= 3) { + ::core::panicking::panic("assertion failed: __symbols.len() >= 3") + }; + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant2(__symbols); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0; + let __end = __sym2.2; + let __nt = super::__action8::<>(input, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (3, 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) { + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action9::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (1, 3) + } + 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) { + if !(__symbols.len() >= 4) { + ::core::panicking::panic("assertion failed: __symbols.len() >= 4") + }; + let __sym3 = __pop_Variant2(__symbols); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant1(__symbols); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0; + let __end = __sym3.2; + let __nt = + super::__action10::<>(input, __sym0, __sym1, __sym2, __sym3); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (4, 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) { + if !(__symbols.len() >= 4) { + ::core::panicking::panic("assertion failed: __symbols.len() >= 4") + }; + let __sym3 = __pop_Variant2(__symbols); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant1(__symbols); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0; + let __end = __sym3.2; + let __nt = + super::__action11::<>(input, __sym0, __sym1, __sym2, __sym3); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (4, 4) + } + 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) { + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action12::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (1, 4) + } + 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) { + if !(__symbols.len() >= 3) { + ::core::panicking::panic("assertion failed: __symbols.len() >= 3") + }; + let __sym2 = __pop_Variant3(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym2.2; + let __nt = super::__action13::<>(input, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (3, 5) + } + 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) { + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action14::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (1, 5) + } + 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) { + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action17::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (1, 6) + } + 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) { + if !(__symbols.len() >= 3) { + ::core::panicking::panic("assertion failed: __symbols.len() >= 3") + }; + let __sym2 = __pop_Variant3(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0; + let __end = __sym2.2; + let __nt = super::__action23::<>(input, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (3, 7) + } + 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) { + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action24::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (1, 7) + } + 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) { + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action18::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (1, 8) + } + 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) { + if !(__symbols.len() >= 3) { + ::core::panicking::panic("assertion failed: __symbols.len() >= 3") + }; + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant3(__symbols); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0; + let __end = __sym2.2; + let __nt = super::__action19::<>(input, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (3, 8) + } + 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) { + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action20::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (1, 8) + } + 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) { + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action21::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (1, 8) + } + 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) { + if !(__symbols.len() >= 4) { + ::core::panicking::panic("assertion failed: __symbols.len() >= 4") + }; + let __sym3 = __pop_Variant3(__symbols); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant1(__symbols); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0; + let __end = __sym3.2; + let __nt = + super::__action22::<>(input, __sym0, __sym1, __sym2, __sym3); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (4, 8) + } + 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) { + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action25::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (1, 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) { + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action6::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant1(__nt), __end)); + (1, 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) { + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action0::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (1, 12) + } + 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) { + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action1::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (1, 13) + } + 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) { + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action2::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (1, 14) + } + 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) { + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action5::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (1, 15) + } + 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) { + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action4::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (1, 16) + } + } + pub use self::__parse__Term::TermParser; + #[rustfmt::skip] + #[allow(non_snake_case, non_camel_case_types, unused_mut, + unused_variables, unused_imports, unused_parens, clippy :: all)] + mod __parse__Term1 { + use crate::data::*; + #[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(String), + Variant2(Term), + Variant3(Type), + } + const __ACTION: &[i8] = + &[2, 15, 0, 0, 0, 0, 0, 0, 0, 16, 0, 2, 15, 0, 0, 0, 0, 4, 0, 5, + 16, 0, 2, 15, -13, 0, 0, 0, 4, 0, 5, 16, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 7, 29, + 0, 0, 0, 0, 0, 8, 0, 16, 30, 7, 29, 0, 0, 0, 0, 0, 8, 0, 16, + 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 2, 15, 0, 0, 0, 0, 4, + 0, 5, 16, 0, 2, 15, 0, 0, 0, 0, 4, 0, 5, 16, 0, 7, 29, 0, 0, + 0, 0, 0, 8, 0, 16, 30, 7, 29, 0, 0, 0, 0, 0, 8, 0, 16, 30, + -7, -7, -7, 0, 0, -7, -7, 0, -7, -7, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, -5, -5, -5, 0, 0, -5, -5, 0, -5, -5, 0, -2, -2, + -2, -2, -2, -2, -2, 0, -2, -2, 0, -10, -10, -10, 0, 0, -10, + -10, 0, -10, -10, 0, -12, -12, -12, 0, 0, -12, -12, 0, -12, + -12, 0, -4, -4, -4, 0, 0, 6, -4, 0, -4, -4, 0, 0, 0, 22, 0, + 0, 0, 0, 0, 0, 0, 0, -3, -3, -3, 0, 0, 6, -3, 0, -3, -3, 0, + -6, -6, -6, 0, 0, -6, -6, 0, -6, -6, 0, 0, 0, 0, 0, 9, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, -19, -19, -19, + -19, 0, -19, -19, 0, -19, -19, 0, -18, -18, -18, -18, 0, + -18, -18, 0, -18, -18, 0, -11, -11, -11, 0, 0, -11, -11, 0, + -11, -11, 0, -15, -15, -15, 11, 0, -15, -15, 0, -15, -15, 0, + -16, -16, -16, -16, 0, -16, -16, 0, -16, -16, 0, -1, -1, -1, + -1, 0, -1, -1, 0, -1, -1, 0, 0, 0, -21, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 37, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0, + 0, 0, 0, 0, -9, -9, -9, 0, 0, -9, -9, 0, -9, -9, 0, -8, -8, + -8, 0, 0, -8, -8, 0, -8, -8, 0, -14, -14, -14, 0, 0, -14, + -14, 0, -14, -14, 0, -17, -17, -17, -17, 0, -17, -17, 0, + -17, -17, 0, -20, -20, -20, -20, 0, -20, -20, 0, -20, -20, + 0]; + fn __action(state: i8, integer: usize) -> i8 { + __ACTION[(state as usize) * 11 + integer] + } + const __EOF_ACTION: &[i8] = + &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -7, -24, -5, -2, 0, 0, 0, 0, + 0, -6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; + fn __goto(state: i8, nt: usize) -> i8 { + match nt { + 0 => 24, + 1 => + match state { + 3 => 22, + 4 => 23, + 5..=6 | 10..=11 => 25, + 7 => 32, + _ => 12, + }, + 2 => 2, + 3 => match state { 0 => 13, _ => 16, }, + 4 => match state { 8 => 33, 9 => 34, _ => 17, }, + 5 => match state { 2 => 20, _ => 18, }, + 6 => 19, + 7 => match state { 6 => 30, 10 => 35, _ => 26, }, + 8 => match state { 11 => 37, _ => 27, }, + 9 => 31, + _ => 0, + } + } + const __TERMINAL: &[&str] = + &[r###""(""###, r###""()""###, r###"")""###, r###""->""###, + r###"".""###, r###"":""###, r###""\\""###, + r###""forall""###, r###""λ""###, r###"r#"[A-Za-z_]+"#"###, + r###"r#"\\^[A-Za-z_]+"#"###]; + fn __expected_tokens(__state: i8) + -> alloc::vec::Vec { + __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() + } + fn __expected_tokens_from_states<'input>(__states: &[i8], + _: core::marker::PhantomData<(&'input ())>) + -> alloc::vec::Vec { + __TERMINAL.iter().enumerate().filter_map(|(index, terminal)| + { + if __accepts(None, __states, Some(index), + core::marker::PhantomData::<(&())>) { + Some(alloc::string::ToString::to_string(terminal)) + } else { None } + }).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 = Term; + 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, 11 - 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) + } + fn expected_tokens_from_states(&self, states: &[i8]) + -> alloc::vec::Vec { + __expected_tokens_from_states(states, + core::marker::PhantomData::<(&())>) + } + #[inline] + fn uses_error_recovery(&self) -> bool { false } + #[inline] + fn error_recovery_symbol(&self, + recovery: __state_machine::ErrorRecovery) + -> Self::Symbol { + { + ::core::panicking::panic_fmt(format_args!("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 { + __simulate_reduce(action, core::marker::PhantomData::<(&())>) + } + } + fn __token_to_integer<'input>(__token: &Token<'input>, + _: core::marker::PhantomData<(&'input ())>) -> Option { + match *__token { + Token(2, _) if true => Some(0), + Token(3, _) if true => Some(1), + Token(4, _) if true => Some(2), + Token(5, _) if true => Some(3), + Token(6, _) if true => Some(4), + Token(7, _) if true => Some(5), + Token(8, _) if true => Some(6), + Token(9, _) if true => Some(7), + Token(10, _) if true => Some(8), + Token(0, _) if true => Some(9), + Token(1, _) if true => Some(10), + _ => None, + } + } + fn __token_to_symbol<'input>(__token_index: usize, + __token: Token<'input>, + _: core::marker::PhantomData<(&'input ())>) -> __Symbol<'input> { + match __token_index { + 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 => + match __token { + Token(2, __tok0) | Token(3, __tok0) | Token(4, __tok0) | + Token(5, __tok0) | Token(6, __tok0) | Token(7, __tok0) | + Token(8, __tok0) | Token(9, __tok0) | Token(10, __tok0) | + Token(0, __tok0) | Token(1, __tok0) if true => + __Symbol::Variant0(__tok0), + _ => + ::core::panicking::panic("internal error: entered unreachable code"), + }, + _ => + ::core::panicking::panic("internal error: entered unreachable code"), + } + } + fn __simulate_reduce<'input>(__reduce_index: i8, + _: core::marker::PhantomData<(&'input ())>) + -> __state_machine::SimulatedReduce<__StateMachine<'input>> { + match __reduce_index { + 0 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 0, + } + } + 1 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 1, + } + } + 2 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 2, + nonterminal_produced: 2, + } + } + 3 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 2, + } + } + 4 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 3, + } + } + 5 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 3, + nonterminal_produced: 3, + } + } + 6 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 3, + } + } + 7 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 4, + nonterminal_produced: 4, + } + } + 8 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 4, + nonterminal_produced: 4, + } + } + 9 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 4, + } + } + 10 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 3, + nonterminal_produced: 5, + } + } + 11 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 5, + } + } + 12 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 6, + } + } + 13 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 3, + nonterminal_produced: 7, + } + } + 14 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 7, + } + } + 15 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 8, + } + } + 16 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 3, + nonterminal_produced: 8, + } + } + 17 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 8, + } + } + 18 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 8, + } + } + 19 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 4, + nonterminal_produced: 8, + } + } + 20 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 9, + } + } + 21 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 10, + } + } + 22 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 11, + } + } + 23 => __state_machine::SimulatedReduce::Accept, + 24 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 13, + } + } + 25 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 14, + } + } + 26 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 15, + } + } + 27 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 16, + } + } + _ => { + ::core::panicking::panic_fmt(format_args!("invalid reduction index {0}", + __reduce_index)); + } + } + } + pub struct Term1Parser { + builder: __lalrpop_util::lexer::MatcherBuilder, + _priv: (), + } + impl Term1Parser { + pub fn new() -> Term1Parser { + let __builder = super::__intern_token::new_builder(); + Term1Parser { 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) + } + } + fn __accepts<'input>(__error_state: Option, __states: &[i8], + __opt_integer: Option, + _: core::marker::PhantomData<(&'input ())>) -> bool { + let mut __states = __states.to_vec(); + __states.extend(__error_state); + loop { + let mut __states_len = __states.len(); + let __top = __states[__states_len - 1]; + let __action = + match __opt_integer { + None => __EOF_ACTION[__top as usize], + Some(__integer) => __action(__top, __integer), + }; + if __action == 0 { return false; } + if __action > 0 { return true; } + let (__to_pop, __nt) = + match __simulate_reduce(-(__action + 1), + core::marker::PhantomData::<(&())>) { + __state_machine::SimulatedReduce::Reduce { + states_to_pop, nonterminal_produced } => + (states_to_pop, nonterminal_produced), + __state_machine::SimulatedReduce::Accept => return true, + }; + __states_len -= __to_pop; + __states.truncate(__states_len); + let __top = __states[__states_len - 1]; + let __next_state = __goto(__top, __nt); + __states.push(__next_state); + } + } + 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 => { + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action0::<>(input, __sym0); + return Some(Ok(__nt)); + } + 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::<(&())>) + } + _ => { + ::core::panicking::panic_fmt(format_args!("invalid action code {0}", + __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() -> ! { + { + ::core::panicking::panic_fmt(format_args!("symbol type mismatch")); + } + } + fn __pop_Variant1<'input>(__symbols: + &mut alloc::vec::Vec<(usize, __Symbol<'input>, usize)>) + -> (usize, String, usize) { + match __symbols.pop() { + Some((__l, __Symbol::Variant1(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch(), + } + } + fn __pop_Variant2<'input>(__symbols: + &mut alloc::vec::Vec<(usize, __Symbol<'input>, usize)>) + -> (usize, Term, usize) { + match __symbols.pop() { + Some((__l, __Symbol::Variant2(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch(), + } + } + fn __pop_Variant3<'input>(__symbols: + &mut alloc::vec::Vec<(usize, __Symbol<'input>, usize)>) + -> (usize, Type, usize) { + match __symbols.pop() { + Some((__l, __Symbol::Variant3(__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) { + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action26::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant1(__nt), __end)); + (1, 0) + } + pub(crate) fn __reduce1<'input>(input: &'input str, + __lookahead_start: Option<&usize>, + __symbols: &mut alloc::vec::Vec<(usize, __Symbol<'input>, usize)>, + _: core::marker::PhantomData<(&'input ())>) -> (usize, usize) { + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action27::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant1(__nt), __end)); + (1, 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) { + if !(__symbols.len() >= 2) { + ::core::panicking::panic("assertion failed: __symbols.len() >= 2") + }; + let __sym1 = __pop_Variant2(__symbols); + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym1.2; + let __nt = super::__action15::<>(input, __sym0, __sym1); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (2, 2) + } + 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) { + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action16::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (1, 2) + } + pub(crate) fn __reduce4<'input>(input: &'input str, + __lookahead_start: Option<&usize>, + __symbols: &mut alloc::vec::Vec<(usize, __Symbol<'input>, usize)>, + _: core::marker::PhantomData<(&'input ())>) -> (usize, usize) { + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action7::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (1, 3) + } + 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) { + if !(__symbols.len() >= 3) { + ::core::panicking::panic("assertion failed: __symbols.len() >= 3") + }; + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant2(__symbols); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0; + let __end = __sym2.2; + let __nt = super::__action8::<>(input, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (3, 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) { + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action9::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (1, 3) + } + 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) { + if !(__symbols.len() >= 4) { + ::core::panicking::panic("assertion failed: __symbols.len() >= 4") + }; + let __sym3 = __pop_Variant2(__symbols); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant1(__symbols); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0; + let __end = __sym3.2; + let __nt = + super::__action10::<>(input, __sym0, __sym1, __sym2, __sym3); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (4, 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) { + if !(__symbols.len() >= 4) { + ::core::panicking::panic("assertion failed: __symbols.len() >= 4") + }; + let __sym3 = __pop_Variant2(__symbols); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant1(__symbols); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0; + let __end = __sym3.2; + let __nt = + super::__action11::<>(input, __sym0, __sym1, __sym2, __sym3); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (4, 4) + } + 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) { + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action12::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (1, 4) + } + 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) { + if !(__symbols.len() >= 3) { + ::core::panicking::panic("assertion failed: __symbols.len() >= 3") + }; + let __sym2 = __pop_Variant3(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym2.2; + let __nt = super::__action13::<>(input, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (3, 5) + } + 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) { + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action14::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (1, 5) + } + 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) { + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action17::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (1, 6) + } + 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) { + if !(__symbols.len() >= 3) { + ::core::panicking::panic("assertion failed: __symbols.len() >= 3") + }; + let __sym2 = __pop_Variant3(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0; + let __end = __sym2.2; + let __nt = super::__action23::<>(input, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (3, 7) + } + 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) { + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action24::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (1, 7) + } + 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) { + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action18::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (1, 8) + } + 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) { + if !(__symbols.len() >= 3) { + ::core::panicking::panic("assertion failed: __symbols.len() >= 3") + }; + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant3(__symbols); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0; + let __end = __sym2.2; + let __nt = super::__action19::<>(input, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (3, 8) + } + 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) { + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action20::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (1, 8) + } + 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) { + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action21::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (1, 8) + } + 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) { + if !(__symbols.len() >= 4) { + ::core::panicking::panic("assertion failed: __symbols.len() >= 4") + }; + let __sym3 = __pop_Variant3(__symbols); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant1(__symbols); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0; + let __end = __sym3.2; + let __nt = + super::__action22::<>(input, __sym0, __sym1, __sym2, __sym3); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (4, 8) + } + 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) { + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action25::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (1, 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) { + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action6::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant1(__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) { + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action3::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (1, 11) + } + pub(crate) fn __reduce24<'input>(input: &'input str, + __lookahead_start: Option<&usize>, + __symbols: &mut alloc::vec::Vec<(usize, __Symbol<'input>, usize)>, + _: core::marker::PhantomData<(&'input ())>) -> (usize, usize) { + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action1::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (1, 13) + } + 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) { + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action2::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (1, 14) + } + 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) { + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action5::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (1, 15) + } + 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) { + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action4::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (1, 16) + } + } + pub use self::__parse__Term1::Term1Parser; + #[rustfmt::skip] + #[allow(non_snake_case, non_camel_case_types, unused_mut, + unused_variables, unused_imports, unused_parens, clippy :: all)] + mod __parse__Term2 { + use crate::data::*; + #[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(String), + Variant2(Term), + Variant3(Type), + } + const __ACTION: &[i8] = + &[2, 16, 0, 0, 0, 0, 3, 0, 4, 17, 0, 2, 16, 0, 0, 0, 0, 3, 0, 4, + 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 17, 0, 2, 16, -13, 0, 0, 0, 3, 0, 4, 17, 0, 9, 29, + 0, 0, 0, 0, 0, 10, 0, 17, 30, 2, 16, 0, 0, 0, 0, 3, 0, 4, + 17, 0, 2, 16, 0, 0, 0, 0, 3, 0, 4, 17, 0, 9, 29, 0, 0, 0, 0, + 0, 10, 0, 17, 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 0, 9, 29, + 0, 0, 0, 0, 0, 10, 0, 17, 30, 9, 29, 0, 0, 0, 0, 0, 10, 0, + 17, 30, -7, -7, -7, 0, 0, -7, -7, 0, -7, -7, 0, -10, -10, + -10, 0, 0, -10, -10, 0, -10, -10, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, -5, -5, -5, 0, 0, -5, -5, 0, -5, -5, 0, -2, -2, -2, + -2, -2, -2, -2, 0, -2, -2, 0, -12, -12, -12, 0, 0, -12, -12, + 0, -12, -12, 0, -4, -4, -4, 0, 0, 6, -4, 0, -4, -4, 0, 0, 0, + 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, -3, -3, -3, 0, 0, 6, -3, 0, + -3, -3, 0, -6, -6, -6, 0, 0, -6, -6, 0, -6, -6, 0, -19, -19, + -19, -19, 0, -19, -19, 0, -19, -19, 0, -18, -18, -18, -18, + 0, -18, -18, 0, -18, -18, 0, -11, -11, -11, 0, 0, -11, -11, + 0, -11, -11, 0, -15, -15, -15, 11, 0, -15, -15, 0, -15, -15, + 0, -16, -16, -16, -16, 0, -16, -16, 0, -16, -16, 0, -1, -1, + -1, -1, 0, -1, -1, 0, -1, -1, 0, -9, -9, -9, 0, 0, -9, -9, + 0, -9, -9, 0, -8, -8, -8, 0, 0, -8, -8, 0, -8, -8, 0, 0, 0, + -21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 37, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, -14, -14, -14, 0, 0, + -14, -14, 0, -14, -14, 0, -17, -17, -17, -17, 0, -17, -17, + 0, -17, -17, 0, -20, -20, -20, -20, 0, -20, -20, 0, -20, + -20, 0]; + fn __action(state: i8, integer: usize) -> i8 { + __ACTION[(state as usize) * 11 + integer] + } + const __EOF_ACTION: &[i8] = + &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -7, -10, -25, -5, -2, 0, 0, + 0, 0, 0, 0, -6, 0, 0, 0, 0, 0, 0, -9, -8, 0, 0, 0, 0, 0, 0]; + fn __goto(state: i8, nt: usize) -> i8 { + match nt { + 0 => 24, + 1 => + match state { + 2 => 20, + 3 => 21, + 5 | 8 | 10..=11 => 25, + 9 => 34, + _ => 12, + }, + 2 => 4, + 3 => 13, + 4 => match state { 0 => 14, 6 => 30, 7 => 31, _ => 17, }, + 5 => match state { 4 => 22, _ => 18, }, + 6 => 19, + 7 => match state { 8 => 32, 10 => 35, _ => 26, }, + 8 => match state { 11 => 37, _ => 27, }, + 9 => 33, + _ => 0, + } + } + const __TERMINAL: &[&str] = + &[r###""(""###, r###""()""###, r###"")""###, r###""->""###, + r###"".""###, r###"":""###, r###""\\""###, + r###""forall""###, r###""λ""###, r###"r#"[A-Za-z_]+"#"###, + r###"r#"\\^[A-Za-z_]+"#"###]; + fn __expected_tokens(__state: i8) + -> alloc::vec::Vec { + __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() + } + fn __expected_tokens_from_states<'input>(__states: &[i8], + _: core::marker::PhantomData<(&'input ())>) + -> alloc::vec::Vec { + __TERMINAL.iter().enumerate().filter_map(|(index, terminal)| + { + if __accepts(None, __states, Some(index), + core::marker::PhantomData::<(&())>) { + Some(alloc::string::ToString::to_string(terminal)) + } else { None } + }).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 = Term; + 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, 11 - 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) + } + fn expected_tokens_from_states(&self, states: &[i8]) + -> alloc::vec::Vec { + __expected_tokens_from_states(states, + core::marker::PhantomData::<(&())>) + } + #[inline] + fn uses_error_recovery(&self) -> bool { false } + #[inline] + fn error_recovery_symbol(&self, + recovery: __state_machine::ErrorRecovery) + -> Self::Symbol { + { + ::core::panicking::panic_fmt(format_args!("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 { + __simulate_reduce(action, core::marker::PhantomData::<(&())>) + } + } + fn __token_to_integer<'input>(__token: &Token<'input>, + _: core::marker::PhantomData<(&'input ())>) -> Option { + match *__token { + Token(2, _) if true => Some(0), + Token(3, _) if true => Some(1), + Token(4, _) if true => Some(2), + Token(5, _) if true => Some(3), + Token(6, _) if true => Some(4), + Token(7, _) if true => Some(5), + Token(8, _) if true => Some(6), + Token(9, _) if true => Some(7), + Token(10, _) if true => Some(8), + Token(0, _) if true => Some(9), + Token(1, _) if true => Some(10), + _ => None, + } + } + fn __token_to_symbol<'input>(__token_index: usize, + __token: Token<'input>, + _: core::marker::PhantomData<(&'input ())>) -> __Symbol<'input> { + match __token_index { + 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 => + match __token { + Token(2, __tok0) | Token(3, __tok0) | Token(4, __tok0) | + Token(5, __tok0) | Token(6, __tok0) | Token(7, __tok0) | + Token(8, __tok0) | Token(9, __tok0) | Token(10, __tok0) | + Token(0, __tok0) | Token(1, __tok0) if true => + __Symbol::Variant0(__tok0), + _ => + ::core::panicking::panic("internal error: entered unreachable code"), + }, + _ => + ::core::panicking::panic("internal error: entered unreachable code"), + } + } + fn __simulate_reduce<'input>(__reduce_index: i8, + _: core::marker::PhantomData<(&'input ())>) + -> __state_machine::SimulatedReduce<__StateMachine<'input>> { + match __reduce_index { + 0 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 0, + } + } + 1 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 1, + } + } + 2 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 2, + nonterminal_produced: 2, + } + } + 3 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 2, + } + } + 4 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 3, + } + } + 5 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 3, + nonterminal_produced: 3, + } + } + 6 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 3, + } + } + 7 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 4, + nonterminal_produced: 4, + } + } + 8 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 4, + nonterminal_produced: 4, + } + } + 9 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 4, + } + } + 10 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 3, + nonterminal_produced: 5, + } + } + 11 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 5, + } + } + 12 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 6, + } + } + 13 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 3, + nonterminal_produced: 7, + } + } + 14 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 7, + } + } + 15 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 8, + } + } + 16 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 3, + nonterminal_produced: 8, + } + } + 17 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 8, + } + } + 18 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 8, + } + } + 19 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 4, + nonterminal_produced: 8, + } + } + 20 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 9, + } + } + 21 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 10, + } + } + 22 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 11, + } + } + 23 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 12, + } + } + 24 => __state_machine::SimulatedReduce::Accept, + 25 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 14, + } + } + 26 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 15, + } + } + 27 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 16, + } + } + _ => { + ::core::panicking::panic_fmt(format_args!("invalid reduction index {0}", + __reduce_index)); + } + } + } + pub struct Term2Parser { + builder: __lalrpop_util::lexer::MatcherBuilder, + _priv: (), + } + impl Term2Parser { + pub fn new() -> Term2Parser { + let __builder = super::__intern_token::new_builder(); + Term2Parser { 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) + } + } + fn __accepts<'input>(__error_state: Option, __states: &[i8], + __opt_integer: Option, + _: core::marker::PhantomData<(&'input ())>) -> bool { + let mut __states = __states.to_vec(); + __states.extend(__error_state); + loop { + let mut __states_len = __states.len(); + let __top = __states[__states_len - 1]; + let __action = + match __opt_integer { + None => __EOF_ACTION[__top as usize], + Some(__integer) => __action(__top, __integer), + }; + if __action == 0 { return false; } + if __action > 0 { return true; } + let (__to_pop, __nt) = + match __simulate_reduce(-(__action + 1), + core::marker::PhantomData::<(&())>) { + __state_machine::SimulatedReduce::Reduce { + states_to_pop, nonterminal_produced } => + (states_to_pop, nonterminal_produced), + __state_machine::SimulatedReduce::Accept => return true, + }; + __states_len -= __to_pop; + __states.truncate(__states_len); + let __top = __states[__states_len - 1]; + let __next_state = __goto(__top, __nt); + __states.push(__next_state); + } + } + 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 => { + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action1::<>(input, __sym0); + return Some(Ok(__nt)); + } + 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::<(&())>) + } + _ => { + ::core::panicking::panic_fmt(format_args!("invalid action code {0}", + __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() -> ! { + { + ::core::panicking::panic_fmt(format_args!("symbol type mismatch")); + } + } + fn __pop_Variant1<'input>(__symbols: + &mut alloc::vec::Vec<(usize, __Symbol<'input>, usize)>) + -> (usize, String, usize) { + match __symbols.pop() { + Some((__l, __Symbol::Variant1(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch(), + } + } + fn __pop_Variant2<'input>(__symbols: + &mut alloc::vec::Vec<(usize, __Symbol<'input>, usize)>) + -> (usize, Term, usize) { + match __symbols.pop() { + Some((__l, __Symbol::Variant2(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch(), + } + } + fn __pop_Variant3<'input>(__symbols: + &mut alloc::vec::Vec<(usize, __Symbol<'input>, usize)>) + -> (usize, Type, usize) { + match __symbols.pop() { + Some((__l, __Symbol::Variant3(__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) { + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action26::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant1(__nt), __end)); + (1, 0) + } + pub(crate) fn __reduce1<'input>(input: &'input str, + __lookahead_start: Option<&usize>, + __symbols: &mut alloc::vec::Vec<(usize, __Symbol<'input>, usize)>, + _: core::marker::PhantomData<(&'input ())>) -> (usize, usize) { + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action27::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant1(__nt), __end)); + (1, 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) { + if !(__symbols.len() >= 2) { + ::core::panicking::panic("assertion failed: __symbols.len() >= 2") + }; + let __sym1 = __pop_Variant2(__symbols); + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym1.2; + let __nt = super::__action15::<>(input, __sym0, __sym1); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (2, 2) + } + 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) { + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action16::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (1, 2) + } + pub(crate) fn __reduce4<'input>(input: &'input str, + __lookahead_start: Option<&usize>, + __symbols: &mut alloc::vec::Vec<(usize, __Symbol<'input>, usize)>, + _: core::marker::PhantomData<(&'input ())>) -> (usize, usize) { + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action7::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (1, 3) + } + 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) { + if !(__symbols.len() >= 3) { + ::core::panicking::panic("assertion failed: __symbols.len() >= 3") + }; + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant2(__symbols); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0; + let __end = __sym2.2; + let __nt = super::__action8::<>(input, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (3, 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) { + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action9::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (1, 3) + } + 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) { + if !(__symbols.len() >= 4) { + ::core::panicking::panic("assertion failed: __symbols.len() >= 4") + }; + let __sym3 = __pop_Variant2(__symbols); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant1(__symbols); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0; + let __end = __sym3.2; + let __nt = + super::__action10::<>(input, __sym0, __sym1, __sym2, __sym3); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (4, 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) { + if !(__symbols.len() >= 4) { + ::core::panicking::panic("assertion failed: __symbols.len() >= 4") + }; + let __sym3 = __pop_Variant2(__symbols); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant1(__symbols); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0; + let __end = __sym3.2; + let __nt = + super::__action11::<>(input, __sym0, __sym1, __sym2, __sym3); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (4, 4) + } + 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) { + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action12::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (1, 4) + } + 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) { + if !(__symbols.len() >= 3) { + ::core::panicking::panic("assertion failed: __symbols.len() >= 3") + }; + let __sym2 = __pop_Variant3(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym2.2; + let __nt = super::__action13::<>(input, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (3, 5) + } + 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) { + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action14::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (1, 5) + } + 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) { + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action17::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (1, 6) + } + 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) { + if !(__symbols.len() >= 3) { + ::core::panicking::panic("assertion failed: __symbols.len() >= 3") + }; + let __sym2 = __pop_Variant3(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0; + let __end = __sym2.2; + let __nt = super::__action23::<>(input, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (3, 7) + } + 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) { + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action24::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (1, 7) + } + 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) { + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action18::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (1, 8) + } + 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) { + if !(__symbols.len() >= 3) { + ::core::panicking::panic("assertion failed: __symbols.len() >= 3") + }; + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant3(__symbols); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0; + let __end = __sym2.2; + let __nt = super::__action19::<>(input, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (3, 8) + } + 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) { + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action20::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (1, 8) + } + 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) { + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action21::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (1, 8) + } + 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) { + if !(__symbols.len() >= 4) { + ::core::panicking::panic("assertion failed: __symbols.len() >= 4") + }; + let __sym3 = __pop_Variant3(__symbols); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant1(__symbols); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0; + let __end = __sym3.2; + let __nt = + super::__action22::<>(input, __sym0, __sym1, __sym2, __sym3); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (4, 8) + } + 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) { + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action25::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (1, 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) { + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action6::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant1(__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) { + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action3::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (1, 11) + } + pub(crate) fn __reduce23<'input>(input: &'input str, + __lookahead_start: Option<&usize>, + __symbols: &mut alloc::vec::Vec<(usize, __Symbol<'input>, usize)>, + _: core::marker::PhantomData<(&'input ())>) -> (usize, usize) { + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action0::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (1, 12) + } + pub(crate) fn __reduce25<'input>(input: &'input str, + __lookahead_start: Option<&usize>, + __symbols: &mut alloc::vec::Vec<(usize, __Symbol<'input>, usize)>, + _: core::marker::PhantomData<(&'input ())>) -> (usize, usize) { + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action2::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (1, 14) + } + 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) { + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action5::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (1, 15) + } + 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) { + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action4::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (1, 16) + } + } + pub use self::__parse__Term2::Term2Parser; + #[rustfmt::skip] + #[allow(non_snake_case, non_camel_case_types, unused_mut, + unused_variables, unused_imports, unused_parens, clippy :: all)] + mod __parse__Term4 { + use crate::data::*; + #[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(String), + Variant2(Term), + Variant3(Type), + } + const __ACTION: &[i8] = + &[2, 17, 0, 0, 0, 0, 3, 0, 4, 18, 0, 2, 17, 0, 0, 0, 0, 3, 0, 4, + 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 18, 0, 7, 27, 0, 0, 0, 0, 0, 8, 0, 18, 28, 2, 17, + -13, 0, 0, 0, 3, 0, 4, 18, 0, 7, 27, 0, 0, 0, 0, 0, 8, 0, + 18, 28, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 0, 2, 17, 0, 0, 0, 0, + 3, 0, 4, 18, 0, 2, 17, 0, 0, 0, 0, 3, 0, 4, 18, 0, 7, 27, 0, + 0, 0, 0, 0, 8, 0, 18, 28, 7, 27, 0, 0, 0, 0, 0, 8, 0, 18, + 28, -7, -7, -7, 0, 0, -7, -7, 0, -7, -7, 0, -10, -10, -10, + 0, 0, -10, -10, 0, -10, -10, 0, -12, -12, -12, 0, 0, -12, + -12, 0, -12, -12, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, -5, + -5, -5, 0, 0, -5, -5, 0, -5, -5, 0, -2, -2, -2, -2, -2, -2, + -2, 0, -2, -2, 0, -4, -4, -4, 0, 0, 5, -4, 0, -4, -4, 0, 0, + 0, 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, -19, -19, -19, -19, 0, + -19, -19, 0, -19, -19, 0, -18, -18, -18, -18, 0, -18, -18, + 0, -18, -18, 0, -11, -11, -11, 0, 0, -11, -11, 0, -11, -11, + 0, -15, -15, -15, 11, 0, -15, -15, 0, -15, -15, 0, -16, -16, + -16, -16, 0, -16, -16, 0, -16, -16, 0, -1, -1, -1, -1, 0, + -1, -1, 0, -1, -1, 0, -3, -3, -3, 0, 0, 5, -3, 0, -3, -3, 0, + -6, -6, -6, 0, 0, -6, -6, 0, -6, -6, 0, 0, 0, -21, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 37, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 12, 0, 0, 0, 0, 0, 0, -9, -9, -9, 0, 0, -9, -9, 0, -9, -9, + 0, -8, -8, -8, 0, 0, -8, -8, 0, -8, -8, 0, -14, -14, -14, 0, + 0, -14, -14, 0, -14, -14, 0, -17, -17, -17, -17, 0, -17, + -17, 0, -17, -17, 0, -20, -20, -20, -20, 0, -20, -20, 0, + -20, -20, 0]; + fn __action(state: i8, integer: usize) -> i8 { + __ACTION[(state as usize) * 11 + integer] + } + const __EOF_ACTION: &[i8] = + &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -7, -10, -12, -26, -5, -2, + 0, 0, 0, 0, -19, -18, -11, -15, -16, -1, 0, -6, 0, 0, 0, -9, + -8, -14, -17, -20]; + fn __goto(state: i8, nt: usize) -> i8 { + match nt { + 0 => 22, + 1 => + match state { + 2 => 20, + 3 => 21, + 4 | 6 | 10..=11 => 23, + 7 => 32, + _ => 12, + }, + 2 => 5, + 3 => 13, + 4 => match state { 8 => 33, 9 => 34, _ => 14, }, + 5 => match state { 1 => 18, 5 => 28, _ => 15, }, + 6 => 19, + 7 => match state { 6 => 30, 10 => 35, _ => 24, }, + 8 => match state { 11 => 37, _ => 25, }, + 9 => 31, + _ => 0, + } + } + const __TERMINAL: &[&str] = + &[r###""(""###, r###""()""###, r###"")""###, r###""->""###, + r###"".""###, r###"":""###, r###""\\""###, + r###""forall""###, r###""λ""###, r###"r#"[A-Za-z_]+"#"###, + r###"r#"\\^[A-Za-z_]+"#"###]; + fn __expected_tokens(__state: i8) + -> alloc::vec::Vec { + __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() + } + fn __expected_tokens_from_states<'input>(__states: &[i8], + _: core::marker::PhantomData<(&'input ())>) + -> alloc::vec::Vec { + __TERMINAL.iter().enumerate().filter_map(|(index, terminal)| + { + if __accepts(None, __states, Some(index), + core::marker::PhantomData::<(&())>) { + Some(alloc::string::ToString::to_string(terminal)) + } else { None } + }).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 = Term; + 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, 11 - 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) + } + fn expected_tokens_from_states(&self, states: &[i8]) + -> alloc::vec::Vec { + __expected_tokens_from_states(states, + core::marker::PhantomData::<(&())>) + } + #[inline] + fn uses_error_recovery(&self) -> bool { false } + #[inline] + fn error_recovery_symbol(&self, + recovery: __state_machine::ErrorRecovery) + -> Self::Symbol { + { + ::core::panicking::panic_fmt(format_args!("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 { + __simulate_reduce(action, core::marker::PhantomData::<(&())>) + } + } + fn __token_to_integer<'input>(__token: &Token<'input>, + _: core::marker::PhantomData<(&'input ())>) -> Option { + match *__token { + Token(2, _) if true => Some(0), + Token(3, _) if true => Some(1), + Token(4, _) if true => Some(2), + Token(5, _) if true => Some(3), + Token(6, _) if true => Some(4), + Token(7, _) if true => Some(5), + Token(8, _) if true => Some(6), + Token(9, _) if true => Some(7), + Token(10, _) if true => Some(8), + Token(0, _) if true => Some(9), + Token(1, _) if true => Some(10), + _ => None, + } + } + fn __token_to_symbol<'input>(__token_index: usize, + __token: Token<'input>, + _: core::marker::PhantomData<(&'input ())>) -> __Symbol<'input> { + match __token_index { + 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 => + match __token { + Token(2, __tok0) | Token(3, __tok0) | Token(4, __tok0) | + Token(5, __tok0) | Token(6, __tok0) | Token(7, __tok0) | + Token(8, __tok0) | Token(9, __tok0) | Token(10, __tok0) | + Token(0, __tok0) | Token(1, __tok0) if true => + __Symbol::Variant0(__tok0), + _ => + ::core::panicking::panic("internal error: entered unreachable code"), + }, + _ => + ::core::panicking::panic("internal error: entered unreachable code"), + } + } + fn __simulate_reduce<'input>(__reduce_index: i8, + _: core::marker::PhantomData<(&'input ())>) + -> __state_machine::SimulatedReduce<__StateMachine<'input>> { + match __reduce_index { + 0 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 0, + } + } + 1 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 1, + } + } + 2 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 2, + nonterminal_produced: 2, + } + } + 3 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 2, + } + } + 4 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 3, + } + } + 5 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 3, + nonterminal_produced: 3, + } + } + 6 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 3, + } + } + 7 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 4, + nonterminal_produced: 4, + } + } + 8 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 4, + nonterminal_produced: 4, + } + } + 9 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 4, + } + } + 10 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 3, + nonterminal_produced: 5, + } + } + 11 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 5, + } + } + 12 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 6, + } + } + 13 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 3, + nonterminal_produced: 7, + } + } + 14 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 7, + } + } + 15 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 8, + } + } + 16 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 3, + nonterminal_produced: 8, + } + } + 17 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 8, + } + } + 18 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 8, + } + } + 19 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 4, + nonterminal_produced: 8, + } + } + 20 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 9, + } + } + 21 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 10, + } + } + 22 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 11, + } + } + 23 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 12, + } + } + 24 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 13, + } + } + 25 => __state_machine::SimulatedReduce::Accept, + 26 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 15, + } + } + 27 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 16, + } + } + _ => { + ::core::panicking::panic_fmt(format_args!("invalid reduction index {0}", + __reduce_index)); + } + } + } + pub struct Term4Parser { + builder: __lalrpop_util::lexer::MatcherBuilder, + _priv: (), + } + impl Term4Parser { + pub fn new() -> Term4Parser { + let __builder = super::__intern_token::new_builder(); + Term4Parser { 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) + } + } + fn __accepts<'input>(__error_state: Option, __states: &[i8], + __opt_integer: Option, + _: core::marker::PhantomData<(&'input ())>) -> bool { + let mut __states = __states.to_vec(); + __states.extend(__error_state); + loop { + let mut __states_len = __states.len(); + let __top = __states[__states_len - 1]; + let __action = + match __opt_integer { + None => __EOF_ACTION[__top as usize], + Some(__integer) => __action(__top, __integer), + }; + if __action == 0 { return false; } + if __action > 0 { return true; } + let (__to_pop, __nt) = + match __simulate_reduce(-(__action + 1), + core::marker::PhantomData::<(&())>) { + __state_machine::SimulatedReduce::Reduce { + states_to_pop, nonterminal_produced } => + (states_to_pop, nonterminal_produced), + __state_machine::SimulatedReduce::Accept => return true, + }; + __states_len -= __to_pop; + __states.truncate(__states_len); + let __top = __states[__states_len - 1]; + let __next_state = __goto(__top, __nt); + __states.push(__next_state); + } + } + 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 => { + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action2::<>(input, __sym0); + return Some(Ok(__nt)); + } + 26 => { + __reduce26(input, __lookahead_start, __symbols, + core::marker::PhantomData::<(&())>) + } + 27 => { + __reduce27(input, __lookahead_start, __symbols, + core::marker::PhantomData::<(&())>) + } + _ => { + ::core::panicking::panic_fmt(format_args!("invalid action code {0}", + __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() -> ! { + { + ::core::panicking::panic_fmt(format_args!("symbol type mismatch")); + } + } + fn __pop_Variant1<'input>(__symbols: + &mut alloc::vec::Vec<(usize, __Symbol<'input>, usize)>) + -> (usize, String, usize) { + match __symbols.pop() { + Some((__l, __Symbol::Variant1(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch(), + } + } + fn __pop_Variant2<'input>(__symbols: + &mut alloc::vec::Vec<(usize, __Symbol<'input>, usize)>) + -> (usize, Term, usize) { + match __symbols.pop() { + Some((__l, __Symbol::Variant2(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch(), + } + } + fn __pop_Variant3<'input>(__symbols: + &mut alloc::vec::Vec<(usize, __Symbol<'input>, usize)>) + -> (usize, Type, usize) { + match __symbols.pop() { + Some((__l, __Symbol::Variant3(__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) { + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action26::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant1(__nt), __end)); + (1, 0) + } + pub(crate) fn __reduce1<'input>(input: &'input str, + __lookahead_start: Option<&usize>, + __symbols: &mut alloc::vec::Vec<(usize, __Symbol<'input>, usize)>, + _: core::marker::PhantomData<(&'input ())>) -> (usize, usize) { + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action27::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant1(__nt), __end)); + (1, 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) { + if !(__symbols.len() >= 2) { + ::core::panicking::panic("assertion failed: __symbols.len() >= 2") + }; + let __sym1 = __pop_Variant2(__symbols); + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym1.2; + let __nt = super::__action15::<>(input, __sym0, __sym1); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (2, 2) + } + 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) { + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action16::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (1, 2) + } + pub(crate) fn __reduce4<'input>(input: &'input str, + __lookahead_start: Option<&usize>, + __symbols: &mut alloc::vec::Vec<(usize, __Symbol<'input>, usize)>, + _: core::marker::PhantomData<(&'input ())>) -> (usize, usize) { + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action7::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (1, 3) + } + 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) { + if !(__symbols.len() >= 3) { + ::core::panicking::panic("assertion failed: __symbols.len() >= 3") + }; + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant2(__symbols); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0; + let __end = __sym2.2; + let __nt = super::__action8::<>(input, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (3, 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) { + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action9::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (1, 3) + } + 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) { + if !(__symbols.len() >= 4) { + ::core::panicking::panic("assertion failed: __symbols.len() >= 4") + }; + let __sym3 = __pop_Variant2(__symbols); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant1(__symbols); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0; + let __end = __sym3.2; + let __nt = + super::__action10::<>(input, __sym0, __sym1, __sym2, __sym3); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (4, 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) { + if !(__symbols.len() >= 4) { + ::core::panicking::panic("assertion failed: __symbols.len() >= 4") + }; + let __sym3 = __pop_Variant2(__symbols); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant1(__symbols); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0; + let __end = __sym3.2; + let __nt = + super::__action11::<>(input, __sym0, __sym1, __sym2, __sym3); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (4, 4) + } + 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) { + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action12::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (1, 4) + } + 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) { + if !(__symbols.len() >= 3) { + ::core::panicking::panic("assertion failed: __symbols.len() >= 3") + }; + let __sym2 = __pop_Variant3(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym2.2; + let __nt = super::__action13::<>(input, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (3, 5) + } + 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) { + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action14::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (1, 5) + } + 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) { + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action17::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (1, 6) + } + 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) { + if !(__symbols.len() >= 3) { + ::core::panicking::panic("assertion failed: __symbols.len() >= 3") + }; + let __sym2 = __pop_Variant3(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0; + let __end = __sym2.2; + let __nt = super::__action23::<>(input, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (3, 7) + } + 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) { + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action24::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (1, 7) + } + 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) { + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action18::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (1, 8) + } + 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) { + if !(__symbols.len() >= 3) { + ::core::panicking::panic("assertion failed: __symbols.len() >= 3") + }; + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant3(__symbols); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0; + let __end = __sym2.2; + let __nt = super::__action19::<>(input, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (3, 8) + } + 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) { + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action20::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (1, 8) + } + 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) { + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action21::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (1, 8) + } + 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) { + if !(__symbols.len() >= 4) { + ::core::panicking::panic("assertion failed: __symbols.len() >= 4") + }; + let __sym3 = __pop_Variant3(__symbols); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant1(__symbols); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0; + let __end = __sym3.2; + let __nt = + super::__action22::<>(input, __sym0, __sym1, __sym2, __sym3); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (4, 8) + } + 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) { + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action25::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (1, 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) { + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action6::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant1(__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) { + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action3::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (1, 11) + } + pub(crate) fn __reduce23<'input>(input: &'input str, + __lookahead_start: Option<&usize>, + __symbols: &mut alloc::vec::Vec<(usize, __Symbol<'input>, usize)>, + _: core::marker::PhantomData<(&'input ())>) -> (usize, usize) { + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action0::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (1, 12) + } + 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) { + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action1::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (1, 13) + } + pub(crate) fn __reduce26<'input>(input: &'input str, + __lookahead_start: Option<&usize>, + __symbols: &mut alloc::vec::Vec<(usize, __Symbol<'input>, usize)>, + _: core::marker::PhantomData<(&'input ())>) -> (usize, usize) { + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action5::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (1, 15) + } + 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) { + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action4::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (1, 16) + } + } + pub use self::__parse__Term4::Term4Parser; + #[rustfmt::skip] + #[allow(non_snake_case, non_camel_case_types, unused_mut, + unused_variables, unused_imports, unused_parens, clippy :: all)] + mod __parse__Type { + use crate::data::*; + #[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(String), + Variant2(Term), + Variant3(Type), + } + const __ACTION: &[i8] = + &[2, 10, 0, 0, 0, 0, 0, 3, 0, 11, 12, 2, 10, 0, 0, 0, 0, 0, 3, 0, + 11, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 2, 10, 0, 0, 0, 0, + 0, 3, 0, 11, 12, 2, 10, 0, 0, 0, 0, 0, 3, 0, 11, 12, 0, 0, + -19, -19, 0, 0, 0, 0, 0, 0, 0, 0, 0, -18, -18, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -15, 4, 0, + 0, 0, 0, 0, 0, 0, 0, 0, -16, -16, 0, 0, 0, 0, 0, 0, 0, 0, 0, + -2, -2, -2, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, -21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, -14, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -17, -17, 0, 0, 0, 0, 0, 0, 0, + 0, 0, -20, -20, 0, 0, 0, 0, 0, 0, 0]; + fn __action(state: i8, integer: usize) -> i8 { + __ACTION[(state as usize) * 11 + integer] + } + const __EOF_ACTION: &[i8] = + &[0, 0, 0, 0, 0, -19, -18, -27, -15, -16, -2, -1, 0, 0, 0, -14, + -17, -20]; + fn __goto(state: i8, nt: usize) -> i8 { + match nt { + 0 => 5, + 1 => match state { 2 => 14, _ => 6, }, + 7 => match state { 1 => 12, 3 => 15, _ => 7, }, + 8 => match state { 4 => 17, _ => 8, }, + 9 => 13, + _ => 0, + } + } + const __TERMINAL: &[&str] = + &[r###""(""###, r###""()""###, r###"")""###, r###""->""###, + r###"".""###, r###"":""###, r###""\\""###, + r###""forall""###, r###""λ""###, r###"r#"[A-Za-z_]+"#"###, + r###"r#"\\^[A-Za-z_]+"#"###]; + fn __expected_tokens(__state: i8) + -> alloc::vec::Vec { + __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() + } + fn __expected_tokens_from_states<'input>(__states: &[i8], + _: core::marker::PhantomData<(&'input ())>) + -> alloc::vec::Vec { + __TERMINAL.iter().enumerate().filter_map(|(index, terminal)| + { + if __accepts(None, __states, Some(index), + core::marker::PhantomData::<(&())>) { + Some(alloc::string::ToString::to_string(terminal)) + } else { None } + }).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 = Type; + 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, 11 - 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) + } + fn expected_tokens_from_states(&self, states: &[i8]) + -> alloc::vec::Vec { + __expected_tokens_from_states(states, + core::marker::PhantomData::<(&())>) + } + #[inline] + fn uses_error_recovery(&self) -> bool { false } + #[inline] + fn error_recovery_symbol(&self, + recovery: __state_machine::ErrorRecovery) + -> Self::Symbol { + { + ::core::panicking::panic_fmt(format_args!("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 { + __simulate_reduce(action, core::marker::PhantomData::<(&())>) + } + } + fn __token_to_integer<'input>(__token: &Token<'input>, + _: core::marker::PhantomData<(&'input ())>) -> Option { + match *__token { + Token(2, _) if true => Some(0), + Token(3, _) if true => Some(1), + Token(4, _) if true => Some(2), + Token(5, _) if true => Some(3), + Token(6, _) if true => Some(4), + Token(7, _) if true => Some(5), + Token(8, _) if true => Some(6), + Token(9, _) if true => Some(7), + Token(10, _) if true => Some(8), + Token(0, _) if true => Some(9), + Token(1, _) if true => Some(10), + _ => None, + } + } + fn __token_to_symbol<'input>(__token_index: usize, + __token: Token<'input>, + _: core::marker::PhantomData<(&'input ())>) -> __Symbol<'input> { + match __token_index { + 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 => + match __token { + Token(2, __tok0) | Token(3, __tok0) | Token(4, __tok0) | + Token(5, __tok0) | Token(6, __tok0) | Token(7, __tok0) | + Token(8, __tok0) | Token(9, __tok0) | Token(10, __tok0) | + Token(0, __tok0) | Token(1, __tok0) if true => + __Symbol::Variant0(__tok0), + _ => + ::core::panicking::panic("internal error: entered unreachable code"), + }, + _ => + ::core::panicking::panic("internal error: entered unreachable code"), + } + } + fn __simulate_reduce<'input>(__reduce_index: i8, + _: core::marker::PhantomData<(&'input ())>) + -> __state_machine::SimulatedReduce<__StateMachine<'input>> { + match __reduce_index { + 0 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 0, + } + } + 1 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 1, + } + } + 2 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 2, + nonterminal_produced: 2, + } + } + 3 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 2, + } + } + 4 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 3, + } + } + 5 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 3, + nonterminal_produced: 3, + } + } + 6 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 3, + } + } + 7 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 4, + nonterminal_produced: 4, + } + } + 8 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 4, + nonterminal_produced: 4, + } + } + 9 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 4, + } + } + 10 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 3, + nonterminal_produced: 5, + } + } + 11 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 5, + } + } + 12 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 6, + } + } + 13 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 3, + nonterminal_produced: 7, + } + } + 14 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 7, + } + } + 15 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 8, + } + } + 16 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 3, + nonterminal_produced: 8, + } + } + 17 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 8, + } + } + 18 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 8, + } + } + 19 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 4, + nonterminal_produced: 8, + } + } + 20 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 9, + } + } + 21 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 10, + } + } + 22 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 11, + } + } + 23 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 12, + } + } + 24 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 13, + } + } + 25 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 14, + } + } + 26 => __state_machine::SimulatedReduce::Accept, + 27 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 16, + } + } + _ => { + ::core::panicking::panic_fmt(format_args!("invalid reduction index {0}", + __reduce_index)); + } + } + } + pub struct TypeParser { + builder: __lalrpop_util::lexer::MatcherBuilder, + _priv: (), + } + impl TypeParser { + pub fn new() -> TypeParser { + let __builder = super::__intern_token::new_builder(); + TypeParser { 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) + } + } + fn __accepts<'input>(__error_state: Option, __states: &[i8], + __opt_integer: Option, + _: core::marker::PhantomData<(&'input ())>) -> bool { + let mut __states = __states.to_vec(); + __states.extend(__error_state); + loop { + let mut __states_len = __states.len(); + let __top = __states[__states_len - 1]; + let __action = + match __opt_integer { + None => __EOF_ACTION[__top as usize], + Some(__integer) => __action(__top, __integer), + }; + if __action == 0 { return false; } + if __action > 0 { return true; } + let (__to_pop, __nt) = + match __simulate_reduce(-(__action + 1), + core::marker::PhantomData::<(&())>) { + __state_machine::SimulatedReduce::Reduce { + states_to_pop, nonterminal_produced } => + (states_to_pop, nonterminal_produced), + __state_machine::SimulatedReduce::Accept => return true, + }; + __states_len -= __to_pop; + __states.truncate(__states_len); + let __top = __states[__states_len - 1]; + let __next_state = __goto(__top, __nt); + __states.push(__next_state); + } + } + 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 => { + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action5::<>(input, __sym0); + return Some(Ok(__nt)); + } + 27 => { + __reduce27(input, __lookahead_start, __symbols, + core::marker::PhantomData::<(&())>) + } + _ => { + ::core::panicking::panic_fmt(format_args!("invalid action code {0}", + __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() -> ! { + { + ::core::panicking::panic_fmt(format_args!("symbol type mismatch")); + } + } + fn __pop_Variant1<'input>(__symbols: + &mut alloc::vec::Vec<(usize, __Symbol<'input>, usize)>) + -> (usize, String, usize) { + match __symbols.pop() { + Some((__l, __Symbol::Variant1(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch(), + } + } + fn __pop_Variant2<'input>(__symbols: + &mut alloc::vec::Vec<(usize, __Symbol<'input>, usize)>) + -> (usize, Term, usize) { + match __symbols.pop() { + Some((__l, __Symbol::Variant2(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch(), + } + } + fn __pop_Variant3<'input>(__symbols: + &mut alloc::vec::Vec<(usize, __Symbol<'input>, usize)>) + -> (usize, Type, usize) { + match __symbols.pop() { + Some((__l, __Symbol::Variant3(__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) { + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action26::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant1(__nt), __end)); + (1, 0) + } + pub(crate) fn __reduce1<'input>(input: &'input str, + __lookahead_start: Option<&usize>, + __symbols: &mut alloc::vec::Vec<(usize, __Symbol<'input>, usize)>, + _: core::marker::PhantomData<(&'input ())>) -> (usize, usize) { + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action27::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant1(__nt), __end)); + (1, 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) { + if !(__symbols.len() >= 2) { + ::core::panicking::panic("assertion failed: __symbols.len() >= 2") + }; + let __sym1 = __pop_Variant2(__symbols); + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym1.2; + let __nt = super::__action15::<>(input, __sym0, __sym1); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (2, 2) + } + 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) { + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action16::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (1, 2) + } + pub(crate) fn __reduce4<'input>(input: &'input str, + __lookahead_start: Option<&usize>, + __symbols: &mut alloc::vec::Vec<(usize, __Symbol<'input>, usize)>, + _: core::marker::PhantomData<(&'input ())>) -> (usize, usize) { + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action7::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (1, 3) + } + 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) { + if !(__symbols.len() >= 3) { + ::core::panicking::panic("assertion failed: __symbols.len() >= 3") + }; + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant2(__symbols); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0; + let __end = __sym2.2; + let __nt = super::__action8::<>(input, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (3, 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) { + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action9::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (1, 3) + } + 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) { + if !(__symbols.len() >= 4) { + ::core::panicking::panic("assertion failed: __symbols.len() >= 4") + }; + let __sym3 = __pop_Variant2(__symbols); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant1(__symbols); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0; + let __end = __sym3.2; + let __nt = + super::__action10::<>(input, __sym0, __sym1, __sym2, __sym3); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (4, 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) { + if !(__symbols.len() >= 4) { + ::core::panicking::panic("assertion failed: __symbols.len() >= 4") + }; + let __sym3 = __pop_Variant2(__symbols); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant1(__symbols); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0; + let __end = __sym3.2; + let __nt = + super::__action11::<>(input, __sym0, __sym1, __sym2, __sym3); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (4, 4) + } + 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) { + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action12::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (1, 4) + } + 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) { + if !(__symbols.len() >= 3) { + ::core::panicking::panic("assertion failed: __symbols.len() >= 3") + }; + let __sym2 = __pop_Variant3(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym2.2; + let __nt = super::__action13::<>(input, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (3, 5) + } + 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) { + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action14::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (1, 5) + } + 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) { + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action17::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (1, 6) + } + 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) { + if !(__symbols.len() >= 3) { + ::core::panicking::panic("assertion failed: __symbols.len() >= 3") + }; + let __sym2 = __pop_Variant3(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0; + let __end = __sym2.2; + let __nt = super::__action23::<>(input, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (3, 7) + } + 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) { + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action24::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (1, 7) + } + 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) { + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action18::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (1, 8) + } + 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) { + if !(__symbols.len() >= 3) { + ::core::panicking::panic("assertion failed: __symbols.len() >= 3") + }; + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant3(__symbols); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0; + let __end = __sym2.2; + let __nt = super::__action19::<>(input, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (3, 8) + } + 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) { + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action20::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (1, 8) + } + 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) { + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action21::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (1, 8) + } + 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) { + if !(__symbols.len() >= 4) { + ::core::panicking::panic("assertion failed: __symbols.len() >= 4") + }; + let __sym3 = __pop_Variant3(__symbols); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant1(__symbols); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0; + let __end = __sym3.2; + let __nt = + super::__action22::<>(input, __sym0, __sym1, __sym2, __sym3); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (4, 8) + } + 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) { + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action25::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (1, 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) { + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action6::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant1(__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) { + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action3::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (1, 11) + } + pub(crate) fn __reduce23<'input>(input: &'input str, + __lookahead_start: Option<&usize>, + __symbols: &mut alloc::vec::Vec<(usize, __Symbol<'input>, usize)>, + _: core::marker::PhantomData<(&'input ())>) -> (usize, usize) { + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action0::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (1, 12) + } + 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) { + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action1::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (1, 13) + } + 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) { + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action2::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (1, 14) + } + 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) { + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action4::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (1, 16) + } + } + pub use self::__parse__Type::TypeParser; + #[rustfmt::skip] + #[allow(non_snake_case, non_camel_case_types, unused_mut, + unused_variables, unused_imports, unused_parens, clippy :: all)] + mod __parse__Type0 { + use crate::data::*; + #[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(String), + Variant2(Term), + Variant3(Type), + } + const __ACTION: &[i8] = + &[2, 9, 0, 0, 0, 0, 0, 3, 0, 10, 11, 2, 9, 0, 0, 0, 0, 0, 3, 0, + 10, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 2, 9, 0, 0, 0, 0, + 0, 3, 0, 10, 11, 2, 9, 0, 0, 0, 0, 0, 3, 0, 10, 11, 0, 0, + -19, -19, 0, 0, 0, 0, 0, 0, 0, 0, 0, -18, -18, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -16, -16, 0, + 0, 0, 0, 0, 0, 0, 0, 0, -2, -2, -2, 0, 0, 0, 0, 0, 0, 0, 0, + -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, -21, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, -15, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, -17, -17, + 0, 0, 0, 0, 0, 0, 0, 0, 0, -14, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, -20, -20, 0, 0, 0, 0, 0, 0, 0]; + fn __action(state: i8, integer: usize) -> i8 { + __ACTION[(state as usize) * 11 + integer] + } + const __EOF_ACTION: &[i8] = + &[0, 0, 0, 0, 0, -19, -18, -28, -16, -2, -1, 0, 0, 0, 0, -17, 0, + -20]; + fn __goto(state: i8, nt: usize) -> i8 { + match nt { + 0 => 5, + 1 => match state { 2 => 14, _ => 6, }, + 7 => match state { 3 => 16, _ => 11, }, + 8 => match state { 0 => 7, 4 => 17, _ => 12, }, + 9 => 13, + _ => 0, + } + } + const __TERMINAL: &[&str] = + &[r###""(""###, r###""()""###, r###"")""###, r###""->""###, + r###"".""###, r###"":""###, r###""\\""###, + r###""forall""###, r###""λ""###, r###"r#"[A-Za-z_]+"#"###, + r###"r#"\\^[A-Za-z_]+"#"###]; + fn __expected_tokens(__state: i8) + -> alloc::vec::Vec { + __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() + } + fn __expected_tokens_from_states<'input>(__states: &[i8], + _: core::marker::PhantomData<(&'input ())>) + -> alloc::vec::Vec { + __TERMINAL.iter().enumerate().filter_map(|(index, terminal)| + { + if __accepts(None, __states, Some(index), + core::marker::PhantomData::<(&())>) { + Some(alloc::string::ToString::to_string(terminal)) + } else { None } + }).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 = Type; + 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, 11 - 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) + } + fn expected_tokens_from_states(&self, states: &[i8]) + -> alloc::vec::Vec { + __expected_tokens_from_states(states, + core::marker::PhantomData::<(&())>) + } + #[inline] + fn uses_error_recovery(&self) -> bool { false } + #[inline] + fn error_recovery_symbol(&self, + recovery: __state_machine::ErrorRecovery) + -> Self::Symbol { + { + ::core::panicking::panic_fmt(format_args!("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 { + __simulate_reduce(action, core::marker::PhantomData::<(&())>) + } + } + fn __token_to_integer<'input>(__token: &Token<'input>, + _: core::marker::PhantomData<(&'input ())>) -> Option { + match *__token { + Token(2, _) if true => Some(0), + Token(3, _) if true => Some(1), + Token(4, _) if true => Some(2), + Token(5, _) if true => Some(3), + Token(6, _) if true => Some(4), + Token(7, _) if true => Some(5), + Token(8, _) if true => Some(6), + Token(9, _) if true => Some(7), + Token(10, _) if true => Some(8), + Token(0, _) if true => Some(9), + Token(1, _) if true => Some(10), + _ => None, + } + } + fn __token_to_symbol<'input>(__token_index: usize, + __token: Token<'input>, + _: core::marker::PhantomData<(&'input ())>) -> __Symbol<'input> { + match __token_index { + 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 => + match __token { + Token(2, __tok0) | Token(3, __tok0) | Token(4, __tok0) | + Token(5, __tok0) | Token(6, __tok0) | Token(7, __tok0) | + Token(8, __tok0) | Token(9, __tok0) | Token(10, __tok0) | + Token(0, __tok0) | Token(1, __tok0) if true => + __Symbol::Variant0(__tok0), + _ => + ::core::panicking::panic("internal error: entered unreachable code"), + }, + _ => + ::core::panicking::panic("internal error: entered unreachable code"), + } + } + fn __simulate_reduce<'input>(__reduce_index: i8, + _: core::marker::PhantomData<(&'input ())>) + -> __state_machine::SimulatedReduce<__StateMachine<'input>> { + match __reduce_index { + 0 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 0, + } + } + 1 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 1, + } + } + 2 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 2, + nonterminal_produced: 2, + } + } + 3 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 2, + } + } + 4 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 3, + } + } + 5 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 3, + nonterminal_produced: 3, + } + } + 6 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 3, + } + } + 7 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 4, + nonterminal_produced: 4, + } + } + 8 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 4, + nonterminal_produced: 4, + } + } + 9 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 4, + } + } + 10 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 3, + nonterminal_produced: 5, + } + } + 11 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 5, + } + } + 12 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 6, + } + } + 13 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 3, + nonterminal_produced: 7, + } + } + 14 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 7, + } + } + 15 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 8, + } + } + 16 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 3, + nonterminal_produced: 8, + } + } + 17 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 8, + } + } + 18 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 8, + } + } + 19 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 4, + nonterminal_produced: 8, + } + } + 20 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 9, + } + } + 21 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 10, + } + } + 22 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 11, + } + } + 23 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 12, + } + } + 24 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 13, + } + } + 25 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 14, + } + } + 26 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 15, + } + } + 27 => __state_machine::SimulatedReduce::Accept, + _ => { + ::core::panicking::panic_fmt(format_args!("invalid reduction index {0}", + __reduce_index)); + } + } + } + pub struct Type0Parser { + builder: __lalrpop_util::lexer::MatcherBuilder, + _priv: (), + } + impl Type0Parser { + pub fn new() -> Type0Parser { + let __builder = super::__intern_token::new_builder(); + Type0Parser { 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) + } + } + fn __accepts<'input>(__error_state: Option, __states: &[i8], + __opt_integer: Option, + _: core::marker::PhantomData<(&'input ())>) -> bool { + let mut __states = __states.to_vec(); + __states.extend(__error_state); + loop { + let mut __states_len = __states.len(); + let __top = __states[__states_len - 1]; + let __action = + match __opt_integer { + None => __EOF_ACTION[__top as usize], + Some(__integer) => __action(__top, __integer), + }; + if __action == 0 { return false; } + if __action > 0 { return true; } + let (__to_pop, __nt) = + match __simulate_reduce(-(__action + 1), + core::marker::PhantomData::<(&())>) { + __state_machine::SimulatedReduce::Reduce { + states_to_pop, nonterminal_produced } => + (states_to_pop, nonterminal_produced), + __state_machine::SimulatedReduce::Accept => return true, + }; + __states_len -= __to_pop; + __states.truncate(__states_len); + let __top = __states[__states_len - 1]; + let __next_state = __goto(__top, __nt); + __states.push(__next_state); + } + } + 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 => { + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action4::<>(input, __sym0); + return Some(Ok(__nt)); + } + _ => { + ::core::panicking::panic_fmt(format_args!("invalid action code {0}", + __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() -> ! { + { + ::core::panicking::panic_fmt(format_args!("symbol type mismatch")); + } + } + fn __pop_Variant1<'input>(__symbols: + &mut alloc::vec::Vec<(usize, __Symbol<'input>, usize)>) + -> (usize, String, usize) { + match __symbols.pop() { + Some((__l, __Symbol::Variant1(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch(), + } + } + fn __pop_Variant2<'input>(__symbols: + &mut alloc::vec::Vec<(usize, __Symbol<'input>, usize)>) + -> (usize, Term, usize) { + match __symbols.pop() { + Some((__l, __Symbol::Variant2(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch(), + } + } + fn __pop_Variant3<'input>(__symbols: + &mut alloc::vec::Vec<(usize, __Symbol<'input>, usize)>) + -> (usize, Type, usize) { + match __symbols.pop() { + Some((__l, __Symbol::Variant3(__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) { + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action26::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant1(__nt), __end)); + (1, 0) + } + pub(crate) fn __reduce1<'input>(input: &'input str, + __lookahead_start: Option<&usize>, + __symbols: &mut alloc::vec::Vec<(usize, __Symbol<'input>, usize)>, + _: core::marker::PhantomData<(&'input ())>) -> (usize, usize) { + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action27::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant1(__nt), __end)); + (1, 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) { + if !(__symbols.len() >= 2) { + ::core::panicking::panic("assertion failed: __symbols.len() >= 2") + }; + let __sym1 = __pop_Variant2(__symbols); + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym1.2; + let __nt = super::__action15::<>(input, __sym0, __sym1); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (2, 2) + } + 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) { + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action16::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (1, 2) + } + pub(crate) fn __reduce4<'input>(input: &'input str, + __lookahead_start: Option<&usize>, + __symbols: &mut alloc::vec::Vec<(usize, __Symbol<'input>, usize)>, + _: core::marker::PhantomData<(&'input ())>) -> (usize, usize) { + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action7::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (1, 3) + } + 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) { + if !(__symbols.len() >= 3) { + ::core::panicking::panic("assertion failed: __symbols.len() >= 3") + }; + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant2(__symbols); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0; + let __end = __sym2.2; + let __nt = super::__action8::<>(input, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (3, 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) { + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action9::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (1, 3) + } + 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) { + if !(__symbols.len() >= 4) { + ::core::panicking::panic("assertion failed: __symbols.len() >= 4") + }; + let __sym3 = __pop_Variant2(__symbols); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant1(__symbols); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0; + let __end = __sym3.2; + let __nt = + super::__action10::<>(input, __sym0, __sym1, __sym2, __sym3); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (4, 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) { + if !(__symbols.len() >= 4) { + ::core::panicking::panic("assertion failed: __symbols.len() >= 4") + }; + let __sym3 = __pop_Variant2(__symbols); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant1(__symbols); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0; + let __end = __sym3.2; + let __nt = + super::__action11::<>(input, __sym0, __sym1, __sym2, __sym3); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (4, 4) + } + 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) { + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action12::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (1, 4) + } + 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) { + if !(__symbols.len() >= 3) { + ::core::panicking::panic("assertion failed: __symbols.len() >= 3") + }; + let __sym2 = __pop_Variant3(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym2.2; + let __nt = super::__action13::<>(input, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (3, 5) + } + 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) { + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action14::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (1, 5) + } + 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) { + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action17::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (1, 6) + } + 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) { + if !(__symbols.len() >= 3) { + ::core::panicking::panic("assertion failed: __symbols.len() >= 3") + }; + let __sym2 = __pop_Variant3(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0; + let __end = __sym2.2; + let __nt = super::__action23::<>(input, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (3, 7) + } + 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) { + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action24::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (1, 7) + } + 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) { + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action18::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (1, 8) + } + 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) { + if !(__symbols.len() >= 3) { + ::core::panicking::panic("assertion failed: __symbols.len() >= 3") + }; + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant3(__symbols); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0; + let __end = __sym2.2; + let __nt = super::__action19::<>(input, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (3, 8) + } + 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) { + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action20::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (1, 8) + } + 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) { + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action21::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (1, 8) + } + 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) { + if !(__symbols.len() >= 4) { + ::core::panicking::panic("assertion failed: __symbols.len() >= 4") + }; + let __sym3 = __pop_Variant3(__symbols); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant1(__symbols); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0; + let __end = __sym3.2; + let __nt = + super::__action22::<>(input, __sym0, __sym1, __sym2, __sym3); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (4, 8) + } + 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) { + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action25::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (1, 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) { + let __sym0 = __pop_Variant1(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action6::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant1(__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) { + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action3::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (1, 11) + } + pub(crate) fn __reduce23<'input>(input: &'input str, + __lookahead_start: Option<&usize>, + __symbols: &mut alloc::vec::Vec<(usize, __Symbol<'input>, usize)>, + _: core::marker::PhantomData<(&'input ())>) -> (usize, usize) { + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action0::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (1, 12) + } + 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) { + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action1::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (1, 13) + } + 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) { + let __sym0 = __pop_Variant2(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action2::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant2(__nt), __end)); + (1, 14) + } + 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) { + let __sym0 = __pop_Variant3(__symbols); + let __start = __sym0.0; + let __end = __sym0.2; + let __nt = super::__action5::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (1, 15) + } + } + pub use self::__parse__Type0::Type0Parser; + mod __intern_token { + #![allow(unused_imports)] + use crate::data::*; + #[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)] = + &[("^([A-Z_a-z]+)", false), ("^((?:\\^[A-Z_a-z]+))", false), + ("^(\\()", false), ("^((?:\\(\\)))", false), + ("^(\\))", false), ("^((?:\\->))", false), + ("^(\\.)", false), ("^(:)", false), ("^(\\\\)", false), + ("^((?:forall))", 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)] + #[allow(clippy :: too_many_arguments)] + fn __action0<'input>(input: &'input str, + (_, __0, _): (usize, Term, usize)) -> Term { + __0 + } + #[allow(unused_variables)] + #[allow(clippy :: too_many_arguments)] + fn __action1<'input>(input: &'input str, + (_, __0, _): (usize, Term, usize)) -> Term { + __0 + } + #[allow(unused_variables)] + #[allow(clippy :: too_many_arguments)] + fn __action2<'input>(input: &'input str, + (_, __0, _): (usize, Term, usize)) -> Term { + __0 + } + #[allow(unused_variables)] + #[allow(clippy :: too_many_arguments)] + fn __action3<'input>(input: &'input str, + (_, __0, _): (usize, Term, usize)) -> Term { + __0 + } + #[allow(unused_variables)] + #[allow(clippy :: too_many_arguments)] + fn __action4<'input>(input: &'input str, + (_, __0, _): (usize, Type, usize)) -> Type { + __0 + } + #[allow(unused_variables)] + #[allow(clippy :: too_many_arguments)] + fn __action5<'input>(input: &'input str, + (_, __0, _): (usize, Type, usize)) -> Type { + __0 + } + #[allow(unused_variables)] + #[allow(clippy :: too_many_arguments)] + fn __action6<'input>(input: &'input str, + (_, __0, _): (usize, String, usize)) -> String { + __0 + } + #[allow(unused_variables)] + #[allow(clippy :: too_many_arguments)] + fn __action7<'input>(input: &'input str, + (_, __0, _): (usize, &'input str, usize)) -> Term { + Term::Unit + } + #[allow(unused_variables)] + #[allow(clippy :: too_many_arguments)] + fn __action8<'input>(input: &'input str, + (_, _, _): (usize, &'input str, usize), + (_, term, _): (usize, Term, usize), + (_, _, _): (usize, &'input str, usize)) -> Term { + term + } + #[allow(unused_variables)] + #[allow(clippy :: too_many_arguments)] + fn __action9<'input>(input: &'input str, + (_, __0, _): (usize, String, usize)) -> Term { + Term::Var(__0) + } + #[allow(unused_variables)] + #[allow(clippy :: too_many_arguments)] + fn __action10<'input>(input: &'input str, + (_, _, _): (usize, &'input str, usize), + (_, name, _): (usize, String, usize), + (_, _, _): (usize, &'input str, usize), + (_, term, _): (usize, Term, usize)) -> Term { + Term::Lam(name, Box::new(term)) + } + #[allow(unused_variables)] + #[allow(clippy :: too_many_arguments)] + fn __action11<'input>(input: &'input str, + (_, _, _): (usize, &'input str, usize), + (_, name, _): (usize, String, usize), + (_, _, _): (usize, &'input str, usize), + (_, term, _): (usize, Term, usize)) -> Term { + Term::Lam(name, Box::new(term)) + } + #[allow(unused_variables)] + #[allow(clippy :: too_many_arguments)] + fn __action12<'input>(input: &'input str, + (_, __0, _): (usize, Term, usize)) -> Term { + __0 + } + #[allow(unused_variables)] + #[allow(clippy :: too_many_arguments)] + fn __action13<'input>(input: &'input str, + (_, term, _): (usize, Term, usize), + (_, _, _): (usize, &'input str, usize), + (_, ty, _): (usize, Type, usize)) -> Term { + Term::Annot(Box::new(term), ty) + } + #[allow(unused_variables)] + #[allow(clippy :: too_many_arguments)] + fn __action14<'input>(input: &'input str, + (_, __0, _): (usize, Term, usize)) -> Term { + __0 + } + #[allow(unused_variables)] + #[allow(clippy :: too_many_arguments)] + fn __action15<'input>(input: &'input str, + (_, func, _): (usize, Term, usize), (_, arg, _): (usize, Term, usize)) + -> Term { + Term::App(Box::new(func), Box::new(arg)) + } + #[allow(unused_variables)] + #[allow(clippy :: too_many_arguments)] + fn __action16<'input>(input: &'input str, + (_, __0, _): (usize, Term, usize)) -> Term { + __0 + } + #[allow(unused_variables)] + #[allow(clippy :: too_many_arguments)] + fn __action17<'input>(input: &'input str, + (_, __0, _): (usize, Term, usize)) -> Term { + __0 + } + #[allow(unused_variables)] + #[allow(clippy :: too_many_arguments)] + fn __action18<'input>(input: &'input str, + (_, __0, _): (usize, &'input str, usize)) -> Type { + Type::Unit + } + #[allow(unused_variables)] + #[allow(clippy :: too_many_arguments)] + fn __action19<'input>(input: &'input str, + (_, _, _): (usize, &'input str, usize), + (_, ty, _): (usize, Type, usize), + (_, _, _): (usize, &'input str, usize)) -> Type { + ty + } + #[allow(unused_variables)] + #[allow(clippy :: too_many_arguments)] + fn __action20<'input>(input: &'input str, + (_, __0, _): (usize, String, usize)) -> Type { + Type::Var(__0) + } + #[allow(unused_variables)] + #[allow(clippy :: too_many_arguments)] + fn __action21<'input>(input: &'input str, + (_, __0, _): (usize, String, usize)) -> Type { + Type::Existential(__0) + } + #[allow(unused_variables)] + #[allow(clippy :: too_many_arguments)] + fn __action22<'input>(input: &'input str, + (_, _, _): (usize, &'input str, usize), + (_, name, _): (usize, String, usize), + (_, _, _): (usize, &'input str, usize), + (_, ty, _): (usize, Type, usize)) -> Type { + Type::Polytype(name, Box::new(ty)) + } + #[allow(unused_variables)] + #[allow(clippy :: too_many_arguments)] + fn __action23<'input>(input: &'input str, (_, a, _): (usize, Type, usize), + (_, _, _): (usize, &'input str, usize), + (_, b, _): (usize, Type, usize)) -> Type { + Type::Arrow(Box::new(a), Box::new(b)) + } + #[allow(unused_variables)] + #[allow(clippy :: too_many_arguments)] + fn __action24<'input>(input: &'input str, + (_, __0, _): (usize, Type, usize)) -> Type { + __0 + } + #[allow(unused_variables)] + #[allow(clippy :: too_many_arguments)] + fn __action25<'input>(input: &'input str, + (_, __0, _): (usize, Type, usize)) -> Type { + __0 + } + #[allow(unused_variables)] + #[allow(clippy :: too_many_arguments)] + fn __action26<'input>(input: &'input str, + (_, __0, _): (usize, &'input str, usize)) -> String { + __0.to_string() + } + #[allow(unused_variables)] + #[allow(clippy :: too_many_arguments)] + fn __action27<'input>(input: &'input str, + (_, __0, _): (usize, &'input str, usize)) -> String { + __0.to_string() + } + #[allow(clippy :: type_complexity)] + 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 }), + } + } + } +} +const DEPTH: ::std::thread::LocalKey<::std::cell::Cell> = + { + #[inline] + fn __init() -> ::std::cell::Cell { ::std::cell::Cell::new(0) } + #[inline] + unsafe fn __getit(init: + ::std::option::Option<&mut ::std::option::Option<::std::cell::Cell>>) + -> ::std::option::Option<&'static ::std::cell::Cell> { + #[thread_local] + static __KEY: + ::std::thread::local_impl::Key<::std::cell::Cell> = + ::std::thread::local_impl::Key::<::std::cell::Cell>::new(); + + #[allow(unused_unsafe)] + unsafe { + __KEY.get(move || + { + if let ::std::option::Option::Some(init) = init { + if let ::std::option::Option::Some(value) = init.take() { + return value; + } else if true { + { + ::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}", + format_args!("missing default value"))); + }; + } + } + __init() + }) + } + } + unsafe { ::std::thread::LocalKey::new(__getit) } + };