use crate::parser::{lexer, ast, Error};
use lexer::Tok;
use ast::Ast;
#[allow(unused_extern_crates)]
extern crate lalrpop_util as __lalrpop_util;
#[allow(unused_imports)]
use self::__lalrpop_util::state_machine as __state_machine;
#[allow(unused_extern_crates)]
extern crate alloc;
#[rustfmt::skip]
#[allow(explicit_outlives_requirements, non_snake_case, non_camel_case_types, unused_mut, unused_variables, unused_imports, unused_parens, clippy::needless_lifetimes, clippy::type_complexity, clippy::needless_return, clippy::too_many_arguments, clippy::never_loop, clippy::match_single_binding, clippy::needless_raw_string_hashes)]
mod __parse__Ast {
use crate::parser::{lexer, ast, Error};
use lexer::Tok;
use ast::Ast;
#[allow(unused_extern_crates)]
extern crate lalrpop_util as __lalrpop_util;
#[allow(unused_imports)]
use self::__lalrpop_util::state_machine as __state_machine;
#[allow(unused_extern_crates)]
extern crate alloc;
use super::__ToTriple;
#[allow(dead_code)]
pub(crate) enum __Symbol<>
{
Variant0(Tok),
Variant1(u8),
Variant2(ast::Ast),
}
const __ACTION: &[i8] = &[
0, 0, 3, 0, 0, 11, 12,
-2, 0, 3, -2, 0, 11, 12,
0, 0, 3, 0, 5, 11, 12,
0, 0, 3, 0, 0, 11, 12,
0, 0, 3, 0, 0, 11, 12,
-1, 0, 3, -1, 0, 11, 12,
4, 0, 0, 0, 0, 0, 0,
-5, -5, -5, -5, 0, -5, -5,
-7, 13, -7, -7, 0, -7, -7,
-3, -3, -3, -3, 0, -3, -3,
-9, -9, -9, -9, 0, -9, -9,
-8, -8, -8, -8, 0, -8, -8,
-4, -4, -4, -4, 0, -4, -4,
-6, 13, -6, -6, 0, -6, -6,
4, 0, 0, 16, 0, 0, 0,
-10, -10, -10, -10, 0, -10, -10,
4, 0, 0, 18, 0, 0, 0,
-11, -11, -11, -11, 0, -11, -11,
];
fn __action(state: i8, integer: usize) -> i8 {
__ACTION[(state as usize) * 7 + integer]
}
const __EOF_ACTION: &[i8] = &[
0,
-2,
0,
0,
0,
-1,
-12,
-5,
-7,
-3,
-9,
-8,
-4,
-6,
0,
-10,
0,
-11,
];
fn __goto(state: i8, nt: usize) -> i8 {
match nt {
0 => match state {
2 => 14,
4 => 16,
_ => 6,
},
1 => 7,
2 => match state {
1 | 5 => 13,
_ => 8,
},
3 => match state {
3 => 5,
_ => 1,
},
4 => 9,
_ => 0,
}
}
const __TERMINAL: &[&str] = &[
r###""|""###,
r###""?""###,
r###""(""###,
r###"")""###,
r###""!""###,
r###""digit""###,
r###""literal""###,
];
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<
>(
__states: &[i8],
_: core::marker::PhantomData<()>,
) -> 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()
}
struct __StateMachine<>
where
{
__phantom: core::marker::PhantomData<()>,
}
impl<> __state_machine::ParserDefinition for __StateMachine<>
where
{
type Location = usize;
type Error = Error;
type Token = Tok;
type TokenIndex = usize;
type Symbol = __Symbol<>;
type Success = ast::Ast;
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, 7 - 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 {
panic!("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(
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<
>(
__token: &Tok,
_: core::marker::PhantomData<()>,
) -> Option<usize>
{
#[warn(unused_variables)]
match __token {
lexer::Tok::Or if true => Some(0),
lexer::Tok::QMark if true => Some(1),
lexer::Tok::LParen if true => Some(2),
lexer::Tok::RParen if true => Some(3),
lexer::Tok::Exclam if true => Some(4),
lexer::Tok::Digit if true => Some(5),
lexer::Tok::Byte { b: _, .. } if true => Some(6),
_ => None,
}
}
fn __token_to_symbol<
>(
__token_index: usize,
__token: Tok,
_: core::marker::PhantomData<()>,
) -> __Symbol<>
{
#[allow(clippy::manual_range_patterns)]match __token_index {
0 | 1 | 2 | 3 | 4 | 5 => __Symbol::Variant0(__token),
6 => match __token {
lexer::Tok::Byte { b: __tok0, .. } if true => __Symbol::Variant1(__tok0),
_ => unreachable!(),
},
_ => unreachable!(),
}
}
fn __simulate_reduce<
>(
__reduce_index: i8,
_: core::marker::PhantomData<()>,
) -> __state_machine::SimulatedReduce<__StateMachine<>>
{
match __reduce_index {
0 => {
__state_machine::SimulatedReduce::Reduce {
states_to_pop: 3,
nonterminal_produced: 0,
}
}
1 => {
__state_machine::SimulatedReduce::Reduce {
states_to_pop: 1,
nonterminal_produced: 0,
}
}
2 => {
__state_machine::SimulatedReduce::Reduce {
states_to_pop: 1,
nonterminal_produced: 1,
}
}
3 => {
__state_machine::SimulatedReduce::Reduce {
states_to_pop: 2,
nonterminal_produced: 2,
}
}
4 => {
__state_machine::SimulatedReduce::Reduce {
states_to_pop: 1,
nonterminal_produced: 2,
}
}
5 => {
__state_machine::SimulatedReduce::Reduce {
states_to_pop: 2,
nonterminal_produced: 3,
}
}
6 => {
__state_machine::SimulatedReduce::Reduce {
states_to_pop: 1,
nonterminal_produced: 3,
}
}
7 => {
__state_machine::SimulatedReduce::Reduce {
states_to_pop: 1,
nonterminal_produced: 4,
}
}
8 => {
__state_machine::SimulatedReduce::Reduce {
states_to_pop: 1,
nonterminal_produced: 4,
}
}
9 => {
__state_machine::SimulatedReduce::Reduce {
states_to_pop: 3,
nonterminal_produced: 4,
}
}
10 => {
__state_machine::SimulatedReduce::Reduce {
states_to_pop: 4,
nonterminal_produced: 4,
}
}
11 => __state_machine::SimulatedReduce::Accept,
12 => {
__state_machine::SimulatedReduce::Reduce {
states_to_pop: 1,
nonterminal_produced: 6,
}
}
13 => {
__state_machine::SimulatedReduce::Reduce {
states_to_pop: 1,
nonterminal_produced: 7,
}
}
14 => {
__state_machine::SimulatedReduce::Reduce {
states_to_pop: 1,
nonterminal_produced: 8,
}
}
_ => panic!("invalid reduction index {}", __reduce_index)
}
}
pub struct AstParser {
_priv: (),
}
impl Default for AstParser { fn default() -> Self { Self::new() } }
impl AstParser {
pub fn new() -> AstParser {
AstParser {
_priv: (),
}
}
#[allow(dead_code)]
pub fn parse<
__TOKEN: __ToTriple<>,
__TOKENS: IntoIterator<Item=__TOKEN>,
>(
&self,
__tokens0: __TOKENS,
) -> Result<ast::Ast, __lalrpop_util::ParseError<usize, Tok, Error>>
{
let __tokens = __tokens0.into_iter();
let mut __tokens = __tokens.map(|t| __ToTriple::to_triple(t));
__state_machine::Parser::drive(
__StateMachine {
__phantom: core::marker::PhantomData::<()>,
},
__tokens,
)
}
}
fn __accepts<
>(
__error_state: Option<i8>,
__states: &[i8],
__opt_integer: Option<usize>,
_: core::marker::PhantomData<()>,
) -> 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);
}
}
fn __reduce<
>(
__action: i8,
__lookahead_start: Option<&usize>,
__states: &mut alloc::vec::Vec<i8>,
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
_: core::marker::PhantomData<()>,
) -> Option<Result<ast::Ast,__lalrpop_util::ParseError<usize, Tok, Error>>>
{
let (__pop_states, __nonterminal) = match __action {
0 => {
__reduce0(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
}
1 => {
__reduce1(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
}
2 => {
__reduce2(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
}
3 => {
__reduce3(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
}
4 => {
__reduce4(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
}
5 => {
__reduce5(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
}
6 => {
__reduce6(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
}
7 => {
__reduce7(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
}
8 => {
__reduce8(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
}
9 => {
__reduce9(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
}
10 => {
__reduce10(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
}
11 => {
let __sym0 = __pop_Variant2(__symbols);
let __start = __sym0.0;
let __end = __sym0.2;
let __nt = super::__action3::<>(__sym0);
return Some(Ok(__nt));
}
12 => {
__reduce12(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
}
13 => {
__reduce13(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
}
14 => {
__reduce14(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
}
_ => panic!("invalid action code {}", __action)
};
let __states_len = __states.len();
__states.truncate(__states_len - __pop_states);
let __state = *__states.last().unwrap();
let __next_state = __goto(__state, __nonterminal);
__states.push(__next_state);
None
}
#[inline(never)]
fn __symbol_type_mismatch() -> ! {
panic!("symbol type mismatch")
}
fn __pop_Variant0<
>(
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>
) -> (usize, Tok, usize)
{
match __symbols.pop() {
Some((__l, __Symbol::Variant0(__v), __r)) => (__l, __v, __r),
_ => __symbol_type_mismatch()
}
}
fn __pop_Variant2<
>(
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>
) -> (usize, ast::Ast, usize)
{
match __symbols.pop() {
Some((__l, __Symbol::Variant2(__v), __r)) => (__l, __v, __r),
_ => __symbol_type_mismatch()
}
}
fn __pop_Variant1<
>(
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>
) -> (usize, u8, usize)
{
match __symbols.pop() {
Some((__l, __Symbol::Variant1(__v), __r)) => (__l, __v, __r),
_ => __symbol_type_mismatch()
}
}
fn __reduce0<
>(
__lookahead_start: Option<&usize>,
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
_: core::marker::PhantomData<()>,
) -> (usize, usize)
{
assert!(__symbols.len() >= 3);
let __sym2 = __pop_Variant2(__symbols);
let __sym1 = __pop_Variant0(__symbols);
let __sym0 = __pop_Variant2(__symbols);
let __start = __sym0.0;
let __end = __sym2.2;
let __nt = super::__action9::<>(__sym0, __sym1, __sym2);
__symbols.push((__start, __Symbol::Variant2(__nt), __end));
(3, 0)
}
fn __reduce1<
>(
__lookahead_start: Option<&usize>,
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
_: core::marker::PhantomData<()>,
) -> (usize, usize)
{
let __sym0 = __pop_Variant2(__symbols);
let __start = __sym0.0;
let __end = __sym0.2;
let __nt = super::__action10::<>(__sym0);
__symbols.push((__start, __Symbol::Variant2(__nt), __end));
(1, 0)
}
fn __reduce2<
>(
__lookahead_start: Option<&usize>,
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
_: core::marker::PhantomData<()>,
) -> (usize, usize)
{
let __sym0 = __pop_Variant2(__symbols);
let __start = __sym0.0;
let __end = __sym0.2;
let __nt = super::__action4::<>(__sym0);
__symbols.push((__start, __Symbol::Variant2(__nt), __end));
(1, 1)
}
fn __reduce3<
>(
__lookahead_start: Option<&usize>,
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
_: core::marker::PhantomData<()>,
) -> (usize, usize)
{
assert!(__symbols.len() >= 2);
let __sym1 = __pop_Variant0(__symbols);
let __sym0 = __pop_Variant2(__symbols);
let __start = __sym0.0;
let __end = __sym1.2;
let __nt = super::__action5::<>(__sym0, __sym1);
__symbols.push((__start, __Symbol::Variant2(__nt), __end));
(2, 2)
}
fn __reduce4<
>(
__lookahead_start: Option<&usize>,
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
_: core::marker::PhantomData<()>,
) -> (usize, usize)
{
let __sym0 = __pop_Variant2(__symbols);
let __start = __sym0.0;
let __end = __sym0.2;
let __nt = super::__action6::<>(__sym0);
__symbols.push((__start, __Symbol::Variant2(__nt), __end));
(1, 2)
}
fn __reduce5<
>(
__lookahead_start: Option<&usize>,
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
_: core::marker::PhantomData<()>,
) -> (usize, usize)
{
assert!(__symbols.len() >= 2);
let __sym1 = __pop_Variant2(__symbols);
let __sym0 = __pop_Variant2(__symbols);
let __start = __sym0.0;
let __end = __sym1.2;
let __nt = super::__action7::<>(__sym0, __sym1);
__symbols.push((__start, __Symbol::Variant2(__nt), __end));
(2, 3)
}
fn __reduce6<
>(
__lookahead_start: Option<&usize>,
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
_: core::marker::PhantomData<()>,
) -> (usize, usize)
{
let __sym0 = __pop_Variant2(__symbols);
let __start = __sym0.0;
let __end = __sym0.2;
let __nt = super::__action8::<>(__sym0);
__symbols.push((__start, __Symbol::Variant2(__nt), __end));
(1, 3)
}
fn __reduce7<
>(
__lookahead_start: Option<&usize>,
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
_: core::marker::PhantomData<()>,
) -> (usize, usize)
{
let __sym0 = __pop_Variant1(__symbols);
let __start = __sym0.0;
let __end = __sym0.2;
let __nt = super::__action11::<>(__sym0);
__symbols.push((__start, __Symbol::Variant2(__nt), __end));
(1, 4)
}
fn __reduce8<
>(
__lookahead_start: Option<&usize>,
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
_: core::marker::PhantomData<()>,
) -> (usize, usize)
{
let __sym0 = __pop_Variant0(__symbols);
let __start = __sym0.0;
let __end = __sym0.2;
let __nt = super::__action12::<>(__sym0);
__symbols.push((__start, __Symbol::Variant2(__nt), __end));
(1, 4)
}
fn __reduce9<
>(
__lookahead_start: Option<&usize>,
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
_: core::marker::PhantomData<()>,
) -> (usize, usize)
{
assert!(__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::__action13::<>(__sym0, __sym1, __sym2);
__symbols.push((__start, __Symbol::Variant2(__nt), __end));
(3, 4)
}
fn __reduce10<
>(
__lookahead_start: Option<&usize>,
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
_: core::marker::PhantomData<()>,
) -> (usize, usize)
{
assert!(__symbols.len() >= 4);
let __sym3 = __pop_Variant0(__symbols);
let __sym2 = __pop_Variant2(__symbols);
let __sym1 = __pop_Variant0(__symbols);
let __sym0 = __pop_Variant0(__symbols);
let __start = __sym0.0;
let __end = __sym3.2;
let __nt = super::__action14::<>(__sym0, __sym1, __sym2, __sym3);
__symbols.push((__start, __Symbol::Variant2(__nt), __end));
(4, 4)
}
fn __reduce12<
>(
__lookahead_start: Option<&usize>,
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
_: core::marker::PhantomData<()>,
) -> (usize, usize)
{
let __sym0 = __pop_Variant2(__symbols);
let __start = __sym0.0;
let __end = __sym0.2;
let __nt = super::__action0::<>(__sym0);
__symbols.push((__start, __Symbol::Variant2(__nt), __end));
(1, 6)
}
fn __reduce13<
>(
__lookahead_start: Option<&usize>,
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
_: core::marker::PhantomData<()>,
) -> (usize, usize)
{
let __sym0 = __pop_Variant2(__symbols);
let __start = __sym0.0;
let __end = __sym0.2;
let __nt = super::__action1::<>(__sym0);
__symbols.push((__start, __Symbol::Variant2(__nt), __end));
(1, 7)
}
fn __reduce14<
>(
__lookahead_start: Option<&usize>,
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
_: core::marker::PhantomData<()>,
) -> (usize, usize)
{
let __sym0 = __pop_Variant2(__symbols);
let __start = __sym0.0;
let __end = __sym0.2;
let __nt = super::__action2::<>(__sym0);
__symbols.push((__start, __Symbol::Variant2(__nt), __end));
(1, 8)
}
}
#[allow(unused_imports)]
pub use self::__parse__Ast::AstParser;
#[rustfmt::skip]
#[allow(explicit_outlives_requirements, non_snake_case, non_camel_case_types, unused_mut, unused_variables, unused_imports, unused_parens, clippy::needless_lifetimes, clippy::type_complexity, clippy::needless_return, clippy::too_many_arguments, clippy::never_loop, clippy::match_single_binding, clippy::needless_raw_string_hashes)]
mod __parse__Ast1 {
use crate::parser::{lexer, ast, Error};
use lexer::Tok;
use ast::Ast;
#[allow(unused_extern_crates)]
extern crate lalrpop_util as __lalrpop_util;
#[allow(unused_imports)]
use self::__lalrpop_util::state_machine as __state_machine;
#[allow(unused_extern_crates)]
extern crate alloc;
use super::__ToTriple;
#[allow(dead_code)]
pub(crate) enum __Symbol<>
{
Variant0(Tok),
Variant1(u8),
Variant2(ast::Ast),
}
const __ACTION: &[i8] = &[
0, 0, 2, 0, 0, 9, 10,
0, 0, 2, 0, 4, 9, 10,
-2, 0, 2, -2, 0, 9, 10,
0, 0, 2, 0, 0, 9, 10,
0, 0, 2, 0, 0, 9, 10,
-1, 0, 2, -1, 0, 9, 10,
0, 0, 0, 0, 0, 0, 0,
-3, -3, -3, -3, 0, -3, -3,
-9, -9, -9, -9, 0, -9, -9,
-8, -8, -8, -8, 0, -8, -8,
5, 0, 0, 14, 0, 0, 0,
-5, -5, -5, -5, 0, -5, -5,
-7, 15, -7, -7, 0, -7, -7,
-10, -10, -10, -10, 0, -10, -10,
-4, -4, -4, -4, 0, -4, -4,
-6, 15, -6, -6, 0, -6, -6,
5, 0, 0, 18, 0, 0, 0,
-11, -11, -11, -11, 0, -11, -11,
];
fn __action(state: i8, integer: usize) -> i8 {
__ACTION[(state as usize) * 7 + integer]
}
const __EOF_ACTION: &[i8] = &[
0,
0,
0,
0,
0,
0,
-13,
-3,
-9,
-8,
0,
0,
0,
-10,
0,
0,
0,
-11,
];
fn __goto(state: i8, nt: usize) -> i8 {
match nt {
0 => match state {
3 => 16,
_ => 10,
},
1 => match state {
1..=5 => 11,
_ => 6,
},
2 => match state {
2 | 5 => 15,
_ => 12,
},
3 => match state {
4 => 5,
_ => 2,
},
4 => 7,
_ => 0,
}
}
const __TERMINAL: &[&str] = &[
r###""|""###,
r###""?""###,
r###""(""###,
r###"")""###,
r###""!""###,
r###""digit""###,
r###""literal""###,
];
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<
>(
__states: &[i8],
_: core::marker::PhantomData<()>,
) -> 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()
}
struct __StateMachine<>
where
{
__phantom: core::marker::PhantomData<()>,
}
impl<> __state_machine::ParserDefinition for __StateMachine<>
where
{
type Location = usize;
type Error = Error;
type Token = Tok;
type TokenIndex = usize;
type Symbol = __Symbol<>;
type Success = ast::Ast;
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, 7 - 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 {
panic!("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(
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<
>(
__token: &Tok,
_: core::marker::PhantomData<()>,
) -> Option<usize>
{
#[warn(unused_variables)]
match __token {
lexer::Tok::Or if true => Some(0),
lexer::Tok::QMark if true => Some(1),
lexer::Tok::LParen if true => Some(2),
lexer::Tok::RParen if true => Some(3),
lexer::Tok::Exclam if true => Some(4),
lexer::Tok::Digit if true => Some(5),
lexer::Tok::Byte { b: _, .. } if true => Some(6),
_ => None,
}
}
fn __token_to_symbol<
>(
__token_index: usize,
__token: Tok,
_: core::marker::PhantomData<()>,
) -> __Symbol<>
{
#[allow(clippy::manual_range_patterns)]match __token_index {
0 | 1 | 2 | 3 | 4 | 5 => __Symbol::Variant0(__token),
6 => match __token {
lexer::Tok::Byte { b: __tok0, .. } if true => __Symbol::Variant1(__tok0),
_ => unreachable!(),
},
_ => unreachable!(),
}
}
fn __simulate_reduce<
>(
__reduce_index: i8,
_: core::marker::PhantomData<()>,
) -> __state_machine::SimulatedReduce<__StateMachine<>>
{
match __reduce_index {
0 => {
__state_machine::SimulatedReduce::Reduce {
states_to_pop: 3,
nonterminal_produced: 0,
}
}
1 => {
__state_machine::SimulatedReduce::Reduce {
states_to_pop: 1,
nonterminal_produced: 0,
}
}
2 => {
__state_machine::SimulatedReduce::Reduce {
states_to_pop: 1,
nonterminal_produced: 1,
}
}
3 => {
__state_machine::SimulatedReduce::Reduce {
states_to_pop: 2,
nonterminal_produced: 2,
}
}
4 => {
__state_machine::SimulatedReduce::Reduce {
states_to_pop: 1,
nonterminal_produced: 2,
}
}
5 => {
__state_machine::SimulatedReduce::Reduce {
states_to_pop: 2,
nonterminal_produced: 3,
}
}
6 => {
__state_machine::SimulatedReduce::Reduce {
states_to_pop: 1,
nonterminal_produced: 3,
}
}
7 => {
__state_machine::SimulatedReduce::Reduce {
states_to_pop: 1,
nonterminal_produced: 4,
}
}
8 => {
__state_machine::SimulatedReduce::Reduce {
states_to_pop: 1,
nonterminal_produced: 4,
}
}
9 => {
__state_machine::SimulatedReduce::Reduce {
states_to_pop: 3,
nonterminal_produced: 4,
}
}
10 => {
__state_machine::SimulatedReduce::Reduce {
states_to_pop: 4,
nonterminal_produced: 4,
}
}
11 => {
__state_machine::SimulatedReduce::Reduce {
states_to_pop: 1,
nonterminal_produced: 5,
}
}
12 => __state_machine::SimulatedReduce::Accept,
13 => {
__state_machine::SimulatedReduce::Reduce {
states_to_pop: 1,
nonterminal_produced: 7,
}
}
14 => {
__state_machine::SimulatedReduce::Reduce {
states_to_pop: 1,
nonterminal_produced: 8,
}
}
_ => panic!("invalid reduction index {}", __reduce_index)
}
}
pub struct Ast1Parser {
_priv: (),
}
impl Default for Ast1Parser { fn default() -> Self { Self::new() } }
impl Ast1Parser {
pub fn new() -> Ast1Parser {
Ast1Parser {
_priv: (),
}
}
#[allow(dead_code)]
pub fn parse<
__TOKEN: __ToTriple<>,
__TOKENS: IntoIterator<Item=__TOKEN>,
>(
&self,
__tokens0: __TOKENS,
) -> Result<ast::Ast, __lalrpop_util::ParseError<usize, Tok, Error>>
{
let __tokens = __tokens0.into_iter();
let mut __tokens = __tokens.map(|t| __ToTriple::to_triple(t));
__state_machine::Parser::drive(
__StateMachine {
__phantom: core::marker::PhantomData::<()>,
},
__tokens,
)
}
}
fn __accepts<
>(
__error_state: Option<i8>,
__states: &[i8],
__opt_integer: Option<usize>,
_: core::marker::PhantomData<()>,
) -> 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);
}
}
fn __reduce<
>(
__action: i8,
__lookahead_start: Option<&usize>,
__states: &mut alloc::vec::Vec<i8>,
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
_: core::marker::PhantomData<()>,
) -> Option<Result<ast::Ast,__lalrpop_util::ParseError<usize, Tok, Error>>>
{
let (__pop_states, __nonterminal) = match __action {
0 => {
__reduce0(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
}
1 => {
__reduce1(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
}
2 => {
__reduce2(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
}
3 => {
__reduce3(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
}
4 => {
__reduce4(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
}
5 => {
__reduce5(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
}
6 => {
__reduce6(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
}
7 => {
__reduce7(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
}
8 => {
__reduce8(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
}
9 => {
__reduce9(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
}
10 => {
__reduce10(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
}
11 => {
__reduce11(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
}
12 => {
let __sym0 = __pop_Variant2(__symbols);
let __start = __sym0.0;
let __end = __sym0.2;
let __nt = super::__action0::<>(__sym0);
return Some(Ok(__nt));
}
13 => {
__reduce13(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
}
14 => {
__reduce14(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
}
_ => panic!("invalid action code {}", __action)
};
let __states_len = __states.len();
__states.truncate(__states_len - __pop_states);
let __state = *__states.last().unwrap();
let __next_state = __goto(__state, __nonterminal);
__states.push(__next_state);
None
}
#[inline(never)]
fn __symbol_type_mismatch() -> ! {
panic!("symbol type mismatch")
}
fn __pop_Variant0<
>(
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>
) -> (usize, Tok, usize)
{
match __symbols.pop() {
Some((__l, __Symbol::Variant0(__v), __r)) => (__l, __v, __r),
_ => __symbol_type_mismatch()
}
}
fn __pop_Variant2<
>(
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>
) -> (usize, ast::Ast, usize)
{
match __symbols.pop() {
Some((__l, __Symbol::Variant2(__v), __r)) => (__l, __v, __r),
_ => __symbol_type_mismatch()
}
}
fn __pop_Variant1<
>(
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>
) -> (usize, u8, usize)
{
match __symbols.pop() {
Some((__l, __Symbol::Variant1(__v), __r)) => (__l, __v, __r),
_ => __symbol_type_mismatch()
}
}
fn __reduce0<
>(
__lookahead_start: Option<&usize>,
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
_: core::marker::PhantomData<()>,
) -> (usize, usize)
{
assert!(__symbols.len() >= 3);
let __sym2 = __pop_Variant2(__symbols);
let __sym1 = __pop_Variant0(__symbols);
let __sym0 = __pop_Variant2(__symbols);
let __start = __sym0.0;
let __end = __sym2.2;
let __nt = super::__action9::<>(__sym0, __sym1, __sym2);
__symbols.push((__start, __Symbol::Variant2(__nt), __end));
(3, 0)
}
fn __reduce1<
>(
__lookahead_start: Option<&usize>,
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
_: core::marker::PhantomData<()>,
) -> (usize, usize)
{
let __sym0 = __pop_Variant2(__symbols);
let __start = __sym0.0;
let __end = __sym0.2;
let __nt = super::__action10::<>(__sym0);
__symbols.push((__start, __Symbol::Variant2(__nt), __end));
(1, 0)
}
fn __reduce2<
>(
__lookahead_start: Option<&usize>,
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
_: core::marker::PhantomData<()>,
) -> (usize, usize)
{
let __sym0 = __pop_Variant2(__symbols);
let __start = __sym0.0;
let __end = __sym0.2;
let __nt = super::__action4::<>(__sym0);
__symbols.push((__start, __Symbol::Variant2(__nt), __end));
(1, 1)
}
fn __reduce3<
>(
__lookahead_start: Option<&usize>,
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
_: core::marker::PhantomData<()>,
) -> (usize, usize)
{
assert!(__symbols.len() >= 2);
let __sym1 = __pop_Variant0(__symbols);
let __sym0 = __pop_Variant2(__symbols);
let __start = __sym0.0;
let __end = __sym1.2;
let __nt = super::__action5::<>(__sym0, __sym1);
__symbols.push((__start, __Symbol::Variant2(__nt), __end));
(2, 2)
}
fn __reduce4<
>(
__lookahead_start: Option<&usize>,
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
_: core::marker::PhantomData<()>,
) -> (usize, usize)
{
let __sym0 = __pop_Variant2(__symbols);
let __start = __sym0.0;
let __end = __sym0.2;
let __nt = super::__action6::<>(__sym0);
__symbols.push((__start, __Symbol::Variant2(__nt), __end));
(1, 2)
}
fn __reduce5<
>(
__lookahead_start: Option<&usize>,
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
_: core::marker::PhantomData<()>,
) -> (usize, usize)
{
assert!(__symbols.len() >= 2);
let __sym1 = __pop_Variant2(__symbols);
let __sym0 = __pop_Variant2(__symbols);
let __start = __sym0.0;
let __end = __sym1.2;
let __nt = super::__action7::<>(__sym0, __sym1);
__symbols.push((__start, __Symbol::Variant2(__nt), __end));
(2, 3)
}
fn __reduce6<
>(
__lookahead_start: Option<&usize>,
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
_: core::marker::PhantomData<()>,
) -> (usize, usize)
{
let __sym0 = __pop_Variant2(__symbols);
let __start = __sym0.0;
let __end = __sym0.2;
let __nt = super::__action8::<>(__sym0);
__symbols.push((__start, __Symbol::Variant2(__nt), __end));
(1, 3)
}
fn __reduce7<
>(
__lookahead_start: Option<&usize>,
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
_: core::marker::PhantomData<()>,
) -> (usize, usize)
{
let __sym0 = __pop_Variant1(__symbols);
let __start = __sym0.0;
let __end = __sym0.2;
let __nt = super::__action11::<>(__sym0);
__symbols.push((__start, __Symbol::Variant2(__nt), __end));
(1, 4)
}
fn __reduce8<
>(
__lookahead_start: Option<&usize>,
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
_: core::marker::PhantomData<()>,
) -> (usize, usize)
{
let __sym0 = __pop_Variant0(__symbols);
let __start = __sym0.0;
let __end = __sym0.2;
let __nt = super::__action12::<>(__sym0);
__symbols.push((__start, __Symbol::Variant2(__nt), __end));
(1, 4)
}
fn __reduce9<
>(
__lookahead_start: Option<&usize>,
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
_: core::marker::PhantomData<()>,
) -> (usize, usize)
{
assert!(__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::__action13::<>(__sym0, __sym1, __sym2);
__symbols.push((__start, __Symbol::Variant2(__nt), __end));
(3, 4)
}
fn __reduce10<
>(
__lookahead_start: Option<&usize>,
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
_: core::marker::PhantomData<()>,
) -> (usize, usize)
{
assert!(__symbols.len() >= 4);
let __sym3 = __pop_Variant0(__symbols);
let __sym2 = __pop_Variant2(__symbols);
let __sym1 = __pop_Variant0(__symbols);
let __sym0 = __pop_Variant0(__symbols);
let __start = __sym0.0;
let __end = __sym3.2;
let __nt = super::__action14::<>(__sym0, __sym1, __sym2, __sym3);
__symbols.push((__start, __Symbol::Variant2(__nt), __end));
(4, 4)
}
fn __reduce11<
>(
__lookahead_start: Option<&usize>,
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
_: core::marker::PhantomData<()>,
) -> (usize, usize)
{
let __sym0 = __pop_Variant2(__symbols);
let __start = __sym0.0;
let __end = __sym0.2;
let __nt = super::__action3::<>(__sym0);
__symbols.push((__start, __Symbol::Variant2(__nt), __end));
(1, 5)
}
fn __reduce13<
>(
__lookahead_start: Option<&usize>,
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
_: core::marker::PhantomData<()>,
) -> (usize, usize)
{
let __sym0 = __pop_Variant2(__symbols);
let __start = __sym0.0;
let __end = __sym0.2;
let __nt = super::__action1::<>(__sym0);
__symbols.push((__start, __Symbol::Variant2(__nt), __end));
(1, 7)
}
fn __reduce14<
>(
__lookahead_start: Option<&usize>,
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
_: core::marker::PhantomData<()>,
) -> (usize, usize)
{
let __sym0 = __pop_Variant2(__symbols);
let __start = __sym0.0;
let __end = __sym0.2;
let __nt = super::__action2::<>(__sym0);
__symbols.push((__start, __Symbol::Variant2(__nt), __end));
(1, 8)
}
}
#[allow(unused_imports)]
pub use self::__parse__Ast1::Ast1Parser;
#[rustfmt::skip]
#[allow(explicit_outlives_requirements, non_snake_case, non_camel_case_types, unused_mut, unused_variables, unused_imports, unused_parens, clippy::needless_lifetimes, clippy::type_complexity, clippy::needless_return, clippy::too_many_arguments, clippy::never_loop, clippy::match_single_binding, clippy::needless_raw_string_hashes)]
mod __parse__Ast2 {
use crate::parser::{lexer, ast, Error};
use lexer::Tok;
use ast::Ast;
#[allow(unused_extern_crates)]
extern crate lalrpop_util as __lalrpop_util;
#[allow(unused_imports)]
use self::__lalrpop_util::state_machine as __state_machine;
#[allow(unused_extern_crates)]
extern crate alloc;
use super::__ToTriple;
#[allow(dead_code)]
pub(crate) enum __Symbol<>
{
Variant0(Tok),
Variant1(u8),
Variant2(ast::Ast),
}
const __ACTION: &[i8] = &[
0, 0, 2, 0, 0, 10, 11,
0, 0, 2, 0, 4, 10, 11,
-2, 0, 2, -2, 0, 10, 11,
0, 0, 2, 0, 0, 10, 11,
0, 0, 2, 0, 0, 10, 11,
-1, 0, 2, -1, 0, 10, 11,
-5, -5, -5, -5, 0, -5, -5,
0, 12, 0, 0, 0, 0, 0,
-3, -3, -3, -3, 0, -3, -3,
-9, -9, -9, -9, 0, -9, -9,
-8, -8, -8, -8, 0, -8, -8,
-4, -4, -4, -4, 0, -4, -4,
5, 0, 0, 15, 0, 0, 0,
-7, 12, -7, -7, 0, -7, -7,
-10, -10, -10, -10, 0, -10, -10,
-6, 12, -6, -6, 0, -6, -6,
5, 0, 0, 18, 0, 0, 0,
-11, -11, -11, -11, 0, -11, -11,
];
fn __action(state: i8, integer: usize) -> i8 {
__ACTION[(state as usize) * 7 + integer]
}
const __EOF_ACTION: &[i8] = &[
0,
0,
0,
0,
0,
0,
-5,
-14,
-3,
-9,
-8,
-4,
0,
0,
-10,
0,
0,
-11,
];
fn __goto(state: i8, nt: usize) -> i8 {
match nt {
0 => match state {
3 => 16,
_ => 12,
},
1 => 6,
2 => match state {
0 => 7,
2 | 5 => 15,
_ => 13,
},
3 => match state {
4 => 5,
_ => 2,
},
4 => 8,
_ => 0,
}
}
const __TERMINAL: &[&str] = &[
r###""|""###,
r###""?""###,
r###""(""###,
r###"")""###,
r###""!""###,
r###""digit""###,
r###""literal""###,
];
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<
>(
__states: &[i8],
_: core::marker::PhantomData<()>,
) -> 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()
}
struct __StateMachine<>
where
{
__phantom: core::marker::PhantomData<()>,
}
impl<> __state_machine::ParserDefinition for __StateMachine<>
where
{
type Location = usize;
type Error = Error;
type Token = Tok;
type TokenIndex = usize;
type Symbol = __Symbol<>;
type Success = ast::Ast;
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, 7 - 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 {
panic!("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(
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<
>(
__token: &Tok,
_: core::marker::PhantomData<()>,
) -> Option<usize>
{
#[warn(unused_variables)]
match __token {
lexer::Tok::Or if true => Some(0),
lexer::Tok::QMark if true => Some(1),
lexer::Tok::LParen if true => Some(2),
lexer::Tok::RParen if true => Some(3),
lexer::Tok::Exclam if true => Some(4),
lexer::Tok::Digit if true => Some(5),
lexer::Tok::Byte { b: _, .. } if true => Some(6),
_ => None,
}
}
fn __token_to_symbol<
>(
__token_index: usize,
__token: Tok,
_: core::marker::PhantomData<()>,
) -> __Symbol<>
{
#[allow(clippy::manual_range_patterns)]match __token_index {
0 | 1 | 2 | 3 | 4 | 5 => __Symbol::Variant0(__token),
6 => match __token {
lexer::Tok::Byte { b: __tok0, .. } if true => __Symbol::Variant1(__tok0),
_ => unreachable!(),
},
_ => unreachable!(),
}
}
fn __simulate_reduce<
>(
__reduce_index: i8,
_: core::marker::PhantomData<()>,
) -> __state_machine::SimulatedReduce<__StateMachine<>>
{
match __reduce_index {
0 => {
__state_machine::SimulatedReduce::Reduce {
states_to_pop: 3,
nonterminal_produced: 0,
}
}
1 => {
__state_machine::SimulatedReduce::Reduce {
states_to_pop: 1,
nonterminal_produced: 0,
}
}
2 => {
__state_machine::SimulatedReduce::Reduce {
states_to_pop: 1,
nonterminal_produced: 1,
}
}
3 => {
__state_machine::SimulatedReduce::Reduce {
states_to_pop: 2,
nonterminal_produced: 2,
}
}
4 => {
__state_machine::SimulatedReduce::Reduce {
states_to_pop: 1,
nonterminal_produced: 2,
}
}
5 => {
__state_machine::SimulatedReduce::Reduce {
states_to_pop: 2,
nonterminal_produced: 3,
}
}
6 => {
__state_machine::SimulatedReduce::Reduce {
states_to_pop: 1,
nonterminal_produced: 3,
}
}
7 => {
__state_machine::SimulatedReduce::Reduce {
states_to_pop: 1,
nonterminal_produced: 4,
}
}
8 => {
__state_machine::SimulatedReduce::Reduce {
states_to_pop: 1,
nonterminal_produced: 4,
}
}
9 => {
__state_machine::SimulatedReduce::Reduce {
states_to_pop: 3,
nonterminal_produced: 4,
}
}
10 => {
__state_machine::SimulatedReduce::Reduce {
states_to_pop: 4,
nonterminal_produced: 4,
}
}
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::Accept,
14 => {
__state_machine::SimulatedReduce::Reduce {
states_to_pop: 1,
nonterminal_produced: 8,
}
}
_ => panic!("invalid reduction index {}", __reduce_index)
}
}
pub struct Ast2Parser {
_priv: (),
}
impl Default for Ast2Parser { fn default() -> Self { Self::new() } }
impl Ast2Parser {
pub fn new() -> Ast2Parser {
Ast2Parser {
_priv: (),
}
}
#[allow(dead_code)]
pub fn parse<
__TOKEN: __ToTriple<>,
__TOKENS: IntoIterator<Item=__TOKEN>,
>(
&self,
__tokens0: __TOKENS,
) -> Result<ast::Ast, __lalrpop_util::ParseError<usize, Tok, Error>>
{
let __tokens = __tokens0.into_iter();
let mut __tokens = __tokens.map(|t| __ToTriple::to_triple(t));
__state_machine::Parser::drive(
__StateMachine {
__phantom: core::marker::PhantomData::<()>,
},
__tokens,
)
}
}
fn __accepts<
>(
__error_state: Option<i8>,
__states: &[i8],
__opt_integer: Option<usize>,
_: core::marker::PhantomData<()>,
) -> 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);
}
}
fn __reduce<
>(
__action: i8,
__lookahead_start: Option<&usize>,
__states: &mut alloc::vec::Vec<i8>,
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
_: core::marker::PhantomData<()>,
) -> Option<Result<ast::Ast,__lalrpop_util::ParseError<usize, Tok, Error>>>
{
let (__pop_states, __nonterminal) = match __action {
0 => {
__reduce0(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
}
1 => {
__reduce1(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
}
2 => {
__reduce2(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
}
3 => {
__reduce3(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
}
4 => {
__reduce4(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
}
5 => {
__reduce5(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
}
6 => {
__reduce6(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
}
7 => {
__reduce7(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
}
8 => {
__reduce8(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
}
9 => {
__reduce9(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
}
10 => {
__reduce10(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
}
11 => {
__reduce11(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
}
12 => {
__reduce12(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
}
13 => {
let __sym0 = __pop_Variant2(__symbols);
let __start = __sym0.0;
let __end = __sym0.2;
let __nt = super::__action1::<>(__sym0);
return Some(Ok(__nt));
}
14 => {
__reduce14(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
}
_ => panic!("invalid action code {}", __action)
};
let __states_len = __states.len();
__states.truncate(__states_len - __pop_states);
let __state = *__states.last().unwrap();
let __next_state = __goto(__state, __nonterminal);
__states.push(__next_state);
None
}
#[inline(never)]
fn __symbol_type_mismatch() -> ! {
panic!("symbol type mismatch")
}
fn __pop_Variant0<
>(
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>
) -> (usize, Tok, usize)
{
match __symbols.pop() {
Some((__l, __Symbol::Variant0(__v), __r)) => (__l, __v, __r),
_ => __symbol_type_mismatch()
}
}
fn __pop_Variant2<
>(
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>
) -> (usize, ast::Ast, usize)
{
match __symbols.pop() {
Some((__l, __Symbol::Variant2(__v), __r)) => (__l, __v, __r),
_ => __symbol_type_mismatch()
}
}
fn __pop_Variant1<
>(
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>
) -> (usize, u8, usize)
{
match __symbols.pop() {
Some((__l, __Symbol::Variant1(__v), __r)) => (__l, __v, __r),
_ => __symbol_type_mismatch()
}
}
fn __reduce0<
>(
__lookahead_start: Option<&usize>,
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
_: core::marker::PhantomData<()>,
) -> (usize, usize)
{
assert!(__symbols.len() >= 3);
let __sym2 = __pop_Variant2(__symbols);
let __sym1 = __pop_Variant0(__symbols);
let __sym0 = __pop_Variant2(__symbols);
let __start = __sym0.0;
let __end = __sym2.2;
let __nt = super::__action9::<>(__sym0, __sym1, __sym2);
__symbols.push((__start, __Symbol::Variant2(__nt), __end));
(3, 0)
}
fn __reduce1<
>(
__lookahead_start: Option<&usize>,
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
_: core::marker::PhantomData<()>,
) -> (usize, usize)
{
let __sym0 = __pop_Variant2(__symbols);
let __start = __sym0.0;
let __end = __sym0.2;
let __nt = super::__action10::<>(__sym0);
__symbols.push((__start, __Symbol::Variant2(__nt), __end));
(1, 0)
}
fn __reduce2<
>(
__lookahead_start: Option<&usize>,
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
_: core::marker::PhantomData<()>,
) -> (usize, usize)
{
let __sym0 = __pop_Variant2(__symbols);
let __start = __sym0.0;
let __end = __sym0.2;
let __nt = super::__action4::<>(__sym0);
__symbols.push((__start, __Symbol::Variant2(__nt), __end));
(1, 1)
}
fn __reduce3<
>(
__lookahead_start: Option<&usize>,
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
_: core::marker::PhantomData<()>,
) -> (usize, usize)
{
assert!(__symbols.len() >= 2);
let __sym1 = __pop_Variant0(__symbols);
let __sym0 = __pop_Variant2(__symbols);
let __start = __sym0.0;
let __end = __sym1.2;
let __nt = super::__action5::<>(__sym0, __sym1);
__symbols.push((__start, __Symbol::Variant2(__nt), __end));
(2, 2)
}
fn __reduce4<
>(
__lookahead_start: Option<&usize>,
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
_: core::marker::PhantomData<()>,
) -> (usize, usize)
{
let __sym0 = __pop_Variant2(__symbols);
let __start = __sym0.0;
let __end = __sym0.2;
let __nt = super::__action6::<>(__sym0);
__symbols.push((__start, __Symbol::Variant2(__nt), __end));
(1, 2)
}
fn __reduce5<
>(
__lookahead_start: Option<&usize>,
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
_: core::marker::PhantomData<()>,
) -> (usize, usize)
{
assert!(__symbols.len() >= 2);
let __sym1 = __pop_Variant2(__symbols);
let __sym0 = __pop_Variant2(__symbols);
let __start = __sym0.0;
let __end = __sym1.2;
let __nt = super::__action7::<>(__sym0, __sym1);
__symbols.push((__start, __Symbol::Variant2(__nt), __end));
(2, 3)
}
fn __reduce6<
>(
__lookahead_start: Option<&usize>,
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
_: core::marker::PhantomData<()>,
) -> (usize, usize)
{
let __sym0 = __pop_Variant2(__symbols);
let __start = __sym0.0;
let __end = __sym0.2;
let __nt = super::__action8::<>(__sym0);
__symbols.push((__start, __Symbol::Variant2(__nt), __end));
(1, 3)
}
fn __reduce7<
>(
__lookahead_start: Option<&usize>,
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
_: core::marker::PhantomData<()>,
) -> (usize, usize)
{
let __sym0 = __pop_Variant1(__symbols);
let __start = __sym0.0;
let __end = __sym0.2;
let __nt = super::__action11::<>(__sym0);
__symbols.push((__start, __Symbol::Variant2(__nt), __end));
(1, 4)
}
fn __reduce8<
>(
__lookahead_start: Option<&usize>,
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
_: core::marker::PhantomData<()>,
) -> (usize, usize)
{
let __sym0 = __pop_Variant0(__symbols);
let __start = __sym0.0;
let __end = __sym0.2;
let __nt = super::__action12::<>(__sym0);
__symbols.push((__start, __Symbol::Variant2(__nt), __end));
(1, 4)
}
fn __reduce9<
>(
__lookahead_start: Option<&usize>,
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
_: core::marker::PhantomData<()>,
) -> (usize, usize)
{
assert!(__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::__action13::<>(__sym0, __sym1, __sym2);
__symbols.push((__start, __Symbol::Variant2(__nt), __end));
(3, 4)
}
fn __reduce10<
>(
__lookahead_start: Option<&usize>,
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
_: core::marker::PhantomData<()>,
) -> (usize, usize)
{
assert!(__symbols.len() >= 4);
let __sym3 = __pop_Variant0(__symbols);
let __sym2 = __pop_Variant2(__symbols);
let __sym1 = __pop_Variant0(__symbols);
let __sym0 = __pop_Variant0(__symbols);
let __start = __sym0.0;
let __end = __sym3.2;
let __nt = super::__action14::<>(__sym0, __sym1, __sym2, __sym3);
__symbols.push((__start, __Symbol::Variant2(__nt), __end));
(4, 4)
}
fn __reduce11<
>(
__lookahead_start: Option<&usize>,
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
_: core::marker::PhantomData<()>,
) -> (usize, usize)
{
let __sym0 = __pop_Variant2(__symbols);
let __start = __sym0.0;
let __end = __sym0.2;
let __nt = super::__action3::<>(__sym0);
__symbols.push((__start, __Symbol::Variant2(__nt), __end));
(1, 5)
}
fn __reduce12<
>(
__lookahead_start: Option<&usize>,
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
_: core::marker::PhantomData<()>,
) -> (usize, usize)
{
let __sym0 = __pop_Variant2(__symbols);
let __start = __sym0.0;
let __end = __sym0.2;
let __nt = super::__action0::<>(__sym0);
__symbols.push((__start, __Symbol::Variant2(__nt), __end));
(1, 6)
}
fn __reduce14<
>(
__lookahead_start: Option<&usize>,
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
_: core::marker::PhantomData<()>,
) -> (usize, usize)
{
let __sym0 = __pop_Variant2(__symbols);
let __start = __sym0.0;
let __end = __sym0.2;
let __nt = super::__action2::<>(__sym0);
__symbols.push((__start, __Symbol::Variant2(__nt), __end));
(1, 8)
}
}
#[allow(unused_imports)]
pub use self::__parse__Ast2::Ast2Parser;
#[rustfmt::skip]
#[allow(explicit_outlives_requirements, non_snake_case, non_camel_case_types, unused_mut, unused_variables, unused_imports, unused_parens, clippy::needless_lifetimes, clippy::type_complexity, clippy::needless_return, clippy::too_many_arguments, clippy::never_loop, clippy::match_single_binding, clippy::needless_raw_string_hashes)]
mod __parse__Ast3 {
use crate::parser::{lexer, ast, Error};
use lexer::Tok;
use ast::Ast;
#[allow(unused_extern_crates)]
extern crate lalrpop_util as __lalrpop_util;
#[allow(unused_imports)]
use self::__lalrpop_util::state_machine as __state_machine;
#[allow(unused_extern_crates)]
extern crate alloc;
use super::__ToTriple;
#[allow(dead_code)]
pub(crate) enum __Symbol<>
{
Variant0(Tok),
Variant1(u8),
Variant2(ast::Ast),
}
const __ACTION: &[i8] = &[
0, 0, 3, 0, 0, 11, 12,
0, 0, 3, 0, 0, 11, 12,
0, 0, 3, 0, 5, 11, 12,
-2, 0, 3, -2, 0, 11, 12,
0, 0, 3, 0, 0, 11, 12,
0, 0, 3, 0, 0, 11, 12,
-1, 0, 3, -1, 0, 11, 12,
-5, -5, -5, -5, 0, -5, -5,
-7, 13, -7, -7, 0, -7, -7,
-3, -3, -3, -3, 0, -3, -3,
-9, -9, -9, -9, 0, -9, -9,
-8, -8, -8, -8, 0, -8, -8,
-4, -4, -4, -4, 0, -4, -4,
-6, 13, -6, -6, 0, -6, -6,
6, 0, 0, 16, 0, 0, 0,
-10, -10, -10, -10, 0, -10, -10,
6, 0, 0, 18, 0, 0, 0,
-11, -11, -11, -11, 0, -11, -11,
];
fn __action(state: i8, integer: usize) -> i8 {
__ACTION[(state as usize) * 7 + integer]
}
const __EOF_ACTION: &[i8] = &[
0,
-15,
0,
0,
0,
0,
0,
-5,
-7,
-3,
-9,
-8,
-4,
-6,
0,
-10,
0,
-11,
];
fn __goto(state: i8, nt: usize) -> i8 {
match nt {
0 => match state {
4 => 16,
_ => 14,
},
1 => 7,
2 => match state {
1 | 3 | 6 => 13,
_ => 8,
},
3 => match state {
0 => 1,
5 => 6,
_ => 3,
},
4 => 9,
_ => 0,
}
}
const __TERMINAL: &[&str] = &[
r###""|""###,
r###""?""###,
r###""(""###,
r###"")""###,
r###""!""###,
r###""digit""###,
r###""literal""###,
];
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<
>(
__states: &[i8],
_: core::marker::PhantomData<()>,
) -> 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()
}
struct __StateMachine<>
where
{
__phantom: core::marker::PhantomData<()>,
}
impl<> __state_machine::ParserDefinition for __StateMachine<>
where
{
type Location = usize;
type Error = Error;
type Token = Tok;
type TokenIndex = usize;
type Symbol = __Symbol<>;
type Success = ast::Ast;
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, 7 - 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 {
panic!("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(
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<
>(
__token: &Tok,
_: core::marker::PhantomData<()>,
) -> Option<usize>
{
#[warn(unused_variables)]
match __token {
lexer::Tok::Or if true => Some(0),
lexer::Tok::QMark if true => Some(1),
lexer::Tok::LParen if true => Some(2),
lexer::Tok::RParen if true => Some(3),
lexer::Tok::Exclam if true => Some(4),
lexer::Tok::Digit if true => Some(5),
lexer::Tok::Byte { b: _, .. } if true => Some(6),
_ => None,
}
}
fn __token_to_symbol<
>(
__token_index: usize,
__token: Tok,
_: core::marker::PhantomData<()>,
) -> __Symbol<>
{
#[allow(clippy::manual_range_patterns)]match __token_index {
0 | 1 | 2 | 3 | 4 | 5 => __Symbol::Variant0(__token),
6 => match __token {
lexer::Tok::Byte { b: __tok0, .. } if true => __Symbol::Variant1(__tok0),
_ => unreachable!(),
},
_ => unreachable!(),
}
}
fn __simulate_reduce<
>(
__reduce_index: i8,
_: core::marker::PhantomData<()>,
) -> __state_machine::SimulatedReduce<__StateMachine<>>
{
match __reduce_index {
0 => {
__state_machine::SimulatedReduce::Reduce {
states_to_pop: 3,
nonterminal_produced: 0,
}
}
1 => {
__state_machine::SimulatedReduce::Reduce {
states_to_pop: 1,
nonterminal_produced: 0,
}
}
2 => {
__state_machine::SimulatedReduce::Reduce {
states_to_pop: 1,
nonterminal_produced: 1,
}
}
3 => {
__state_machine::SimulatedReduce::Reduce {
states_to_pop: 2,
nonterminal_produced: 2,
}
}
4 => {
__state_machine::SimulatedReduce::Reduce {
states_to_pop: 1,
nonterminal_produced: 2,
}
}
5 => {
__state_machine::SimulatedReduce::Reduce {
states_to_pop: 2,
nonterminal_produced: 3,
}
}
6 => {
__state_machine::SimulatedReduce::Reduce {
states_to_pop: 1,
nonterminal_produced: 3,
}
}
7 => {
__state_machine::SimulatedReduce::Reduce {
states_to_pop: 1,
nonterminal_produced: 4,
}
}
8 => {
__state_machine::SimulatedReduce::Reduce {
states_to_pop: 1,
nonterminal_produced: 4,
}
}
9 => {
__state_machine::SimulatedReduce::Reduce {
states_to_pop: 3,
nonterminal_produced: 4,
}
}
10 => {
__state_machine::SimulatedReduce::Reduce {
states_to_pop: 4,
nonterminal_produced: 4,
}
}
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: 1,
nonterminal_produced: 7,
}
}
14 => __state_machine::SimulatedReduce::Accept,
_ => panic!("invalid reduction index {}", __reduce_index)
}
}
pub struct Ast3Parser {
_priv: (),
}
impl Default for Ast3Parser { fn default() -> Self { Self::new() } }
impl Ast3Parser {
pub fn new() -> Ast3Parser {
Ast3Parser {
_priv: (),
}
}
#[allow(dead_code)]
pub fn parse<
__TOKEN: __ToTriple<>,
__TOKENS: IntoIterator<Item=__TOKEN>,
>(
&self,
__tokens0: __TOKENS,
) -> Result<ast::Ast, __lalrpop_util::ParseError<usize, Tok, Error>>
{
let __tokens = __tokens0.into_iter();
let mut __tokens = __tokens.map(|t| __ToTriple::to_triple(t));
__state_machine::Parser::drive(
__StateMachine {
__phantom: core::marker::PhantomData::<()>,
},
__tokens,
)
}
}
fn __accepts<
>(
__error_state: Option<i8>,
__states: &[i8],
__opt_integer: Option<usize>,
_: core::marker::PhantomData<()>,
) -> 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);
}
}
fn __reduce<
>(
__action: i8,
__lookahead_start: Option<&usize>,
__states: &mut alloc::vec::Vec<i8>,
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
_: core::marker::PhantomData<()>,
) -> Option<Result<ast::Ast,__lalrpop_util::ParseError<usize, Tok, Error>>>
{
let (__pop_states, __nonterminal) = match __action {
0 => {
__reduce0(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
}
1 => {
__reduce1(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
}
2 => {
__reduce2(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
}
3 => {
__reduce3(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
}
4 => {
__reduce4(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
}
5 => {
__reduce5(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
}
6 => {
__reduce6(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
}
7 => {
__reduce7(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
}
8 => {
__reduce8(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
}
9 => {
__reduce9(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
}
10 => {
__reduce10(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
}
11 => {
__reduce11(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
}
12 => {
__reduce12(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
}
13 => {
__reduce13(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
}
14 => {
let __sym0 = __pop_Variant2(__symbols);
let __start = __sym0.0;
let __end = __sym0.2;
let __nt = super::__action2::<>(__sym0);
return Some(Ok(__nt));
}
_ => panic!("invalid action code {}", __action)
};
let __states_len = __states.len();
__states.truncate(__states_len - __pop_states);
let __state = *__states.last().unwrap();
let __next_state = __goto(__state, __nonterminal);
__states.push(__next_state);
None
}
#[inline(never)]
fn __symbol_type_mismatch() -> ! {
panic!("symbol type mismatch")
}
fn __pop_Variant0<
>(
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>
) -> (usize, Tok, usize)
{
match __symbols.pop() {
Some((__l, __Symbol::Variant0(__v), __r)) => (__l, __v, __r),
_ => __symbol_type_mismatch()
}
}
fn __pop_Variant2<
>(
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>
) -> (usize, ast::Ast, usize)
{
match __symbols.pop() {
Some((__l, __Symbol::Variant2(__v), __r)) => (__l, __v, __r),
_ => __symbol_type_mismatch()
}
}
fn __pop_Variant1<
>(
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>
) -> (usize, u8, usize)
{
match __symbols.pop() {
Some((__l, __Symbol::Variant1(__v), __r)) => (__l, __v, __r),
_ => __symbol_type_mismatch()
}
}
fn __reduce0<
>(
__lookahead_start: Option<&usize>,
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
_: core::marker::PhantomData<()>,
) -> (usize, usize)
{
assert!(__symbols.len() >= 3);
let __sym2 = __pop_Variant2(__symbols);
let __sym1 = __pop_Variant0(__symbols);
let __sym0 = __pop_Variant2(__symbols);
let __start = __sym0.0;
let __end = __sym2.2;
let __nt = super::__action9::<>(__sym0, __sym1, __sym2);
__symbols.push((__start, __Symbol::Variant2(__nt), __end));
(3, 0)
}
fn __reduce1<
>(
__lookahead_start: Option<&usize>,
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
_: core::marker::PhantomData<()>,
) -> (usize, usize)
{
let __sym0 = __pop_Variant2(__symbols);
let __start = __sym0.0;
let __end = __sym0.2;
let __nt = super::__action10::<>(__sym0);
__symbols.push((__start, __Symbol::Variant2(__nt), __end));
(1, 0)
}
fn __reduce2<
>(
__lookahead_start: Option<&usize>,
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
_: core::marker::PhantomData<()>,
) -> (usize, usize)
{
let __sym0 = __pop_Variant2(__symbols);
let __start = __sym0.0;
let __end = __sym0.2;
let __nt = super::__action4::<>(__sym0);
__symbols.push((__start, __Symbol::Variant2(__nt), __end));
(1, 1)
}
fn __reduce3<
>(
__lookahead_start: Option<&usize>,
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
_: core::marker::PhantomData<()>,
) -> (usize, usize)
{
assert!(__symbols.len() >= 2);
let __sym1 = __pop_Variant0(__symbols);
let __sym0 = __pop_Variant2(__symbols);
let __start = __sym0.0;
let __end = __sym1.2;
let __nt = super::__action5::<>(__sym0, __sym1);
__symbols.push((__start, __Symbol::Variant2(__nt), __end));
(2, 2)
}
fn __reduce4<
>(
__lookahead_start: Option<&usize>,
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
_: core::marker::PhantomData<()>,
) -> (usize, usize)
{
let __sym0 = __pop_Variant2(__symbols);
let __start = __sym0.0;
let __end = __sym0.2;
let __nt = super::__action6::<>(__sym0);
__symbols.push((__start, __Symbol::Variant2(__nt), __end));
(1, 2)
}
fn __reduce5<
>(
__lookahead_start: Option<&usize>,
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
_: core::marker::PhantomData<()>,
) -> (usize, usize)
{
assert!(__symbols.len() >= 2);
let __sym1 = __pop_Variant2(__symbols);
let __sym0 = __pop_Variant2(__symbols);
let __start = __sym0.0;
let __end = __sym1.2;
let __nt = super::__action7::<>(__sym0, __sym1);
__symbols.push((__start, __Symbol::Variant2(__nt), __end));
(2, 3)
}
fn __reduce6<
>(
__lookahead_start: Option<&usize>,
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
_: core::marker::PhantomData<()>,
) -> (usize, usize)
{
let __sym0 = __pop_Variant2(__symbols);
let __start = __sym0.0;
let __end = __sym0.2;
let __nt = super::__action8::<>(__sym0);
__symbols.push((__start, __Symbol::Variant2(__nt), __end));
(1, 3)
}
fn __reduce7<
>(
__lookahead_start: Option<&usize>,
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
_: core::marker::PhantomData<()>,
) -> (usize, usize)
{
let __sym0 = __pop_Variant1(__symbols);
let __start = __sym0.0;
let __end = __sym0.2;
let __nt = super::__action11::<>(__sym0);
__symbols.push((__start, __Symbol::Variant2(__nt), __end));
(1, 4)
}
fn __reduce8<
>(
__lookahead_start: Option<&usize>,
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
_: core::marker::PhantomData<()>,
) -> (usize, usize)
{
let __sym0 = __pop_Variant0(__symbols);
let __start = __sym0.0;
let __end = __sym0.2;
let __nt = super::__action12::<>(__sym0);
__symbols.push((__start, __Symbol::Variant2(__nt), __end));
(1, 4)
}
fn __reduce9<
>(
__lookahead_start: Option<&usize>,
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
_: core::marker::PhantomData<()>,
) -> (usize, usize)
{
assert!(__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::__action13::<>(__sym0, __sym1, __sym2);
__symbols.push((__start, __Symbol::Variant2(__nt), __end));
(3, 4)
}
fn __reduce10<
>(
__lookahead_start: Option<&usize>,
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
_: core::marker::PhantomData<()>,
) -> (usize, usize)
{
assert!(__symbols.len() >= 4);
let __sym3 = __pop_Variant0(__symbols);
let __sym2 = __pop_Variant2(__symbols);
let __sym1 = __pop_Variant0(__symbols);
let __sym0 = __pop_Variant0(__symbols);
let __start = __sym0.0;
let __end = __sym3.2;
let __nt = super::__action14::<>(__sym0, __sym1, __sym2, __sym3);
__symbols.push((__start, __Symbol::Variant2(__nt), __end));
(4, 4)
}
fn __reduce11<
>(
__lookahead_start: Option<&usize>,
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
_: core::marker::PhantomData<()>,
) -> (usize, usize)
{
let __sym0 = __pop_Variant2(__symbols);
let __start = __sym0.0;
let __end = __sym0.2;
let __nt = super::__action3::<>(__sym0);
__symbols.push((__start, __Symbol::Variant2(__nt), __end));
(1, 5)
}
fn __reduce12<
>(
__lookahead_start: Option<&usize>,
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
_: core::marker::PhantomData<()>,
) -> (usize, usize)
{
let __sym0 = __pop_Variant2(__symbols);
let __start = __sym0.0;
let __end = __sym0.2;
let __nt = super::__action0::<>(__sym0);
__symbols.push((__start, __Symbol::Variant2(__nt), __end));
(1, 6)
}
fn __reduce13<
>(
__lookahead_start: Option<&usize>,
__symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
_: core::marker::PhantomData<()>,
) -> (usize, usize)
{
let __sym0 = __pop_Variant2(__symbols);
let __start = __sym0.0;
let __end = __sym0.2;
let __nt = super::__action1::<>(__sym0);
__symbols.push((__start, __Symbol::Variant2(__nt), __end));
(1, 7)
}
}
#[allow(unused_imports)]
pub use self::__parse__Ast3::Ast3Parser;
#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, clippy::just_underscores_and_digits)]
fn __action0<
>(
(_, __0, _): (usize, ast::Ast, usize),
) -> ast::Ast
{
__0
}
#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, clippy::just_underscores_and_digits)]
fn __action1<
>(
(_, __0, _): (usize, ast::Ast, usize),
) -> ast::Ast
{
__0
}
#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, clippy::just_underscores_and_digits)]
fn __action2<
>(
(_, __0, _): (usize, ast::Ast, usize),
) -> ast::Ast
{
__0
}
#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, clippy::just_underscores_and_digits)]
fn __action3<
>(
(_, __0, _): (usize, ast::Ast, usize),
) -> ast::Ast
{
__0
}
#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, clippy::just_underscores_and_digits)]
fn __action4<
>(
(_, t, _): (usize, ast::Ast, usize),
) -> ast::Ast
{
t
}
#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, clippy::just_underscores_and_digits)]
fn __action5<
>(
(_, t, _): (usize, ast::Ast, usize),
(_, _, _): (usize, Tok, usize),
) -> ast::Ast
{
Ast::zero_or_one(t)
}
#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, clippy::just_underscores_and_digits)]
fn __action6<
>(
(_, __0, _): (usize, ast::Ast, usize),
) -> ast::Ast
{
__0
}
#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, clippy::just_underscores_and_digits)]
fn __action7<
>(
(_, lhs, _): (usize, ast::Ast, usize),
(_, rhs, _): (usize, ast::Ast, usize),
) -> ast::Ast
{
Ast::then(lhs, rhs)
}
#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, clippy::just_underscores_and_digits)]
fn __action8<
>(
(_, __0, _): (usize, ast::Ast, usize),
) -> ast::Ast
{
__0
}
#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, clippy::just_underscores_and_digits)]
fn __action9<
>(
(_, lhs, _): (usize, ast::Ast, usize),
(_, _, _): (usize, Tok, usize),
(_, rhs, _): (usize, ast::Ast, usize),
) -> ast::Ast
{
Ast::or(lhs, rhs)
}
#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, clippy::just_underscores_and_digits)]
fn __action10<
>(
(_, __0, _): (usize, ast::Ast, usize),
) -> ast::Ast
{
__0
}
#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, clippy::just_underscores_and_digits)]
fn __action11<
>(
(_, l, _): (usize, u8, usize),
) -> ast::Ast
{
Ast::byte(l)
}
#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, clippy::just_underscores_and_digits)]
fn __action12<
>(
(_, __0, _): (usize, Tok, usize),
) -> ast::Ast
{
Ast::digit()
}
#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, clippy::just_underscores_and_digits)]
fn __action13<
>(
(_, _, _): (usize, Tok, usize),
(_, p, _): (usize, ast::Ast, usize),
(_, _, _): (usize, Tok, usize),
) -> ast::Ast
{
p
}
#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, clippy::just_underscores_and_digits)]
fn __action14<
>(
(_, _, _): (usize, Tok, usize),
(_, _, _): (usize, Tok, usize),
(_, p, _): (usize, ast::Ast, usize),
(_, _, _): (usize, Tok, usize),
) -> ast::Ast
{
Ast::case_sensitive(p)
}
#[allow(clippy::type_complexity, dead_code)]
pub trait __ToTriple<>
{
fn to_triple(self) -> Result<(usize,Tok,usize), __lalrpop_util::ParseError<usize, Tok, Error>>;
}
impl<> __ToTriple<> for (usize, Tok, usize)
{
fn to_triple(self) -> Result<(usize,Tok,usize), __lalrpop_util::ParseError<usize, Tok, Error>> {
Ok(self)
}
}
impl<> __ToTriple<> for Result<(usize, Tok, usize), Error>
{
fn to_triple(self) -> Result<(usize,Tok,usize), __lalrpop_util::ParseError<usize, Tok, Error>> {
self.map_err(|error| __lalrpop_util::ParseError::User { error })
}
}