// auto-generated: "lalrpop 0.19.6" // sha3: 779020ca179c7d99169ea2a3dc209511d4dc5bfa2f6290c09a821c6f93ced8c use crate::{Tree, Literal, Lambda}; use std::rc::Rc; #[allow(unused_extern_crates)] extern crate lalrpop_util as __lalrpop_util; #[allow(unused_imports)] use self::__lalrpop_util::state_machine as __state_machine; extern crate core; extern crate alloc; #[cfg_attr(rustfmt, rustfmt_skip)] mod __parse__Tree { #![allow(non_snake_case, non_camel_case_types, unused_mut, unused_variables, unused_imports, unused_parens)] use crate::{Tree, Literal, Lambda}; use std::rc::Rc; #[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(Box), Variant2(bool), Variant3(Literal), Variant4(f64), Variant5(Rc), Variant6(Rc<[String]>), Variant7(String), Variant8(alloc::vec::Vec), Variant9(Tree), Variant10(alloc::vec::Vec), } const __ACTION: &[i8] = &[ // State 0 20, 21, 2, 0, 0, 0, 0, 22, 23, // State 1 20, 21, 2, 0, 4, 5, 6, 22, 23, // State 2 20, 21, 2, 26, 0, 0, 0, 22, 23, // State 3 0, 0, 8, 0, 0, 0, 0, 0, 23, // State 4 20, 21, 2, 0, 0, 0, 0, 22, 23, // State 5 0, 0, 0, -10, 0, 0, 0, 0, 23, // State 6 20, 21, 2, 0, 0, 0, 0, 22, 23, // State 7 0, 0, 0, 0, 0, 0, 0, 0, 23, // State 8 20, 21, 2, 0, 0, 0, 0, 22, 23, // State 9 0, 0, 0, -11, 0, 0, 0, 0, 23, // State 10 0, 0, 0, -10, 0, 0, 0, 0, 23, // State 11 20, 21, 2, 0, 0, 0, 0, 22, 23, // State 12 20, 21, 2, 0, 0, 0, 0, 22, 23, // State 13 20, 21, 2, 0, 0, 0, 0, 22, 23, // State 14 -7, -7, -7, -7, 0, 0, 0, -7, -7, // State 15 -22, -22, -22, -22, 0, 0, 0, -22, -22, // State 16 -6, -6, -6, -6, 0, 0, 0, -6, -6, // State 17 -5, -5, -5, -5, 0, 0, 0, -5, -5, // State 18 0, 0, 0, 0, 0, 0, 0, 0, 0, // State 19 -3, -3, -3, -3, 0, 0, 0, -3, -3, // State 20 -2, -2, -2, -2, 0, 0, 0, -2, -2, // State 21 -8, -8, -8, -8, 0, 0, 0, -8, -8, // State 22 -12, -12, -12, -12, 0, 0, 0, -12, -12, // State 23 -23, -23, -23, -23, 0, 0, 0, -23, -23, // State 24 -24, -24, -24, -24, 0, 0, 0, -24, -24, // State 25 -17, -17, -17, -17, 0, 0, 0, -17, -17, // State 26 0, 0, 0, 13, 0, 0, 0, 0, 0, // State 27 0, 0, 0, -15, 0, 0, 0, 0, -15, // State 28 0, 0, 0, 33, 0, 0, 0, 0, 0, // State 29 0, 0, 0, -1, 0, 0, 0, 0, 0, // State 30 0, 0, 0, -4, 0, 0, 0, 0, 0, // State 31 0, 0, 0, -16, 0, 0, 0, 0, -16, // State 32 -18, -18, -18, -18, 0, 0, 0, -18, -18, // State 33 0, 0, 0, 14, 0, 0, 0, 0, 0, // State 34 0, 0, 0, 38, 0, 0, 0, 0, 0, // State 35 0, 0, 0, 39, 0, 0, 0, 0, 0, // State 36 0, 0, 0, -9, 0, 0, 0, 0, 0, // State 37 -20, -20, -20, -20, 0, 0, 0, -20, -20, // State 38 -21, -21, -21, -21, 0, 0, 0, -21, -21, // State 39 0, 0, 0, 41, 0, 0, 0, 0, 0, // State 40 -19, -19, -19, -19, 0, 0, 0, -19, -19, ]; fn __action(state: i8, integer: usize) -> i8 { __ACTION[(state as usize) * 9 + integer] } const __EOF_ACTION: &[i8] = &[ // State 0 0, // State 1 0, // State 2 0, // State 3 0, // State 4 0, // State 5 0, // State 6 0, // State 7 0, // State 8 0, // State 9 0, // State 10 0, // State 11 0, // State 12 0, // State 13 0, // State 14 -7, // State 15 -22, // State 16 -6, // State 17 -5, // State 18 -25, // State 19 -3, // State 20 -2, // State 21 -8, // State 22 -12, // State 23 0, // State 24 0, // State 25 -17, // State 26 0, // State 27 0, // State 28 0, // State 29 0, // State 30 0, // State 31 0, // State 32 -18, // State 33 0, // State 34 0, // State 35 0, // State 36 0, // State 37 -20, // State 38 -21, // State 39 0, // State 40 -19, ]; fn __goto(state: i8, nt: usize) -> i8 { match nt { 0 => 28, 1 => 14, 2 => 29, 3 => 15, 4 => 16, 5 => match state { 13 => 39, _ => 35, }, 6 => match state { 10 => 33, _ => 26, }, 7 => match state { 3 => 6, 7 => 10, 5 | 10 => 27, 9 => 31, _ => 17, }, 9 => 9, 10 => match state { 8 => 11, 0 => 18, 1 => 23, 2 => 24, 6 => 30, 11 => 34, 12..=13 => 36, _ => 8, }, 11 => 2, _ => 0, } } fn __expected_tokens(__state: i8) -> alloc::vec::Vec { const __TERMINAL: &[&str] = &[ r###""#f""###, r###""#t""###, r###""(""###, r###"")""###, r###""define""###, r###""if""###, r###""lambda (""###, r###"r#"[0-9]+(\\.[0-9]+)?"#"###, r###"r#"[A-Za-z!$%&*+\\-./:<=>?@^_~][A-Za-z!$%&*+\\-./:<=>?@^_~0-9]*"#"###, ]; __TERMINAL.iter().enumerate().filter_map(|(index, terminal)| { let next_state = __action(__state, index); if next_state == 0 { None } else { Some(alloc::string::ToString::to_string(terminal)) } }).collect() } pub(crate) struct __StateMachine<'input, 's> where { input: &'input str, __phantom: core::marker::PhantomData<(&'input (), &'s ())>, } impl<'input, 's> __state_machine::ParserDefinition for __StateMachine<'input, 's> where { type Location = usize; type Error = &'static str; type Token = Token<'input>; type TokenIndex = usize; type Symbol = __Symbol<'input>; type Success = Tree; type StateIndex = i8; type Action = i8; type ReduceIndex = i8; type NonterminalIndex = usize; #[inline] fn start_location(&self) -> Self::Location { Default::default() } #[inline] fn start_state(&self) -> Self::StateIndex { 0 } #[inline] fn token_to_index(&self, token: &Self::Token) -> Option { __token_to_integer(token, core::marker::PhantomData::<(&(), &())>) } #[inline] fn action(&self, state: i8, integer: usize) -> i8 { __action(state, integer) } #[inline] fn error_action(&self, state: i8) -> i8 { __action(state, 9 - 1) } #[inline] fn eof_action(&self, state: i8) -> i8 { __EOF_ACTION[state as usize] } #[inline] fn goto(&self, state: i8, nt: usize) -> i8 { __goto(state, nt) } fn token_to_symbol(&self, token_index: usize, token: Self::Token) -> Self::Symbol { __token_to_symbol(token_index, token, core::marker::PhantomData::<(&(), &())>) } fn expected_tokens(&self, state: i8) -> alloc::vec::Vec { __expected_tokens(state) } #[inline] fn uses_error_recovery(&self) -> bool { false } #[inline] fn error_recovery_symbol( &self, recovery: __state_machine::ErrorRecovery, ) -> Self::Symbol { panic!("error recovery not enabled for this grammar") } fn reduce( &mut self, action: i8, start_location: Option<&Self::Location>, states: &mut alloc::vec::Vec, symbols: &mut alloc::vec::Vec<__state_machine::SymbolTriple>, ) -> Option<__state_machine::ParseResult> { __reduce( self.input, action, start_location, states, symbols, core::marker::PhantomData::<(&(), &())>, ) } fn simulate_reduce(&self, action: i8) -> __state_machine::SimulatedReduce { panic!("error recovery not enabled for this grammar") } } fn __token_to_integer< 'input, 's, >( __token: &Token<'input>, _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> Option { match *__token { Token(2, _) if true => Some(0), Token(3, _) if true => Some(1), Token(4, _) if true => Some(2), Token(5, _) if true => Some(3), Token(6, _) if true => Some(4), Token(7, _) if true => Some(5), Token(8, _) if true => Some(6), Token(0, _) if true => Some(7), Token(1, _) if true => Some(8), _ => None, } } fn __token_to_symbol< 'input, 's, >( __token_index: usize, __token: Token<'input>, _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> __Symbol<'input> { match __token_index { 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 => match __token { Token(2, __tok0) | Token(3, __tok0) | Token(4, __tok0) | Token(5, __tok0) | Token(6, __tok0) | Token(7, __tok0) | Token(8, __tok0) | Token(0, __tok0) | Token(1, __tok0) if true => __Symbol::Variant0(__tok0), _ => unreachable!(), }, _ => unreachable!(), } } pub(crate) struct TreeParser { builder: __lalrpop_util::lexer::MatcherBuilder, _priv: (), } impl TreeParser { pub(crate) fn new() -> TreeParser { let __builder = super::__intern_token::new_builder(); TreeParser { builder: __builder, _priv: (), } } #[allow(dead_code)] pub(crate) fn parse< 'input, 's, >( &self, input: &'input str, ) -> Result, &'static str>> { let mut __tokens = self.builder.matcher(input); __state_machine::Parser::drive( __StateMachine { input, __phantom: core::marker::PhantomData::<(&(), &())>, }, __tokens, ) } } pub(crate) fn __reduce< 'input, 's, >( input: &'input str, __action: i8, __lookahead_start: Option<&usize>, __states: &mut alloc::vec::Vec, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> Option, &'static str>>> { let (__pop_states, __nonterminal) = match __action { 0 => { __reduce0(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) } 1 => { __reduce1(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) } 2 => { __reduce2(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) } 3 => { __reduce3(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) } 4 => { __reduce4(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) } 5 => { __reduce5(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) } 6 => { __reduce6(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) } 7 => { __reduce7(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) } 8 => { __reduce8(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) } 9 => { __reduce9(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) } 10 => { __reduce10(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) } 11 => { __reduce11(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) } 12 => { __reduce12(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) } 13 => { __reduce13(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) } 14 => { __reduce14(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) } 15 => { __reduce15(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) } 16 => { __reduce16(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) } 17 => { __reduce17(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) } 18 => { __reduce18(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) } 19 => { __reduce19(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) } 20 => { __reduce20(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) } 21 => { __reduce21(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) } 22 => { __reduce22(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) } 23 => { __reduce23(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) } 24 => { // __Tree = Tree => ActionFn(0); let __sym0 = __pop_Variant9(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); let __nt = super::__action0::<>(input, __sym0); return Some(Ok(__nt)); } _ => panic!("invalid action code {}", __action) }; let __states_len = __states.len(); __states.truncate(__states_len - __pop_states); let __state = *__states.last().unwrap(); let __next_state = __goto(__state, __nonterminal); __states.push(__next_state); None } #[inline(never)] fn __symbol_type_mismatch() -> ! { panic!("symbol type mismatch") } fn __pop_Variant1< 'input, >( __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> ) -> (usize, Box, usize) { match __symbols.pop() { Some((__l, __Symbol::Variant1(__v), __r)) => (__l, __v, __r), _ => __symbol_type_mismatch() } } fn __pop_Variant3< 'input, >( __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> ) -> (usize, Literal, usize) { match __symbols.pop() { Some((__l, __Symbol::Variant3(__v), __r)) => (__l, __v, __r), _ => __symbol_type_mismatch() } } fn __pop_Variant6< 'input, >( __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> ) -> (usize, Rc<[String]>, usize) { match __symbols.pop() { Some((__l, __Symbol::Variant6(__v), __r)) => (__l, __v, __r), _ => __symbol_type_mismatch() } } fn __pop_Variant5< 'input, >( __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> ) -> (usize, Rc, usize) { match __symbols.pop() { Some((__l, __Symbol::Variant5(__v), __r)) => (__l, __v, __r), _ => __symbol_type_mismatch() } } fn __pop_Variant7< 'input, >( __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> ) -> (usize, String, usize) { match __symbols.pop() { Some((__l, __Symbol::Variant7(__v), __r)) => (__l, __v, __r), _ => __symbol_type_mismatch() } } fn __pop_Variant9< 'input, >( __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> ) -> (usize, Tree, usize) { match __symbols.pop() { Some((__l, __Symbol::Variant9(__v), __r)) => (__l, __v, __r), _ => __symbol_type_mismatch() } } fn __pop_Variant8< 'input, >( __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> ) -> (usize, alloc::vec::Vec, usize) { match __symbols.pop() { Some((__l, __Symbol::Variant8(__v), __r)) => (__l, __v, __r), _ => __symbol_type_mismatch() } } fn __pop_Variant10< 'input, >( __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> ) -> (usize, alloc::vec::Vec, usize) { match __symbols.pop() { Some((__l, __Symbol::Variant10(__v), __r)) => (__l, __v, __r), _ => __symbol_type_mismatch() } } fn __pop_Variant2< 'input, >( __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> ) -> (usize, bool, usize) { match __symbols.pop() { Some((__l, __Symbol::Variant2(__v), __r)) => (__l, __v, __r), _ => __symbol_type_mismatch() } } fn __pop_Variant4< 'input, >( __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> ) -> (usize, f64, usize) { match __symbols.pop() { Some((__l, __Symbol::Variant4(__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, 's, >( input: &'input str, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { // BTree = Box => ActionFn(7); let __sym0 = __pop_Variant1(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); let __nt = super::__action7::<>(input, __sym0); __symbols.push((__start, __Symbol::Variant1(__nt), __end)); (1, 0) } pub(crate) fn __reduce1< 'input, 's, >( input: &'input str, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { // Bool = "#t" => ActionFn(13); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); let __nt = super::__action13::<>(input, __sym0); __symbols.push((__start, __Symbol::Variant2(__nt), __end)); (1, 1) } pub(crate) fn __reduce2< 'input, 's, >( input: &'input str, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { // Bool = "#f" => ActionFn(14); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); let __nt = super::__action14::<>(input, __sym0); __symbols.push((__start, __Symbol::Variant2(__nt), __end)); (1, 1) } pub(crate) fn __reduce3< 'input, 's, >( input: &'input str, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { // Box = Tree => ActionFn(15); let __sym0 = __pop_Variant9(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); let __nt = super::__action15::<>(input, __sym0); __symbols.push((__start, __Symbol::Variant1(__nt), __end)); (1, 2) } pub(crate) fn __reduce4< 'input, 's, >( input: &'input str, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { // Literal = Sym => ActionFn(8); let __sym0 = __pop_Variant7(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); let __nt = super::__action8::<>(input, __sym0); __symbols.push((__start, __Symbol::Variant3(__nt), __end)); (1, 3) } pub(crate) fn __reduce5< 'input, 's, >( input: &'input str, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { // Literal = Num => ActionFn(9); let __sym0 = __pop_Variant4(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); let __nt = super::__action9::<>(input, __sym0); __symbols.push((__start, __Symbol::Variant3(__nt), __end)); (1, 3) } pub(crate) fn __reduce6< 'input, 's, >( input: &'input str, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { // Literal = Bool => ActionFn(10); let __sym0 = __pop_Variant2(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); let __nt = super::__action10::<>(input, __sym0); __symbols.push((__start, __Symbol::Variant3(__nt), __end)); (1, 3) } pub(crate) fn __reduce7< 'input, 's, >( input: &'input str, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { // Num = r#"[0-9]+(\\.[0-9]+)?"# => ActionFn(12); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); let __nt = super::__action12::<>(input, __sym0); __symbols.push((__start, __Symbol::Variant4(__nt), __end)); (1, 4) } pub(crate) fn __reduce8< 'input, 's, >( input: &'input str, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { // Rc = Tree => ActionFn(16); let __sym0 = __pop_Variant9(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); let __nt = super::__action16::<>(input, __sym0); __symbols.push((__start, __Symbol::Variant5(__nt), __end)); (1, 5) } pub(crate) fn __reduce9< 'input, 's, >( input: &'input str, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { // RcSlice = => ActionFn(24); let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); let __end = __start.clone(); let __nt = super::__action24::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (0, 6) } pub(crate) fn __reduce10< 'input, 's, >( input: &'input str, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { // RcSlice = Sym+ => ActionFn(25); let __sym0 = __pop_Variant8(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); let __nt = super::__action25::<>(input, __sym0); __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 6) } pub(crate) fn __reduce11< 'input, 's, >( input: &'input str, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { // Sym = r#"[A-Za-z!$%&*+\\-./:<=>?@^_~][A-Za-z!$%&*+\\-./:<=>?@^_~0-9]*"# => ActionFn(11); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); let __nt = super::__action11::<>(input, __sym0); __symbols.push((__start, __Symbol::Variant7(__nt), __end)); (1, 7) } pub(crate) fn __reduce12< 'input, 's, >( input: &'input str, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { // Sym* = => ActionFn(20); let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); let __end = __start.clone(); let __nt = super::__action20::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant8(__nt), __end)); (0, 8) } pub(crate) fn __reduce13< 'input, 's, >( input: &'input str, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { // Sym* = Sym+ => ActionFn(21); let __sym0 = __pop_Variant8(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); let __nt = super::__action21::<>(input, __sym0); __symbols.push((__start, __Symbol::Variant8(__nt), __end)); (1, 8) } pub(crate) fn __reduce14< 'input, 's, >( input: &'input str, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { // Sym+ = Sym => ActionFn(22); let __sym0 = __pop_Variant7(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); let __nt = super::__action22::<>(input, __sym0); __symbols.push((__start, __Symbol::Variant8(__nt), __end)); (1, 9) } pub(crate) fn __reduce15< 'input, 's, >( input: &'input str, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { // Sym+ = Sym+, Sym => ActionFn(23); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant7(__symbols); let __sym0 = __pop_Variant8(__symbols); let __start = __sym0.0.clone(); let __end = __sym1.2.clone(); let __nt = super::__action23::<>(input, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant8(__nt), __end)); (2, 9) } pub(crate) fn __reduce16< 'input, 's, >( input: &'input str, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { // Tree = "(", Tree+, ")" => ActionFn(1); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant10(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0.clone(); let __end = __sym2.2.clone(); let __nt = super::__action1::<>(input, __sym0, __sym1, __sym2); __symbols.push((__start, __Symbol::Variant9(__nt), __end)); (3, 10) } pub(crate) fn __reduce17< 'input, 's, >( input: &'input str, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { // Tree = "(", "define", Sym, BTree, ")" => ActionFn(2); assert!(__symbols.len() >= 5); let __sym4 = __pop_Variant0(__symbols); let __sym3 = __pop_Variant1(__symbols); let __sym2 = __pop_Variant7(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0.clone(); let __end = __sym4.2.clone(); let __nt = super::__action2::<>(input, __sym0, __sym1, __sym2, __sym3, __sym4); __symbols.push((__start, __Symbol::Variant9(__nt), __end)); (5, 10) } pub(crate) fn __reduce18< 'input, 's, >( input: &'input str, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { // Tree = "(", "define", "(", Sym, RcSlice, ")", Rc, ")" => ActionFn(3); assert!(__symbols.len() >= 8); let __sym7 = __pop_Variant0(__symbols); let __sym6 = __pop_Variant5(__symbols); let __sym5 = __pop_Variant0(__symbols); let __sym4 = __pop_Variant6(__symbols); let __sym3 = __pop_Variant7(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0.clone(); let __end = __sym7.2.clone(); let __nt = super::__action3::<>(input, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7); __symbols.push((__start, __Symbol::Variant9(__nt), __end)); (8, 10) } pub(crate) fn __reduce19< 'input, 's, >( input: &'input str, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { // Tree = "(", "if", Tree, Tree, Tree, ")" => ActionFn(4); assert!(__symbols.len() >= 6); let __sym5 = __pop_Variant0(__symbols); let __sym4 = __pop_Variant9(__symbols); let __sym3 = __pop_Variant9(__symbols); let __sym2 = __pop_Variant9(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0.clone(); let __end = __sym5.2.clone(); let __nt = super::__action4::<>(input, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5); __symbols.push((__start, __Symbol::Variant9(__nt), __end)); (6, 10) } pub(crate) fn __reduce20< 'input, 's, >( input: &'input str, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { // Tree = "(", "lambda (", RcSlice, ")", Rc, ")" => ActionFn(5); assert!(__symbols.len() >= 6); let __sym5 = __pop_Variant0(__symbols); let __sym4 = __pop_Variant5(__symbols); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant6(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0.clone(); let __end = __sym5.2.clone(); let __nt = super::__action5::<>(input, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5); __symbols.push((__start, __Symbol::Variant9(__nt), __end)); (6, 10) } pub(crate) fn __reduce21< 'input, 's, >( input: &'input str, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { // Tree = Literal => ActionFn(6); let __sym0 = __pop_Variant3(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); let __nt = super::__action6::<>(input, __sym0); __symbols.push((__start, __Symbol::Variant9(__nt), __end)); (1, 10) } pub(crate) fn __reduce22< 'input, 's, >( input: &'input str, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { // Tree+ = Tree => ActionFn(18); let __sym0 = __pop_Variant9(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); let __nt = super::__action18::<>(input, __sym0); __symbols.push((__start, __Symbol::Variant10(__nt), __end)); (1, 11) } pub(crate) fn __reduce23< 'input, 's, >( input: &'input str, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { // Tree+ = Tree+, Tree => ActionFn(19); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant9(__symbols); let __sym0 = __pop_Variant10(__symbols); let __start = __sym0.0.clone(); let __end = __sym1.2.clone(); let __nt = super::__action19::<>(input, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant10(__nt), __end)); (2, 11) } } pub(crate) use self::__parse__Tree::TreeParser; #[cfg_attr(rustfmt, rustfmt_skip)] mod __intern_token { #![allow(unused_imports)] use crate::{Tree, Literal, Lambda}; use std::rc::Rc; #[allow(unused_extern_crates)] extern crate lalrpop_util as __lalrpop_util; #[allow(unused_imports)] use self::__lalrpop_util::state_machine as __state_machine; extern crate core; extern crate alloc; pub fn new_builder() -> __lalrpop_util::lexer::MatcherBuilder { let __strs: &[(&str, bool)] = &[ ("^([0-9]+(\\.[0-9]+)?)", false), ("^([!\\$-\\&\\*-\\+\\--/:<-Z\\^-_a-z\\~][!\\$-\\&\\*-\\+\\--:<-Z\\^-_a-z\\~]*)", false), ("^(\\#f)", false), ("^(\\#t)", false), ("^(\\()", false), ("^(\\))", false), ("^(define)", false), ("^(if)", false), ("^(lambda \\()", false), (r"^(\s*)", true), ]; __lalrpop_util::lexer::MatcherBuilder::new(__strs.iter().copied()).unwrap() } } pub(crate) use self::__lalrpop_util::lexer::Token; #[allow(unused_variables)] fn __action0< 'input, 's, >( input: &'input str, (_, __0, _): (usize, Tree, usize), ) -> Tree { __0 } #[allow(unused_variables)] fn __action1< 'input, 's, >( input: &'input str, (_, _, _): (usize, &'input str, usize), (_, __0, _): (usize, alloc::vec::Vec, usize), (_, _, _): (usize, &'input str, usize), ) -> Tree { Tree::Branch(__0) } #[allow(unused_variables)] fn __action2< 'input, 's, >( input: &'input str, (_, _, _): (usize, &'input str, usize), (_, _, _): (usize, &'input str, usize), (_, __0, _): (usize, String, usize), (_, __1, _): (usize, Box, usize), (_, _, _): (usize, &'input str, usize), ) -> Tree { Tree::Define(__0, __1) } #[allow(unused_variables)] fn __action3< 'input, 's, >( input: &'input str, (_, _, _): (usize, &'input str, usize), (_, _, _): (usize, &'input str, usize), (_, _, _): (usize, &'input str, usize), (_, name, _): (usize, String, usize), (_, args, _): (usize, Rc<[String]>, usize), (_, _, _): (usize, &'input str, usize), (_, body, _): (usize, Rc, usize), (_, _, _): (usize, &'input str, usize), ) -> Tree { Tree::Define(name, Box::new(Tree::Lambda(Lambda(args, body)))) } #[allow(unused_variables)] fn __action4< 'input, 's, >( input: &'input str, (_, _, _): (usize, &'input str, usize), (_, _, _): (usize, &'input str, usize), (_, __0, _): (usize, Tree, usize), (_, __1, _): (usize, Tree, usize), (_, __2, _): (usize, Tree, usize), (_, _, _): (usize, &'input str, usize), ) -> Tree { Tree::If(Box::new([__0, __1, __2])) } #[allow(unused_variables)] fn __action5< 'input, 's, >( input: &'input str, (_, _, _): (usize, &'input str, usize), (_, _, _): (usize, &'input str, usize), (_, __0, _): (usize, Rc<[String]>, usize), (_, _, _): (usize, &'input str, usize), (_, __1, _): (usize, Rc, usize), (_, _, _): (usize, &'input str, usize), ) -> Tree { Tree::Lambda(Lambda(__0, __1)) } #[allow(unused_variables)] fn __action6< 'input, 's, >( input: &'input str, (_, __0, _): (usize, Literal, usize), ) -> Tree { Tree::Leaf(__0) } #[allow(unused_variables)] fn __action7< 'input, 's, >( input: &'input str, (_, __0, _): (usize, Box, usize), ) -> Box { __0 } #[allow(unused_variables)] fn __action8< 'input, 's, >( input: &'input str, (_, __0, _): (usize, String, usize), ) -> Literal { Literal::Sym(__0) } #[allow(unused_variables)] fn __action9< 'input, 's, >( input: &'input str, (_, __0, _): (usize, f64, usize), ) -> Literal { Literal::Num(__0) } #[allow(unused_variables)] fn __action10< 'input, 's, >( input: &'input str, (_, __0, _): (usize, bool, usize), ) -> Literal { Literal::Bool(__0) } #[allow(unused_variables)] fn __action11< 'input, 's, >( input: &'input str, (_, __0, _): (usize, &'input str, usize), ) -> String { __0.to_owned() } #[allow(unused_variables)] fn __action12< 'input, 's, >( input: &'input str, (_, __0, _): (usize, &'input str, usize), ) -> f64 { __0.parse().unwrap() } #[allow(unused_variables)] fn __action13< 'input, 's, >( input: &'input str, (_, __0, _): (usize, &'input str, usize), ) -> bool { true } #[allow(unused_variables)] fn __action14< 'input, 's, >( input: &'input str, (_, __0, _): (usize, &'input str, usize), ) -> bool { false } #[allow(unused_variables)] fn __action15< 'input, 's, >( input: &'input str, (_, __0, _): (usize, Tree, usize), ) -> Box { Box::new(__0) } #[allow(unused_variables)] fn __action16< 'input, 's, >( input: &'input str, (_, __0, _): (usize, Tree, usize), ) -> Rc { Rc::new(__0) } #[allow(unused_variables)] fn __action17< 'input, 's, >( input: &'input str, (_, __0, _): (usize, alloc::vec::Vec, usize), ) -> Rc<[String]> { __0.into() } #[allow(unused_variables)] fn __action18< 'input, 's, >( input: &'input str, (_, __0, _): (usize, Tree, usize), ) -> alloc::vec::Vec { alloc::vec![__0] } #[allow(unused_variables)] fn __action19< 'input, 's, >( input: &'input str, (_, v, _): (usize, alloc::vec::Vec, usize), (_, e, _): (usize, Tree, usize), ) -> alloc::vec::Vec { { let mut v = v; v.push(e); v } } #[allow(unused_variables)] fn __action20< 'input, 's, >( input: &'input str, __lookbehind: &usize, __lookahead: &usize, ) -> alloc::vec::Vec { alloc::vec![] } #[allow(unused_variables)] fn __action21< 'input, 's, >( input: &'input str, (_, v, _): (usize, alloc::vec::Vec, usize), ) -> alloc::vec::Vec { v } #[allow(unused_variables)] fn __action22< 'input, 's, >( input: &'input str, (_, __0, _): (usize, String, usize), ) -> alloc::vec::Vec { alloc::vec![__0] } #[allow(unused_variables)] fn __action23< 'input, 's, >( input: &'input str, (_, v, _): (usize, alloc::vec::Vec, usize), (_, e, _): (usize, String, usize), ) -> alloc::vec::Vec { { let mut v = v; v.push(e); v } } #[allow(unused_variables)] fn __action24< 'input, 's, >( input: &'input str, __lookbehind: &usize, __lookahead: &usize, ) -> Rc<[String]> { let __start0 = __lookbehind.clone(); let __end0 = __lookahead.clone(); let __temp0 = __action20( input, &__start0, &__end0, ); let __temp0 = (__start0, __temp0, __end0); __action17( input, __temp0, ) } #[allow(unused_variables)] fn __action25< 'input, 's, >( input: &'input str, __0: (usize, alloc::vec::Vec, usize), ) -> Rc<[String]> { let __start0 = __0.0.clone(); let __end0 = __0.2.clone(); let __temp0 = __action21( input, __0, ); let __temp0 = (__start0, __temp0, __end0); __action17( input, __temp0, ) } pub trait __ToTriple<'input, 's, > { fn to_triple(value: Self) -> Result<(usize,Token<'input>,usize), __lalrpop_util::ParseError, &'static str>>; } impl<'input, 's, > __ToTriple<'input, 's, > for (usize, Token<'input>, usize) { fn to_triple(value: Self) -> Result<(usize,Token<'input>,usize), __lalrpop_util::ParseError, &'static str>> { Ok(value) } } impl<'input, 's, > __ToTriple<'input, 's, > for Result<(usize, Token<'input>, usize), &'static str> { fn to_triple(value: Self) -> Result<(usize,Token<'input>,usize), __lalrpop_util::ParseError, &'static str>> { match value { Ok(v) => Ok(v), Err(error) => Err(__lalrpop_util::ParseError::User { error }), } } }