8759 lines
390 KiB
Rust
8759 lines
390 KiB
Rust
#![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<Type> {
|
||
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<Context> {
|
||
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<Context> {
|
||
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<Context> {
|
||
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<Context> {
|
||
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<Term>),
|
||
App(Box<Term>, Box<Term>),
|
||
Annot(Box<Term>, 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<Type>),
|
||
Arrow(Box<Type>, Box<Type>),
|
||
}
|
||
#[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<Monotype> {
|
||
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<String>;
|
||
}
|
||
}
|
||
#[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<FreeVar> {
|
||
fn free_vars_with_context(ctx: &Context, ty: &Type)
|
||
-> HashSet<FreeVar> {
|
||
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<Monotype>, Box<Monotype>),
|
||
}
|
||
#[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<ContextEntry>);
|
||
#[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<ContextEntry>) -> 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<str>)
|
||
-> 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<str>) -> 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<str>)
|
||
-> Option<(usize, Option<Monotype>)> {
|
||
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<str>) -> bool {
|
||
self.lookup_existential(name).is_some()
|
||
}
|
||
/// Returns a list of names of unsolved existentials
|
||
pub fn unsolved_existentials(&self) -> HashSet<String> {
|
||
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<P>(&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<Type> {
|
||
{
|
||
::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<Context> {
|
||
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<Context> {
|
||
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<Context> {
|
||
{
|
||
::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<Term>),
|
||
|
||
/// Lambda application.
|
||
App(Box<Term>, Box<Term>),
|
||
|
||
/// Type annotation
|
||
Annot(Box<Term>, 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<Type>),
|
||
Arrow(Box<Type>, Box<Type>),
|
||
}
|
||
#[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<Monotype> {
|
||
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<Monotype>, Box<Monotype>),
|
||
}
|
||
#[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<ContextEntry>,
|
||
len: Rc<RefCell<usize>>,
|
||
}
|
||
#[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<Option<Monotype>> {
|
||
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<Option<Monotype>>
|
||
{
|
||
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<Type> {
|
||
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<Type>
|
||
{
|
||
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<ContextIndex> {
|
||
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<ContextIndex>
|
||
{
|
||
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<RefCell<usize>>,
|
||
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<Rc<RefCell<usize>>>;
|
||
let _: ::core::cmp::AssertParamIsEq<usize>;
|
||
}
|
||
}
|
||
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<DashMap<&'static str, usize>> =
|
||
{
|
||
#[inline]
|
||
fn __init() -> DashMap<&'static str, usize> { DashMap::new() }
|
||
#[inline]
|
||
unsafe fn __getit(init:
|
||
::std::option::Option<&mut ::std::option::Option<DashMap<&'static str,
|
||
usize>>>)
|
||
->
|
||
::std::option::Option<&'static DashMap<&'static str,
|
||
usize>> {
|
||
#[thread_local]
|
||
static __KEY:
|
||
::std::thread::local_impl::Key<DashMap<&'static str, usize>>
|
||
=
|
||
::std::thread::local_impl::Key::<DashMap<&'static str,
|
||
usize>>::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<alloc::string::String> {
|
||
__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<alloc::string::String> {
|
||
__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<usize> {
|
||
__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<alloc::string::String> {
|
||
__expected_tokens(state)
|
||
}
|
||
fn expected_tokens_from_states(&self, states: &[i8])
|
||
-> alloc::vec::Vec<alloc::string::String> {
|
||
__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>)
|
||
-> 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<i8>,
|
||
symbols:
|
||
&mut alloc::vec::Vec<__state_machine::SymbolTriple<Self>>)
|
||
-> Option<__state_machine::ParseResult<Self>> {
|
||
__reduce(self.input, action, start_location, states, symbols,
|
||
core::marker::PhantomData::<(&())>)
|
||
}
|
||
fn simulate_reduce(&self, action: i8)
|
||
-> __state_machine::SimulatedReduce<Self> {
|
||
__simulate_reduce(action, core::marker::PhantomData::<(&())>)
|
||
}
|
||
}
|
||
fn __token_to_integer<'input>(__token: &Token<'input>,
|
||
_: core::marker::PhantomData<(&'input ())>) -> Option<usize> {
|
||
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<String,
|
||
__lalrpop_util::ParseError<usize, Token<'input>,
|
||
&'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<i8>, __states: &[i8],
|
||
__opt_integer: Option<usize>,
|
||
_: 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<i8>,
|
||
__symbols: &mut alloc::vec::Vec<(usize, __Symbol<'input>, usize)>,
|
||
_: core::marker::PhantomData<(&'input ())>)
|
||
->
|
||
Option<Result<String,
|
||
__lalrpop_util::ParseError<usize, Token<'input>,
|
||
&'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<alloc::string::String> {
|
||
__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<alloc::string::String> {
|
||
__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<usize> {
|
||
__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<alloc::string::String> {
|
||
__expected_tokens(state)
|
||
}
|
||
fn expected_tokens_from_states(&self, states: &[i8])
|
||
-> alloc::vec::Vec<alloc::string::String> {
|
||
__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>)
|
||
-> 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<i8>,
|
||
symbols:
|
||
&mut alloc::vec::Vec<__state_machine::SymbolTriple<Self>>)
|
||
-> Option<__state_machine::ParseResult<Self>> {
|
||
__reduce(self.input, action, start_location, states, symbols,
|
||
core::marker::PhantomData::<(&())>)
|
||
}
|
||
fn simulate_reduce(&self, action: i8)
|
||
-> __state_machine::SimulatedReduce<Self> {
|
||
__simulate_reduce(action, core::marker::PhantomData::<(&())>)
|
||
}
|
||
}
|
||
fn __token_to_integer<'input>(__token: &Token<'input>,
|
||
_: core::marker::PhantomData<(&'input ())>) -> Option<usize> {
|
||
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<Term,
|
||
__lalrpop_util::ParseError<usize, Token<'input>,
|
||
&'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<i8>, __states: &[i8],
|
||
__opt_integer: Option<usize>,
|
||
_: 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<i8>,
|
||
__symbols: &mut alloc::vec::Vec<(usize, __Symbol<'input>, usize)>,
|
||
_: core::marker::PhantomData<(&'input ())>)
|
||
->
|
||
Option<Result<Term,
|
||
__lalrpop_util::ParseError<usize, Token<'input>,
|
||
&'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<alloc::string::String> {
|
||
__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<alloc::string::String> {
|
||
__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<usize> {
|
||
__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<alloc::string::String> {
|
||
__expected_tokens(state)
|
||
}
|
||
fn expected_tokens_from_states(&self, states: &[i8])
|
||
-> alloc::vec::Vec<alloc::string::String> {
|
||
__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>)
|
||
-> 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<i8>,
|
||
symbols:
|
||
&mut alloc::vec::Vec<__state_machine::SymbolTriple<Self>>)
|
||
-> Option<__state_machine::ParseResult<Self>> {
|
||
__reduce(self.input, action, start_location, states, symbols,
|
||
core::marker::PhantomData::<(&())>)
|
||
}
|
||
fn simulate_reduce(&self, action: i8)
|
||
-> __state_machine::SimulatedReduce<Self> {
|
||
__simulate_reduce(action, core::marker::PhantomData::<(&())>)
|
||
}
|
||
}
|
||
fn __token_to_integer<'input>(__token: &Token<'input>,
|
||
_: core::marker::PhantomData<(&'input ())>) -> Option<usize> {
|
||
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<Term,
|
||
__lalrpop_util::ParseError<usize, Token<'input>,
|
||
&'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<i8>, __states: &[i8],
|
||
__opt_integer: Option<usize>,
|
||
_: 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<i8>,
|
||
__symbols: &mut alloc::vec::Vec<(usize, __Symbol<'input>, usize)>,
|
||
_: core::marker::PhantomData<(&'input ())>)
|
||
->
|
||
Option<Result<Term,
|
||
__lalrpop_util::ParseError<usize, Token<'input>,
|
||
&'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<alloc::string::String> {
|
||
__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<alloc::string::String> {
|
||
__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<usize> {
|
||
__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<alloc::string::String> {
|
||
__expected_tokens(state)
|
||
}
|
||
fn expected_tokens_from_states(&self, states: &[i8])
|
||
-> alloc::vec::Vec<alloc::string::String> {
|
||
__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>)
|
||
-> 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<i8>,
|
||
symbols:
|
||
&mut alloc::vec::Vec<__state_machine::SymbolTriple<Self>>)
|
||
-> Option<__state_machine::ParseResult<Self>> {
|
||
__reduce(self.input, action, start_location, states, symbols,
|
||
core::marker::PhantomData::<(&())>)
|
||
}
|
||
fn simulate_reduce(&self, action: i8)
|
||
-> __state_machine::SimulatedReduce<Self> {
|
||
__simulate_reduce(action, core::marker::PhantomData::<(&())>)
|
||
}
|
||
}
|
||
fn __token_to_integer<'input>(__token: &Token<'input>,
|
||
_: core::marker::PhantomData<(&'input ())>) -> Option<usize> {
|
||
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<Term,
|
||
__lalrpop_util::ParseError<usize, Token<'input>,
|
||
&'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<i8>, __states: &[i8],
|
||
__opt_integer: Option<usize>,
|
||
_: 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<i8>,
|
||
__symbols: &mut alloc::vec::Vec<(usize, __Symbol<'input>, usize)>,
|
||
_: core::marker::PhantomData<(&'input ())>)
|
||
->
|
||
Option<Result<Term,
|
||
__lalrpop_util::ParseError<usize, Token<'input>,
|
||
&'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<alloc::string::String> {
|
||
__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<alloc::string::String> {
|
||
__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<usize> {
|
||
__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<alloc::string::String> {
|
||
__expected_tokens(state)
|
||
}
|
||
fn expected_tokens_from_states(&self, states: &[i8])
|
||
-> alloc::vec::Vec<alloc::string::String> {
|
||
__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>)
|
||
-> 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<i8>,
|
||
symbols:
|
||
&mut alloc::vec::Vec<__state_machine::SymbolTriple<Self>>)
|
||
-> Option<__state_machine::ParseResult<Self>> {
|
||
__reduce(self.input, action, start_location, states, symbols,
|
||
core::marker::PhantomData::<(&())>)
|
||
}
|
||
fn simulate_reduce(&self, action: i8)
|
||
-> __state_machine::SimulatedReduce<Self> {
|
||
__simulate_reduce(action, core::marker::PhantomData::<(&())>)
|
||
}
|
||
}
|
||
fn __token_to_integer<'input>(__token: &Token<'input>,
|
||
_: core::marker::PhantomData<(&'input ())>) -> Option<usize> {
|
||
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<Term,
|
||
__lalrpop_util::ParseError<usize, Token<'input>,
|
||
&'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<i8>, __states: &[i8],
|
||
__opt_integer: Option<usize>,
|
||
_: 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<i8>,
|
||
__symbols: &mut alloc::vec::Vec<(usize, __Symbol<'input>, usize)>,
|
||
_: core::marker::PhantomData<(&'input ())>)
|
||
->
|
||
Option<Result<Term,
|
||
__lalrpop_util::ParseError<usize, Token<'input>,
|
||
&'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<alloc::string::String> {
|
||
__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<alloc::string::String> {
|
||
__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<usize> {
|
||
__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<alloc::string::String> {
|
||
__expected_tokens(state)
|
||
}
|
||
fn expected_tokens_from_states(&self, states: &[i8])
|
||
-> alloc::vec::Vec<alloc::string::String> {
|
||
__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>)
|
||
-> 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<i8>,
|
||
symbols:
|
||
&mut alloc::vec::Vec<__state_machine::SymbolTriple<Self>>)
|
||
-> Option<__state_machine::ParseResult<Self>> {
|
||
__reduce(self.input, action, start_location, states, symbols,
|
||
core::marker::PhantomData::<(&())>)
|
||
}
|
||
fn simulate_reduce(&self, action: i8)
|
||
-> __state_machine::SimulatedReduce<Self> {
|
||
__simulate_reduce(action, core::marker::PhantomData::<(&())>)
|
||
}
|
||
}
|
||
fn __token_to_integer<'input>(__token: &Token<'input>,
|
||
_: core::marker::PhantomData<(&'input ())>) -> Option<usize> {
|
||
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<Type,
|
||
__lalrpop_util::ParseError<usize, Token<'input>,
|
||
&'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<i8>, __states: &[i8],
|
||
__opt_integer: Option<usize>,
|
||
_: 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<i8>,
|
||
__symbols: &mut alloc::vec::Vec<(usize, __Symbol<'input>, usize)>,
|
||
_: core::marker::PhantomData<(&'input ())>)
|
||
->
|
||
Option<Result<Type,
|
||
__lalrpop_util::ParseError<usize, Token<'input>,
|
||
&'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<alloc::string::String> {
|
||
__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<alloc::string::String> {
|
||
__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<usize> {
|
||
__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<alloc::string::String> {
|
||
__expected_tokens(state)
|
||
}
|
||
fn expected_tokens_from_states(&self, states: &[i8])
|
||
-> alloc::vec::Vec<alloc::string::String> {
|
||
__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>)
|
||
-> 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<i8>,
|
||
symbols:
|
||
&mut alloc::vec::Vec<__state_machine::SymbolTriple<Self>>)
|
||
-> Option<__state_machine::ParseResult<Self>> {
|
||
__reduce(self.input, action, start_location, states, symbols,
|
||
core::marker::PhantomData::<(&())>)
|
||
}
|
||
fn simulate_reduce(&self, action: i8)
|
||
-> __state_machine::SimulatedReduce<Self> {
|
||
__simulate_reduce(action, core::marker::PhantomData::<(&())>)
|
||
}
|
||
}
|
||
fn __token_to_integer<'input>(__token: &Token<'input>,
|
||
_: core::marker::PhantomData<(&'input ())>) -> Option<usize> {
|
||
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<Type,
|
||
__lalrpop_util::ParseError<usize, Token<'input>,
|
||
&'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<i8>, __states: &[i8],
|
||
__opt_integer: Option<usize>,
|
||
_: 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<i8>,
|
||
__symbols: &mut alloc::vec::Vec<(usize, __Symbol<'input>, usize)>,
|
||
_: core::marker::PhantomData<(&'input ())>)
|
||
->
|
||
Option<Result<Type,
|
||
__lalrpop_util::ParseError<usize, Token<'input>,
|
||
&'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<usize, Token<'input>, &'static str>>;
|
||
}
|
||
impl<'input> __ToTriple<'input> for (usize, Token<'input>, usize) {
|
||
fn to_triple(value: Self)
|
||
->
|
||
Result<(usize, Token<'input>, usize),
|
||
__lalrpop_util::ParseError<usize, Token<'input>,
|
||
&'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<usize, Token<'input>,
|
||
&'static str>> {
|
||
match value {
|
||
Ok(v) => Ok(v),
|
||
Err(error) => Err(__lalrpop_util::ParseError::User { error }),
|
||
}
|
||
}
|
||
}
|
||
}
|
||
const DEPTH: ::std::thread::LocalKey<::std::cell::Cell<usize>> =
|
||
{
|
||
#[inline]
|
||
fn __init() -> ::std::cell::Cell<usize> { ::std::cell::Cell::new(0) }
|
||
#[inline]
|
||
unsafe fn __getit(init:
|
||
::std::option::Option<&mut ::std::option::Option<::std::cell::Cell<usize>>>)
|
||
-> ::std::option::Option<&'static ::std::cell::Cell<usize>> {
|
||
#[thread_local]
|
||
static __KEY:
|
||
::std::thread::local_impl::Key<::std::cell::Cell<usize>> =
|
||
::std::thread::local_impl::Key::<::std::cell::Cell<usize>>::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) }
|
||
};
|