diff --git a/src/ast.rs b/src/ast.rs index d4029e6..6d99b4b 100644 --- a/src/ast.rs +++ b/src/ast.rs @@ -5,6 +5,7 @@ use std::rc::Rc; crate enum Tree { Leaf(Literal), Define(String, Box), + Set(String, Box), If(Box<[Tree; 3]>), // Its easier to box the lambdas in the parser than the vm, as // here we see all of them exactly once diff --git a/src/eval.rs b/src/eval.rs index 5eaf1c6..fb4d850 100644 --- a/src/eval.rs +++ b/src/eval.rs @@ -70,6 +70,11 @@ pub(crate) fn eval(t: &ast::Tree, env: Rc>) -> Result { + let val = eval(to, Rc::clone(&env))?; + env.borrow_mut().set(name, val)?; + Value::Trap + } ast::Tree::If(box [cond, tcase, fcase]) => { let b = eval(cond, Rc::clone(&env))?.as_bool()?; let body = if b { tcase } else { fcase }; @@ -134,8 +139,20 @@ impl Env { pub(crate) fn define(&mut self, name: String, val: Value) { assert_ne!(val, Value::Trap); // TODO: Better error + // TODO: Error on previous def self.vars.insert(name, val); } + + crate fn set(&mut self, name: &str, val: Value) -> Result<(), RTError> { + if let Some(loc) = self.vars.get_mut(name) { + *loc = val; + Ok(()) + } else if let Some(parent) = &self.enclosing { + parent.borrow_mut().set(name, val) + } else { + err(format!("Tried to `set!` un `define`d var `{}`", name)) + } + } } pub(crate) fn default_env() -> Env { diff --git a/src/grammar.lalrpop b/src/grammar.lalrpop index 3aed6d9..b85479b 100644 --- a/src/grammar.lalrpop +++ b/src/grammar.lalrpop @@ -21,6 +21,7 @@ pub(crate) Tree: Tree = { => Tree::Define(name, Box::new(Tree::Func(Rc::new(Func{args, body})))), "(" "if" ")" => Tree::If(Box::new([<>])), "(" "lambda (" ")" ")" => Tree::Func(Rc::new(Func{<>})), + "(" "set!" ")" => Tree::Set(<>), Literal => Tree::Leaf(<>), } diff --git a/src/grammar.rs b/src/grammar.rs index dea8cd9..8b7d0b8 100644 --- a/src/grammar.rs +++ b/src/grammar.rs @@ -1,13 +1,13 @@ // auto-generated: "lalrpop 0.19.6" -// sha3: e06bc49958cb5e211ea88ac1ea9d95dffc9b12e0e8f9e43b4681a168821c +// sha3: 5cdf62b36e7f305a16087e7575bb60a55df0da8fdd57413f4ded28c458e7da use crate::ast::*; 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 alloc; extern crate core; +extern crate alloc; #[cfg_attr(rustfmt, rustfmt_skip)] mod __parse__File { @@ -39,114 +39,122 @@ mod __parse__File { } const __ACTION: &[i8] = &[ // State 0 - 28, 4, 29, 5, 0, 0, 0, 0, 0, 0, 30, 31, + 30, 4, 31, 5, 0, 0, 0, 0, 0, 0, 0, 32, 33, // State 1 - 28, 0, 29, 5, 0, 0, 0, 0, 0, 0, 30, 31, + 30, 0, 31, 5, 0, 0, 0, 0, 0, 0, 0, 32, 33, // State 2 - 28, 0, 29, 5, -31, 0, 0, 0, 0, 0, 30, 31, + 30, 0, 31, 5, -32, 0, 0, 0, 0, 0, 0, 32, 33, // State 3 - 0, 0, 0, 0, 0, 0, 0, 0, 35, 36, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 37, 38, 0, 0, 0, // State 4 - 28, 0, 29, 5, 0, 7, 8, 9, 0, 0, 30, 31, + 30, 0, 31, 5, 0, 7, 8, 9, 0, 0, 10, 32, 33, // State 5 - 28, 0, 29, 5, 37, 0, 0, 0, 0, 0, 30, 31, + 30, 0, 31, 5, 39, 0, 0, 0, 0, 0, 0, 32, 33, // State 6 - 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 31, + 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 33, // State 7 - 28, 0, 29, 5, 0, 0, 0, 0, 0, 0, 30, 31, + 30, 0, 31, 5, 0, 0, 0, 0, 0, 0, 0, 32, 33, // State 8 - 0, 0, 0, 0, 14, 0, 0, 0, 0, 0, 0, 31, + 0, 0, 0, 0, 15, 0, 0, 0, 0, 0, 0, 0, 33, // State 9 - 28, 0, 29, 5, 0, 0, 0, 0, 0, 0, 30, 31, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, // State 10 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 31, + 30, 0, 31, 5, 0, 0, 0, 0, 0, 0, 0, 32, 33, // State 11 - 28, 0, 29, 5, 0, 0, 0, 0, 0, 0, 30, 31, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, // State 12 - 0, 0, 0, 0, 17, 0, 0, 0, 0, 0, 0, 31, + 30, 0, 31, 5, 0, 0, 0, 0, 0, 0, 0, 32, 33, // State 13 - 28, 0, 29, 5, 0, 0, 0, 0, 0, 0, 30, 31, + 0, 0, 0, 0, 19, 0, 0, 0, 0, 0, 0, 0, 33, // State 14 - 0, 0, 0, 0, 19, 0, 0, 0, 0, 0, 0, 31, + 30, 0, 31, 5, 0, 0, 0, 0, 0, 0, 0, 32, 33, // State 15 - 28, 0, 29, 5, 0, 0, 0, 0, 0, 0, 30, 31, + 30, 0, 31, 5, 0, 0, 0, 0, 0, 0, 0, 32, 33, // State 16 - 28, 0, 29, 5, 0, 0, 0, 0, 0, 0, 30, 31, + 0, 0, 0, 0, 21, 0, 0, 0, 0, 0, 0, 0, 33, // State 17 - 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 31, + 30, 0, 31, 5, 0, 0, 0, 0, 0, 0, 0, 32, 33, // State 18 - 28, 0, 29, 5, 0, 0, 0, 0, 0, 0, 30, 31, + 30, 0, 31, 5, 0, 0, 0, 0, 0, 0, 0, 32, 33, // State 19 - 28, 0, 29, 5, 0, 0, 0, 0, 0, 0, 30, 31, + 0, 0, 0, 0, 22, 0, 0, 0, 0, 0, 0, 0, 33, // State 20 - -14, 0, -14, -14, -14, 0, 0, 0, 0, 0, -14, -14, + 30, 0, 31, 5, 0, 0, 0, 0, 0, 0, 0, 32, 33, // State 21 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 30, 0, 31, 5, 0, 0, 0, 0, 0, 0, 0, 32, 33, // State 22 - -28, 0, -28, -28, -28, 0, 0, 0, 0, 0, -28, -28, + -14, 0, -14, -14, -14, 0, 0, 0, 0, 0, 0, -14, -14, // State 23 - -13, 0, -13, -13, -13, 0, 0, 0, 0, 0, -13, -13, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // State 24 - -12, 0, -12, -12, -12, 0, 0, 0, 0, 0, -12, -12, + -29, 0, -29, -29, -29, 0, 0, 0, 0, 0, 0, -29, -29, // State 25 - -29, 0, -29, -29, -29, 0, 0, 0, 0, 0, -29, -29, + -13, 0, -13, -13, -13, 0, 0, 0, 0, 0, 0, -13, -13, // State 26 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + -12, 0, -12, -12, -12, 0, 0, 0, 0, 0, 0, -12, -12, // State 27 - -3, 0, -3, -3, -3, 0, 0, 0, 0, 0, -3, -3, + -30, 0, -30, -30, -30, 0, 0, 0, 0, 0, 0, -30, -30, // State 28 - -2, 0, -2, -2, -2, 0, 0, 0, 0, 0, -2, -2, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // State 29 - -15, 0, -15, -15, -15, 0, 0, 0, 0, 0, -15, -15, + -3, 0, -3, -3, -3, 0, 0, 0, 0, 0, 0, -3, -3, // State 30 - -16, 0, -16, -16, -16, 0, 0, 0, 0, 0, -16, -16, + -2, 0, -2, -2, -2, 0, 0, 0, 0, 0, 0, -2, -2, // State 31 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + -15, 0, -15, -15, -15, 0, 0, 0, 0, 0, 0, -15, -15, // State 32 - -30, 0, -30, -30, -30, 0, 0, 0, 0, 0, -30, -30, + -16, 0, -16, -16, -16, 0, 0, 0, 0, 0, 0, -16, -16, // State 33 - -7, 0, -7, -7, 0, 0, 0, 0, 0, 0, -7, -7, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // State 34 - -11, 0, -11, -11, 0, 0, 0, 0, 0, 0, -11, -11, + -31, 0, -31, -31, -31, 0, 0, 0, 0, 0, 0, -31, -31, // State 35 - -10, 0, -10, -10, 0, 0, 0, 0, 0, 0, -10, -10, + -7, 0, -7, -7, 0, 0, 0, 0, 0, 0, 0, -7, -7, // State 36 - -21, 0, -21, -21, -21, 0, 0, 0, 0, 0, -21, -21, + -11, 0, -11, -11, 0, 0, 0, 0, 0, 0, 0, -11, -11, // State 37 - 0, 0, 0, 0, -19, 0, 0, 0, 0, 0, 0, -19, + -10, 0, -10, -10, 0, 0, 0, 0, 0, 0, 0, -10, -10, // State 38 - 0, 0, 0, 0, 44, 0, 0, 0, 0, 0, 0, 0, + -21, 0, -21, -21, -21, 0, 0, 0, 0, 0, 0, -21, -21, // State 39 - 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, -19, 0, 0, 0, 0, 0, 0, 0, -19, // State 40 - 0, 0, 0, 0, -4, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 47, 0, 0, 0, 0, 0, 0, 0, 0, // State 41 - 0, 0, 0, 0, -20, 0, 0, 0, 0, 0, 0, -20, + 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, // State 42 - 0, 0, 0, 0, 47, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, -4, 0, 0, 0, 0, 0, 0, 0, 0, // State 43 - -22, 0, -22, -22, -22, 0, 0, 0, 0, 0, -22, -22, + 0, 0, 0, 0, -20, 0, 0, 0, 0, 0, 0, 0, -20, // State 44 - 0, 0, 0, 0, 49, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 50, 0, 0, 0, 0, 0, 0, 0, 0, // State 45 - 0, 0, 0, 0, 50, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 51, 0, 0, 0, 0, 0, 0, 0, 0, // State 46 - -26, 0, -26, -26, -26, 0, 0, 0, 0, 0, -26, -26, + -22, 0, -22, -22, -22, 0, 0, 0, 0, 0, 0, -22, -22, // State 47 - 0, 0, 0, 0, 52, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 53, 0, 0, 0, 0, 0, 0, 0, 0, // State 48 - -25, 0, -25, -25, -25, 0, 0, 0, 0, 0, -25, -25, + 0, 0, 0, 0, 54, 0, 0, 0, 0, 0, 0, 0, 0, // State 49 - -27, 0, -27, -27, -27, 0, 0, 0, 0, 0, -27, -27, + -26, 0, -26, -26, -26, 0, 0, 0, 0, 0, 0, -26, -26, // State 50 - 0, 0, 0, 0, 53, 0, 0, 0, 0, 0, 0, 0, + -28, 0, -28, -28, -28, 0, 0, 0, 0, 0, 0, -28, -28, // State 51 - -23, 0, -23, -23, -23, 0, 0, 0, 0, 0, -23, -23, + 0, 0, 0, 0, 56, 0, 0, 0, 0, 0, 0, 0, 0, // State 52 - -24, 0, -24, -24, -24, 0, 0, 0, 0, 0, -24, -24, + -25, 0, -25, -25, -25, 0, 0, 0, 0, 0, 0, -25, -25, + // State 53 + -27, 0, -27, -27, -27, 0, 0, 0, 0, 0, 0, -27, -27, + // State 54 + 0, 0, 0, 0, 57, 0, 0, 0, 0, 0, 0, 0, 0, + // State 55 + -23, 0, -23, -23, -23, 0, 0, 0, 0, 0, 0, -23, -23, + // State 56 + -24, 0, -24, -24, -24, 0, 0, 0, 0, 0, 0, -24, -24, ]; fn __action(state: i8, integer: usize) -> i8 { - __ACTION[(state as usize) * 12 + integer] + __ACTION[(state as usize) * 13 + integer] } const __EOF_ACTION: &[i8] = &[ // State 0 @@ -154,7 +162,7 @@ mod __parse__File { // State 1 0, // State 2 - -31, + -32, // State 3 0, // State 4 @@ -190,43 +198,43 @@ mod __parse__File { // State 19 0, // State 20 - -14, + 0, // State 21 - -32, + 0, // State 22 - -28, + -14, // State 23 - -13, + -33, // State 24 - -12, - // State 25 -29, + // State 25 + -13, // State 26 - -6, + -12, // State 27 - -3, - // State 28 - -2, - // State 29 - -15, - // State 30 - -16, - // State 31 - -5, - // State 32 -30, + // State 28 + -6, + // State 29 + -3, + // State 30 + -2, + // State 31 + -15, + // State 32 + -16, // State 33 - 0, + -5, // State 34 - 0, + -31, // State 35 0, // State 36 - -21, + 0, // State 37 0, // State 38 - 0, + -21, // State 39 0, // State 40 @@ -236,66 +244,78 @@ mod __parse__File { // State 42 0, // State 43 - -22, + 0, // State 44 0, // State 45 0, // State 46 - -26, + -22, // State 47 0, // State 48 - -25, - // State 49 - -27, - // State 50 0, + // State 49 + -26, + // State 50 + -28, // State 51 - -23, + 0, // State 52 + -25, + // State 53 + -27, + // State 54 + 0, + // State 55 + -23, + // State 56 -24, ]; fn __goto(state: i8, nt: usize) -> i8 { match nt { - 0 => 38, - 1 => 20, - 2 => 39, - 3 => 21, + 0 => match state { + 15 => 45, + _ => 40, + }, + 1 => 22, + 2 => 41, + 3 => 23, 4 => 1, - 6 => 33, - 7 => 22, - 8 => 23, + 6 => 35, + 7 => 24, + 8 => 25, 9 => match state { - 6 => 9, - 10 => 14, - 8 | 14 => 37, - 12 | 17 => 41, - _ => 24, + 6 => 10, + 9 => 15, + 11 => 16, + 8 | 16 => 39, + 13 | 19 => 43, + _ => 26, }, 11 => match state { - 14 => 17, - _ => 12, + 16 => 19, + _ => 13, }, 12 => match state { - 7 => 11, - 11 => 15, - 2 | 5 => 32, - 9 => 40, - 15 => 44, - _ => 25, + 7 => 12, + 12 => 17, + 2 | 5 => 34, + 10 | 15 => 42, + 17 => 47, + _ => 27, }, 13 => match state { 4 => 5, _ => 2, }, 14 => match state { - 1 => 31, - 13 => 42, - 16 => 45, - 18 => 47, - 19 => 50, - _ => 26, + 1 => 33, + 14 => 44, + 18 => 48, + 20 => 51, + 21 => 54, + _ => 28, }, _ => 0, } @@ -312,6 +332,7 @@ mod __parse__File { r###""lambda (""###, r###""r7rs""###, r###""scheme""###, + r###""set!""###, r###"r#"[0-9]+(\\.[0-9]+)?"#"###, r###"r#"[A-Za-z!$%&*+\\-./:<=>?@^_~][A-Za-z!$%&*+\\-./:<=>?@^_~0-9]*"#"###, ]; @@ -366,7 +387,7 @@ mod __parse__File { #[inline] fn error_action(&self, state: i8) -> i8 { - __action(state, 12 - 1) + __action(state, 13 - 1) } #[inline] @@ -440,8 +461,9 @@ mod __parse__File { Token(9, _) if true => Some(7), Token(10, _) if true => Some(8), Token(11, _) if true => Some(9), - Token(0, _) if true => Some(10), - Token(1, _) if true => Some(11), + Token(12, _) if true => Some(10), + Token(0, _) if true => Some(11), + Token(1, _) if true => Some(12), _ => None, } } @@ -455,8 +477,8 @@ mod __parse__File { ) -> __Symbol<'input> { match __token_index { - 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 => match __token { - Token(2, __tok0) | Token(3, __tok0) | Token(4, __tok0) | Token(5, __tok0) | Token(6, __tok0) | Token(7, __tok0) | Token(8, __tok0) | Token(9, __tok0) | Token(10, __tok0) | Token(11, __tok0) | Token(0, __tok0) | Token(1, __tok0) if true => __Symbol::Variant0(__tok0), + 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 => match __token { + Token(2, __tok0) | Token(3, __tok0) | Token(4, __tok0) | Token(5, __tok0) | Token(6, __tok0) | Token(7, __tok0) | Token(8, __tok0) | Token(9, __tok0) | Token(10, __tok0) | Token(11, __tok0) | Token(12, __tok0) | Token(0, __tok0) | Token(1, __tok0) if true => __Symbol::Variant0(__tok0), _ => unreachable!(), }, _ => unreachable!(), @@ -602,6 +624,9 @@ mod __parse__File { __reduce30(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) } 31 => { + __reduce31(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) + } + 32 => { // __File = File => ActionFn(0); let __sym0 = __pop_Variant3(__symbols); let __start = __sym0.0.clone(); @@ -609,8 +634,8 @@ mod __parse__File { let __nt = super::__action0::<>(input, __sym0); return Some(Ok(__nt)); } - 32 => { - __reduce32(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) + 33 => { + __reduce33(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) } _ => panic!("invalid action code {}", __action) }; @@ -756,11 +781,11 @@ mod __parse__File { _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { - // BTree = Box => ActionFn(10); + // BTree = Box => ActionFn(11); let __sym0 = __pop_Variant1(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action10::<>(input, __sym0); + let __nt = super::__action11::<>(input, __sym0); __symbols.push((__start, __Symbol::Variant1(__nt), __end)); (1, 0) } @@ -774,11 +799,11 @@ mod __parse__File { _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { - // Bool = "#t" => ActionFn(16); + // Bool = "#t" => ActionFn(17); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action16::<>(input, __sym0); + let __nt = super::__action17::<>(input, __sym0); __symbols.push((__start, __Symbol::Variant2(__nt), __end)); (1, 1) } @@ -792,11 +817,11 @@ mod __parse__File { _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { - // Bool = "#f" => ActionFn(17); + // Bool = "#f" => ActionFn(18); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action17::<>(input, __sym0); + let __nt = super::__action18::<>(input, __sym0); __symbols.push((__start, __Symbol::Variant2(__nt), __end)); (1, 1) } @@ -810,11 +835,11 @@ mod __parse__File { _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { - // Box = Tree => ActionFn(21); + // Box = Tree => ActionFn(22); let __sym0 = __pop_Variant10(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action21::<>(input, __sym0); + let __nt = super::__action22::<>(input, __sym0); __symbols.push((__start, __Symbol::Variant1(__nt), __end)); (1, 2) } @@ -828,13 +853,13 @@ mod __parse__File { _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { - // File = Lang, Trees => ActionFn(30); + // File = Lang, Trees => ActionFn(31); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant3(__symbols); let __sym0 = __pop_Variant4(__symbols); let __start = __sym0.0.clone(); let __end = __sym1.2.clone(); - let __nt = super::__action30::<>(input, __sym0, __sym1); + let __nt = super::__action31::<>(input, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant3(__nt), __end)); (2, 3) } @@ -848,11 +873,11 @@ mod __parse__File { _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { - // File = Trees => ActionFn(31); + // File = Trees => ActionFn(32); let __sym0 = __pop_Variant3(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action31::<>(input, __sym0); + let __nt = super::__action32::<>(input, __sym0); __symbols.push((__start, __Symbol::Variant3(__nt), __end)); (1, 3) } @@ -866,13 +891,13 @@ mod __parse__File { _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { - // Lang = "#lang", LangName => ActionFn(18); + // Lang = "#lang", LangName => ActionFn(19); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0.clone(); let __end = __sym1.2.clone(); - let __nt = super::__action18::<>(input, __sym0, __sym1); + let __nt = super::__action19::<>(input, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant4(__nt), __end)); (2, 4) } @@ -886,11 +911,11 @@ mod __parse__File { _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { - // Lang? = Lang => ActionFn(26); + // Lang? = Lang => ActionFn(27); let __sym0 = __pop_Variant4(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action26::<>(input, __sym0); + let __nt = super::__action27::<>(input, __sym0); __symbols.push((__start, __Symbol::Variant5(__nt), __end)); (1, 5) } @@ -904,10 +929,10 @@ mod __parse__File { _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { - // Lang? = => ActionFn(27); + // Lang? = => ActionFn(28); let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); let __end = __start.clone(); - let __nt = super::__action27::<>(input, &__start, &__end); + let __nt = super::__action28::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant5(__nt), __end)); (0, 5) } @@ -921,11 +946,11 @@ mod __parse__File { _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { - // LangName = "scheme" => ActionFn(19); + // LangName = "scheme" => ActionFn(20); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action19::<>(input, __sym0); + let __nt = super::__action20::<>(input, __sym0); __symbols.push((__start, __Symbol::Variant0(__nt), __end)); (1, 6) } @@ -939,11 +964,11 @@ mod __parse__File { _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { - // LangName = "r7rs" => ActionFn(20); + // LangName = "r7rs" => ActionFn(21); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action20::<>(input, __sym0); + let __nt = super::__action21::<>(input, __sym0); __symbols.push((__start, __Symbol::Variant0(__nt), __end)); (1, 6) } @@ -957,11 +982,11 @@ mod __parse__File { _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { - // Literal = Sym => ActionFn(11); + // Literal = Sym => ActionFn(12); let __sym0 = __pop_Variant8(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action11::<>(input, __sym0); + let __nt = super::__action12::<>(input, __sym0); __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 7) } @@ -975,11 +1000,11 @@ mod __parse__File { _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { - // Literal = Num => ActionFn(12); + // Literal = Num => ActionFn(13); let __sym0 = __pop_Variant7(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action12::<>(input, __sym0); + let __nt = super::__action13::<>(input, __sym0); __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 7) } @@ -993,11 +1018,11 @@ mod __parse__File { _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { - // Literal = Bool => ActionFn(13); + // Literal = Bool => ActionFn(14); let __sym0 = __pop_Variant2(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action13::<>(input, __sym0); + let __nt = super::__action14::<>(input, __sym0); __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 7) } @@ -1011,11 +1036,11 @@ mod __parse__File { _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { - // Num = r#"[0-9]+(\\.[0-9]+)?"# => ActionFn(15); + // Num = r#"[0-9]+(\\.[0-9]+)?"# => ActionFn(16); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action15::<>(input, __sym0); + let __nt = super::__action16::<>(input, __sym0); __symbols.push((__start, __Symbol::Variant7(__nt), __end)); (1, 8) } @@ -1029,11 +1054,11 @@ mod __parse__File { _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { - // Sym = r#"[A-Za-z!$%&*+\\-./:<=>?@^_~][A-Za-z!$%&*+\\-./:<=>?@^_~0-9]*"# => ActionFn(14); + // Sym = r#"[A-Za-z!$%&*+\\-./:<=>?@^_~][A-Za-z!$%&*+\\-./:<=>?@^_~0-9]*"# => ActionFn(15); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action14::<>(input, __sym0); + let __nt = super::__action15::<>(input, __sym0); __symbols.push((__start, __Symbol::Variant8(__nt), __end)); (1, 9) } @@ -1047,10 +1072,10 @@ mod __parse__File { _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { - // Sym* = => ActionFn(22); + // Sym* = => ActionFn(23); let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); let __end = __start.clone(); - let __nt = super::__action22::<>(input, &__start, &__end); + let __nt = super::__action23::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant9(__nt), __end)); (0, 10) } @@ -1064,11 +1089,11 @@ mod __parse__File { _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { - // Sym* = Sym+ => ActionFn(23); + // Sym* = Sym+ => ActionFn(24); let __sym0 = __pop_Variant9(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action23::<>(input, __sym0); + let __nt = super::__action24::<>(input, __sym0); __symbols.push((__start, __Symbol::Variant9(__nt), __end)); (1, 10) } @@ -1082,11 +1107,11 @@ mod __parse__File { _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { - // Sym+ = Sym => ActionFn(28); + // Sym+ = Sym => ActionFn(29); let __sym0 = __pop_Variant8(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action28::<>(input, __sym0); + let __nt = super::__action29::<>(input, __sym0); __symbols.push((__start, __Symbol::Variant9(__nt), __end)); (1, 11) } @@ -1100,13 +1125,13 @@ mod __parse__File { _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { - // Sym+ = Sym+, Sym => ActionFn(29); + // Sym+ = Sym+, Sym => ActionFn(30); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant8(__symbols); let __sym0 = __pop_Variant9(__symbols); let __start = __sym0.0.clone(); let __end = __sym1.2.clone(); - let __nt = super::__action29::<>(input, __sym0, __sym1); + let __nt = super::__action30::<>(input, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant9(__nt), __end)); (2, 11) } @@ -1164,7 +1189,7 @@ mod __parse__File { _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { - // Tree = "(", "define", "(", Sym, ")", Trees, ")" => ActionFn(32); + // Tree = "(", "define", "(", Sym, ")", Trees, ")" => ActionFn(33); assert!(__symbols.len() >= 7); let __sym6 = __pop_Variant0(__symbols); let __sym5 = __pop_Variant3(__symbols); @@ -1175,7 +1200,7 @@ mod __parse__File { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0.clone(); let __end = __sym6.2.clone(); - let __nt = super::__action32::<>(input, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6); + let __nt = super::__action33::<>(input, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6); __symbols.push((__start, __Symbol::Variant10(__nt), __end)); (7, 12) } @@ -1189,7 +1214,7 @@ mod __parse__File { _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { - // Tree = "(", "define", "(", Sym, Sym+, ")", Trees, ")" => ActionFn(33); + // Tree = "(", "define", "(", Sym, Sym+, ")", Trees, ")" => ActionFn(34); assert!(__symbols.len() >= 8); let __sym7 = __pop_Variant0(__symbols); let __sym6 = __pop_Variant3(__symbols); @@ -1201,7 +1226,7 @@ mod __parse__File { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0.clone(); let __end = __sym7.2.clone(); - let __nt = super::__action33::<>(input, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7); + let __nt = super::__action34::<>(input, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7); __symbols.push((__start, __Symbol::Variant10(__nt), __end)); (8, 12) } @@ -1239,7 +1264,7 @@ mod __parse__File { _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { - // Tree = "(", "lambda (", ")", Trees, ")" => ActionFn(34); + // Tree = "(", "lambda (", ")", Trees, ")" => ActionFn(35); assert!(__symbols.len() >= 5); let __sym4 = __pop_Variant0(__symbols); let __sym3 = __pop_Variant3(__symbols); @@ -1248,7 +1273,7 @@ mod __parse__File { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0.clone(); let __end = __sym4.2.clone(); - let __nt = super::__action34::<>(input, __sym0, __sym1, __sym2, __sym3, __sym4); + let __nt = super::__action35::<>(input, __sym0, __sym1, __sym2, __sym3, __sym4); __symbols.push((__start, __Symbol::Variant10(__nt), __end)); (5, 12) } @@ -1262,7 +1287,7 @@ mod __parse__File { _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { - // Tree = "(", "lambda (", Sym+, ")", Trees, ")" => ActionFn(35); + // Tree = "(", "lambda (", Sym+, ")", Trees, ")" => ActionFn(36); assert!(__symbols.len() >= 6); let __sym5 = __pop_Variant0(__symbols); let __sym4 = __pop_Variant3(__symbols); @@ -1272,7 +1297,7 @@ mod __parse__File { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0.clone(); let __end = __sym5.2.clone(); - let __nt = super::__action35::<>(input, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5); + let __nt = super::__action36::<>(input, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5); __symbols.push((__start, __Symbol::Variant10(__nt), __end)); (6, 12) } @@ -1286,13 +1311,18 @@ mod __parse__File { _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { - // Tree = Literal => ActionFn(9); - let __sym0 = __pop_Variant6(__symbols); + // Tree = "(", "set!", Sym, BTree, ")" => ActionFn(9); + assert!(__symbols.len() >= 5); + let __sym4 = __pop_Variant0(__symbols); + let __sym3 = __pop_Variant1(__symbols); + let __sym2 = __pop_Variant8(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0.clone(); - let __end = __sym0.2.clone(); - let __nt = super::__action9::<>(input, __sym0); + let __end = __sym4.2.clone(); + let __nt = super::__action9::<>(input, __sym0, __sym1, __sym2, __sym3, __sym4); __symbols.push((__start, __Symbol::Variant10(__nt), __end)); - (1, 12) + (5, 12) } pub(crate) fn __reduce28< 'input, @@ -1304,13 +1334,13 @@ mod __parse__File { _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { - // Tree+ = Tree => ActionFn(24); - let __sym0 = __pop_Variant10(__symbols); + // Tree = Literal => ActionFn(10); + let __sym0 = __pop_Variant6(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action24::<>(input, __sym0); - __symbols.push((__start, __Symbol::Variant3(__nt), __end)); - (1, 13) + let __nt = super::__action10::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant10(__nt), __end)); + (1, 12) } pub(crate) fn __reduce29< 'input, @@ -1322,17 +1352,35 @@ mod __parse__File { _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { - // Tree+ = Tree+, Tree => ActionFn(25); + // Tree+ = Tree => ActionFn(25); + let __sym0 = __pop_Variant10(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action25::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (1, 13) + } + pub(crate) fn __reduce30< + '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(26); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant10(__symbols); let __sym0 = __pop_Variant3(__symbols); let __start = __sym0.0.clone(); let __end = __sym1.2.clone(); - let __nt = super::__action25::<>(input, __sym0, __sym1); + let __nt = super::__action26::<>(input, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant3(__nt), __end)); (2, 13) } - pub(crate) fn __reduce30< + pub(crate) fn __reduce31< 'input, 's, >( @@ -1350,7 +1398,7 @@ mod __parse__File { __symbols.push((__start, __Symbol::Variant3(__nt), __end)); (1, 14) } - pub(crate) fn __reduce32< + pub(crate) fn __reduce33< 'input, 's, >( @@ -1401,100 +1449,108 @@ mod __parse__Tree { } const __ACTION: &[i8] = &[ // State 0 - 24, 0, 25, 2, 0, 0, 0, 0, 0, 0, 26, 27, + 26, 0, 27, 2, 0, 0, 0, 0, 0, 0, 0, 28, 29, // State 1 - 24, 0, 25, 2, 0, 4, 5, 6, 0, 0, 26, 27, + 26, 0, 27, 2, 0, 4, 5, 6, 0, 0, 7, 28, 29, // State 2 - 24, 0, 25, 2, 30, 0, 0, 0, 0, 0, 26, 27, + 26, 0, 27, 2, 32, 0, 0, 0, 0, 0, 0, 28, 29, // State 3 - 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 27, + 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 29, // State 4 - 24, 0, 25, 2, 0, 0, 0, 0, 0, 0, 26, 27, + 26, 0, 27, 2, 0, 0, 0, 0, 0, 0, 0, 28, 29, // State 5 - 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 27, + 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 29, // State 6 - 24, 0, 25, 2, 0, 0, 0, 0, 0, 0, 26, 27, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 29, // State 7 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 27, + 26, 0, 27, 2, 0, 0, 0, 0, 0, 0, 0, 28, 29, // State 8 - 24, 0, 25, 2, 0, 0, 0, 0, 0, 0, 26, 27, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 29, // State 9 - 0, 0, 0, 0, 14, 0, 0, 0, 0, 0, 0, 27, + 26, 0, 27, 2, 0, 0, 0, 0, 0, 0, 0, 28, 29, // State 10 - 24, 0, 25, 2, 0, 0, 0, 0, 0, 0, 26, 27, + 0, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 29, // State 11 - 0, 0, 0, 0, 17, 0, 0, 0, 0, 0, 0, 27, + 26, 0, 27, 2, 0, 0, 0, 0, 0, 0, 0, 28, 29, // State 12 - 24, 0, 25, 2, 0, 0, 0, 0, 0, 0, 26, 27, + 26, 0, 27, 2, 0, 0, 0, 0, 0, 0, 0, 28, 29, // State 13 - 24, 0, 25, 2, 0, 0, 0, 0, 0, 0, 26, 27, + 0, 0, 0, 0, 19, 0, 0, 0, 0, 0, 0, 0, 29, // State 14 - 24, 0, 25, 2, -31, 0, 0, 0, 0, 0, 26, 27, + 26, 0, 27, 2, 0, 0, 0, 0, 0, 0, 0, 28, 29, // State 15 - 0, 0, 0, 0, 18, 0, 0, 0, 0, 0, 0, 27, + 26, 0, 27, 2, 0, 0, 0, 0, 0, 0, 0, 28, 29, // State 16 - 24, 0, 25, 2, 0, 0, 0, 0, 0, 0, 26, 27, + 26, 0, 27, 2, -32, 0, 0, 0, 0, 0, 0, 28, 29, // State 17 - 24, 0, 25, 2, 0, 0, 0, 0, 0, 0, 26, 27, + 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 29, // State 18 - -14, 0, -14, -14, -14, 0, 0, 0, 0, 0, -14, -14, + 26, 0, 27, 2, 0, 0, 0, 0, 0, 0, 0, 28, 29, // State 19 - -28, 0, -28, -28, -28, 0, 0, 0, 0, 0, -28, -28, + 26, 0, 27, 2, 0, 0, 0, 0, 0, 0, 0, 28, 29, // State 20 - -13, 0, -13, -13, -13, 0, 0, 0, 0, 0, -13, -13, + -14, 0, -14, -14, -14, 0, 0, 0, 0, 0, 0, -14, -14, // State 21 - -12, 0, -12, -12, -12, 0, 0, 0, 0, 0, -12, -12, + -29, 0, -29, -29, -29, 0, 0, 0, 0, 0, 0, -29, -29, // State 22 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + -13, 0, -13, -13, -13, 0, 0, 0, 0, 0, 0, -13, -13, // State 23 - -3, 0, -3, -3, -3, 0, 0, 0, 0, 0, -3, -3, + -12, 0, -12, -12, -12, 0, 0, 0, 0, 0, 0, -12, -12, // State 24 - -2, 0, -2, -2, -2, 0, 0, 0, 0, 0, -2, -2, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // State 25 - -15, 0, -15, -15, -15, 0, 0, 0, 0, 0, -15, -15, + -3, 0, -3, -3, -3, 0, 0, 0, 0, 0, 0, -3, -3, // State 26 - -16, 0, -16, -16, -16, 0, 0, 0, 0, 0, -16, -16, + -2, 0, -2, -2, -2, 0, 0, 0, 0, 0, 0, -2, -2, // State 27 - -29, 0, -29, -29, -29, 0, 0, 0, 0, 0, -29, -29, + -15, 0, -15, -15, -15, 0, 0, 0, 0, 0, 0, -15, -15, // State 28 - -30, 0, -30, -30, -30, 0, 0, 0, 0, 0, -30, -30, + -16, 0, -16, -16, -16, 0, 0, 0, 0, 0, 0, -16, -16, // State 29 - -21, 0, -21, -21, -21, 0, 0, 0, 0, 0, -21, -21, + -30, 0, -30, -30, -30, 0, 0, 0, 0, 0, 0, -30, -30, // State 30 - 0, 0, 0, 0, -19, 0, 0, 0, 0, 0, 0, -19, + -31, 0, -31, -31, -31, 0, 0, 0, 0, 0, 0, -31, -31, // State 31 - 0, 0, 0, 0, 37, 0, 0, 0, 0, 0, 0, 0, + -21, 0, -21, -21, -21, 0, 0, 0, 0, 0, 0, -21, -21, // State 32 - 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, -19, 0, 0, 0, 0, 0, 0, 0, -19, // State 33 - 0, 0, 0, 0, -4, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 40, 0, 0, 0, 0, 0, 0, 0, 0, // State 34 - 0, 0, 0, 0, -20, 0, 0, 0, 0, 0, 0, -20, + 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, // State 35 - 0, 0, 0, 0, 40, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, -4, 0, 0, 0, 0, 0, 0, 0, 0, // State 36 - -22, 0, -22, -22, -22, 0, 0, 0, 0, 0, -22, -22, + 0, 0, 0, 0, -20, 0, 0, 0, 0, 0, 0, 0, -20, // State 37 - 0, 0, 0, 0, 42, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 43, 0, 0, 0, 0, 0, 0, 0, 0, // State 38 - 0, 0, 0, 0, 43, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 44, 0, 0, 0, 0, 0, 0, 0, 0, // State 39 - -26, 0, -26, -26, -26, 0, 0, 0, 0, 0, -26, -26, + -22, 0, -22, -22, -22, 0, 0, 0, 0, 0, 0, -22, -22, // State 40 - 0, 0, 0, 0, 45, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 46, 0, 0, 0, 0, 0, 0, 0, 0, // State 41 - -25, 0, -25, -25, -25, 0, 0, 0, 0, 0, -25, -25, + 0, 0, 0, 0, 47, 0, 0, 0, 0, 0, 0, 0, 0, // State 42 - -27, 0, -27, -27, -27, 0, 0, 0, 0, 0, -27, -27, + -26, 0, -26, -26, -26, 0, 0, 0, 0, 0, 0, -26, -26, // State 43 - 0, 0, 0, 0, 46, 0, 0, 0, 0, 0, 0, 0, + -28, 0, -28, -28, -28, 0, 0, 0, 0, 0, 0, -28, -28, // State 44 - -23, 0, -23, -23, -23, 0, 0, 0, 0, 0, -23, -23, + 0, 0, 0, 0, 49, 0, 0, 0, 0, 0, 0, 0, 0, // State 45 - -24, 0, -24, -24, -24, 0, 0, 0, 0, 0, -24, -24, + -25, 0, -25, -25, -25, 0, 0, 0, 0, 0, 0, -25, -25, + // State 46 + -27, 0, -27, -27, -27, 0, 0, 0, 0, 0, 0, -27, -27, + // State 47 + 0, 0, 0, 0, 50, 0, 0, 0, 0, 0, 0, 0, 0, + // State 48 + -23, 0, -23, -23, -23, 0, 0, 0, 0, 0, 0, -23, -23, + // State 49 + -24, 0, -24, -24, -24, 0, 0, 0, 0, 0, 0, -24, -24, ]; fn __action(state: i8, integer: usize) -> i8 { - __ACTION[(state as usize) * 12 + integer] + __ACTION[(state as usize) * 13 + integer] } const __EOF_ACTION: &[i8] = &[ // State 0 @@ -1534,33 +1590,33 @@ mod __parse__Tree { // State 17 0, // State 18 - -14, + 0, // State 19 - -28, + 0, // State 20 - -13, + -14, // State 21 - -12, + -29, // State 22 - -33, + -13, // State 23 - -3, + -12, // State 24 - -2, + -34, // State 25 - -15, + -3, // State 26 - -16, + -2, // State 27 - 0, + -15, // State 28 - 0, + -16, // State 29 - -21, + 0, // State 30 0, // State 31 - 0, + -21, // State 32 0, // State 33 @@ -1570,62 +1626,74 @@ mod __parse__Tree { // State 35 0, // State 36 - -22, + 0, // State 37 0, // State 38 0, // State 39 - -26, + -22, // State 40 0, // State 41 - -25, - // State 42 - -27, - // State 43 0, + // State 42 + -26, + // State 43 + -28, // State 44 - -23, + 0, // State 45 + -25, + // State 46 + -27, + // State 47 + 0, + // State 48 + -23, + // State 49 -24, ]; fn __goto(state: i8, nt: usize) -> i8 { match nt { - 0 => 31, - 1 => 18, - 2 => 32, - 7 => 19, - 8 => 20, + 0 => match state { + 12 => 38, + _ => 33, + }, + 1 => 20, + 2 => 34, + 7 => 21, + 8 => 22, 9 => match state { - 3 => 6, - 7 => 11, - 5 | 11 => 30, - 9 | 15 => 34, - _ => 21, + 3 => 7, + 6 => 12, + 8 => 13, + 5 | 13 => 32, + 10 | 17 => 36, + _ => 23, }, 11 => match state { - 11 => 15, - _ => 9, + 13 => 17, + _ => 10, }, 12 => match state { - 4 => 8, - 8 => 12, - 0 => 22, - 2 | 14 => 28, - 6 => 33, - 12 => 37, - _ => 27, + 4 => 9, + 9 => 14, + 0 => 24, + 2 | 16 => 30, + 7 | 12 => 35, + 14 => 40, + _ => 29, }, 13 => match state { 1 => 2, - _ => 14, + _ => 16, }, 14 => match state { - 13 => 38, - 16 => 40, - 17 => 43, - _ => 35, + 15 => 41, + 18 => 44, + 19 => 47, + _ => 37, }, _ => 0, } @@ -1642,6 +1710,7 @@ mod __parse__Tree { r###""lambda (""###, r###""r7rs""###, r###""scheme""###, + r###""set!""###, r###"r#"[0-9]+(\\.[0-9]+)?"#"###, r###"r#"[A-Za-z!$%&*+\\-./:<=>?@^_~][A-Za-z!$%&*+\\-./:<=>?@^_~0-9]*"#"###, ]; @@ -1696,7 +1765,7 @@ mod __parse__Tree { #[inline] fn error_action(&self, state: i8) -> i8 { - __action(state, 12 - 1) + __action(state, 13 - 1) } #[inline] @@ -1770,8 +1839,9 @@ mod __parse__Tree { Token(9, _) if true => Some(7), Token(10, _) if true => Some(8), Token(11, _) if true => Some(9), - Token(0, _) if true => Some(10), - Token(1, _) if true => Some(11), + Token(12, _) if true => Some(10), + Token(0, _) if true => Some(11), + Token(1, _) if true => Some(12), _ => None, } } @@ -1785,8 +1855,8 @@ mod __parse__Tree { ) -> __Symbol<'input> { match __token_index { - 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 => match __token { - Token(2, __tok0) | Token(3, __tok0) | Token(4, __tok0) | Token(5, __tok0) | Token(6, __tok0) | Token(7, __tok0) | Token(8, __tok0) | Token(9, __tok0) | Token(10, __tok0) | Token(11, __tok0) | Token(0, __tok0) | Token(1, __tok0) if true => __Symbol::Variant0(__tok0), + 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 => match __token { + Token(2, __tok0) | Token(3, __tok0) | Token(4, __tok0) | Token(5, __tok0) | Token(6, __tok0) | Token(7, __tok0) | Token(8, __tok0) | Token(9, __tok0) | Token(10, __tok0) | Token(11, __tok0) | Token(12, __tok0) | Token(0, __tok0) | Token(1, __tok0) if true => __Symbol::Variant0(__tok0), _ => unreachable!(), }, _ => unreachable!(), @@ -1935,6 +2005,9 @@ mod __parse__Tree { __reduce31(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) } 32 => { + __reduce32(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) + } + 33 => { // __Tree = Tree => ActionFn(1); let __sym0 = __pop_Variant10(__symbols); let __start = __sym0.0.clone(); @@ -2086,11 +2159,11 @@ mod __parse__Tree { _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { - // BTree = Box => ActionFn(10); + // BTree = Box => ActionFn(11); let __sym0 = __pop_Variant1(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action10::<>(input, __sym0); + let __nt = super::__action11::<>(input, __sym0); __symbols.push((__start, __Symbol::Variant1(__nt), __end)); (1, 0) } @@ -2104,11 +2177,11 @@ mod __parse__Tree { _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { - // Bool = "#t" => ActionFn(16); + // Bool = "#t" => ActionFn(17); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action16::<>(input, __sym0); + let __nt = super::__action17::<>(input, __sym0); __symbols.push((__start, __Symbol::Variant2(__nt), __end)); (1, 1) } @@ -2122,11 +2195,11 @@ mod __parse__Tree { _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { - // Bool = "#f" => ActionFn(17); + // Bool = "#f" => ActionFn(18); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action17::<>(input, __sym0); + let __nt = super::__action18::<>(input, __sym0); __symbols.push((__start, __Symbol::Variant2(__nt), __end)); (1, 1) } @@ -2140,11 +2213,11 @@ mod __parse__Tree { _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { - // Box = Tree => ActionFn(21); + // Box = Tree => ActionFn(22); let __sym0 = __pop_Variant10(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action21::<>(input, __sym0); + let __nt = super::__action22::<>(input, __sym0); __symbols.push((__start, __Symbol::Variant1(__nt), __end)); (1, 2) } @@ -2158,13 +2231,13 @@ mod __parse__Tree { _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { - // File = Lang, Trees => ActionFn(30); + // File = Lang, Trees => ActionFn(31); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant3(__symbols); let __sym0 = __pop_Variant4(__symbols); let __start = __sym0.0.clone(); let __end = __sym1.2.clone(); - let __nt = super::__action30::<>(input, __sym0, __sym1); + let __nt = super::__action31::<>(input, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant3(__nt), __end)); (2, 3) } @@ -2178,11 +2251,11 @@ mod __parse__Tree { _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { - // File = Trees => ActionFn(31); + // File = Trees => ActionFn(32); let __sym0 = __pop_Variant3(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action31::<>(input, __sym0); + let __nt = super::__action32::<>(input, __sym0); __symbols.push((__start, __Symbol::Variant3(__nt), __end)); (1, 3) } @@ -2196,13 +2269,13 @@ mod __parse__Tree { _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { - // Lang = "#lang", LangName => ActionFn(18); + // Lang = "#lang", LangName => ActionFn(19); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0.clone(); let __end = __sym1.2.clone(); - let __nt = super::__action18::<>(input, __sym0, __sym1); + let __nt = super::__action19::<>(input, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant4(__nt), __end)); (2, 4) } @@ -2216,11 +2289,11 @@ mod __parse__Tree { _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { - // Lang? = Lang => ActionFn(26); + // Lang? = Lang => ActionFn(27); let __sym0 = __pop_Variant4(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action26::<>(input, __sym0); + let __nt = super::__action27::<>(input, __sym0); __symbols.push((__start, __Symbol::Variant5(__nt), __end)); (1, 5) } @@ -2234,10 +2307,10 @@ mod __parse__Tree { _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { - // Lang? = => ActionFn(27); + // Lang? = => ActionFn(28); let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); let __end = __start.clone(); - let __nt = super::__action27::<>(input, &__start, &__end); + let __nt = super::__action28::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant5(__nt), __end)); (0, 5) } @@ -2251,11 +2324,11 @@ mod __parse__Tree { _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { - // LangName = "scheme" => ActionFn(19); + // LangName = "scheme" => ActionFn(20); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action19::<>(input, __sym0); + let __nt = super::__action20::<>(input, __sym0); __symbols.push((__start, __Symbol::Variant0(__nt), __end)); (1, 6) } @@ -2269,11 +2342,11 @@ mod __parse__Tree { _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { - // LangName = "r7rs" => ActionFn(20); + // LangName = "r7rs" => ActionFn(21); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action20::<>(input, __sym0); + let __nt = super::__action21::<>(input, __sym0); __symbols.push((__start, __Symbol::Variant0(__nt), __end)); (1, 6) } @@ -2287,11 +2360,11 @@ mod __parse__Tree { _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { - // Literal = Sym => ActionFn(11); + // Literal = Sym => ActionFn(12); let __sym0 = __pop_Variant8(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action11::<>(input, __sym0); + let __nt = super::__action12::<>(input, __sym0); __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 7) } @@ -2305,11 +2378,11 @@ mod __parse__Tree { _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { - // Literal = Num => ActionFn(12); + // Literal = Num => ActionFn(13); let __sym0 = __pop_Variant7(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action12::<>(input, __sym0); + let __nt = super::__action13::<>(input, __sym0); __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 7) } @@ -2323,11 +2396,11 @@ mod __parse__Tree { _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { - // Literal = Bool => ActionFn(13); + // Literal = Bool => ActionFn(14); let __sym0 = __pop_Variant2(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action13::<>(input, __sym0); + let __nt = super::__action14::<>(input, __sym0); __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 7) } @@ -2341,11 +2414,11 @@ mod __parse__Tree { _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { - // Num = r#"[0-9]+(\\.[0-9]+)?"# => ActionFn(15); + // Num = r#"[0-9]+(\\.[0-9]+)?"# => ActionFn(16); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action15::<>(input, __sym0); + let __nt = super::__action16::<>(input, __sym0); __symbols.push((__start, __Symbol::Variant7(__nt), __end)); (1, 8) } @@ -2359,11 +2432,11 @@ mod __parse__Tree { _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { - // Sym = r#"[A-Za-z!$%&*+\\-./:<=>?@^_~][A-Za-z!$%&*+\\-./:<=>?@^_~0-9]*"# => ActionFn(14); + // Sym = r#"[A-Za-z!$%&*+\\-./:<=>?@^_~][A-Za-z!$%&*+\\-./:<=>?@^_~0-9]*"# => ActionFn(15); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action14::<>(input, __sym0); + let __nt = super::__action15::<>(input, __sym0); __symbols.push((__start, __Symbol::Variant8(__nt), __end)); (1, 9) } @@ -2377,10 +2450,10 @@ mod __parse__Tree { _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { - // Sym* = => ActionFn(22); + // Sym* = => ActionFn(23); let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); let __end = __start.clone(); - let __nt = super::__action22::<>(input, &__start, &__end); + let __nt = super::__action23::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant9(__nt), __end)); (0, 10) } @@ -2394,11 +2467,11 @@ mod __parse__Tree { _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { - // Sym* = Sym+ => ActionFn(23); + // Sym* = Sym+ => ActionFn(24); let __sym0 = __pop_Variant9(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action23::<>(input, __sym0); + let __nt = super::__action24::<>(input, __sym0); __symbols.push((__start, __Symbol::Variant9(__nt), __end)); (1, 10) } @@ -2412,11 +2485,11 @@ mod __parse__Tree { _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { - // Sym+ = Sym => ActionFn(28); + // Sym+ = Sym => ActionFn(29); let __sym0 = __pop_Variant8(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action28::<>(input, __sym0); + let __nt = super::__action29::<>(input, __sym0); __symbols.push((__start, __Symbol::Variant9(__nt), __end)); (1, 11) } @@ -2430,13 +2503,13 @@ mod __parse__Tree { _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { - // Sym+ = Sym+, Sym => ActionFn(29); + // Sym+ = Sym+, Sym => ActionFn(30); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant8(__symbols); let __sym0 = __pop_Variant9(__symbols); let __start = __sym0.0.clone(); let __end = __sym1.2.clone(); - let __nt = super::__action29::<>(input, __sym0, __sym1); + let __nt = super::__action30::<>(input, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant9(__nt), __end)); (2, 11) } @@ -2494,7 +2567,7 @@ mod __parse__Tree { _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { - // Tree = "(", "define", "(", Sym, ")", Trees, ")" => ActionFn(32); + // Tree = "(", "define", "(", Sym, ")", Trees, ")" => ActionFn(33); assert!(__symbols.len() >= 7); let __sym6 = __pop_Variant0(__symbols); let __sym5 = __pop_Variant3(__symbols); @@ -2505,7 +2578,7 @@ mod __parse__Tree { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0.clone(); let __end = __sym6.2.clone(); - let __nt = super::__action32::<>(input, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6); + let __nt = super::__action33::<>(input, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6); __symbols.push((__start, __Symbol::Variant10(__nt), __end)); (7, 12) } @@ -2519,7 +2592,7 @@ mod __parse__Tree { _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { - // Tree = "(", "define", "(", Sym, Sym+, ")", Trees, ")" => ActionFn(33); + // Tree = "(", "define", "(", Sym, Sym+, ")", Trees, ")" => ActionFn(34); assert!(__symbols.len() >= 8); let __sym7 = __pop_Variant0(__symbols); let __sym6 = __pop_Variant3(__symbols); @@ -2531,7 +2604,7 @@ mod __parse__Tree { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0.clone(); let __end = __sym7.2.clone(); - let __nt = super::__action33::<>(input, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7); + let __nt = super::__action34::<>(input, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7); __symbols.push((__start, __Symbol::Variant10(__nt), __end)); (8, 12) } @@ -2569,7 +2642,7 @@ mod __parse__Tree { _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { - // Tree = "(", "lambda (", ")", Trees, ")" => ActionFn(34); + // Tree = "(", "lambda (", ")", Trees, ")" => ActionFn(35); assert!(__symbols.len() >= 5); let __sym4 = __pop_Variant0(__symbols); let __sym3 = __pop_Variant3(__symbols); @@ -2578,7 +2651,7 @@ mod __parse__Tree { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0.clone(); let __end = __sym4.2.clone(); - let __nt = super::__action34::<>(input, __sym0, __sym1, __sym2, __sym3, __sym4); + let __nt = super::__action35::<>(input, __sym0, __sym1, __sym2, __sym3, __sym4); __symbols.push((__start, __Symbol::Variant10(__nt), __end)); (5, 12) } @@ -2592,7 +2665,7 @@ mod __parse__Tree { _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { - // Tree = "(", "lambda (", Sym+, ")", Trees, ")" => ActionFn(35); + // Tree = "(", "lambda (", Sym+, ")", Trees, ")" => ActionFn(36); assert!(__symbols.len() >= 6); let __sym5 = __pop_Variant0(__symbols); let __sym4 = __pop_Variant3(__symbols); @@ -2602,7 +2675,7 @@ mod __parse__Tree { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0.clone(); let __end = __sym5.2.clone(); - let __nt = super::__action35::<>(input, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5); + let __nt = super::__action36::<>(input, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5); __symbols.push((__start, __Symbol::Variant10(__nt), __end)); (6, 12) } @@ -2616,13 +2689,18 @@ mod __parse__Tree { _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { - // Tree = Literal => ActionFn(9); - let __sym0 = __pop_Variant6(__symbols); + // Tree = "(", "set!", Sym, BTree, ")" => ActionFn(9); + assert!(__symbols.len() >= 5); + let __sym4 = __pop_Variant0(__symbols); + let __sym3 = __pop_Variant1(__symbols); + let __sym2 = __pop_Variant8(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0.clone(); - let __end = __sym0.2.clone(); - let __nt = super::__action9::<>(input, __sym0); + let __end = __sym4.2.clone(); + let __nt = super::__action9::<>(input, __sym0, __sym1, __sym2, __sym3, __sym4); __symbols.push((__start, __Symbol::Variant10(__nt), __end)); - (1, 12) + (5, 12) } pub(crate) fn __reduce28< 'input, @@ -2634,13 +2712,13 @@ mod __parse__Tree { _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { - // Tree+ = Tree => ActionFn(24); - let __sym0 = __pop_Variant10(__symbols); + // Tree = Literal => ActionFn(10); + let __sym0 = __pop_Variant6(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action24::<>(input, __sym0); - __symbols.push((__start, __Symbol::Variant3(__nt), __end)); - (1, 13) + let __nt = super::__action10::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant10(__nt), __end)); + (1, 12) } pub(crate) fn __reduce29< 'input, @@ -2652,17 +2730,35 @@ mod __parse__Tree { _: core::marker::PhantomData<(&'input (), &'s ())>, ) -> (usize, usize) { - // Tree+ = Tree+, Tree => ActionFn(25); + // Tree+ = Tree => ActionFn(25); + let __sym0 = __pop_Variant10(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action25::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant3(__nt), __end)); + (1, 13) + } + pub(crate) fn __reduce30< + '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(26); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant10(__symbols); let __sym0 = __pop_Variant3(__symbols); let __start = __sym0.0.clone(); let __end = __sym1.2.clone(); - let __nt = super::__action25::<>(input, __sym0, __sym1); + let __nt = super::__action26::<>(input, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant3(__nt), __end)); (2, 13) } - pub(crate) fn __reduce30< + pub(crate) fn __reduce31< 'input, 's, >( @@ -2680,7 +2776,7 @@ mod __parse__Tree { __symbols.push((__start, __Symbol::Variant3(__nt), __end)); (1, 14) } - pub(crate) fn __reduce31< + pub(crate) fn __reduce32< 'input, 's, >( @@ -2725,6 +2821,7 @@ mod __intern_token { ("^(lambda \\()", false), ("^(r7rs)", false), ("^(scheme)", false), + ("^(set!)", false), ("^(;[\u{0}-\t\u{b}-\u{c}\u{e}-\u{10ffff}]*[\n\r]*)", true), ("^([\t-\r \u{85}\u{a0}\u{1680}\u{2000}-\u{200a}\u{2028}-\u{2029}\u{202f}\u{205f}\u{3000}]*)", true), ]; @@ -2734,59 +2831,89 @@ mod __intern_token { pub(crate) use self::__lalrpop_util::lexer::Token; #[allow(unused_variables)] -fn __action0<'input, 's>( +fn __action0< + 'input, + 's, +>( input: &'input str, (_, __0, _): (usize, alloc::vec::Vec, usize), -) -> alloc::vec::Vec { +) -> alloc::vec::Vec +{ __0 } #[allow(unused_variables)] -fn __action1<'input, 's>(input: &'input str, (_, __0, _): (usize, Tree, usize)) -> Tree { +fn __action1< + 'input, + 's, +>( + input: &'input str, + (_, __0, _): (usize, Tree, usize), +) -> Tree +{ __0 } #[allow(unused_variables)] -fn __action2<'input, 's>( +fn __action2< + 'input, + 's, +>( input: &'input str, (_, _, _): (usize, core::option::Option<()>, usize), (_, __0, _): (usize, alloc::vec::Vec, usize), -) -> alloc::vec::Vec { +) -> alloc::vec::Vec +{ __0 } #[allow(unused_variables)] -fn __action3<'input, 's>( +fn __action3< + 'input, + 's, +>( input: &'input str, (_, __0, _): (usize, alloc::vec::Vec, usize), -) -> alloc::vec::Vec { +) -> alloc::vec::Vec +{ __0 } #[allow(unused_variables)] -fn __action4<'input, 's>( +fn __action4< + 'input, + 's, +>( input: &'input str, (_, _, _): (usize, &'input str, usize), (_, __0, _): (usize, alloc::vec::Vec, usize), (_, _, _): (usize, &'input str, usize), -) -> Tree { +) -> Tree +{ Tree::Branch(__0) } #[allow(unused_variables)] -fn __action5<'input, 's>( +fn __action5< + '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 +{ Tree::Define(__0, __1) } #[allow(unused_variables)] -fn __action6<'input, 's>( +fn __action6< + 'input, + 's, +>( input: &'input str, (_, _, _): (usize, &'input str, usize), (_, _, _): (usize, &'input str, usize), @@ -2796,12 +2923,16 @@ fn __action6<'input, 's>( (_, _, _): (usize, &'input str, usize), (_, body, _): (usize, alloc::vec::Vec, usize), (_, _, _): (usize, &'input str, usize), -) -> Tree { - Tree::Define(name, Box::new(Tree::Func(Rc::new(Func { args, body })))) +) -> Tree +{ + Tree::Define(name, Box::new(Tree::Func(Rc::new(Func{args, body})))) } #[allow(unused_variables)] -fn __action7<'input, 's>( +fn __action7< + 'input, + 's, +>( input: &'input str, (_, _, _): (usize, &'input str, usize), (_, _, _): (usize, &'input str, usize), @@ -2809,12 +2940,16 @@ fn __action7<'input, 's>( (_, __1, _): (usize, Tree, usize), (_, __2, _): (usize, Tree, usize), (_, _, _): (usize, &'input str, usize), -) -> Tree { +) -> Tree +{ Tree::If(Box::new([__0, __1, __2])) } #[allow(unused_variables)] -fn __action8<'input, 's>( +fn __action8< + 'input, + 's, +>( input: &'input str, (_, _, _): (usize, &'input str, usize), (_, _, _): (usize, &'input str, usize), @@ -2822,191 +2957,337 @@ fn __action8<'input, 's>( (_, _, _): (usize, &'input str, usize), (_, body, _): (usize, alloc::vec::Vec, usize), (_, _, _): (usize, &'input str, usize), -) -> Tree { - Tree::Func(Rc::new(Func { - args: args, - body: body, - })) +) -> Tree +{ + Tree::Func(Rc::new(Func{args:args, body:body})) } #[allow(unused_variables)] -fn __action9<'input, 's>(input: &'input str, (_, __0, _): (usize, Literal, usize)) -> Tree { +fn __action9< + '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::Set(__0, __1) +} + +#[allow(unused_variables)] +fn __action10< + 'input, + 's, +>( + input: &'input str, + (_, __0, _): (usize, Literal, usize), +) -> Tree +{ Tree::Leaf(__0) } #[allow(unused_variables)] -fn __action10<'input, 's>(input: &'input str, (_, __0, _): (usize, Box, usize)) -> Box { +fn __action11< + 'input, + 's, +>( + input: &'input str, + (_, __0, _): (usize, Box, usize), +) -> Box +{ __0 } #[allow(unused_variables)] -fn __action11<'input, 's>(input: &'input str, (_, __0, _): (usize, String, usize)) -> Literal { +fn __action12< + 'input, + 's, +>( + input: &'input str, + (_, __0, _): (usize, String, usize), +) -> Literal +{ Literal::Sym(__0) } #[allow(unused_variables)] -fn __action12<'input, 's>(input: &'input str, (_, __0, _): (usize, f64, usize)) -> Literal { +fn __action13< + 'input, + 's, +>( + input: &'input str, + (_, __0, _): (usize, f64, usize), +) -> Literal +{ Literal::Num(__0) } #[allow(unused_variables)] -fn __action13<'input, 's>(input: &'input str, (_, __0, _): (usize, bool, usize)) -> Literal { +fn __action14< + 'input, + 's, +>( + input: &'input str, + (_, __0, _): (usize, bool, usize), +) -> Literal +{ Literal::Bool(__0) } #[allow(unused_variables)] -fn __action14<'input, 's>(input: &'input str, (_, __0, _): (usize, &'input str, usize)) -> String { +fn __action15< + 'input, + 's, +>( + input: &'input str, + (_, __0, _): (usize, &'input str, usize), +) -> String +{ __0.to_owned() } #[allow(unused_variables)] -fn __action15<'input, 's>(input: &'input str, (_, __0, _): (usize, &'input str, usize)) -> f64 { +fn __action16< + 'input, + 's, +>( + input: &'input str, + (_, __0, _): (usize, &'input str, usize), +) -> f64 +{ __0.parse().unwrap() } #[allow(unused_variables)] -fn __action16<'input, 's>(input: &'input str, (_, __0, _): (usize, &'input str, usize)) -> bool { +fn __action17< + 'input, + 's, +>( + input: &'input str, + (_, __0, _): (usize, &'input str, usize), +) -> bool +{ true } #[allow(unused_variables)] -fn __action17<'input, 's>(input: &'input str, (_, __0, _): (usize, &'input str, usize)) -> bool { +fn __action18< + 'input, + 's, +>( + input: &'input str, + (_, __0, _): (usize, &'input str, usize), +) -> bool +{ false } #[allow(unused_variables)] -fn __action18<'input, 's>( +fn __action19< + 'input, + 's, +>( input: &'input str, (_, __0, _): (usize, &'input str, usize), (_, __1, _): (usize, &'input str, usize), -) -> () { +) -> () +{ () } #[allow(unused_variables)] -fn __action19<'input, 's>( +fn __action20< + 'input, + 's, +>( input: &'input str, (_, __0, _): (usize, &'input str, usize), -) -> &'input str { +) -> &'input str +{ __0 } #[allow(unused_variables)] -fn __action20<'input, 's>( +fn __action21< + 'input, + 's, +>( input: &'input str, (_, __0, _): (usize, &'input str, usize), -) -> &'input str { +) -> &'input str +{ __0 } #[allow(unused_variables)] -fn __action21<'input, 's>(input: &'input str, (_, __0, _): (usize, Tree, usize)) -> Box { +fn __action22< + 'input, + 's, +>( + input: &'input str, + (_, __0, _): (usize, Tree, usize), +) -> Box +{ Box::new(__0) } #[allow(unused_variables)] -fn __action22<'input, 's>( +fn __action23< + 'input, + 's, +>( input: &'input str, __lookbehind: &usize, __lookahead: &usize, -) -> alloc::vec::Vec { +) -> alloc::vec::Vec +{ alloc::vec![] } #[allow(unused_variables)] -fn __action23<'input, 's>( +fn __action24< + 'input, + 's, +>( input: &'input str, (_, v, _): (usize, alloc::vec::Vec, usize), -) -> alloc::vec::Vec { +) -> alloc::vec::Vec +{ v } #[allow(unused_variables)] -fn __action24<'input, 's>( +fn __action25< + 'input, + 's, +>( input: &'input str, (_, __0, _): (usize, Tree, usize), -) -> alloc::vec::Vec { +) -> alloc::vec::Vec +{ alloc::vec![__0] } #[allow(unused_variables)] -fn __action25<'input, 's>( +fn __action26< + '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 - } +) -> alloc::vec::Vec +{ + { let mut v = v; v.push(e); v } } #[allow(unused_variables)] -fn __action26<'input, 's>( +fn __action27< + 'input, + 's, +>( input: &'input str, (_, __0, _): (usize, (), usize), -) -> core::option::Option<()> { +) -> core::option::Option<()> +{ Some(__0) } #[allow(unused_variables)] -fn __action27<'input, 's>( +fn __action28< + 'input, + 's, +>( input: &'input str, __lookbehind: &usize, __lookahead: &usize, -) -> core::option::Option<()> { +) -> core::option::Option<()> +{ None } #[allow(unused_variables)] -fn __action28<'input, 's>( +fn __action29< + 'input, + 's, +>( input: &'input str, (_, __0, _): (usize, String, usize), -) -> alloc::vec::Vec { +) -> alloc::vec::Vec +{ alloc::vec![__0] } #[allow(unused_variables)] -fn __action29<'input, 's>( +fn __action30< + '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 - } +) -> alloc::vec::Vec +{ + { let mut v = v; v.push(e); v } } #[allow(unused_variables)] -fn __action30<'input, 's>( +fn __action31< + 'input, + 's, +>( input: &'input str, __0: (usize, (), usize), __1: (usize, alloc::vec::Vec, usize), -) -> alloc::vec::Vec { +) -> alloc::vec::Vec +{ let __start0 = __0.0.clone(); let __end0 = __0.2.clone(); - let __temp0 = __action26(input, __0); + let __temp0 = __action27( + input, + __0, + ); let __temp0 = (__start0, __temp0, __end0); - __action2(input, __temp0, __1) + __action2( + input, + __temp0, + __1, + ) } #[allow(unused_variables)] -fn __action31<'input, 's>( +fn __action32< + 'input, + 's, +>( input: &'input str, __0: (usize, alloc::vec::Vec, usize), -) -> alloc::vec::Vec { +) -> alloc::vec::Vec +{ let __start0 = __0.0.clone(); let __end0 = __0.0.clone(); - let __temp0 = __action27(input, &__start0, &__end0); + let __temp0 = __action28( + input, + &__start0, + &__end0, + ); let __temp0 = (__start0, __temp0, __end0); - __action2(input, __temp0, __0) + __action2( + input, + __temp0, + __0, + ) } #[allow(unused_variables)] -fn __action32<'input, 's>( +fn __action33< + 'input, + 's, +>( input: &'input str, __0: (usize, &'input str, usize), __1: (usize, &'input str, usize), @@ -3015,16 +3296,34 @@ fn __action32<'input, 's>( __4: (usize, &'input str, usize), __5: (usize, alloc::vec::Vec, usize), __6: (usize, &'input str, usize), -) -> Tree { +) -> Tree +{ let __start0 = __3.2.clone(); let __end0 = __4.0.clone(); - let __temp0 = __action22(input, &__start0, &__end0); + let __temp0 = __action23( + input, + &__start0, + &__end0, + ); let __temp0 = (__start0, __temp0, __end0); - __action6(input, __0, __1, __2, __3, __temp0, __4, __5, __6) + __action6( + input, + __0, + __1, + __2, + __3, + __temp0, + __4, + __5, + __6, + ) } #[allow(unused_variables)] -fn __action33<'input, 's>( +fn __action34< + 'input, + 's, +>( input: &'input str, __0: (usize, &'input str, usize), __1: (usize, &'input str, usize), @@ -3034,32 +3333,65 @@ fn __action33<'input, 's>( __5: (usize, &'input str, usize), __6: (usize, alloc::vec::Vec, usize), __7: (usize, &'input str, usize), -) -> Tree { +) -> Tree +{ let __start0 = __4.0.clone(); let __end0 = __4.2.clone(); - let __temp0 = __action23(input, __4); + let __temp0 = __action24( + input, + __4, + ); let __temp0 = (__start0, __temp0, __end0); - __action6(input, __0, __1, __2, __3, __temp0, __5, __6, __7) + __action6( + input, + __0, + __1, + __2, + __3, + __temp0, + __5, + __6, + __7, + ) } #[allow(unused_variables)] -fn __action34<'input, 's>( +fn __action35< + 'input, + 's, +>( input: &'input str, __0: (usize, &'input str, usize), __1: (usize, &'input str, usize), __2: (usize, &'input str, usize), __3: (usize, alloc::vec::Vec, usize), __4: (usize, &'input str, usize), -) -> Tree { +) -> Tree +{ let __start0 = __1.2.clone(); let __end0 = __2.0.clone(); - let __temp0 = __action22(input, &__start0, &__end0); + let __temp0 = __action23( + input, + &__start0, + &__end0, + ); let __temp0 = (__start0, __temp0, __end0); - __action8(input, __0, __1, __temp0, __2, __3, __4) + __action8( + input, + __0, + __1, + __temp0, + __2, + __3, + __4, + ) } #[allow(unused_variables)] -fn __action35<'input, 's>( +fn __action36< + 'input, + 's, +>( input: &'input str, __0: (usize, &'input str, usize), __1: (usize, &'input str, usize), @@ -3067,40 +3399,37 @@ fn __action35<'input, 's>( __3: (usize, &'input str, usize), __4: (usize, alloc::vec::Vec, usize), __5: (usize, &'input str, usize), -) -> Tree { +) -> Tree +{ let __start0 = __2.0.clone(); let __end0 = __2.2.clone(); - let __temp0 = __action23(input, __2); + let __temp0 = __action24( + input, + __2, + ); let __temp0 = (__start0, __temp0, __end0); - __action8(input, __0, __1, __temp0, __3, __4, __5) + __action8( + input, + __0, + __1, + __temp0, + __3, + __4, + __5, + ) } -pub trait __ToTriple<'input, 's> { - fn to_triple( - value: Self, - ) -> Result< - (usize, Token<'input>, usize), - __lalrpop_util::ParseError, &'static str>, - >; +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>, - > { +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>, - > { +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 }), diff --git a/src/tests.rs b/src/tests.rs index 7aecb78..c69e945 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -18,7 +18,7 @@ upstream for this fn run_pass() { let manifest_dir = Path::new(env!("CARGO_MANIFEST_DIR")); - insta::glob!("test/run-pass/**.scm", |p| { + insta::glob!("test/run-pass/**/*.scm", |p| { let p = PathBuf::from( p.canonicalize() .unwrap()