From 91dc00aa8986e7ff90e1a7090170fbc9396b60b9 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Mon, 20 Jul 2015 13:02:15 -0400 Subject: [PATCH] better test for using `super` --- lalrpop-test/src/expr.rs | 2634 ++++++------- lalrpop-test/src/expr_arena.rs | 5780 ++++++++++++++-------------- lalrpop-test/src/loc.rs | 246 +- lalrpop-test/src/main.rs | 28 +- lalrpop-test/src/sub.rs | 282 +- lalrpop-test/src/use_super.lalrpop | 14 + lalrpop-test/src/use_super.rs | 185 + lalrpop/src/lr1/ascent.rs | 14 +- 8 files changed, 4711 insertions(+), 4472 deletions(-) create mode 100644 lalrpop-test/src/use_super.lalrpop create mode 100644 lalrpop-test/src/use_super.rs diff --git a/lalrpop-test/src/expr.rs b/lalrpop-test/src/expr.rs index f3e8dae..549b6d2 100644 --- a/lalrpop-test/src/expr.rs +++ b/lalrpop-test/src/expr.rs @@ -34,12 +34,14 @@ mod __parse__Expr { #![allow(non_snake_case, non_camel_case_types, unused_mut, unused_variables, unused_imports)] use util::tok::Tok; + extern crate lalrpop_util as __lalrpop_util; + use self::__lalrpop_util::ParseError as __ParseError; pub enum __Nonterminal<> { - Factor(i32), Term(i32), - Expr(i32), ____Expr(i32), + Expr(i32), + Factor(i32), } // State 0 @@ -79,12 +81,12 @@ mod __parse__Expr { // Term = (*) "Num" ["/"] // __Expr = (*) Expr [EOF] // - // "(" -> Shift(S2) // "Num" -> Shift(S5) + // "(" -> Shift(S4) // - // Term -> S1 - // Expr -> S4 - // Factor -> S3 + // Expr -> S3 + // Factor -> S1 + // Term -> S2 pub fn __state0< __TOKENS: Iterator, >( @@ -96,18 +98,18 @@ mod __parse__Expr { { let mut __result: (Option<()>, Option<((), Tok, ())>, __Nonterminal<>); match __lookahead { - Some((_, __tok @ Tok::LParen(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym0 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state2(scale, __lookbehind, __lookahead, __tokens, __sym0)); - } Some((_, Tok::Num(__tok0), __loc)) => { let mut __lookbehind = Some(__loc); let mut __sym0 = &mut Some((__tok0)); let __lookahead = __tokens.next(); __result = try!(__state5(scale, __lookbehind, __lookahead, __tokens, __sym0)); } + Some((_, __tok @ Tok::LParen(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym0 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state4(scale, __lookbehind, __lookahead, __tokens, __sym0)); + } _ => { return Err(__lookahead); } @@ -115,17 +117,17 @@ mod __parse__Expr { loop { let (__lookbehind, __lookahead, __nt) = __result; match __nt { - __Nonterminal::Term(__nt) => { - let __sym0 = &mut Some(__nt); - __result = try!(__state1(scale, __lookbehind, __lookahead, __tokens, __sym0)); - } __Nonterminal::Expr(__nt) => { let __sym0 = &mut Some(__nt); - __result = try!(__state4(scale, __lookbehind, __lookahead, __tokens, __sym0)); + __result = try!(__state3(scale, __lookbehind, __lookahead, __tokens, __sym0)); } __Nonterminal::Factor(__nt) => { let __sym0 = &mut Some(__nt); - __result = try!(__state3(scale, __lookbehind, __lookahead, __tokens, __sym0)); + __result = try!(__state1(scale, __lookbehind, __lookahead, __tokens, __sym0)); + } + __Nonterminal::Term(__nt) => { + let __sym0 = &mut Some(__nt); + __result = try!(__state2(scale, __lookbehind, __lookahead, __tokens, __sym0)); } _ => { return Ok((__lookbehind, __lookahead, __nt)); @@ -135,17 +137,25 @@ mod __parse__Expr { } // State 1 - // Factor = Term (*) [EOF] - // Factor = Term (*) ["*"] - // Factor = Term (*) ["+"] - // Factor = Term (*) ["-"] - // Factor = Term (*) ["/"] + // Expr = Factor (*) [EOF] + // Expr = Factor (*) ["+"] + // Expr = Factor (*) ["-"] + // Factor = Factor (*) "*" Term [EOF] + // Factor = Factor (*) "*" Term ["*"] + // Factor = Factor (*) "*" Term ["+"] + // Factor = Factor (*) "*" Term ["-"] + // Factor = Factor (*) "*" Term ["/"] + // Factor = Factor (*) "/" Term [EOF] + // Factor = Factor (*) "/" Term ["*"] + // Factor = Factor (*) "/" Term ["+"] + // Factor = Factor (*) "/" Term ["-"] + // Factor = Factor (*) "/" Term ["/"] // - // "+" -> Reduce(Factor = Term => Call(ActionFn(6));) - // EOF -> Reduce(Factor = Term => Call(ActionFn(6));) - // "*" -> Reduce(Factor = Term => Call(ActionFn(6));) - // "/" -> Reduce(Factor = Term => Call(ActionFn(6));) - // "-" -> Reduce(Factor = Term => Call(ActionFn(6));) + // "*" -> Shift(S6) + // "/" -> Shift(S7) + // "-" -> Reduce(Expr = Factor => Call(ActionFn(3));) + // EOF -> Reduce(Expr = Factor => Call(ActionFn(3));) + // "+" -> Reduce(Expr = Factor => Call(ActionFn(3));) // pub fn __state1< __TOKENS: Iterator, @@ -159,6 +169,75 @@ mod __parse__Expr { { let mut __result: (Option<()>, Option<((), Tok, ())>, __Nonterminal<>); match __lookahead { + Some((_, __tok @ Tok::Times(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state6(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + } + Some((_, __tok @ Tok::Div(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state7(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action3(scale, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + None => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action3(scale, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action3(scale, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + + // State 2 + // Factor = Term (*) [EOF] + // Factor = Term (*) ["*"] + // Factor = Term (*) ["+"] + // Factor = Term (*) ["-"] + // Factor = Term (*) ["/"] + // + // "/" -> Reduce(Factor = Term => Call(ActionFn(6));) + // "-" -> Reduce(Factor = Term => Call(ActionFn(6));) + // "+" -> Reduce(Factor = Term => Call(ActionFn(6));) + // EOF -> Reduce(Factor = Term => Call(ActionFn(6));) + // "*" -> Reduce(Factor = Term => Call(ActionFn(6));) + // + pub fn __state2< + __TOKENS: Iterator, + >( + scale: i32, + __lookbehind: Option<()>, + __lookahead: Option<((), Tok, ())>, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + ) -> Result<(Option<()>, Option<((), Tok, ())>, __Nonterminal<>), Option<((), Tok, ())>> + { + let mut __result: (Option<()>, Option<((), Tok, ())>, __Nonterminal<>); + match __lookahead { + Some((_, Tok::Div(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action6(scale, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action6(scale, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } Some((_, Tok::Plus(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __nt = super::__action6(scale, __sym0); @@ -174,23 +253,62 @@ mod __parse__Expr { let __nt = super::__action6(scale, __sym0); return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } - Some((_, Tok::Div(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action6(scale, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action6(scale, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } _ => { return Err(__lookahead); } } } - // State 2 + // State 3 + // Expr = Expr (*) "+" Factor [EOF] + // Expr = Expr (*) "+" Factor ["+"] + // Expr = Expr (*) "+" Factor ["-"] + // Expr = Expr (*) "-" Factor [EOF] + // Expr = Expr (*) "-" Factor ["+"] + // Expr = Expr (*) "-" Factor ["-"] + // __Expr = Expr (*) [EOF] + // + // EOF -> Reduce(__Expr = Expr => Call(ActionFn(0));) + // "-" -> Shift(S8) + // "+" -> Shift(S9) + // + pub fn __state3< + __TOKENS: Iterator, + >( + scale: i32, + __lookbehind: Option<()>, + __lookahead: Option<((), Tok, ())>, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + ) -> Result<(Option<()>, Option<((), Tok, ())>, __Nonterminal<>), Option<((), Tok, ())>> + { + let mut __result: (Option<()>, Option<((), Tok, ())>, __Nonterminal<>); + match __lookahead { + Some((_, __tok @ Tok::Minus(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state8(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + } + Some((_, __tok @ Tok::Plus(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state9(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + } + None => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action0(scale, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::____Expr(__nt))); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + + // State 4 // Expr = (*) Expr "+" Factor [")"] // Expr = (*) Expr "+" Factor ["+"] // Expr = (*) Expr "+" Factor ["-"] @@ -231,13 +349,13 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "(" -> Shift(S10) - // "Num" -> Shift(S9) + // "(" -> Shift(S12) + // "Num" -> Shift(S10) // - // Factor -> S6 - // Term -> S7 - // Expr -> S8 - pub fn __state2< + // Factor -> S14 + // Term -> S11 + // Expr -> S13 + pub fn __state4< __TOKENS: Iterator, >( scale: i32, @@ -253,13 +371,13 @@ mod __parse__Expr { let mut __lookbehind = Some(__loc); let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state10(scale, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state12(scale, __lookbehind, __lookahead, __tokens, __sym1)); } Some((_, Tok::Num(__tok0), __loc)) => { let mut __lookbehind = Some(__loc); let mut __sym1 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state9(scale, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state10(scale, __lookbehind, __lookahead, __tokens, __sym1)); } _ => { return Err(__lookahead); @@ -270,15 +388,15 @@ mod __parse__Expr { match __nt { __Nonterminal::Factor(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state6(scale, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state14(scale, __lookbehind, __lookahead, __tokens, __sym1)); } __Nonterminal::Term(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state7(scale, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state11(scale, __lookbehind, __lookahead, __tokens, __sym1)); } __Nonterminal::Expr(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state8(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + __result = try!(__state13(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); } _ => { return Ok((__lookbehind, __lookahead, __nt)); @@ -288,122 +406,6 @@ mod __parse__Expr { return Ok(__result); } - // State 3 - // Expr = Factor (*) [EOF] - // Expr = Factor (*) ["+"] - // Expr = Factor (*) ["-"] - // Factor = Factor (*) "*" Term [EOF] - // Factor = Factor (*) "*" Term ["*"] - // Factor = Factor (*) "*" Term ["+"] - // Factor = Factor (*) "*" Term ["-"] - // Factor = Factor (*) "*" Term ["/"] - // Factor = Factor (*) "/" Term [EOF] - // Factor = Factor (*) "/" Term ["*"] - // Factor = Factor (*) "/" Term ["+"] - // Factor = Factor (*) "/" Term ["-"] - // Factor = Factor (*) "/" Term ["/"] - // - // "+" -> Reduce(Expr = Factor => Call(ActionFn(3));) - // "*" -> Shift(S12) - // EOF -> Reduce(Expr = Factor => Call(ActionFn(3));) - // "-" -> Reduce(Expr = Factor => Call(ActionFn(3));) - // "/" -> Shift(S11) - // - pub fn __state3< - __TOKENS: Iterator, - >( - scale: i32, - __lookbehind: Option<()>, - __lookahead: Option<((), Tok, ())>, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - ) -> Result<(Option<()>, Option<((), Tok, ())>, __Nonterminal<>), Option<((), Tok, ())>> - { - let mut __result: (Option<()>, Option<((), Tok, ())>, __Nonterminal<>); - match __lookahead { - Some((_, __tok @ Tok::Times(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym1 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state12(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); - } - Some((_, __tok @ Tok::Div(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym1 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state11(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); - } - Some((_, Tok::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action3(scale, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - None => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action3(scale, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action3(scale, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 4 - // Expr = Expr (*) "+" Factor [EOF] - // Expr = Expr (*) "+" Factor ["+"] - // Expr = Expr (*) "+" Factor ["-"] - // Expr = Expr (*) "-" Factor [EOF] - // Expr = Expr (*) "-" Factor ["+"] - // Expr = Expr (*) "-" Factor ["-"] - // __Expr = Expr (*) [EOF] - // - // "+" -> Shift(S13) - // EOF -> Reduce(__Expr = Expr => Call(ActionFn(0));) - // "-" -> Shift(S14) - // - pub fn __state4< - __TOKENS: Iterator, - >( - scale: i32, - __lookbehind: Option<()>, - __lookahead: Option<((), Tok, ())>, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - ) -> Result<(Option<()>, Option<((), Tok, ())>, __Nonterminal<>), Option<((), Tok, ())>> - { - let mut __result: (Option<()>, Option<((), Tok, ())>, __Nonterminal<>); - match __lookahead { - Some((_, __tok @ Tok::Plus(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym1 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state13(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); - } - Some((_, __tok @ Tok::Minus(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym1 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state14(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); - } - None => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action0(scale, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::____Expr(__nt))); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - // State 5 // Term = "Num" (*) [EOF] // Term = "Num" (*) ["*"] @@ -411,11 +413,11 @@ mod __parse__Expr { // Term = "Num" (*) ["-"] // Term = "Num" (*) ["/"] // - // "/" -> Reduce(Term = "Num" => Call(ActionFn(7));) // "+" -> Reduce(Term = "Num" => Call(ActionFn(7));) - // EOF -> Reduce(Term = "Num" => Call(ActionFn(7));) - // "-" -> Reduce(Term = "Num" => Call(ActionFn(7));) // "*" -> Reduce(Term = "Num" => Call(ActionFn(7));) + // "-" -> Reduce(Term = "Num" => Call(ActionFn(7));) + // EOF -> Reduce(Term = "Num" => Call(ActionFn(7));) + // "/" -> Reduce(Term = "Num" => Call(ActionFn(7));) // pub fn __state5< __TOKENS: Iterator, @@ -429,17 +431,12 @@ mod __parse__Expr { { let mut __result: (Option<()>, Option<((), Tok, ())>, __Nonterminal<>); match __lookahead { - Some((_, Tok::Div(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action7(scale, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } Some((_, Tok::Plus(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __nt = super::__action7(scale, __sym0); return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); } - None => { + Some((_, Tok::Times(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __nt = super::__action7(scale, __sym0); return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); @@ -449,7 +446,12 @@ mod __parse__Expr { let __nt = super::__action7(scale, __sym0); return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); } - Some((_, Tok::Times(..), _)) => { + None => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action7(scale, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + Some((_, Tok::Div(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __nt = super::__action7(scale, __sym0); return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); @@ -461,26 +463,26 @@ mod __parse__Expr { } // State 6 - // Expr = Factor (*) [")"] - // Expr = Factor (*) ["+"] - // Expr = Factor (*) ["-"] - // Factor = Factor (*) "*" Term [")"] - // Factor = Factor (*) "*" Term ["*"] - // Factor = Factor (*) "*" Term ["+"] - // Factor = Factor (*) "*" Term ["-"] - // Factor = Factor (*) "*" Term ["/"] - // Factor = Factor (*) "/" Term [")"] - // Factor = Factor (*) "/" Term ["*"] - // Factor = Factor (*) "/" Term ["+"] - // Factor = Factor (*) "/" Term ["-"] - // Factor = Factor (*) "/" Term ["/"] + // Factor = Factor "*" (*) Term [EOF] + // Factor = Factor "*" (*) Term ["*"] + // Factor = Factor "*" (*) Term ["+"] + // Factor = Factor "*" (*) Term ["-"] + // Factor = Factor "*" (*) Term ["/"] + // Term = (*) "(" Expr ")" [EOF] + // Term = (*) "(" Expr ")" ["*"] + // Term = (*) "(" Expr ")" ["+"] + // Term = (*) "(" Expr ")" ["-"] + // Term = (*) "(" Expr ")" ["/"] + // Term = (*) "Num" [EOF] + // Term = (*) "Num" ["*"] + // Term = (*) "Num" ["+"] + // Term = (*) "Num" ["-"] + // Term = (*) "Num" ["/"] // - // "*" -> Shift(S16) - // "-" -> Reduce(Expr = Factor => Call(ActionFn(3));) - // "+" -> Reduce(Expr = Factor => Call(ActionFn(3));) - // "/" -> Shift(S15) - // ")" -> Reduce(Expr = Factor => Call(ActionFn(3));) + // "(" -> Shift(S4) + // "Num" -> Shift(S5) // + // Term -> S15 pub fn __state6< __TOKENS: Iterator, >( @@ -489,57 +491,63 @@ mod __parse__Expr { __lookahead: Option<((), Tok, ())>, __tokens: &mut __TOKENS, __sym0: &mut Option, + __sym1: &mut Option, ) -> Result<(Option<()>, Option<((), Tok, ())>, __Nonterminal<>), Option<((), Tok, ())>> { let mut __result: (Option<()>, Option<((), Tok, ())>, __Nonterminal<>); match __lookahead { - Some((_, __tok @ Tok::Times(..), __loc)) => { + Some((_, __tok @ Tok::LParen(..), __loc)) => { let mut __lookbehind = Some(__loc); - let mut __sym1 = &mut Some((__tok)); + let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state16(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + __result = try!(__state4(scale, __lookbehind, __lookahead, __tokens, __sym2)); } - Some((_, __tok @ Tok::Div(..), __loc)) => { + Some((_, Tok::Num(__tok0), __loc)) => { let mut __lookbehind = Some(__loc); - let mut __sym1 = &mut Some((__tok)); + let mut __sym2 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state15(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); - } - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action3(scale, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - Some((_, Tok::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action3(scale, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - Some((_, Tok::RParen(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action3(scale, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + __result = try!(__state5(scale, __lookbehind, __lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); } } + while __sym1.is_some() { + let (__lookbehind, __lookahead, __nt) = __result; + match __nt { + __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state15(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + _ => { + return Ok((__lookbehind, __lookahead, __nt)); + } + } + } return Ok(__result); } // State 7 - // Factor = Term (*) [")"] - // Factor = Term (*) ["*"] - // Factor = Term (*) ["+"] - // Factor = Term (*) ["-"] - // Factor = Term (*) ["/"] + // Factor = Factor "/" (*) Term [EOF] + // Factor = Factor "/" (*) Term ["*"] + // Factor = Factor "/" (*) Term ["+"] + // Factor = Factor "/" (*) Term ["-"] + // Factor = Factor "/" (*) Term ["/"] + // Term = (*) "(" Expr ")" [EOF] + // Term = (*) "(" Expr ")" ["*"] + // Term = (*) "(" Expr ")" ["+"] + // Term = (*) "(" Expr ")" ["-"] + // Term = (*) "(" Expr ")" ["/"] + // Term = (*) "Num" [EOF] + // Term = (*) "Num" ["*"] + // Term = (*) "Num" ["+"] + // Term = (*) "Num" ["-"] + // Term = (*) "Num" ["/"] // - // "/" -> Reduce(Factor = Term => Call(ActionFn(6));) - // ")" -> Reduce(Factor = Term => Call(ActionFn(6));) - // "-" -> Reduce(Factor = Term => Call(ActionFn(6));) - // "+" -> Reduce(Factor = Term => Call(ActionFn(6));) - // "*" -> Reduce(Factor = Term => Call(ActionFn(6));) + // "Num" -> Shift(S5) + // "(" -> Shift(S4) // + // Term -> S16 pub fn __state7< __TOKENS: Iterator, >( @@ -548,58 +556,77 @@ mod __parse__Expr { __lookahead: Option<((), Tok, ())>, __tokens: &mut __TOKENS, __sym0: &mut Option, + __sym1: &mut Option, ) -> Result<(Option<()>, Option<((), Tok, ())>, __Nonterminal<>), Option<((), Tok, ())>> { let mut __result: (Option<()>, Option<((), Tok, ())>, __Nonterminal<>); match __lookahead { - Some((_, Tok::Div(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action6(scale, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + Some((_, Tok::Num(__tok0), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok0)); + let __lookahead = __tokens.next(); + __result = try!(__state5(scale, __lookbehind, __lookahead, __tokens, __sym2)); } - Some((_, Tok::RParen(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action6(scale, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action6(scale, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action6(scale, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Times(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action6(scale, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + Some((_, __tok @ Tok::LParen(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state4(scale, __lookbehind, __lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); } } + while __sym1.is_some() { + let (__lookbehind, __lookahead, __nt) = __result; + match __nt { + __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state16(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + _ => { + return Ok((__lookbehind, __lookahead, __nt)); + } + } + } + return Ok(__result); } // State 8 - // Expr = Expr (*) "+" Factor [")"] - // Expr = Expr (*) "+" Factor ["+"] - // Expr = Expr (*) "+" Factor ["-"] - // Expr = Expr (*) "-" Factor [")"] - // Expr = Expr (*) "-" Factor ["+"] - // Expr = Expr (*) "-" Factor ["-"] - // Term = "(" Expr (*) ")" [EOF] - // Term = "(" Expr (*) ")" ["*"] - // Term = "(" Expr (*) ")" ["+"] - // Term = "(" Expr (*) ")" ["-"] - // Term = "(" Expr (*) ")" ["/"] + // Expr = Expr "-" (*) Factor [EOF] + // Expr = Expr "-" (*) Factor ["+"] + // Expr = Expr "-" (*) Factor ["-"] + // Factor = (*) Factor "*" Term [EOF] + // Factor = (*) Factor "*" Term ["*"] + // Factor = (*) Factor "*" Term ["+"] + // Factor = (*) Factor "*" Term ["-"] + // Factor = (*) Factor "*" Term ["/"] + // Factor = (*) Factor "/" Term [EOF] + // Factor = (*) Factor "/" Term ["*"] + // Factor = (*) Factor "/" Term ["+"] + // Factor = (*) Factor "/" Term ["-"] + // Factor = (*) Factor "/" Term ["/"] + // Factor = (*) Term [EOF] + // Factor = (*) Term ["*"] + // Factor = (*) Term ["+"] + // Factor = (*) Term ["-"] + // Factor = (*) Term ["/"] + // Term = (*) "(" Expr ")" [EOF] + // Term = (*) "(" Expr ")" ["*"] + // Term = (*) "(" Expr ")" ["+"] + // Term = (*) "(" Expr ")" ["-"] + // Term = (*) "(" Expr ")" ["/"] + // Term = (*) "Num" [EOF] + // Term = (*) "Num" ["*"] + // Term = (*) "Num" ["+"] + // Term = (*) "Num" ["-"] + // Term = (*) "Num" ["/"] // - // "-" -> Shift(S18) - // "+" -> Shift(S19) - // ")" -> Shift(S17) + // "Num" -> Shift(S5) + // "(" -> Shift(S4) // + // Factor -> S17 + // Term -> S2 pub fn __state8< __TOKENS: Iterator, >( @@ -607,51 +634,200 @@ mod __parse__Expr { __lookbehind: Option<()>, __lookahead: Option<((), Tok, ())>, __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option, + __sym0: &mut Option, + __sym1: &mut Option, ) -> Result<(Option<()>, Option<((), Tok, ())>, __Nonterminal<>), Option<((), Tok, ())>> { let mut __result: (Option<()>, Option<((), Tok, ())>, __Nonterminal<>); match __lookahead { - Some((_, __tok @ Tok::Minus(..), __loc)) => { + Some((_, Tok::Num(__tok0), __loc)) => { let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok)); + let mut __sym2 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state18(scale, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); + __result = try!(__state5(scale, __lookbehind, __lookahead, __tokens, __sym2)); } - Some((_, __tok @ Tok::Plus(..), __loc)) => { + Some((_, __tok @ Tok::LParen(..), __loc)) => { let mut __lookbehind = Some(__loc); let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state19(scale, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); - } - Some((_, __tok @ Tok::RParen(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state17(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + __result = try!(__state4(scale, __lookbehind, __lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); } } + while __sym1.is_some() { + let (__lookbehind, __lookahead, __nt) = __result; + match __nt { + __Nonterminal::Factor(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state17(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state2(scale, __lookbehind, __lookahead, __tokens, __sym2)); + } + _ => { + return Ok((__lookbehind, __lookahead, __nt)); + } + } + } return Ok(__result); } // State 9 + // Expr = Expr "+" (*) Factor [EOF] + // Expr = Expr "+" (*) Factor ["+"] + // Expr = Expr "+" (*) Factor ["-"] + // Factor = (*) Factor "*" Term [EOF] + // Factor = (*) Factor "*" Term ["*"] + // Factor = (*) Factor "*" Term ["+"] + // Factor = (*) Factor "*" Term ["-"] + // Factor = (*) Factor "*" Term ["/"] + // Factor = (*) Factor "/" Term [EOF] + // Factor = (*) Factor "/" Term ["*"] + // Factor = (*) Factor "/" Term ["+"] + // Factor = (*) Factor "/" Term ["-"] + // Factor = (*) Factor "/" Term ["/"] + // Factor = (*) Term [EOF] + // Factor = (*) Term ["*"] + // Factor = (*) Term ["+"] + // Factor = (*) Term ["-"] + // Factor = (*) Term ["/"] + // Term = (*) "(" Expr ")" [EOF] + // Term = (*) "(" Expr ")" ["*"] + // Term = (*) "(" Expr ")" ["+"] + // Term = (*) "(" Expr ")" ["-"] + // Term = (*) "(" Expr ")" ["/"] + // Term = (*) "Num" [EOF] + // Term = (*) "Num" ["*"] + // Term = (*) "Num" ["+"] + // Term = (*) "Num" ["-"] + // Term = (*) "Num" ["/"] + // + // "Num" -> Shift(S5) + // "(" -> Shift(S4) + // + // Term -> S2 + // Factor -> S18 + pub fn __state9< + __TOKENS: Iterator, + >( + scale: i32, + __lookbehind: Option<()>, + __lookahead: Option<((), Tok, ())>, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + __sym1: &mut Option, + ) -> Result<(Option<()>, Option<((), Tok, ())>, __Nonterminal<>), Option<((), Tok, ())>> + { + let mut __result: (Option<()>, Option<((), Tok, ())>, __Nonterminal<>); + match __lookahead { + Some((_, Tok::Num(__tok0), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok0)); + let __lookahead = __tokens.next(); + __result = try!(__state5(scale, __lookbehind, __lookahead, __tokens, __sym2)); + } + Some((_, __tok @ Tok::LParen(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state4(scale, __lookbehind, __lookahead, __tokens, __sym2)); + } + _ => { + return Err(__lookahead); + } + } + while __sym1.is_some() { + let (__lookbehind, __lookahead, __nt) = __result; + match __nt { + __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state2(scale, __lookbehind, __lookahead, __tokens, __sym2)); + } + __Nonterminal::Factor(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state18(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + _ => { + return Ok((__lookbehind, __lookahead, __nt)); + } + } + } + return Ok(__result); + } + + // State 10 // Term = "Num" (*) [")"] // Term = "Num" (*) ["*"] // Term = "Num" (*) ["+"] // Term = "Num" (*) ["-"] // Term = "Num" (*) ["/"] // - // "+" -> Reduce(Term = "Num" => Call(ActionFn(7));) - // "*" -> Reduce(Term = "Num" => Call(ActionFn(7));) // "-" -> Reduce(Term = "Num" => Call(ActionFn(7));) + // "+" -> Reduce(Term = "Num" => Call(ActionFn(7));) // "/" -> Reduce(Term = "Num" => Call(ActionFn(7));) + // "*" -> Reduce(Term = "Num" => Call(ActionFn(7));) // ")" -> Reduce(Term = "Num" => Call(ActionFn(7));) // - pub fn __state9< + pub fn __state10< + __TOKENS: Iterator, + >( + scale: i32, + __lookbehind: Option<()>, + __lookahead: Option<((), Tok, ())>, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + ) -> Result<(Option<()>, Option<((), Tok, ())>, __Nonterminal<>), Option<((), Tok, ())>> + { + let mut __result: (Option<()>, Option<((), Tok, ())>, __Nonterminal<>); + match __lookahead { + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action7(scale, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action7(scale, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + Some((_, Tok::Div(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action7(scale, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + Some((_, Tok::Times(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action7(scale, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + Some((_, Tok::RParen(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action7(scale, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 11 + // Factor = Term (*) [")"] + // Factor = Term (*) ["*"] + // Factor = Term (*) ["+"] + // Factor = Term (*) ["-"] + // Factor = Term (*) ["/"] + // + // "+" -> Reduce(Factor = Term => Call(ActionFn(6));) + // "/" -> Reduce(Factor = Term => Call(ActionFn(6));) + // ")" -> Reduce(Factor = Term => Call(ActionFn(6));) + // "-" -> Reduce(Factor = Term => Call(ActionFn(6));) + // "*" -> Reduce(Factor = Term => Call(ActionFn(6));) + // + pub fn __state11< __TOKENS: Iterator, >( scale: i32, @@ -665,28 +841,28 @@ mod __parse__Expr { match __lookahead { Some((_, Tok::Plus(..), _)) => { let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action7(scale, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - Some((_, Tok::Times(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action7(scale, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action7(scale, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + let __nt = super::__action6(scale, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } Some((_, Tok::Div(..), _)) => { let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action7(scale, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + let __nt = super::__action6(scale, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } Some((_, Tok::RParen(..), _)) => { let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action7(scale, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + let __nt = super::__action6(scale, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action6(scale, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Times(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action6(scale, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } _ => { return Err(__lookahead); @@ -694,7 +870,7 @@ mod __parse__Expr { } } - // State 10 + // State 12 // Expr = (*) Expr "+" Factor [")"] // Expr = (*) Expr "+" Factor ["+"] // Expr = (*) Expr "+" Factor ["-"] @@ -735,13 +911,13 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "(" -> Shift(S10) - // "Num" -> Shift(S9) + // "(" -> Shift(S12) + // "Num" -> Shift(S10) // - // Factor -> S6 - // Term -> S7 - // Expr -> S20 - pub fn __state10< + // Expr -> S19 + // Factor -> S14 + // Term -> S11 + pub fn __state12< __TOKENS: Iterator, >( scale: i32, @@ -757,13 +933,13 @@ mod __parse__Expr { let mut __lookbehind = Some(__loc); let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state10(scale, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state12(scale, __lookbehind, __lookahead, __tokens, __sym1)); } Some((_, Tok::Num(__tok0), __loc)) => { let mut __lookbehind = Some(__loc); let mut __sym1 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state9(scale, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state10(scale, __lookbehind, __lookahead, __tokens, __sym1)); } _ => { return Err(__lookahead); @@ -772,147 +948,17 @@ mod __parse__Expr { while __sym0.is_some() { let (__lookbehind, __lookahead, __nt) = __result; match __nt { - __Nonterminal::Factor(__nt) => { - let __sym1 = &mut Some(__nt); - __result = try!(__state6(scale, __lookbehind, __lookahead, __tokens, __sym1)); - } - __Nonterminal::Term(__nt) => { - let __sym1 = &mut Some(__nt); - __result = try!(__state7(scale, __lookbehind, __lookahead, __tokens, __sym1)); - } __Nonterminal::Expr(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state20(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + __result = try!(__state19(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); } - _ => { - return Ok((__lookbehind, __lookahead, __nt)); + __Nonterminal::Factor(__nt) => { + let __sym1 = &mut Some(__nt); + __result = try!(__state14(scale, __lookbehind, __lookahead, __tokens, __sym1)); } - } - } - return Ok(__result); - } - - // State 11 - // Factor = Factor "/" (*) Term [EOF] - // Factor = Factor "/" (*) Term ["*"] - // Factor = Factor "/" (*) Term ["+"] - // Factor = Factor "/" (*) Term ["-"] - // Factor = Factor "/" (*) Term ["/"] - // Term = (*) "(" Expr ")" [EOF] - // Term = (*) "(" Expr ")" ["*"] - // Term = (*) "(" Expr ")" ["+"] - // Term = (*) "(" Expr ")" ["-"] - // Term = (*) "(" Expr ")" ["/"] - // Term = (*) "Num" [EOF] - // Term = (*) "Num" ["*"] - // Term = (*) "Num" ["+"] - // Term = (*) "Num" ["-"] - // Term = (*) "Num" ["/"] - // - // "Num" -> Shift(S5) - // "(" -> Shift(S2) - // - // Term -> S21 - pub fn __state11< - __TOKENS: Iterator, - >( - scale: i32, - __lookbehind: Option<()>, - __lookahead: Option<((), Tok, ())>, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option, - ) -> Result<(Option<()>, Option<((), Tok, ())>, __Nonterminal<>), Option<((), Tok, ())>> - { - let mut __result: (Option<()>, Option<((), Tok, ())>, __Nonterminal<>); - match __lookahead { - Some((_, Tok::Num(__tok0), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state5(scale, __lookbehind, __lookahead, __tokens, __sym2)); - } - Some((_, __tok @ Tok::LParen(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state2(scale, __lookbehind, __lookahead, __tokens, __sym2)); - } - _ => { - return Err(__lookahead); - } - } - while __sym1.is_some() { - let (__lookbehind, __lookahead, __nt) = __result; - match __nt { __Nonterminal::Term(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state21(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - _ => { - return Ok((__lookbehind, __lookahead, __nt)); - } - } - } - return Ok(__result); - } - - // State 12 - // Factor = Factor "*" (*) Term [EOF] - // Factor = Factor "*" (*) Term ["*"] - // Factor = Factor "*" (*) Term ["+"] - // Factor = Factor "*" (*) Term ["-"] - // Factor = Factor "*" (*) Term ["/"] - // Term = (*) "(" Expr ")" [EOF] - // Term = (*) "(" Expr ")" ["*"] - // Term = (*) "(" Expr ")" ["+"] - // Term = (*) "(" Expr ")" ["-"] - // Term = (*) "(" Expr ")" ["/"] - // Term = (*) "Num" [EOF] - // Term = (*) "Num" ["*"] - // Term = (*) "Num" ["+"] - // Term = (*) "Num" ["-"] - // Term = (*) "Num" ["/"] - // - // "(" -> Shift(S2) - // "Num" -> Shift(S5) - // - // Term -> S22 - pub fn __state12< - __TOKENS: Iterator, - >( - scale: i32, - __lookbehind: Option<()>, - __lookahead: Option<((), Tok, ())>, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option, - ) -> Result<(Option<()>, Option<((), Tok, ())>, __Nonterminal<>), Option<((), Tok, ())>> - { - let mut __result: (Option<()>, Option<((), Tok, ())>, __Nonterminal<>); - match __lookahead { - Some((_, __tok @ Tok::LParen(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state2(scale, __lookbehind, __lookahead, __tokens, __sym2)); - } - Some((_, Tok::Num(__tok0), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state5(scale, __lookbehind, __lookahead, __tokens, __sym2)); - } - _ => { - return Err(__lookahead); - } - } - while __sym1.is_some() { - let (__lookbehind, __lookahead, __nt) = __result; - match __nt { - __Nonterminal::Term(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state22(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + let __sym1 = &mut Some(__nt); + __result = try!(__state11(scale, __lookbehind, __lookahead, __tokens, __sym1)); } _ => { return Ok((__lookbehind, __lookahead, __nt)); @@ -923,40 +969,22 @@ mod __parse__Expr { } // State 13 - // Expr = Expr "+" (*) Factor [EOF] - // Expr = Expr "+" (*) Factor ["+"] - // Expr = Expr "+" (*) Factor ["-"] - // Factor = (*) Factor "*" Term [EOF] - // Factor = (*) Factor "*" Term ["*"] - // Factor = (*) Factor "*" Term ["+"] - // Factor = (*) Factor "*" Term ["-"] - // Factor = (*) Factor "*" Term ["/"] - // Factor = (*) Factor "/" Term [EOF] - // Factor = (*) Factor "/" Term ["*"] - // Factor = (*) Factor "/" Term ["+"] - // Factor = (*) Factor "/" Term ["-"] - // Factor = (*) Factor "/" Term ["/"] - // Factor = (*) Term [EOF] - // Factor = (*) Term ["*"] - // Factor = (*) Term ["+"] - // Factor = (*) Term ["-"] - // Factor = (*) Term ["/"] - // Term = (*) "(" Expr ")" [EOF] - // Term = (*) "(" Expr ")" ["*"] - // Term = (*) "(" Expr ")" ["+"] - // Term = (*) "(" Expr ")" ["-"] - // Term = (*) "(" Expr ")" ["/"] - // Term = (*) "Num" [EOF] - // Term = (*) "Num" ["*"] - // Term = (*) "Num" ["+"] - // Term = (*) "Num" ["-"] - // Term = (*) "Num" ["/"] + // Expr = Expr (*) "+" Factor [")"] + // Expr = Expr (*) "+" Factor ["+"] + // Expr = Expr (*) "+" Factor ["-"] + // Expr = Expr (*) "-" Factor [")"] + // Expr = Expr (*) "-" Factor ["+"] + // Expr = Expr (*) "-" Factor ["-"] + // Term = "(" Expr (*) ")" [EOF] + // Term = "(" Expr (*) ")" ["*"] + // Term = "(" Expr (*) ")" ["+"] + // Term = "(" Expr (*) ")" ["-"] + // Term = "(" Expr (*) ")" ["/"] // - // "Num" -> Shift(S5) - // "(" -> Shift(S2) + // "-" -> Shift(S22) + // ")" -> Shift(S21) + // "+" -> Shift(S20) // - // Factor -> S23 - // Term -> S1 pub fn __state13< __TOKENS: Iterator, >( @@ -964,82 +992,58 @@ mod __parse__Expr { __lookbehind: Option<()>, __lookahead: Option<((), Tok, ())>, __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option, + __sym0: &mut Option, + __sym1: &mut Option, ) -> Result<(Option<()>, Option<((), Tok, ())>, __Nonterminal<>), Option<((), Tok, ())>> { let mut __result: (Option<()>, Option<((), Tok, ())>, __Nonterminal<>); match __lookahead { - Some((_, Tok::Num(__tok0), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state5(scale, __lookbehind, __lookahead, __tokens, __sym2)); - } - Some((_, __tok @ Tok::LParen(..), __loc)) => { + Some((_, __tok @ Tok::Minus(..), __loc)) => { let mut __lookbehind = Some(__loc); let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state2(scale, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state22(scale, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); + } + Some((_, __tok @ Tok::RParen(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state21(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + Some((_, __tok @ Tok::Plus(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state20(scale, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); } _ => { return Err(__lookahead); } } - while __sym1.is_some() { - let (__lookbehind, __lookahead, __nt) = __result; - match __nt { - __Nonterminal::Factor(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state23(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - __Nonterminal::Term(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state1(scale, __lookbehind, __lookahead, __tokens, __sym2)); - } - _ => { - return Ok((__lookbehind, __lookahead, __nt)); - } - } - } return Ok(__result); } // State 14 - // Expr = Expr "-" (*) Factor [EOF] - // Expr = Expr "-" (*) Factor ["+"] - // Expr = Expr "-" (*) Factor ["-"] - // Factor = (*) Factor "*" Term [EOF] - // Factor = (*) Factor "*" Term ["*"] - // Factor = (*) Factor "*" Term ["+"] - // Factor = (*) Factor "*" Term ["-"] - // Factor = (*) Factor "*" Term ["/"] - // Factor = (*) Factor "/" Term [EOF] - // Factor = (*) Factor "/" Term ["*"] - // Factor = (*) Factor "/" Term ["+"] - // Factor = (*) Factor "/" Term ["-"] - // Factor = (*) Factor "/" Term ["/"] - // Factor = (*) Term [EOF] - // Factor = (*) Term ["*"] - // Factor = (*) Term ["+"] - // Factor = (*) Term ["-"] - // Factor = (*) Term ["/"] - // Term = (*) "(" Expr ")" [EOF] - // Term = (*) "(" Expr ")" ["*"] - // Term = (*) "(" Expr ")" ["+"] - // Term = (*) "(" Expr ")" ["-"] - // Term = (*) "(" Expr ")" ["/"] - // Term = (*) "Num" [EOF] - // Term = (*) "Num" ["*"] - // Term = (*) "Num" ["+"] - // Term = (*) "Num" ["-"] - // Term = (*) "Num" ["/"] + // Expr = Factor (*) [")"] + // Expr = Factor (*) ["+"] + // Expr = Factor (*) ["-"] + // Factor = Factor (*) "*" Term [")"] + // Factor = Factor (*) "*" Term ["*"] + // Factor = Factor (*) "*" Term ["+"] + // Factor = Factor (*) "*" Term ["-"] + // Factor = Factor (*) "*" Term ["/"] + // Factor = Factor (*) "/" Term [")"] + // Factor = Factor (*) "/" Term ["*"] + // Factor = Factor (*) "/" Term ["+"] + // Factor = Factor (*) "/" Term ["-"] + // Factor = Factor (*) "/" Term ["/"] // - // "Num" -> Shift(S5) - // "(" -> Shift(S2) + // "/" -> Shift(S23) + // "+" -> Reduce(Expr = Factor => Call(ActionFn(3));) + // ")" -> Reduce(Expr = Factor => Call(ActionFn(3));) + // "-" -> Reduce(Expr = Factor => Call(ActionFn(3));) + // "*" -> Shift(S24) // - // Factor -> S24 - // Term -> S1 pub fn __state14< __TOKENS: Iterator, >( @@ -1048,67 +1052,57 @@ mod __parse__Expr { __lookahead: Option<((), Tok, ())>, __tokens: &mut __TOKENS, __sym0: &mut Option, - __sym1: &mut Option, ) -> Result<(Option<()>, Option<((), Tok, ())>, __Nonterminal<>), Option<((), Tok, ())>> { let mut __result: (Option<()>, Option<((), Tok, ())>, __Nonterminal<>); match __lookahead { - Some((_, Tok::Num(__tok0), __loc)) => { + Some((_, __tok @ Tok::Div(..), __loc)) => { let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok0)); + let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state5(scale, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state23(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); } - Some((_, __tok @ Tok::LParen(..), __loc)) => { + Some((_, __tok @ Tok::Times(..), __loc)) => { let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok)); + let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state2(scale, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state24(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action3(scale, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + Some((_, Tok::RParen(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action3(scale, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action3(scale, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); } _ => { return Err(__lookahead); } } - while __sym1.is_some() { - let (__lookbehind, __lookahead, __nt) = __result; - match __nt { - __Nonterminal::Factor(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state24(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - __Nonterminal::Term(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state1(scale, __lookbehind, __lookahead, __tokens, __sym2)); - } - _ => { - return Ok((__lookbehind, __lookahead, __nt)); - } - } - } return Ok(__result); } // State 15 - // Factor = Factor "/" (*) Term [")"] - // Factor = Factor "/" (*) Term ["*"] - // Factor = Factor "/" (*) Term ["+"] - // Factor = Factor "/" (*) Term ["-"] - // Factor = Factor "/" (*) Term ["/"] - // Term = (*) "(" Expr ")" [")"] - // Term = (*) "(" Expr ")" ["*"] - // Term = (*) "(" Expr ")" ["+"] - // Term = (*) "(" Expr ")" ["-"] - // Term = (*) "(" Expr ")" ["/"] - // Term = (*) "Num" [")"] - // Term = (*) "Num" ["*"] - // Term = (*) "Num" ["+"] - // Term = (*) "Num" ["-"] - // Term = (*) "Num" ["/"] + // Factor = Factor "*" Term (*) [EOF] + // Factor = Factor "*" Term (*) ["*"] + // Factor = Factor "*" Term (*) ["+"] + // Factor = Factor "*" Term (*) ["-"] + // Factor = Factor "*" Term (*) ["/"] // - // "Num" -> Shift(S9) - // "(" -> Shift(S10) + // "*" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // "/" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // "+" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // "-" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // EOF -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) // - // Term -> S25 pub fn __state15< __TOKENS: Iterator, >( @@ -1118,62 +1112,65 @@ mod __parse__Expr { __tokens: &mut __TOKENS, __sym0: &mut Option, __sym1: &mut Option, + __sym2: &mut Option, ) -> Result<(Option<()>, Option<((), Tok, ())>, __Nonterminal<>), Option<((), Tok, ())>> { let mut __result: (Option<()>, Option<((), Tok, ())>, __Nonterminal<>); match __lookahead { - Some((_, Tok::Num(__tok0), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state9(scale, __lookbehind, __lookahead, __tokens, __sym2)); + Some((_, Tok::Times(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action4(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } - Some((_, __tok @ Tok::LParen(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state10(scale, __lookbehind, __lookahead, __tokens, __sym2)); + Some((_, Tok::Div(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action4(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action4(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action4(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + None => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action4(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } _ => { return Err(__lookahead); } } - while __sym1.is_some() { - let (__lookbehind, __lookahead, __nt) = __result; - match __nt { - __Nonterminal::Term(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state25(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - _ => { - return Ok((__lookbehind, __lookahead, __nt)); - } - } - } - return Ok(__result); } // State 16 - // Factor = Factor "*" (*) Term [")"] - // Factor = Factor "*" (*) Term ["*"] - // Factor = Factor "*" (*) Term ["+"] - // Factor = Factor "*" (*) Term ["-"] - // Factor = Factor "*" (*) Term ["/"] - // Term = (*) "(" Expr ")" [")"] - // Term = (*) "(" Expr ")" ["*"] - // Term = (*) "(" Expr ")" ["+"] - // Term = (*) "(" Expr ")" ["-"] - // Term = (*) "(" Expr ")" ["/"] - // Term = (*) "Num" [")"] - // Term = (*) "Num" ["*"] - // Term = (*) "Num" ["+"] - // Term = (*) "Num" ["-"] - // Term = (*) "Num" ["/"] + // Factor = Factor "/" Term (*) [EOF] + // Factor = Factor "/" Term (*) ["*"] + // Factor = Factor "/" Term (*) ["+"] + // Factor = Factor "/" Term (*) ["-"] + // Factor = Factor "/" Term (*) ["/"] // - // "Num" -> Shift(S9) - // "(" -> Shift(S10) + // EOF -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // "*" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // "/" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // "-" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // "+" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) // - // Term -> S26 pub fn __state16< __TOKENS: Iterator, >( @@ -1183,53 +1180,72 @@ mod __parse__Expr { __tokens: &mut __TOKENS, __sym0: &mut Option, __sym1: &mut Option, + __sym2: &mut Option, ) -> Result<(Option<()>, Option<((), Tok, ())>, __Nonterminal<>), Option<((), Tok, ())>> { let mut __result: (Option<()>, Option<((), Tok, ())>, __Nonterminal<>); match __lookahead { - Some((_, Tok::Num(__tok0), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state9(scale, __lookbehind, __lookahead, __tokens, __sym2)); + None => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action5(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } - Some((_, __tok @ Tok::LParen(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state10(scale, __lookbehind, __lookahead, __tokens, __sym2)); + Some((_, Tok::Times(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action5(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Div(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action5(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action5(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action5(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } _ => { return Err(__lookahead); } } - while __sym1.is_some() { - let (__lookbehind, __lookahead, __nt) = __result; - match __nt { - __Nonterminal::Term(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state26(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - _ => { - return Ok((__lookbehind, __lookahead, __nt)); - } - } - } - return Ok(__result); } // State 17 - // Term = "(" Expr ")" (*) [EOF] - // Term = "(" Expr ")" (*) ["*"] - // Term = "(" Expr ")" (*) ["+"] - // Term = "(" Expr ")" (*) ["-"] - // Term = "(" Expr ")" (*) ["/"] + // Expr = Expr "-" Factor (*) [EOF] + // Expr = Expr "-" Factor (*) ["+"] + // Expr = Expr "-" Factor (*) ["-"] + // Factor = Factor (*) "*" Term [EOF] + // Factor = Factor (*) "*" Term ["*"] + // Factor = Factor (*) "*" Term ["+"] + // Factor = Factor (*) "*" Term ["-"] + // Factor = Factor (*) "*" Term ["/"] + // Factor = Factor (*) "/" Term [EOF] + // Factor = Factor (*) "/" Term ["*"] + // Factor = Factor (*) "/" Term ["+"] + // Factor = Factor (*) "/" Term ["-"] + // Factor = Factor (*) "/" Term ["/"] // - // "/" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) - // "+" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) - // "-" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) - // "*" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) - // EOF -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) + // "*" -> Shift(S6) + // EOF -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // "+" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // "/" -> Shift(S7) + // "-" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) // pub fn __state17< __TOKENS: Iterator, @@ -1238,89 +1254,74 @@ mod __parse__Expr { __lookbehind: Option<()>, __lookahead: Option<((), Tok, ())>, __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option, - __sym2: &mut Option, + __sym0: &mut Option, + __sym1: &mut Option, + __sym2: &mut Option, ) -> Result<(Option<()>, Option<((), Tok, ())>, __Nonterminal<>), Option<((), Tok, ())>> { let mut __result: (Option<()>, Option<((), Tok, ())>, __Nonterminal<>); match __lookahead { - Some((_, Tok::Div(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action8(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + Some((_, __tok @ Tok::Times(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym3 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state6(scale, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); } - Some((_, Tok::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action8(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action8(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - Some((_, Tok::Times(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action8(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + Some((_, __tok @ Tok::Div(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym3 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state7(scale, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); } None => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action8(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + let __nt = super::__action1(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action1(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action1(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); } _ => { return Err(__lookahead); } } + return Ok(__result); } // State 18 - // Expr = Expr "-" (*) Factor [")"] - // Expr = Expr "-" (*) Factor ["+"] - // Expr = Expr "-" (*) Factor ["-"] - // Factor = (*) Factor "*" Term [")"] - // Factor = (*) Factor "*" Term ["*"] - // Factor = (*) Factor "*" Term ["+"] - // Factor = (*) Factor "*" Term ["-"] - // Factor = (*) Factor "*" Term ["/"] - // Factor = (*) Factor "/" Term [")"] - // Factor = (*) Factor "/" Term ["*"] - // Factor = (*) Factor "/" Term ["+"] - // Factor = (*) Factor "/" Term ["-"] - // Factor = (*) Factor "/" Term ["/"] - // Factor = (*) Term [")"] - // Factor = (*) Term ["*"] - // Factor = (*) Term ["+"] - // Factor = (*) Term ["-"] - // Factor = (*) Term ["/"] - // Term = (*) "(" Expr ")" [")"] - // Term = (*) "(" Expr ")" ["*"] - // Term = (*) "(" Expr ")" ["+"] - // Term = (*) "(" Expr ")" ["-"] - // Term = (*) "(" Expr ")" ["/"] - // Term = (*) "Num" [")"] - // Term = (*) "Num" ["*"] - // Term = (*) "Num" ["+"] - // Term = (*) "Num" ["-"] - // Term = (*) "Num" ["/"] + // Expr = Expr "+" Factor (*) [EOF] + // Expr = Expr "+" Factor (*) ["+"] + // Expr = Expr "+" Factor (*) ["-"] + // Factor = Factor (*) "*" Term [EOF] + // Factor = Factor (*) "*" Term ["*"] + // Factor = Factor (*) "*" Term ["+"] + // Factor = Factor (*) "*" Term ["-"] + // Factor = Factor (*) "*" Term ["/"] + // Factor = Factor (*) "/" Term [EOF] + // Factor = Factor (*) "/" Term ["*"] + // Factor = Factor (*) "/" Term ["+"] + // Factor = Factor (*) "/" Term ["-"] + // Factor = Factor (*) "/" Term ["/"] // - // "(" -> Shift(S10) - // "Num" -> Shift(S9) + // "*" -> Shift(S6) + // "+" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) + // EOF -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) + // "-" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) + // "/" -> Shift(S7) // - // Term -> S7 - // Factor -> S27 pub fn __state18< __TOKENS: Iterator, >( @@ -1330,46 +1331,107 @@ mod __parse__Expr { __tokens: &mut __TOKENS, __sym0: &mut Option, __sym1: &mut Option, + __sym2: &mut Option, ) -> Result<(Option<()>, Option<((), Tok, ())>, __Nonterminal<>), Option<((), Tok, ())>> { let mut __result: (Option<()>, Option<((), Tok, ())>, __Nonterminal<>); match __lookahead { - Some((_, __tok @ Tok::LParen(..), __loc)) => { + Some((_, __tok @ Tok::Times(..), __loc)) => { let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok)); + let mut __sym3 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state10(scale, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state6(scale, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); } - Some((_, Tok::Num(__tok0), __loc)) => { + Some((_, __tok @ Tok::Div(..), __loc)) => { let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok0)); + let mut __sym3 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state9(scale, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state7(scale, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action2(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + None => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action2(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action2(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); } _ => { return Err(__lookahead); } } - while __sym1.is_some() { - let (__lookbehind, __lookahead, __nt) = __result; - match __nt { - __Nonterminal::Term(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state7(scale, __lookbehind, __lookahead, __tokens, __sym2)); - } - __Nonterminal::Factor(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state27(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - _ => { - return Ok((__lookbehind, __lookahead, __nt)); - } - } - } return Ok(__result); } // State 19 + // Expr = Expr (*) "+" Factor [")"] + // Expr = Expr (*) "+" Factor ["+"] + // Expr = Expr (*) "+" Factor ["-"] + // Expr = Expr (*) "-" Factor [")"] + // Expr = Expr (*) "-" Factor ["+"] + // Expr = Expr (*) "-" Factor ["-"] + // Term = "(" Expr (*) ")" [")"] + // Term = "(" Expr (*) ")" ["*"] + // Term = "(" Expr (*) ")" ["+"] + // Term = "(" Expr (*) ")" ["-"] + // Term = "(" Expr (*) ")" ["/"] + // + // ")" -> Shift(S25) + // "-" -> Shift(S22) + // "+" -> Shift(S20) + // + pub fn __state19< + __TOKENS: Iterator, + >( + scale: i32, + __lookbehind: Option<()>, + __lookahead: Option<((), Tok, ())>, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + __sym1: &mut Option, + ) -> Result<(Option<()>, Option<((), Tok, ())>, __Nonterminal<>), Option<((), Tok, ())>> + { + let mut __result: (Option<()>, Option<((), Tok, ())>, __Nonterminal<>); + match __lookahead { + Some((_, __tok @ Tok::RParen(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state25(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + Some((_, __tok @ Tok::Minus(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state22(scale, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); + } + Some((_, __tok @ Tok::Plus(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state20(scale, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + + // State 20 // Expr = Expr "+" (*) Factor [")"] // Expr = Expr "+" (*) Factor ["+"] // Expr = Expr "+" (*) Factor ["-"] @@ -1399,12 +1461,163 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "(" -> Shift(S10) - // "Num" -> Shift(S9) + // "Num" -> Shift(S10) + // "(" -> Shift(S12) // - // Factor -> S28 - // Term -> S7 - pub fn __state19< + // Term -> S11 + // Factor -> S26 + pub fn __state20< + __TOKENS: Iterator, + >( + scale: i32, + __lookbehind: Option<()>, + __lookahead: Option<((), Tok, ())>, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + __sym1: &mut Option, + ) -> Result<(Option<()>, Option<((), Tok, ())>, __Nonterminal<>), Option<((), Tok, ())>> + { + let mut __result: (Option<()>, Option<((), Tok, ())>, __Nonterminal<>); + match __lookahead { + Some((_, Tok::Num(__tok0), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok0)); + let __lookahead = __tokens.next(); + __result = try!(__state10(scale, __lookbehind, __lookahead, __tokens, __sym2)); + } + Some((_, __tok @ Tok::LParen(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state12(scale, __lookbehind, __lookahead, __tokens, __sym2)); + } + _ => { + return Err(__lookahead); + } + } + while __sym1.is_some() { + let (__lookbehind, __lookahead, __nt) = __result; + match __nt { + __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state11(scale, __lookbehind, __lookahead, __tokens, __sym2)); + } + __Nonterminal::Factor(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state26(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + _ => { + return Ok((__lookbehind, __lookahead, __nt)); + } + } + } + return Ok(__result); + } + + // State 21 + // Term = "(" Expr ")" (*) [EOF] + // Term = "(" Expr ")" (*) ["*"] + // Term = "(" Expr ")" (*) ["+"] + // Term = "(" Expr ")" (*) ["-"] + // Term = "(" Expr ")" (*) ["/"] + // + // "-" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) + // "+" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) + // "*" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) + // EOF -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) + // "/" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) + // + pub fn __state21< + __TOKENS: Iterator, + >( + scale: i32, + __lookbehind: Option<()>, + __lookahead: Option<((), Tok, ())>, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + __sym1: &mut Option, + __sym2: &mut Option, + ) -> Result<(Option<()>, Option<((), Tok, ())>, __Nonterminal<>), Option<((), Tok, ())>> + { + let mut __result: (Option<()>, Option<((), Tok, ())>, __Nonterminal<>); + match __lookahead { + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action8(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action8(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + Some((_, Tok::Times(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action8(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + None => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action8(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + Some((_, Tok::Div(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action8(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 22 + // Expr = Expr "-" (*) Factor [")"] + // Expr = Expr "-" (*) Factor ["+"] + // Expr = Expr "-" (*) Factor ["-"] + // Factor = (*) Factor "*" Term [")"] + // Factor = (*) Factor "*" Term ["*"] + // Factor = (*) Factor "*" Term ["+"] + // Factor = (*) Factor "*" Term ["-"] + // Factor = (*) Factor "*" Term ["/"] + // Factor = (*) Factor "/" Term [")"] + // Factor = (*) Factor "/" Term ["*"] + // Factor = (*) Factor "/" Term ["+"] + // Factor = (*) Factor "/" Term ["-"] + // Factor = (*) Factor "/" Term ["/"] + // Factor = (*) Term [")"] + // Factor = (*) Term ["*"] + // Factor = (*) Term ["+"] + // Factor = (*) Term ["-"] + // Factor = (*) Term ["/"] + // Term = (*) "(" Expr ")" [")"] + // Term = (*) "(" Expr ")" ["*"] + // Term = (*) "(" Expr ")" ["+"] + // Term = (*) "(" Expr ")" ["-"] + // Term = (*) "(" Expr ")" ["/"] + // Term = (*) "Num" [")"] + // Term = (*) "Num" ["*"] + // Term = (*) "Num" ["+"] + // Term = (*) "Num" ["-"] + // Term = (*) "Num" ["/"] + // + // "(" -> Shift(S12) + // "Num" -> Shift(S10) + // + // Factor -> S27 + // Term -> S11 + pub fn __state22< __TOKENS: Iterator, >( scale: i32, @@ -1421,13 +1634,13 @@ mod __parse__Expr { let mut __lookbehind = Some(__loc); let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state10(scale, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state12(scale, __lookbehind, __lookahead, __tokens, __sym2)); } Some((_, Tok::Num(__tok0), __loc)) => { let mut __lookbehind = Some(__loc); let mut __sym2 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state9(scale, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state10(scale, __lookbehind, __lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); @@ -1438,11 +1651,11 @@ mod __parse__Expr { match __nt { __Nonterminal::Factor(__nt) => { let __sym2 = &mut Some(__nt); - __result = try!(__state28(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + __result = try!(__state27(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); } __Nonterminal::Term(__nt) => { let __sym2 = &mut Some(__nt); - __result = try!(__state7(scale, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state11(scale, __lookbehind, __lookahead, __tokens, __sym2)); } _ => { return Ok((__lookbehind, __lookahead, __nt)); @@ -1452,218 +1665,27 @@ mod __parse__Expr { return Ok(__result); } - // State 20 - // Expr = Expr (*) "+" Factor [")"] - // Expr = Expr (*) "+" Factor ["+"] - // Expr = Expr (*) "+" Factor ["-"] - // Expr = Expr (*) "-" Factor [")"] - // Expr = Expr (*) "-" Factor ["+"] - // Expr = Expr (*) "-" Factor ["-"] - // Term = "(" Expr (*) ")" [")"] - // Term = "(" Expr (*) ")" ["*"] - // Term = "(" Expr (*) ")" ["+"] - // Term = "(" Expr (*) ")" ["-"] - // Term = "(" Expr (*) ")" ["/"] - // - // ")" -> Shift(S29) - // "+" -> Shift(S19) - // "-" -> Shift(S18) - // - pub fn __state20< - __TOKENS: Iterator, - >( - scale: i32, - __lookbehind: Option<()>, - __lookahead: Option<((), Tok, ())>, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option, - ) -> Result<(Option<()>, Option<((), Tok, ())>, __Nonterminal<>), Option<((), Tok, ())>> - { - let mut __result: (Option<()>, Option<((), Tok, ())>, __Nonterminal<>); - match __lookahead { - Some((_, __tok @ Tok::RParen(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state29(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - Some((_, __tok @ Tok::Plus(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state19(scale, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); - } - Some((_, __tok @ Tok::Minus(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state18(scale, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 21 - // Factor = Factor "/" Term (*) [EOF] - // Factor = Factor "/" Term (*) ["*"] - // Factor = Factor "/" Term (*) ["+"] - // Factor = Factor "/" Term (*) ["-"] - // Factor = Factor "/" Term (*) ["/"] - // - // "-" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // EOF -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // "*" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // "/" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // "+" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // - pub fn __state21< - __TOKENS: Iterator, - >( - scale: i32, - __lookbehind: Option<()>, - __lookahead: Option<((), Tok, ())>, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option, - __sym2: &mut Option, - ) -> Result<(Option<()>, Option<((), Tok, ())>, __Nonterminal<>), Option<((), Tok, ())>> - { - let mut __result: (Option<()>, Option<((), Tok, ())>, __Nonterminal<>); - match __lookahead { - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action5(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - None => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action5(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Times(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action5(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Div(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action5(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action5(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 22 - // Factor = Factor "*" Term (*) [EOF] - // Factor = Factor "*" Term (*) ["*"] - // Factor = Factor "*" Term (*) ["+"] - // Factor = Factor "*" Term (*) ["-"] - // Factor = Factor "*" Term (*) ["/"] - // - // "+" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) - // "*" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) - // "-" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) - // EOF -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) - // "/" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) - // - pub fn __state22< - __TOKENS: Iterator, - >( - scale: i32, - __lookbehind: Option<()>, - __lookahead: Option<((), Tok, ())>, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option, - __sym2: &mut Option, - ) -> Result<(Option<()>, Option<((), Tok, ())>, __Nonterminal<>), Option<((), Tok, ())>> - { - let mut __result: (Option<()>, Option<((), Tok, ())>, __Nonterminal<>); - match __lookahead { - Some((_, Tok::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action4(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Times(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action4(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action4(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - None => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action4(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Div(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action4(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - // State 23 - // Expr = Expr "+" Factor (*) [EOF] - // Expr = Expr "+" Factor (*) ["+"] - // Expr = Expr "+" Factor (*) ["-"] - // Factor = Factor (*) "*" Term [EOF] - // Factor = Factor (*) "*" Term ["*"] - // Factor = Factor (*) "*" Term ["+"] - // Factor = Factor (*) "*" Term ["-"] - // Factor = Factor (*) "*" Term ["/"] - // Factor = Factor (*) "/" Term [EOF] - // Factor = Factor (*) "/" Term ["*"] - // Factor = Factor (*) "/" Term ["+"] - // Factor = Factor (*) "/" Term ["-"] - // Factor = Factor (*) "/" Term ["/"] + // Factor = Factor "/" (*) Term [")"] + // Factor = Factor "/" (*) Term ["*"] + // Factor = Factor "/" (*) Term ["+"] + // Factor = Factor "/" (*) Term ["-"] + // Factor = Factor "/" (*) Term ["/"] + // Term = (*) "(" Expr ")" [")"] + // Term = (*) "(" Expr ")" ["*"] + // Term = (*) "(" Expr ")" ["+"] + // Term = (*) "(" Expr ")" ["-"] + // Term = (*) "(" Expr ")" ["/"] + // Term = (*) "Num" [")"] + // Term = (*) "Num" ["*"] + // Term = (*) "Num" ["+"] + // Term = (*) "Num" ["-"] + // Term = (*) "Num" ["/"] // - // "-" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) - // EOF -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) - // "/" -> Shift(S11) - // "+" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) - // "*" -> Shift(S12) + // "(" -> Shift(S12) + // "Num" -> Shift(S10) // + // Term -> S28 pub fn __state23< __TOKENS: Iterator, >( @@ -1673,72 +1695,62 @@ mod __parse__Expr { __tokens: &mut __TOKENS, __sym0: &mut Option, __sym1: &mut Option, - __sym2: &mut Option, ) -> Result<(Option<()>, Option<((), Tok, ())>, __Nonterminal<>), Option<((), Tok, ())>> { let mut __result: (Option<()>, Option<((), Tok, ())>, __Nonterminal<>); match __lookahead { - Some((_, __tok @ Tok::Div(..), __loc)) => { + Some((_, __tok @ Tok::LParen(..), __loc)) => { let mut __lookbehind = Some(__loc); - let mut __sym3 = &mut Some((__tok)); + let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state11(scale, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); + __result = try!(__state12(scale, __lookbehind, __lookahead, __tokens, __sym2)); } - Some((_, __tok @ Tok::Times(..), __loc)) => { + Some((_, Tok::Num(__tok0), __loc)) => { let mut __lookbehind = Some(__loc); - let mut __sym3 = &mut Some((__tok)); + let mut __sym2 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state12(scale, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); - } - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action2(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - None => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action2(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - Some((_, Tok::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action2(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + __result = try!(__state10(scale, __lookbehind, __lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); } } + while __sym1.is_some() { + let (__lookbehind, __lookahead, __nt) = __result; + match __nt { + __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state28(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + _ => { + return Ok((__lookbehind, __lookahead, __nt)); + } + } + } return Ok(__result); } // State 24 - // Expr = Expr "-" Factor (*) [EOF] - // Expr = Expr "-" Factor (*) ["+"] - // Expr = Expr "-" Factor (*) ["-"] - // Factor = Factor (*) "*" Term [EOF] - // Factor = Factor (*) "*" Term ["*"] - // Factor = Factor (*) "*" Term ["+"] - // Factor = Factor (*) "*" Term ["-"] - // Factor = Factor (*) "*" Term ["/"] - // Factor = Factor (*) "/" Term [EOF] - // Factor = Factor (*) "/" Term ["*"] - // Factor = Factor (*) "/" Term ["+"] - // Factor = Factor (*) "/" Term ["-"] - // Factor = Factor (*) "/" Term ["/"] + // Factor = Factor "*" (*) Term [")"] + // Factor = Factor "*" (*) Term ["*"] + // Factor = Factor "*" (*) Term ["+"] + // Factor = Factor "*" (*) Term ["-"] + // Factor = Factor "*" (*) Term ["/"] + // Term = (*) "(" Expr ")" [")"] + // Term = (*) "(" Expr ")" ["*"] + // Term = (*) "(" Expr ")" ["+"] + // Term = (*) "(" Expr ")" ["-"] + // Term = (*) "(" Expr ")" ["/"] + // Term = (*) "Num" [")"] + // Term = (*) "Num" ["*"] + // Term = (*) "Num" ["+"] + // Term = (*) "Num" ["-"] + // Term = (*) "Num" ["/"] // - // "/" -> Shift(S11) - // "*" -> Shift(S12) - // EOF -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) - // "+" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) - // "-" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // "(" -> Shift(S12) + // "Num" -> Shift(S10) // + // Term -> S29 pub fn __state24< __TOKENS: Iterator, >( @@ -1748,338 +1760,42 @@ mod __parse__Expr { __tokens: &mut __TOKENS, __sym0: &mut Option, __sym1: &mut Option, - __sym2: &mut Option, ) -> Result<(Option<()>, Option<((), Tok, ())>, __Nonterminal<>), Option<((), Tok, ())>> { let mut __result: (Option<()>, Option<((), Tok, ())>, __Nonterminal<>); match __lookahead { - Some((_, __tok @ Tok::Div(..), __loc)) => { + Some((_, __tok @ Tok::LParen(..), __loc)) => { let mut __lookbehind = Some(__loc); - let mut __sym3 = &mut Some((__tok)); + let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state11(scale, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); + __result = try!(__state12(scale, __lookbehind, __lookahead, __tokens, __sym2)); } - Some((_, __tok @ Tok::Times(..), __loc)) => { + Some((_, Tok::Num(__tok0), __loc)) => { let mut __lookbehind = Some(__loc); - let mut __sym3 = &mut Some((__tok)); + let mut __sym2 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state12(scale, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); - } - None => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action1(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - Some((_, Tok::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action1(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action1(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + __result = try!(__state10(scale, __lookbehind, __lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); } } + while __sym1.is_some() { + let (__lookbehind, __lookahead, __nt) = __result; + match __nt { + __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state29(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + _ => { + return Ok((__lookbehind, __lookahead, __nt)); + } + } + } return Ok(__result); } // State 25 - // Factor = Factor "/" Term (*) [")"] - // Factor = Factor "/" Term (*) ["*"] - // Factor = Factor "/" Term (*) ["+"] - // Factor = Factor "/" Term (*) ["-"] - // Factor = Factor "/" Term (*) ["/"] - // - // "-" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // "/" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // "*" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // ")" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // "+" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // - pub fn __state25< - __TOKENS: Iterator, - >( - scale: i32, - __lookbehind: Option<()>, - __lookahead: Option<((), Tok, ())>, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option, - __sym2: &mut Option, - ) -> Result<(Option<()>, Option<((), Tok, ())>, __Nonterminal<>), Option<((), Tok, ())>> - { - let mut __result: (Option<()>, Option<((), Tok, ())>, __Nonterminal<>); - match __lookahead { - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action5(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Div(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action5(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Times(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action5(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::RParen(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action5(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action5(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 26 - // Factor = Factor "*" Term (*) [")"] - // Factor = Factor "*" Term (*) ["*"] - // Factor = Factor "*" Term (*) ["+"] - // Factor = Factor "*" Term (*) ["-"] - // Factor = Factor "*" Term (*) ["/"] - // - // "/" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) - // "*" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) - // "-" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) - // "+" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) - // ")" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) - // - pub fn __state26< - __TOKENS: Iterator, - >( - scale: i32, - __lookbehind: Option<()>, - __lookahead: Option<((), Tok, ())>, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option, - __sym2: &mut Option, - ) -> Result<(Option<()>, Option<((), Tok, ())>, __Nonterminal<>), Option<((), Tok, ())>> - { - let mut __result: (Option<()>, Option<((), Tok, ())>, __Nonterminal<>); - match __lookahead { - Some((_, Tok::Div(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action4(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Times(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action4(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action4(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action4(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::RParen(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action4(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 27 - // Expr = Expr "-" Factor (*) [")"] - // Expr = Expr "-" Factor (*) ["+"] - // Expr = Expr "-" Factor (*) ["-"] - // Factor = Factor (*) "*" Term [")"] - // Factor = Factor (*) "*" Term ["*"] - // Factor = Factor (*) "*" Term ["+"] - // Factor = Factor (*) "*" Term ["-"] - // Factor = Factor (*) "*" Term ["/"] - // Factor = Factor (*) "/" Term [")"] - // Factor = Factor (*) "/" Term ["*"] - // Factor = Factor (*) "/" Term ["+"] - // Factor = Factor (*) "/" Term ["-"] - // Factor = Factor (*) "/" Term ["/"] - // - // "+" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) - // ")" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) - // "*" -> Shift(S16) - // "/" -> Shift(S15) - // "-" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) - // - pub fn __state27< - __TOKENS: Iterator, - >( - scale: i32, - __lookbehind: Option<()>, - __lookahead: Option<((), Tok, ())>, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option, - __sym2: &mut Option, - ) -> Result<(Option<()>, Option<((), Tok, ())>, __Nonterminal<>), Option<((), Tok, ())>> - { - let mut __result: (Option<()>, Option<((), Tok, ())>, __Nonterminal<>); - match __lookahead { - Some((_, __tok @ Tok::Times(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym3 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state16(scale, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); - } - Some((_, __tok @ Tok::Div(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym3 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state15(scale, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); - } - Some((_, Tok::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action1(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - Some((_, Tok::RParen(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action1(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action1(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 28 - // Expr = Expr "+" Factor (*) [")"] - // Expr = Expr "+" Factor (*) ["+"] - // Expr = Expr "+" Factor (*) ["-"] - // Factor = Factor (*) "*" Term [")"] - // Factor = Factor (*) "*" Term ["*"] - // Factor = Factor (*) "*" Term ["+"] - // Factor = Factor (*) "*" Term ["-"] - // Factor = Factor (*) "*" Term ["/"] - // Factor = Factor (*) "/" Term [")"] - // Factor = Factor (*) "/" Term ["*"] - // Factor = Factor (*) "/" Term ["+"] - // Factor = Factor (*) "/" Term ["-"] - // Factor = Factor (*) "/" Term ["/"] - // - // "*" -> Shift(S16) - // ")" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) - // "-" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) - // "+" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) - // "/" -> Shift(S15) - // - pub fn __state28< - __TOKENS: Iterator, - >( - scale: i32, - __lookbehind: Option<()>, - __lookahead: Option<((), Tok, ())>, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option, - __sym2: &mut Option, - ) -> Result<(Option<()>, Option<((), Tok, ())>, __Nonterminal<>), Option<((), Tok, ())>> - { - let mut __result: (Option<()>, Option<((), Tok, ())>, __Nonterminal<>); - match __lookahead { - Some((_, __tok @ Tok::Times(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym3 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state16(scale, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); - } - Some((_, __tok @ Tok::Div(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym3 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state15(scale, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); - } - Some((_, Tok::RParen(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action2(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action2(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - Some((_, Tok::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action2(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 29 // Term = "(" Expr ")" (*) [")"] // Term = "(" Expr ")" (*) ["*"] // Term = "(" Expr ")" (*) ["+"] @@ -2087,12 +1803,12 @@ mod __parse__Expr { // Term = "(" Expr ")" (*) ["/"] // // ")" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) - // "*" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) // "+" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) // "-" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) // "/" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) + // "*" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) // - pub fn __state29< + pub fn __state25< __TOKENS: Iterator, >( scale: i32, @@ -2113,13 +1829,6 @@ mod __parse__Expr { let __nt = super::__action8(scale, __sym0, __sym1, __sym2); return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); } - Some((_, Tok::Times(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action8(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } Some((_, Tok::Plus(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); @@ -2141,6 +1850,299 @@ mod __parse__Expr { let __nt = super::__action8(scale, __sym0, __sym1, __sym2); return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); } + Some((_, Tok::Times(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action8(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 26 + // Expr = Expr "+" Factor (*) [")"] + // Expr = Expr "+" Factor (*) ["+"] + // Expr = Expr "+" Factor (*) ["-"] + // Factor = Factor (*) "*" Term [")"] + // Factor = Factor (*) "*" Term ["*"] + // Factor = Factor (*) "*" Term ["+"] + // Factor = Factor (*) "*" Term ["-"] + // Factor = Factor (*) "*" Term ["/"] + // Factor = Factor (*) "/" Term [")"] + // Factor = Factor (*) "/" Term ["*"] + // Factor = Factor (*) "/" Term ["+"] + // Factor = Factor (*) "/" Term ["-"] + // Factor = Factor (*) "/" Term ["/"] + // + // "-" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) + // ")" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) + // "*" -> Shift(S24) + // "+" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) + // "/" -> Shift(S23) + // + pub fn __state26< + __TOKENS: Iterator, + >( + scale: i32, + __lookbehind: Option<()>, + __lookahead: Option<((), Tok, ())>, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + __sym1: &mut Option, + __sym2: &mut Option, + ) -> Result<(Option<()>, Option<((), Tok, ())>, __Nonterminal<>), Option<((), Tok, ())>> + { + let mut __result: (Option<()>, Option<((), Tok, ())>, __Nonterminal<>); + match __lookahead { + Some((_, __tok @ Tok::Times(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym3 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state24(scale, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); + } + Some((_, __tok @ Tok::Div(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym3 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state23(scale, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action2(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + Some((_, Tok::RParen(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action2(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action2(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + + // State 27 + // Expr = Expr "-" Factor (*) [")"] + // Expr = Expr "-" Factor (*) ["+"] + // Expr = Expr "-" Factor (*) ["-"] + // Factor = Factor (*) "*" Term [")"] + // Factor = Factor (*) "*" Term ["*"] + // Factor = Factor (*) "*" Term ["+"] + // Factor = Factor (*) "*" Term ["-"] + // Factor = Factor (*) "*" Term ["/"] + // Factor = Factor (*) "/" Term [")"] + // Factor = Factor (*) "/" Term ["*"] + // Factor = Factor (*) "/" Term ["+"] + // Factor = Factor (*) "/" Term ["-"] + // Factor = Factor (*) "/" Term ["/"] + // + // "-" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // "+" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // "/" -> Shift(S23) + // "*" -> Shift(S24) + // ")" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // + pub fn __state27< + __TOKENS: Iterator, + >( + scale: i32, + __lookbehind: Option<()>, + __lookahead: Option<((), Tok, ())>, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + __sym1: &mut Option, + __sym2: &mut Option, + ) -> Result<(Option<()>, Option<((), Tok, ())>, __Nonterminal<>), Option<((), Tok, ())>> + { + let mut __result: (Option<()>, Option<((), Tok, ())>, __Nonterminal<>); + match __lookahead { + Some((_, __tok @ Tok::Div(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym3 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state23(scale, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); + } + Some((_, __tok @ Tok::Times(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym3 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state24(scale, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action1(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action1(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + Some((_, Tok::RParen(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action1(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + + // State 28 + // Factor = Factor "/" Term (*) [")"] + // Factor = Factor "/" Term (*) ["*"] + // Factor = Factor "/" Term (*) ["+"] + // Factor = Factor "/" Term (*) ["-"] + // Factor = Factor "/" Term (*) ["/"] + // + // "*" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // "/" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // ")" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // "-" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // "+" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // + pub fn __state28< + __TOKENS: Iterator, + >( + scale: i32, + __lookbehind: Option<()>, + __lookahead: Option<((), Tok, ())>, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + __sym1: &mut Option, + __sym2: &mut Option, + ) -> Result<(Option<()>, Option<((), Tok, ())>, __Nonterminal<>), Option<((), Tok, ())>> + { + let mut __result: (Option<()>, Option<((), Tok, ())>, __Nonterminal<>); + match __lookahead { + Some((_, Tok::Times(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action5(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Div(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action5(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::RParen(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action5(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action5(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action5(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 29 + // Factor = Factor "*" Term (*) [")"] + // Factor = Factor "*" Term (*) ["*"] + // Factor = Factor "*" Term (*) ["+"] + // Factor = Factor "*" Term (*) ["-"] + // Factor = Factor "*" Term (*) ["/"] + // + // "/" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // "*" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // "+" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // ")" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // "-" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // + pub fn __state29< + __TOKENS: Iterator, + >( + scale: i32, + __lookbehind: Option<()>, + __lookahead: Option<((), Tok, ())>, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + __sym1: &mut Option, + __sym2: &mut Option, + ) -> Result<(Option<()>, Option<((), Tok, ())>, __Nonterminal<>), Option<((), Tok, ())>> + { + let mut __result: (Option<()>, Option<((), Tok, ())>, __Nonterminal<>); + match __lookahead { + Some((_, Tok::Div(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action4(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Times(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action4(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action4(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::RParen(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action4(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action4(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } _ => { return Err(__lookahead); } diff --git a/lalrpop-test/src/expr_arena.rs b/lalrpop-test/src/expr_arena.rs index a2fbc75..290bd93 100644 --- a/lalrpop-test/src/expr_arena.rs +++ b/lalrpop-test/src/expr_arena.rs @@ -36,16 +36,18 @@ mod __parse__Expr { use expr_arena_ast::{Arena, Node, Op}; use util::tok::Tok; + extern crate lalrpop_util as __lalrpop_util; + use self::__lalrpop_util::ParseError as __ParseError; pub enum __Nonterminal<'ast, > { - Comma_3cExpr_3e(Vec<&'ast Node<'ast>>), - _28_3cExpr_3e_20_22_2c_22_29_2a(::std::vec::Vec<&'ast Node<'ast>>), Factor(&'ast Node<'ast>), Term(&'ast Node<'ast>), Expr_3f(::std::option::Option<&'ast Node<'ast>>), - ____Expr(&'ast Node<'ast>), - _28_3cExpr_3e_20_22_2c_22_29(&'ast Node<'ast>), Expr(&'ast Node<'ast>), + _28_3cExpr_3e_20_22_2c_22_29_2a(::std::vec::Vec<&'ast Node<'ast>>), + ____Expr(&'ast Node<'ast>), + Comma_3cExpr_3e(Vec<&'ast Node<'ast>>), + _28_3cExpr_3e_20_22_2c_22_29(&'ast Node<'ast>), } // State 0 @@ -90,13 +92,13 @@ mod __parse__Expr { // Term = (*) "Num" ["/"] // __Expr = (*) Expr [EOF] // - // "(" -> Shift(S1) - // "Num" -> Shift(S5) + // "(" -> Shift(S6) // "*" -> Shift(S3) + // "Num" -> Shift(S4) // - // Factor -> S4 // Term -> S2 - // Expr -> S6 + // Factor -> S1 + // Expr -> S5 pub fn __state0< 'ast, __TOKENS: Iterator, @@ -113,13 +115,7 @@ mod __parse__Expr { let mut __lookbehind = Some(__loc); let mut __sym0 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state1(arena, __lookbehind, __lookahead, __tokens, __sym0)); - } - Some((_, Tok::Num(__tok0), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym0 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state5(arena, __lookbehind, __lookahead, __tokens, __sym0)); + __result = try!(__state6(arena, __lookbehind, __lookahead, __tokens, __sym0)); } Some((_, __tok @ Tok::Times(..), __loc)) => { let mut __lookbehind = Some(__loc); @@ -127,6 +123,12 @@ mod __parse__Expr { let __lookahead = __tokens.next(); __result = try!(__state3(arena, __lookbehind, __lookahead, __tokens, __sym0)); } + Some((_, Tok::Num(__tok0), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym0 = &mut Some((__tok0)); + let __lookahead = __tokens.next(); + __result = try!(__state4(arena, __lookbehind, __lookahead, __tokens, __sym0)); + } _ => { return Err(__lookahead); } @@ -134,17 +136,17 @@ mod __parse__Expr { loop { let (__lookbehind, __lookahead, __nt) = __result; match __nt { - __Nonterminal::Factor(__nt) => { - let __sym0 = &mut Some(__nt); - __result = try!(__state4(arena, __lookbehind, __lookahead, __tokens, __sym0)); - } __Nonterminal::Term(__nt) => { let __sym0 = &mut Some(__nt); __result = try!(__state2(arena, __lookbehind, __lookahead, __tokens, __sym0)); } + __Nonterminal::Factor(__nt) => { + let __sym0 = &mut Some(__nt); + __result = try!(__state1(arena, __lookbehind, __lookahead, __tokens, __sym0)); + } __Nonterminal::Expr(__nt) => { let __sym0 = &mut Some(__nt); - __result = try!(__state6(arena, __lookbehind, __lookahead, __tokens, __sym0)); + __result = try!(__state5(arena, __lookbehind, __lookahead, __tokens, __sym0)); } _ => { return Ok((__lookbehind, __lookahead, __nt)); @@ -154,6 +156,273 @@ mod __parse__Expr { } // State 1 + // Expr = Factor (*) [EOF] + // Expr = Factor (*) ["+"] + // Expr = Factor (*) ["-"] + // Factor = Factor (*) "*" Term [EOF] + // Factor = Factor (*) "*" Term ["*"] + // Factor = Factor (*) "*" Term ["+"] + // Factor = Factor (*) "*" Term ["-"] + // Factor = Factor (*) "*" Term ["/"] + // Factor = Factor (*) "/" Term [EOF] + // Factor = Factor (*) "/" Term ["*"] + // Factor = Factor (*) "/" Term ["+"] + // Factor = Factor (*) "/" Term ["-"] + // Factor = Factor (*) "/" Term ["/"] + // + // EOF -> Reduce(Expr = Factor => Call(ActionFn(3));) + // "*" -> Shift(S7) + // "+" -> Reduce(Expr = Factor => Call(ActionFn(3));) + // "/" -> Shift(S8) + // "-" -> Reduce(Expr = Factor => Call(ActionFn(3));) + // + pub fn __state1< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize, Tok, usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> + { + let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, __tok @ Tok::Times(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state7(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + } + Some((_, __tok @ Tok::Div(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state8(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + } + None => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action3(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action3(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action3(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + + // State 2 + // Factor = Term (*) [EOF] + // Factor = Term (*) ["*"] + // Factor = Term (*) ["+"] + // Factor = Term (*) ["-"] + // Factor = Term (*) ["/"] + // + // EOF -> Reduce(Factor = Term => Call(ActionFn(7));) + // "+" -> Reduce(Factor = Term => Call(ActionFn(7));) + // "/" -> Reduce(Factor = Term => Call(ActionFn(7));) + // "-" -> Reduce(Factor = Term => Call(ActionFn(7));) + // "*" -> Reduce(Factor = Term => Call(ActionFn(7));) + // + pub fn __state2< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize, Tok, usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> + { + let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); + match __lookahead { + None => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action7(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action7(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Div(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action7(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action7(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Times(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action7(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 3 + // Factor = "*" (*) "(" Comma ")" [EOF] + // Factor = "*" (*) "(" Comma ")" ["*"] + // Factor = "*" (*) "(" Comma ")" ["+"] + // Factor = "*" (*) "(" Comma ")" ["-"] + // Factor = "*" (*) "(" Comma ")" ["/"] + // + // "(" -> Shift(S9) + // + pub fn __state3< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize, Tok, usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> + { + let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, __tok @ Tok::LParen(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state9(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + + // State 4 + // Term = "Num" (*) [EOF] + // Term = "Num" (*) ["*"] + // Term = "Num" (*) ["+"] + // Term = "Num" (*) ["-"] + // Term = "Num" (*) ["/"] + // + // EOF -> Reduce(Term = "Num" => Call(ActionFn(8));) + // "*" -> Reduce(Term = "Num" => Call(ActionFn(8));) + // "/" -> Reduce(Term = "Num" => Call(ActionFn(8));) + // "+" -> Reduce(Term = "Num" => Call(ActionFn(8));) + // "-" -> Reduce(Term = "Num" => Call(ActionFn(8));) + // + pub fn __state4< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize, Tok, usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> + { + let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); + match __lookahead { + None => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action8(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + Some((_, Tok::Times(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action8(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + Some((_, Tok::Div(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action8(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action8(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action8(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 5 + // Expr = Expr (*) "+" Factor [EOF] + // Expr = Expr (*) "+" Factor ["+"] + // Expr = Expr (*) "+" Factor ["-"] + // Expr = Expr (*) "-" Factor [EOF] + // Expr = Expr (*) "-" Factor ["+"] + // Expr = Expr (*) "-" Factor ["-"] + // __Expr = Expr (*) [EOF] + // + // "-" -> Shift(S11) + // EOF -> Reduce(__Expr = Expr => Call(ActionFn(0));) + // "+" -> Shift(S10) + // + pub fn __state5< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize, Tok, usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> + { + let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, __tok @ Tok::Minus(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state11(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + } + Some((_, __tok @ Tok::Plus(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state10(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + } + None => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action0(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::____Expr(__nt))); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + + // State 6 // Expr = (*) Expr "+" Factor [")"] // Expr = (*) Expr "+" Factor ["+"] // Expr = (*) Expr "+" Factor ["-"] @@ -199,14 +468,14 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "Num" -> Shift(S11) - // "(" -> Shift(S7) - // "*" -> Shift(S8) + // "Num" -> Shift(S16) + // "*" -> Shift(S13) + // "(" -> Shift(S14) // - // Term -> S9 - // Expr -> S10 - // Factor -> S12 - pub fn __state1< + // Factor -> S15 + // Expr -> S17 + // Term -> S12 + pub fn __state6< 'ast, __TOKENS: Iterator, >( @@ -223,19 +492,19 @@ mod __parse__Expr { let mut __lookbehind = Some(__loc); let mut __sym1 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state11(arena, __lookbehind, __lookahead, __tokens, __sym1)); - } - Some((_, __tok @ Tok::LParen(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym1 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state7(arena, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state16(arena, __lookbehind, __lookahead, __tokens, __sym1)); } Some((_, __tok @ Tok::Times(..), __loc)) => { let mut __lookbehind = Some(__loc); let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state8(arena, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state13(arena, __lookbehind, __lookahead, __tokens, __sym1)); + } + Some((_, __tok @ Tok::LParen(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state14(arena, __lookbehind, __lookahead, __tokens, __sym1)); } _ => { return Err(__lookahead); @@ -244,15 +513,15 @@ mod __parse__Expr { while __sym0.is_some() { let (__lookbehind, __lookahead, __nt) = __result; match __nt { - __Nonterminal::Term(__nt) => { + __Nonterminal::Factor(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state9(arena, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state15(arena, __lookbehind, __lookahead, __tokens, __sym1)); } __Nonterminal::Expr(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state10(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + __result = try!(__state17(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); } - __Nonterminal::Factor(__nt) => { + __Nonterminal::Term(__nt) => { let __sym1 = &mut Some(__nt); __result = try!(__state12(arena, __lookbehind, __lookahead, __tokens, __sym1)); } @@ -264,20 +533,420 @@ mod __parse__Expr { return Ok(__result); } - // State 2 - // Factor = Term (*) [EOF] + // State 7 + // Factor = Factor "*" (*) Term [EOF] + // Factor = Factor "*" (*) Term ["*"] + // Factor = Factor "*" (*) Term ["+"] + // Factor = Factor "*" (*) Term ["-"] + // Factor = Factor "*" (*) Term ["/"] + // Term = (*) "(" Expr ")" [EOF] + // Term = (*) "(" Expr ")" ["*"] + // Term = (*) "(" Expr ")" ["+"] + // Term = (*) "(" Expr ")" ["-"] + // Term = (*) "(" Expr ")" ["/"] + // Term = (*) "Num" [EOF] + // Term = (*) "Num" ["*"] + // Term = (*) "Num" ["+"] + // Term = (*) "Num" ["-"] + // Term = (*) "Num" ["/"] + // + // "(" -> Shift(S6) + // "Num" -> Shift(S4) + // + // Term -> S18 + pub fn __state7< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize, Tok, usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + __sym1: &mut Option, + ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> + { + let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, __tok @ Tok::LParen(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state6(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + Some((_, Tok::Num(__tok0), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok0)); + let __lookahead = __tokens.next(); + __result = try!(__state4(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + _ => { + return Err(__lookahead); + } + } + while __sym1.is_some() { + let (__lookbehind, __lookahead, __nt) = __result; + match __nt { + __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state18(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + _ => { + return Ok((__lookbehind, __lookahead, __nt)); + } + } + } + return Ok(__result); + } + + // State 8 + // Factor = Factor "/" (*) Term [EOF] + // Factor = Factor "/" (*) Term ["*"] + // Factor = Factor "/" (*) Term ["+"] + // Factor = Factor "/" (*) Term ["-"] + // Factor = Factor "/" (*) Term ["/"] + // Term = (*) "(" Expr ")" [EOF] + // Term = (*) "(" Expr ")" ["*"] + // Term = (*) "(" Expr ")" ["+"] + // Term = (*) "(" Expr ")" ["-"] + // Term = (*) "(" Expr ")" ["/"] + // Term = (*) "Num" [EOF] + // Term = (*) "Num" ["*"] + // Term = (*) "Num" ["+"] + // Term = (*) "Num" ["-"] + // Term = (*) "Num" ["/"] + // + // "Num" -> Shift(S4) + // "(" -> Shift(S6) + // + // Term -> S19 + pub fn __state8< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize, Tok, usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + __sym1: &mut Option, + ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> + { + let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, Tok::Num(__tok0), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok0)); + let __lookahead = __tokens.next(); + __result = try!(__state4(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + Some((_, __tok @ Tok::LParen(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state6(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + _ => { + return Err(__lookahead); + } + } + while __sym1.is_some() { + let (__lookbehind, __lookahead, __nt) = __result; + match __nt { + __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state19(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + _ => { + return Ok((__lookbehind, __lookahead, __nt)); + } + } + } + return Ok(__result); + } + + // State 9 + // ( ",")* = (*) ["("] + // ( ",")* = (*) [")"] + // ( ",")* = (*) ["*"] + // ( ",")* = (*) ["Num"] + // ( ",")* = (*) ( ",")* ( ",") ["("] + // ( ",")* = (*) ( ",")* ( ",") [")"] + // ( ",")* = (*) ( ",")* ( ",") ["*"] + // ( ",")* = (*) ( ",")* ( ",") ["Num"] + // Comma = (*) ( ",")* Expr? [")"] + // Factor = "*" "(" (*) Comma ")" [EOF] + // Factor = "*" "(" (*) Comma ")" ["*"] + // Factor = "*" "(" (*) Comma ")" ["+"] + // Factor = "*" "(" (*) Comma ")" ["-"] + // Factor = "*" "(" (*) Comma ")" ["/"] + // + // "Num" -> Reduce(( ",")* = => Call(ActionFn(13));) + // "(" -> Reduce(( ",")* = => Call(ActionFn(13));) + // ")" -> Reduce(( ",")* = => Call(ActionFn(13));) + // "*" -> Reduce(( ",")* = => Call(ActionFn(13));) + // + // Comma -> S20 + // ( ",")* -> S21 + pub fn __state9< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize, Tok, usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + __sym1: &mut Option, + ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> + { + let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, Tok::Num(_), _)) => { + let __nt = super::__action13(arena, ); + __result = (__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); + } + Some((_, Tok::LParen(..), _)) => { + let __nt = super::__action13(arena, ); + __result = (__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); + } + Some((_, Tok::RParen(..), _)) => { + let __nt = super::__action13(arena, ); + __result = (__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); + } + Some((_, Tok::Times(..), _)) => { + let __nt = super::__action13(arena, ); + __result = (__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); + } + _ => { + return Err(__lookahead); + } + } + while __sym1.is_some() { + let (__lookbehind, __lookahead, __nt) = __result; + match __nt { + __Nonterminal::Comma_3cExpr_3e(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state20(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state21(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + _ => { + return Ok((__lookbehind, __lookahead, __nt)); + } + } + } + return Ok(__result); + } + + // State 10 + // Expr = Expr "+" (*) Factor [EOF] + // Expr = Expr "+" (*) Factor ["+"] + // Expr = Expr "+" (*) Factor ["-"] + // Factor = (*) Factor "*" Term [EOF] + // Factor = (*) Factor "*" Term ["*"] + // Factor = (*) Factor "*" Term ["+"] + // Factor = (*) Factor "*" Term ["-"] + // Factor = (*) Factor "*" Term ["/"] + // Factor = (*) Factor "/" Term [EOF] + // Factor = (*) Factor "/" Term ["*"] + // Factor = (*) Factor "/" Term ["+"] + // Factor = (*) Factor "/" Term ["-"] + // Factor = (*) Factor "/" Term ["/"] + // Factor = (*) Term [EOF] + // Factor = (*) Term ["*"] + // Factor = (*) Term ["+"] + // Factor = (*) Term ["-"] + // Factor = (*) Term ["/"] + // Factor = (*) "*" "(" Comma ")" [EOF] + // Factor = (*) "*" "(" Comma ")" ["*"] + // Factor = (*) "*" "(" Comma ")" ["+"] + // Factor = (*) "*" "(" Comma ")" ["-"] + // Factor = (*) "*" "(" Comma ")" ["/"] + // Term = (*) "(" Expr ")" [EOF] + // Term = (*) "(" Expr ")" ["*"] + // Term = (*) "(" Expr ")" ["+"] + // Term = (*) "(" Expr ")" ["-"] + // Term = (*) "(" Expr ")" ["/"] + // Term = (*) "Num" [EOF] + // Term = (*) "Num" ["*"] + // Term = (*) "Num" ["+"] + // Term = (*) "Num" ["-"] + // Term = (*) "Num" ["/"] + // + // "*" -> Shift(S3) + // "Num" -> Shift(S4) + // "(" -> Shift(S6) + // + // Factor -> S22 + // Term -> S2 + pub fn __state10< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize, Tok, usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + __sym1: &mut Option, + ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> + { + let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, __tok @ Tok::Times(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state3(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + Some((_, Tok::Num(__tok0), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok0)); + let __lookahead = __tokens.next(); + __result = try!(__state4(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + Some((_, __tok @ Tok::LParen(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state6(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + _ => { + return Err(__lookahead); + } + } + while __sym1.is_some() { + let (__lookbehind, __lookahead, __nt) = __result; + match __nt { + __Nonterminal::Factor(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state22(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state2(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + _ => { + return Ok((__lookbehind, __lookahead, __nt)); + } + } + } + return Ok(__result); + } + + // State 11 + // Expr = Expr "-" (*) Factor [EOF] + // Expr = Expr "-" (*) Factor ["+"] + // Expr = Expr "-" (*) Factor ["-"] + // Factor = (*) Factor "*" Term [EOF] + // Factor = (*) Factor "*" Term ["*"] + // Factor = (*) Factor "*" Term ["+"] + // Factor = (*) Factor "*" Term ["-"] + // Factor = (*) Factor "*" Term ["/"] + // Factor = (*) Factor "/" Term [EOF] + // Factor = (*) Factor "/" Term ["*"] + // Factor = (*) Factor "/" Term ["+"] + // Factor = (*) Factor "/" Term ["-"] + // Factor = (*) Factor "/" Term ["/"] + // Factor = (*) Term [EOF] + // Factor = (*) Term ["*"] + // Factor = (*) Term ["+"] + // Factor = (*) Term ["-"] + // Factor = (*) Term ["/"] + // Factor = (*) "*" "(" Comma ")" [EOF] + // Factor = (*) "*" "(" Comma ")" ["*"] + // Factor = (*) "*" "(" Comma ")" ["+"] + // Factor = (*) "*" "(" Comma ")" ["-"] + // Factor = (*) "*" "(" Comma ")" ["/"] + // Term = (*) "(" Expr ")" [EOF] + // Term = (*) "(" Expr ")" ["*"] + // Term = (*) "(" Expr ")" ["+"] + // Term = (*) "(" Expr ")" ["-"] + // Term = (*) "(" Expr ")" ["/"] + // Term = (*) "Num" [EOF] + // Term = (*) "Num" ["*"] + // Term = (*) "Num" ["+"] + // Term = (*) "Num" ["-"] + // Term = (*) "Num" ["/"] + // + // "(" -> Shift(S6) + // "Num" -> Shift(S4) + // "*" -> Shift(S3) + // + // Term -> S2 + // Factor -> S23 + pub fn __state11< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize, Tok, usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + __sym1: &mut Option, + ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> + { + let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, __tok @ Tok::LParen(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state6(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + Some((_, Tok::Num(__tok0), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok0)); + let __lookahead = __tokens.next(); + __result = try!(__state4(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + Some((_, __tok @ Tok::Times(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state3(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + _ => { + return Err(__lookahead); + } + } + while __sym1.is_some() { + let (__lookbehind, __lookahead, __nt) = __result; + match __nt { + __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state2(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + __Nonterminal::Factor(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state23(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + _ => { + return Ok((__lookbehind, __lookahead, __nt)); + } + } + } + return Ok(__result); + } + + // State 12 + // Factor = Term (*) [")"] // Factor = Term (*) ["*"] // Factor = Term (*) ["+"] // Factor = Term (*) ["-"] // Factor = Term (*) ["/"] // - // "*" -> Reduce(Factor = Term => Call(ActionFn(7));) - // "/" -> Reduce(Factor = Term => Call(ActionFn(7));) // "-" -> Reduce(Factor = Term => Call(ActionFn(7));) // "+" -> Reduce(Factor = Term => Call(ActionFn(7));) - // EOF -> Reduce(Factor = Term => Call(ActionFn(7));) + // "/" -> Reduce(Factor = Term => Call(ActionFn(7));) + // ")" -> Reduce(Factor = Term => Call(ActionFn(7));) + // "*" -> Reduce(Factor = Term => Call(ActionFn(7));) // - pub fn __state2< + pub fn __state12< 'ast, __TOKENS: Iterator, >( @@ -290,16 +959,6 @@ mod __parse__Expr { { let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); match __lookahead { - Some((_, Tok::Times(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action7(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Div(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action7(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } Some((_, Tok::Minus(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __nt = super::__action7(arena, __sym0); @@ -310,7 +969,17 @@ mod __parse__Expr { let __nt = super::__action7(arena, __sym0); return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } - None => { + Some((_, Tok::Div(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action7(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::RParen(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action7(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Times(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __nt = super::__action7(arena, __sym0); return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); @@ -321,16 +990,16 @@ mod __parse__Expr { } } - // State 3 - // Factor = "*" (*) "(" Comma ")" [EOF] + // State 13 + // Factor = "*" (*) "(" Comma ")" [")"] // Factor = "*" (*) "(" Comma ")" ["*"] // Factor = "*" (*) "(" Comma ")" ["+"] // Factor = "*" (*) "(" Comma ")" ["-"] // Factor = "*" (*) "(" Comma ")" ["/"] // - // "(" -> Shift(S13) + // "(" -> Shift(S24) // - pub fn __state3< + pub fn __state13< 'ast, __TOKENS: Iterator, >( @@ -347,7 +1016,7 @@ mod __parse__Expr { let mut __lookbehind = Some(__loc); let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state13(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + __result = try!(__state24(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); } _ => { return Err(__lookahead); @@ -356,182 +1025,7 @@ mod __parse__Expr { return Ok(__result); } - // State 4 - // Expr = Factor (*) [EOF] - // Expr = Factor (*) ["+"] - // Expr = Factor (*) ["-"] - // Factor = Factor (*) "*" Term [EOF] - // Factor = Factor (*) "*" Term ["*"] - // Factor = Factor (*) "*" Term ["+"] - // Factor = Factor (*) "*" Term ["-"] - // Factor = Factor (*) "*" Term ["/"] - // Factor = Factor (*) "/" Term [EOF] - // Factor = Factor (*) "/" Term ["*"] - // Factor = Factor (*) "/" Term ["+"] - // Factor = Factor (*) "/" Term ["-"] - // Factor = Factor (*) "/" Term ["/"] - // - // "+" -> Reduce(Expr = Factor => Call(ActionFn(3));) - // "*" -> Shift(S15) - // "-" -> Reduce(Expr = Factor => Call(ActionFn(3));) - // EOF -> Reduce(Expr = Factor => Call(ActionFn(3));) - // "/" -> Shift(S14) - // - pub fn __state4< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize, Tok, usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> - { - let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, __tok @ Tok::Times(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym1 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state15(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); - } - Some((_, __tok @ Tok::Div(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym1 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state14(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); - } - Some((_, Tok::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action3(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action3(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - None => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action3(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 5 - // Term = "Num" (*) [EOF] - // Term = "Num" (*) ["*"] - // Term = "Num" (*) ["+"] - // Term = "Num" (*) ["-"] - // Term = "Num" (*) ["/"] - // - // "/" -> Reduce(Term = "Num" => Call(ActionFn(8));) - // EOF -> Reduce(Term = "Num" => Call(ActionFn(8));) - // "-" -> Reduce(Term = "Num" => Call(ActionFn(8));) - // "*" -> Reduce(Term = "Num" => Call(ActionFn(8));) - // "+" -> Reduce(Term = "Num" => Call(ActionFn(8));) - // - pub fn __state5< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize, Tok, usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> - { - let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, Tok::Div(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action8(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - None => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action8(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action8(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - Some((_, Tok::Times(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action8(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - Some((_, Tok::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action8(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 6 - // Expr = Expr (*) "+" Factor [EOF] - // Expr = Expr (*) "+" Factor ["+"] - // Expr = Expr (*) "+" Factor ["-"] - // Expr = Expr (*) "-" Factor [EOF] - // Expr = Expr (*) "-" Factor ["+"] - // Expr = Expr (*) "-" Factor ["-"] - // __Expr = Expr (*) [EOF] - // - // "+" -> Shift(S17) - // "-" -> Shift(S16) - // EOF -> Reduce(__Expr = Expr => Call(ActionFn(0));) - // - pub fn __state6< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize, Tok, usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> - { - let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, __tok @ Tok::Plus(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym1 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state17(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); - } - Some((_, __tok @ Tok::Minus(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym1 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state16(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); - } - None => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action0(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::____Expr(__nt))); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 7 + // State 14 // Expr = (*) Expr "+" Factor [")"] // Expr = (*) Expr "+" Factor ["+"] // Expr = (*) Expr "+" Factor ["-"] @@ -577,14 +1071,14 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "*" -> Shift(S8) - // "Num" -> Shift(S11) - // "(" -> Shift(S7) + // "Num" -> Shift(S16) + // "(" -> Shift(S14) + // "*" -> Shift(S13) // - // Factor -> S12 - // Expr -> S18 - // Term -> S9 - pub fn __state7< + // Factor -> S15 + // Term -> S12 + // Expr -> S25 + pub fn __state14< 'ast, __TOKENS: Iterator, >( @@ -597,23 +1091,23 @@ mod __parse__Expr { { let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); match __lookahead { - Some((_, __tok @ Tok::Times(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym1 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state8(arena, __lookbehind, __lookahead, __tokens, __sym1)); - } Some((_, Tok::Num(__tok0), __loc)) => { let mut __lookbehind = Some(__loc); let mut __sym1 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state11(arena, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state16(arena, __lookbehind, __lookahead, __tokens, __sym1)); } Some((_, __tok @ Tok::LParen(..), __loc)) => { let mut __lookbehind = Some(__loc); let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state7(arena, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state14(arena, __lookbehind, __lookahead, __tokens, __sym1)); + } + Some((_, __tok @ Tok::Times(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state13(arena, __lookbehind, __lookahead, __tokens, __sym1)); } _ => { return Err(__lookahead); @@ -623,16 +1117,16 @@ mod __parse__Expr { let (__lookbehind, __lookahead, __nt) = __result; match __nt { __Nonterminal::Factor(__nt) => { + let __sym1 = &mut Some(__nt); + __result = try!(__state15(arena, __lookbehind, __lookahead, __tokens, __sym1)); + } + __Nonterminal::Term(__nt) => { let __sym1 = &mut Some(__nt); __result = try!(__state12(arena, __lookbehind, __lookahead, __tokens, __sym1)); } __Nonterminal::Expr(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state18(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); - } - __Nonterminal::Term(__nt) => { - let __sym1 = &mut Some(__nt); - __result = try!(__state9(arena, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state25(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); } _ => { return Ok((__lookbehind, __lookahead, __nt)); @@ -642,55 +1136,28 @@ mod __parse__Expr { return Ok(__result); } - // State 8 - // Factor = "*" (*) "(" Comma ")" [")"] - // Factor = "*" (*) "(" Comma ")" ["*"] - // Factor = "*" (*) "(" Comma ")" ["+"] - // Factor = "*" (*) "(" Comma ")" ["-"] - // Factor = "*" (*) "(" Comma ")" ["/"] + // State 15 + // Expr = Factor (*) [")"] + // Expr = Factor (*) ["+"] + // Expr = Factor (*) ["-"] + // Factor = Factor (*) "*" Term [")"] + // Factor = Factor (*) "*" Term ["*"] + // Factor = Factor (*) "*" Term ["+"] + // Factor = Factor (*) "*" Term ["-"] + // Factor = Factor (*) "*" Term ["/"] + // Factor = Factor (*) "/" Term [")"] + // Factor = Factor (*) "/" Term ["*"] + // Factor = Factor (*) "/" Term ["+"] + // Factor = Factor (*) "/" Term ["-"] + // Factor = Factor (*) "/" Term ["/"] // - // "(" -> Shift(S19) + // "/" -> Shift(S26) + // "-" -> Reduce(Expr = Factor => Call(ActionFn(3));) + // "*" -> Shift(S27) + // ")" -> Reduce(Expr = Factor => Call(ActionFn(3));) + // "+" -> Reduce(Expr = Factor => Call(ActionFn(3));) // - pub fn __state8< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize, Tok, usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> - { - let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, __tok @ Tok::LParen(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym1 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state19(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 9 - // Factor = Term (*) [")"] - // Factor = Term (*) ["*"] - // Factor = Term (*) ["+"] - // Factor = Term (*) ["-"] - // Factor = Term (*) ["/"] - // - // ")" -> Reduce(Factor = Term => Call(ActionFn(7));) - // "-" -> Reduce(Factor = Term => Call(ActionFn(7));) - // "/" -> Reduce(Factor = Term => Call(ActionFn(7));) - // "+" -> Reduce(Factor = Term => Call(ActionFn(7));) - // "*" -> Reduce(Factor = Term => Call(ActionFn(7));) - // - pub fn __state9< + pub fn __state15< 'ast, __TOKENS: Iterator, >( @@ -703,85 +1170,32 @@ mod __parse__Expr { { let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); match __lookahead { - Some((_, Tok::RParen(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action7(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + Some((_, __tok @ Tok::Div(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state26(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + } + Some((_, __tok @ Tok::Times(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state27(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); } Some((_, Tok::Minus(..), _)) => { let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action7(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + let __nt = super::__action3(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); } - Some((_, Tok::Div(..), _)) => { + Some((_, Tok::RParen(..), _)) => { let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action7(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + let __nt = super::__action3(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); } Some((_, Tok::Plus(..), _)) => { let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action7(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Times(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action7(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 10 - // Expr = Expr (*) "+" Factor [")"] - // Expr = Expr (*) "+" Factor ["+"] - // Expr = Expr (*) "+" Factor ["-"] - // Expr = Expr (*) "-" Factor [")"] - // Expr = Expr (*) "-" Factor ["+"] - // Expr = Expr (*) "-" Factor ["-"] - // Term = "(" Expr (*) ")" [EOF] - // Term = "(" Expr (*) ")" ["*"] - // Term = "(" Expr (*) ")" ["+"] - // Term = "(" Expr (*) ")" ["-"] - // Term = "(" Expr (*) ")" ["/"] - // - // "-" -> Shift(S20) - // "+" -> Shift(S22) - // ")" -> Shift(S21) - // - pub fn __state10< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize, Tok, usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> - { - let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, __tok @ Tok::Minus(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state20(arena, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); - } - Some((_, __tok @ Tok::Plus(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state22(arena, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); - } - Some((_, __tok @ Tok::RParen(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state21(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + let __nt = super::__action3(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); } _ => { return Err(__lookahead); @@ -790,7 +1204,7 @@ mod __parse__Expr { return Ok(__result); } - // State 11 + // State 16 // Term = "Num" (*) [")"] // Term = "Num" (*) ["*"] // Term = "Num" (*) ["+"] @@ -798,12 +1212,12 @@ mod __parse__Expr { // Term = "Num" (*) ["/"] // // "/" -> Reduce(Term = "Num" => Call(ActionFn(8));) - // "+" -> Reduce(Term = "Num" => Call(ActionFn(8));) // "-" -> Reduce(Term = "Num" => Call(ActionFn(8));) - // "*" -> Reduce(Term = "Num" => Call(ActionFn(8));) // ")" -> Reduce(Term = "Num" => Call(ActionFn(8));) + // "*" -> Reduce(Term = "Num" => Call(ActionFn(8));) + // "+" -> Reduce(Term = "Num" => Call(ActionFn(8));) // - pub fn __state11< + pub fn __state16< 'ast, __TOKENS: Iterator, >( @@ -821,12 +1235,12 @@ mod __parse__Expr { let __nt = super::__action8(arena, __sym0); return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); } - Some((_, Tok::Plus(..), _)) => { + Some((_, Tok::Minus(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __nt = super::__action8(arena, __sym0); return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); } - Some((_, Tok::Minus(..), _)) => { + Some((_, Tok::RParen(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __nt = super::__action8(arena, __sym0); return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); @@ -836,7 +1250,7 @@ mod __parse__Expr { let __nt = super::__action8(arena, __sym0); return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); } - Some((_, Tok::RParen(..), _)) => { + Some((_, Tok::Plus(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __nt = super::__action8(arena, __sym0); return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); @@ -847,419 +1261,23 @@ mod __parse__Expr { } } - // State 12 - // Expr = Factor (*) [")"] - // Expr = Factor (*) ["+"] - // Expr = Factor (*) ["-"] - // Factor = Factor (*) "*" Term [")"] - // Factor = Factor (*) "*" Term ["*"] - // Factor = Factor (*) "*" Term ["+"] - // Factor = Factor (*) "*" Term ["-"] - // Factor = Factor (*) "*" Term ["/"] - // Factor = Factor (*) "/" Term [")"] - // Factor = Factor (*) "/" Term ["*"] - // Factor = Factor (*) "/" Term ["+"] - // Factor = Factor (*) "/" Term ["-"] - // Factor = Factor (*) "/" Term ["/"] - // - // "*" -> Shift(S24) - // "-" -> Reduce(Expr = Factor => Call(ActionFn(3));) - // "/" -> Shift(S23) - // "+" -> Reduce(Expr = Factor => Call(ActionFn(3));) - // ")" -> Reduce(Expr = Factor => Call(ActionFn(3));) - // - pub fn __state12< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize, Tok, usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> - { - let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, __tok @ Tok::Times(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym1 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state24(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); - } - Some((_, __tok @ Tok::Div(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym1 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state23(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); - } - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action3(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - Some((_, Tok::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action3(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - Some((_, Tok::RParen(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action3(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 13 - // ( ",")* = (*) ["("] - // ( ",")* = (*) [")"] - // ( ",")* = (*) ["*"] - // ( ",")* = (*) ["Num"] - // ( ",")* = (*) ( ",")* ( ",") ["("] - // ( ",")* = (*) ( ",")* ( ",") [")"] - // ( ",")* = (*) ( ",")* ( ",") ["*"] - // ( ",")* = (*) ( ",")* ( ",") ["Num"] - // Comma = (*) ( ",")* Expr? [")"] - // Factor = "*" "(" (*) Comma ")" [EOF] - // Factor = "*" "(" (*) Comma ")" ["*"] - // Factor = "*" "(" (*) Comma ")" ["+"] - // Factor = "*" "(" (*) Comma ")" ["-"] - // Factor = "*" "(" (*) Comma ")" ["/"] - // - // "Num" -> Reduce(( ",")* = => Call(ActionFn(13));) - // ")" -> Reduce(( ",")* = => Call(ActionFn(13));) - // "(" -> Reduce(( ",")* = => Call(ActionFn(13));) - // "*" -> Reduce(( ",")* = => Call(ActionFn(13));) - // - // ( ",")* -> S25 - // Comma -> S26 - pub fn __state13< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize, Tok, usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option, - ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> - { - let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, Tok::Num(_), _)) => { - let __nt = super::__action13(arena, ); - __result = (__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); - } - Some((_, Tok::RParen(..), _)) => { - let __nt = super::__action13(arena, ); - __result = (__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); - } - Some((_, Tok::LParen(..), _)) => { - let __nt = super::__action13(arena, ); - __result = (__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); - } - Some((_, Tok::Times(..), _)) => { - let __nt = super::__action13(arena, ); - __result = (__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); - } - _ => { - return Err(__lookahead); - } - } - while __sym1.is_some() { - let (__lookbehind, __lookahead, __nt) = __result; - match __nt { - __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state25(arena, __lookbehind, __lookahead, __tokens, __sym2)); - } - __Nonterminal::Comma_3cExpr_3e(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state26(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - _ => { - return Ok((__lookbehind, __lookahead, __nt)); - } - } - } - return Ok(__result); - } - - // State 14 - // Factor = Factor "/" (*) Term [EOF] - // Factor = Factor "/" (*) Term ["*"] - // Factor = Factor "/" (*) Term ["+"] - // Factor = Factor "/" (*) Term ["-"] - // Factor = Factor "/" (*) Term ["/"] - // Term = (*) "(" Expr ")" [EOF] - // Term = (*) "(" Expr ")" ["*"] - // Term = (*) "(" Expr ")" ["+"] - // Term = (*) "(" Expr ")" ["-"] - // Term = (*) "(" Expr ")" ["/"] - // Term = (*) "Num" [EOF] - // Term = (*) "Num" ["*"] - // Term = (*) "Num" ["+"] - // Term = (*) "Num" ["-"] - // Term = (*) "Num" ["/"] - // - // "(" -> Shift(S1) - // "Num" -> Shift(S5) - // - // Term -> S27 - pub fn __state14< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize, Tok, usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, - ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> - { - let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, __tok @ Tok::LParen(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state1(arena, __lookbehind, __lookahead, __tokens, __sym2)); - } - Some((_, Tok::Num(__tok0), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state5(arena, __lookbehind, __lookahead, __tokens, __sym2)); - } - _ => { - return Err(__lookahead); - } - } - while __sym1.is_some() { - let (__lookbehind, __lookahead, __nt) = __result; - match __nt { - __Nonterminal::Term(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state27(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - _ => { - return Ok((__lookbehind, __lookahead, __nt)); - } - } - } - return Ok(__result); - } - - // State 15 - // Factor = Factor "*" (*) Term [EOF] - // Factor = Factor "*" (*) Term ["*"] - // Factor = Factor "*" (*) Term ["+"] - // Factor = Factor "*" (*) Term ["-"] - // Factor = Factor "*" (*) Term ["/"] - // Term = (*) "(" Expr ")" [EOF] - // Term = (*) "(" Expr ")" ["*"] - // Term = (*) "(" Expr ")" ["+"] - // Term = (*) "(" Expr ")" ["-"] - // Term = (*) "(" Expr ")" ["/"] - // Term = (*) "Num" [EOF] - // Term = (*) "Num" ["*"] - // Term = (*) "Num" ["+"] - // Term = (*) "Num" ["-"] - // Term = (*) "Num" ["/"] - // - // "Num" -> Shift(S5) - // "(" -> Shift(S1) - // - // Term -> S28 - pub fn __state15< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize, Tok, usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, - ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> - { - let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, Tok::Num(__tok0), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state5(arena, __lookbehind, __lookahead, __tokens, __sym2)); - } - Some((_, __tok @ Tok::LParen(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state1(arena, __lookbehind, __lookahead, __tokens, __sym2)); - } - _ => { - return Err(__lookahead); - } - } - while __sym1.is_some() { - let (__lookbehind, __lookahead, __nt) = __result; - match __nt { - __Nonterminal::Term(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state28(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - _ => { - return Ok((__lookbehind, __lookahead, __nt)); - } - } - } - return Ok(__result); - } - - // State 16 - // Expr = Expr "-" (*) Factor [EOF] - // Expr = Expr "-" (*) Factor ["+"] - // Expr = Expr "-" (*) Factor ["-"] - // Factor = (*) Factor "*" Term [EOF] - // Factor = (*) Factor "*" Term ["*"] - // Factor = (*) Factor "*" Term ["+"] - // Factor = (*) Factor "*" Term ["-"] - // Factor = (*) Factor "*" Term ["/"] - // Factor = (*) Factor "/" Term [EOF] - // Factor = (*) Factor "/" Term ["*"] - // Factor = (*) Factor "/" Term ["+"] - // Factor = (*) Factor "/" Term ["-"] - // Factor = (*) Factor "/" Term ["/"] - // Factor = (*) Term [EOF] - // Factor = (*) Term ["*"] - // Factor = (*) Term ["+"] - // Factor = (*) Term ["-"] - // Factor = (*) Term ["/"] - // Factor = (*) "*" "(" Comma ")" [EOF] - // Factor = (*) "*" "(" Comma ")" ["*"] - // Factor = (*) "*" "(" Comma ")" ["+"] - // Factor = (*) "*" "(" Comma ")" ["-"] - // Factor = (*) "*" "(" Comma ")" ["/"] - // Term = (*) "(" Expr ")" [EOF] - // Term = (*) "(" Expr ")" ["*"] - // Term = (*) "(" Expr ")" ["+"] - // Term = (*) "(" Expr ")" ["-"] - // Term = (*) "(" Expr ")" ["/"] - // Term = (*) "Num" [EOF] - // Term = (*) "Num" ["*"] - // Term = (*) "Num" ["+"] - // Term = (*) "Num" ["-"] - // Term = (*) "Num" ["/"] - // - // "(" -> Shift(S1) - // "*" -> Shift(S3) - // "Num" -> Shift(S5) - // - // Term -> S2 - // Factor -> S29 - pub fn __state16< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize, Tok, usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, - ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> - { - let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, __tok @ Tok::LParen(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state1(arena, __lookbehind, __lookahead, __tokens, __sym2)); - } - Some((_, __tok @ Tok::Times(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state3(arena, __lookbehind, __lookahead, __tokens, __sym2)); - } - Some((_, Tok::Num(__tok0), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state5(arena, __lookbehind, __lookahead, __tokens, __sym2)); - } - _ => { - return Err(__lookahead); - } - } - while __sym1.is_some() { - let (__lookbehind, __lookahead, __nt) = __result; - match __nt { - __Nonterminal::Term(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state2(arena, __lookbehind, __lookahead, __tokens, __sym2)); - } - __Nonterminal::Factor(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state29(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - _ => { - return Ok((__lookbehind, __lookahead, __nt)); - } - } - } - return Ok(__result); - } - // State 17 - // Expr = Expr "+" (*) Factor [EOF] - // Expr = Expr "+" (*) Factor ["+"] - // Expr = Expr "+" (*) Factor ["-"] - // Factor = (*) Factor "*" Term [EOF] - // Factor = (*) Factor "*" Term ["*"] - // Factor = (*) Factor "*" Term ["+"] - // Factor = (*) Factor "*" Term ["-"] - // Factor = (*) Factor "*" Term ["/"] - // Factor = (*) Factor "/" Term [EOF] - // Factor = (*) Factor "/" Term ["*"] - // Factor = (*) Factor "/" Term ["+"] - // Factor = (*) Factor "/" Term ["-"] - // Factor = (*) Factor "/" Term ["/"] - // Factor = (*) Term [EOF] - // Factor = (*) Term ["*"] - // Factor = (*) Term ["+"] - // Factor = (*) Term ["-"] - // Factor = (*) Term ["/"] - // Factor = (*) "*" "(" Comma ")" [EOF] - // Factor = (*) "*" "(" Comma ")" ["*"] - // Factor = (*) "*" "(" Comma ")" ["+"] - // Factor = (*) "*" "(" Comma ")" ["-"] - // Factor = (*) "*" "(" Comma ")" ["/"] - // Term = (*) "(" Expr ")" [EOF] - // Term = (*) "(" Expr ")" ["*"] - // Term = (*) "(" Expr ")" ["+"] - // Term = (*) "(" Expr ")" ["-"] - // Term = (*) "(" Expr ")" ["/"] - // Term = (*) "Num" [EOF] - // Term = (*) "Num" ["*"] - // Term = (*) "Num" ["+"] - // Term = (*) "Num" ["-"] - // Term = (*) "Num" ["/"] + // Expr = Expr (*) "+" Factor [")"] + // Expr = Expr (*) "+" Factor ["+"] + // Expr = Expr (*) "+" Factor ["-"] + // Expr = Expr (*) "-" Factor [")"] + // Expr = Expr (*) "-" Factor ["+"] + // Expr = Expr (*) "-" Factor ["-"] + // Term = "(" Expr (*) ")" [EOF] + // Term = "(" Expr (*) ")" ["*"] + // Term = "(" Expr (*) ")" ["+"] + // Term = "(" Expr (*) ")" ["-"] + // Term = "(" Expr (*) ")" ["/"] // - // "*" -> Shift(S3) - // "(" -> Shift(S1) - // "Num" -> Shift(S5) + // ")" -> Shift(S30) + // "-" -> Shift(S28) + // "+" -> Shift(S29) // - // Factor -> S30 - // Term -> S2 pub fn __state17< 'ast, __TOKENS: Iterator, @@ -1268,69 +1286,49 @@ mod __parse__Expr { __lookbehind: Option, __lookahead: Option<(usize, Tok, usize)>, __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, + __sym0: &mut Option, + __sym1: &mut Option<&'ast Node<'ast>>, ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> { let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); match __lookahead { - Some((_, __tok @ Tok::Times(..), __loc)) => { + Some((_, __tok @ Tok::RParen(..), __loc)) => { let mut __lookbehind = Some(__loc); let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state3(arena, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state30(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); } - Some((_, __tok @ Tok::LParen(..), __loc)) => { + Some((_, __tok @ Tok::Minus(..), __loc)) => { let mut __lookbehind = Some(__loc); let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state1(arena, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state28(arena, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); } - Some((_, Tok::Num(__tok0), __loc)) => { + Some((_, __tok @ Tok::Plus(..), __loc)) => { let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok0)); + let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state5(arena, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state29(arena, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); } _ => { return Err(__lookahead); } } - while __sym1.is_some() { - let (__lookbehind, __lookahead, __nt) = __result; - match __nt { - __Nonterminal::Factor(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state30(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - __Nonterminal::Term(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state2(arena, __lookbehind, __lookahead, __tokens, __sym2)); - } - _ => { - return Ok((__lookbehind, __lookahead, __nt)); - } - } - } return Ok(__result); } // State 18 - // Expr = Expr (*) "+" Factor [")"] - // Expr = Expr (*) "+" Factor ["+"] - // Expr = Expr (*) "+" Factor ["-"] - // Expr = Expr (*) "-" Factor [")"] - // Expr = Expr (*) "-" Factor ["+"] - // Expr = Expr (*) "-" Factor ["-"] - // Term = "(" Expr (*) ")" [")"] - // Term = "(" Expr (*) ")" ["*"] - // Term = "(" Expr (*) ")" ["+"] - // Term = "(" Expr (*) ")" ["-"] - // Term = "(" Expr (*) ")" ["/"] + // Factor = Factor "*" Term (*) [EOF] + // Factor = Factor "*" Term (*) ["*"] + // Factor = Factor "*" Term (*) ["+"] + // Factor = Factor "*" Term (*) ["-"] + // Factor = Factor "*" Term (*) ["/"] // - // "-" -> Shift(S20) - // ")" -> Shift(S31) - // "+" -> Shift(S22) + // "*" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // EOF -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // "-" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // "/" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // "+" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) // pub fn __state18< 'ast, @@ -1340,60 +1338,67 @@ mod __parse__Expr { __lookbehind: Option, __lookahead: Option<(usize, Tok, usize)>, __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option<&'ast Node<'ast>>, + __sym0: &mut Option<&'ast Node<'ast>>, + __sym1: &mut Option, + __sym2: &mut Option<&'ast Node<'ast>>, ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> { let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); match __lookahead { - Some((_, __tok @ Tok::Minus(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state20(arena, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); + Some((_, Tok::Times(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action4(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } - Some((_, __tok @ Tok::RParen(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state31(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + None => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action4(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } - Some((_, __tok @ Tok::Plus(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state22(arena, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action4(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Div(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action4(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action4(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } _ => { return Err(__lookahead); } } - return Ok(__result); } // State 19 - // ( ",")* = (*) ["("] - // ( ",")* = (*) [")"] - // ( ",")* = (*) ["*"] - // ( ",")* = (*) ["Num"] - // ( ",")* = (*) ( ",")* ( ",") ["("] - // ( ",")* = (*) ( ",")* ( ",") [")"] - // ( ",")* = (*) ( ",")* ( ",") ["*"] - // ( ",")* = (*) ( ",")* ( ",") ["Num"] - // Comma = (*) ( ",")* Expr? [")"] - // Factor = "*" "(" (*) Comma ")" [")"] - // Factor = "*" "(" (*) Comma ")" ["*"] - // Factor = "*" "(" (*) Comma ")" ["+"] - // Factor = "*" "(" (*) Comma ")" ["-"] - // Factor = "*" "(" (*) Comma ")" ["/"] + // Factor = Factor "/" Term (*) [EOF] + // Factor = Factor "/" Term (*) ["*"] + // Factor = Factor "/" Term (*) ["+"] + // Factor = Factor "/" Term (*) ["-"] + // Factor = Factor "/" Term (*) ["/"] // - // ")" -> Reduce(( ",")* = => Call(ActionFn(13));) - // "Num" -> Reduce(( ",")* = => Call(ActionFn(13));) - // "*" -> Reduce(( ",")* = => Call(ActionFn(13));) - // "(" -> Reduce(( ",")* = => Call(ActionFn(13));) + // "/" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // "*" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // EOF -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // "+" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // "-" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) // - // ( ",")* -> S25 - // Comma -> S32 pub fn __state19< 'ast, __TOKENS: Iterator, @@ -1402,92 +1407,63 @@ mod __parse__Expr { __lookbehind: Option, __lookahead: Option<(usize, Tok, usize)>, __tokens: &mut __TOKENS, - __sym0: &mut Option, + __sym0: &mut Option<&'ast Node<'ast>>, __sym1: &mut Option, + __sym2: &mut Option<&'ast Node<'ast>>, ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> { let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); match __lookahead { - Some((_, Tok::RParen(..), _)) => { - let __nt = super::__action13(arena, ); - __result = (__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); - } - Some((_, Tok::Num(_), _)) => { - let __nt = super::__action13(arena, ); - __result = (__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); + Some((_, Tok::Div(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action5(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } Some((_, Tok::Times(..), _)) => { - let __nt = super::__action13(arena, ); - __result = (__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action5(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } - Some((_, Tok::LParen(..), _)) => { - let __nt = super::__action13(arena, ); - __result = (__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); + None => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action5(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action5(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action5(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } _ => { return Err(__lookahead); } } - while __sym1.is_some() { - let (__lookbehind, __lookahead, __nt) = __result; - match __nt { - __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state25(arena, __lookbehind, __lookahead, __tokens, __sym2)); - } - __Nonterminal::Comma_3cExpr_3e(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state32(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - _ => { - return Ok((__lookbehind, __lookahead, __nt)); - } - } - } - return Ok(__result); } // State 20 - // Expr = Expr "-" (*) Factor [")"] - // Expr = Expr "-" (*) Factor ["+"] - // Expr = Expr "-" (*) Factor ["-"] - // Factor = (*) Factor "*" Term [")"] - // Factor = (*) Factor "*" Term ["*"] - // Factor = (*) Factor "*" Term ["+"] - // Factor = (*) Factor "*" Term ["-"] - // Factor = (*) Factor "*" Term ["/"] - // Factor = (*) Factor "/" Term [")"] - // Factor = (*) Factor "/" Term ["*"] - // Factor = (*) Factor "/" Term ["+"] - // Factor = (*) Factor "/" Term ["-"] - // Factor = (*) Factor "/" Term ["/"] - // Factor = (*) Term [")"] - // Factor = (*) Term ["*"] - // Factor = (*) Term ["+"] - // Factor = (*) Term ["-"] - // Factor = (*) Term ["/"] - // Factor = (*) "*" "(" Comma ")" [")"] - // Factor = (*) "*" "(" Comma ")" ["*"] - // Factor = (*) "*" "(" Comma ")" ["+"] - // Factor = (*) "*" "(" Comma ")" ["-"] - // Factor = (*) "*" "(" Comma ")" ["/"] - // Term = (*) "(" Expr ")" [")"] - // Term = (*) "(" Expr ")" ["*"] - // Term = (*) "(" Expr ")" ["+"] - // Term = (*) "(" Expr ")" ["-"] - // Term = (*) "(" Expr ")" ["/"] - // Term = (*) "Num" [")"] - // Term = (*) "Num" ["*"] - // Term = (*) "Num" ["+"] - // Term = (*) "Num" ["-"] - // Term = (*) "Num" ["/"] + // Factor = "*" "(" Comma (*) ")" [EOF] + // Factor = "*" "(" Comma (*) ")" ["*"] + // Factor = "*" "(" Comma (*) ")" ["+"] + // Factor = "*" "(" Comma (*) ")" ["-"] + // Factor = "*" "(" Comma (*) ")" ["/"] // - // "(" -> Shift(S7) - // "Num" -> Shift(S11) - // "*" -> Shift(S8) + // ")" -> Shift(S31) // - // Term -> S9 - // Factor -> S33 pub fn __state20< 'ast, __TOKENS: Iterator, @@ -1496,351 +1472,27 @@ mod __parse__Expr { __lookbehind: Option, __lookahead: Option<(usize, Tok, usize)>, __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, + __sym0: &mut Option, __sym1: &mut Option, + __sym2: &mut Option>>, ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> { let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); match __lookahead { - Some((_, __tok @ Tok::LParen(..), __loc)) => { + Some((_, __tok @ Tok::RParen(..), __loc)) => { let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok)); + let mut __sym3 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state7(arena, __lookbehind, __lookahead, __tokens, __sym2)); - } - Some((_, Tok::Num(__tok0), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state11(arena, __lookbehind, __lookahead, __tokens, __sym2)); - } - Some((_, __tok @ Tok::Times(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state8(arena, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state31(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2, __sym3)); } _ => { return Err(__lookahead); } } - while __sym1.is_some() { - let (__lookbehind, __lookahead, __nt) = __result; - match __nt { - __Nonterminal::Term(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state9(arena, __lookbehind, __lookahead, __tokens, __sym2)); - } - __Nonterminal::Factor(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state33(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - _ => { - return Ok((__lookbehind, __lookahead, __nt)); - } - } - } return Ok(__result); } // State 21 - // Term = "(" Expr ")" (*) [EOF] - // Term = "(" Expr ")" (*) ["*"] - // Term = "(" Expr ")" (*) ["+"] - // Term = "(" Expr ")" (*) ["-"] - // Term = "(" Expr ")" (*) ["/"] - // - // "+" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) - // "*" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) - // "-" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) - // "/" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) - // EOF -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) - // - pub fn __state21< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize, Tok, usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option<&'ast Node<'ast>>, - __sym2: &mut Option, - ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> - { - let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, Tok::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action9(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - Some((_, Tok::Times(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action9(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action9(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - Some((_, Tok::Div(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action9(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - None => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action9(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 22 - // Expr = Expr "+" (*) Factor [")"] - // Expr = Expr "+" (*) Factor ["+"] - // Expr = Expr "+" (*) Factor ["-"] - // Factor = (*) Factor "*" Term [")"] - // Factor = (*) Factor "*" Term ["*"] - // Factor = (*) Factor "*" Term ["+"] - // Factor = (*) Factor "*" Term ["-"] - // Factor = (*) Factor "*" Term ["/"] - // Factor = (*) Factor "/" Term [")"] - // Factor = (*) Factor "/" Term ["*"] - // Factor = (*) Factor "/" Term ["+"] - // Factor = (*) Factor "/" Term ["-"] - // Factor = (*) Factor "/" Term ["/"] - // Factor = (*) Term [")"] - // Factor = (*) Term ["*"] - // Factor = (*) Term ["+"] - // Factor = (*) Term ["-"] - // Factor = (*) Term ["/"] - // Factor = (*) "*" "(" Comma ")" [")"] - // Factor = (*) "*" "(" Comma ")" ["*"] - // Factor = (*) "*" "(" Comma ")" ["+"] - // Factor = (*) "*" "(" Comma ")" ["-"] - // Factor = (*) "*" "(" Comma ")" ["/"] - // Term = (*) "(" Expr ")" [")"] - // Term = (*) "(" Expr ")" ["*"] - // Term = (*) "(" Expr ")" ["+"] - // Term = (*) "(" Expr ")" ["-"] - // Term = (*) "(" Expr ")" ["/"] - // Term = (*) "Num" [")"] - // Term = (*) "Num" ["*"] - // Term = (*) "Num" ["+"] - // Term = (*) "Num" ["-"] - // Term = (*) "Num" ["/"] - // - // "*" -> Shift(S8) - // "(" -> Shift(S7) - // "Num" -> Shift(S11) - // - // Factor -> S34 - // Term -> S9 - pub fn __state22< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize, Tok, usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, - ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> - { - let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, __tok @ Tok::Times(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state8(arena, __lookbehind, __lookahead, __tokens, __sym2)); - } - Some((_, __tok @ Tok::LParen(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state7(arena, __lookbehind, __lookahead, __tokens, __sym2)); - } - Some((_, Tok::Num(__tok0), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state11(arena, __lookbehind, __lookahead, __tokens, __sym2)); - } - _ => { - return Err(__lookahead); - } - } - while __sym1.is_some() { - let (__lookbehind, __lookahead, __nt) = __result; - match __nt { - __Nonterminal::Factor(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state34(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - __Nonterminal::Term(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state9(arena, __lookbehind, __lookahead, __tokens, __sym2)); - } - _ => { - return Ok((__lookbehind, __lookahead, __nt)); - } - } - } - return Ok(__result); - } - - // State 23 - // Factor = Factor "/" (*) Term [")"] - // Factor = Factor "/" (*) Term ["*"] - // Factor = Factor "/" (*) Term ["+"] - // Factor = Factor "/" (*) Term ["-"] - // Factor = Factor "/" (*) Term ["/"] - // Term = (*) "(" Expr ")" [")"] - // Term = (*) "(" Expr ")" ["*"] - // Term = (*) "(" Expr ")" ["+"] - // Term = (*) "(" Expr ")" ["-"] - // Term = (*) "(" Expr ")" ["/"] - // Term = (*) "Num" [")"] - // Term = (*) "Num" ["*"] - // Term = (*) "Num" ["+"] - // Term = (*) "Num" ["-"] - // Term = (*) "Num" ["/"] - // - // "(" -> Shift(S7) - // "Num" -> Shift(S11) - // - // Term -> S35 - pub fn __state23< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize, Tok, usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, - ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> - { - let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, __tok @ Tok::LParen(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state7(arena, __lookbehind, __lookahead, __tokens, __sym2)); - } - Some((_, Tok::Num(__tok0), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state11(arena, __lookbehind, __lookahead, __tokens, __sym2)); - } - _ => { - return Err(__lookahead); - } - } - while __sym1.is_some() { - let (__lookbehind, __lookahead, __nt) = __result; - match __nt { - __Nonterminal::Term(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state35(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - _ => { - return Ok((__lookbehind, __lookahead, __nt)); - } - } - } - return Ok(__result); - } - - // State 24 - // Factor = Factor "*" (*) Term [")"] - // Factor = Factor "*" (*) Term ["*"] - // Factor = Factor "*" (*) Term ["+"] - // Factor = Factor "*" (*) Term ["-"] - // Factor = Factor "*" (*) Term ["/"] - // Term = (*) "(" Expr ")" [")"] - // Term = (*) "(" Expr ")" ["*"] - // Term = (*) "(" Expr ")" ["+"] - // Term = (*) "(" Expr ")" ["-"] - // Term = (*) "(" Expr ")" ["/"] - // Term = (*) "Num" [")"] - // Term = (*) "Num" ["*"] - // Term = (*) "Num" ["+"] - // Term = (*) "Num" ["-"] - // Term = (*) "Num" ["/"] - // - // "Num" -> Shift(S11) - // "(" -> Shift(S7) - // - // Term -> S36 - pub fn __state24< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize, Tok, usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, - ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> - { - let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, Tok::Num(__tok0), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state11(arena, __lookbehind, __lookahead, __tokens, __sym2)); - } - Some((_, __tok @ Tok::LParen(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state7(arena, __lookbehind, __lookahead, __tokens, __sym2)); - } - _ => { - return Err(__lookahead); - } - } - while __sym1.is_some() { - let (__lookbehind, __lookahead, __nt) = __result; - match __nt { - __Nonterminal::Term(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state36(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - _ => { - return Ok((__lookbehind, __lookahead, __nt)); - } - } - } - return Ok(__result); - } - - // State 25 // ( ",") = (*) Expr "," ["("] // ( ",") = (*) Expr "," [")"] // ( ",") = (*) Expr "," ["*"] @@ -1901,17 +1553,17 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "*" -> Shift(S44) - // "Num" -> Shift(S37) // ")" -> Reduce(Expr? = => Call(ActionFn(12));) - // "(" -> Shift(S41) + // "Num" -> Shift(S32) + // "(" -> Shift(S38) + // "*" -> Shift(S35) // - // Term -> S39 - // Factor -> S38 - // ( ",") -> S40 - // Expr -> S42 - // Expr? -> S43 - pub fn __state25< + // Term -> S34 + // Expr -> S37 + // ( ",") -> S33 + // Factor -> S39 + // Expr? -> S36 + pub fn __state21< 'ast, __TOKENS: Iterator, >( @@ -1924,23 +1576,23 @@ mod __parse__Expr { { let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); match __lookahead { - Some((_, __tok @ Tok::Times(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym1 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state44(arena, __lookbehind, __lookahead, __tokens, __sym1)); - } Some((_, Tok::Num(__tok0), __loc)) => { let mut __lookbehind = Some(__loc); let mut __sym1 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state37(arena, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state32(arena, __lookbehind, __lookahead, __tokens, __sym1)); } Some((_, __tok @ Tok::LParen(..), __loc)) => { let mut __lookbehind = Some(__loc); let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state41(arena, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state38(arena, __lookbehind, __lookahead, __tokens, __sym1)); + } + Some((_, __tok @ Tok::Times(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state35(arena, __lookbehind, __lookahead, __tokens, __sym1)); } Some((_, Tok::RParen(..), _)) => { let __nt = super::__action12(arena, ); @@ -1955,23 +1607,23 @@ mod __parse__Expr { match __nt { __Nonterminal::Term(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state39(arena, __lookbehind, __lookahead, __tokens, __sym1)); - } - __Nonterminal::Factor(__nt) => { - let __sym1 = &mut Some(__nt); - __result = try!(__state38(arena, __lookbehind, __lookahead, __tokens, __sym1)); - } - __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29(__nt) => { - let __sym1 = &mut Some(__nt); - __result = try!(__state40(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + __result = try!(__state34(arena, __lookbehind, __lookahead, __tokens, __sym1)); } __Nonterminal::Expr(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state42(arena, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state37(arena, __lookbehind, __lookahead, __tokens, __sym1)); + } + __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29(__nt) => { + let __sym1 = &mut Some(__nt); + __result = try!(__state33(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + } + __Nonterminal::Factor(__nt) => { + let __sym1 = &mut Some(__nt); + __result = try!(__state39(arena, __lookbehind, __lookahead, __tokens, __sym1)); } __Nonterminal::Expr_3f(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state43(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + __result = try!(__state36(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); } _ => { return Ok((__lookbehind, __lookahead, __nt)); @@ -1981,258 +1633,7 @@ mod __parse__Expr { return Ok(__result); } - // State 26 - // Factor = "*" "(" Comma (*) ")" [EOF] - // Factor = "*" "(" Comma (*) ")" ["*"] - // Factor = "*" "(" Comma (*) ")" ["+"] - // Factor = "*" "(" Comma (*) ")" ["-"] - // Factor = "*" "(" Comma (*) ")" ["/"] - // - // ")" -> Shift(S45) - // - pub fn __state26< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize, Tok, usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option, - __sym2: &mut Option>>, - ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> - { - let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, __tok @ Tok::RParen(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym3 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state45(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2, __sym3)); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 27 - // Factor = Factor "/" Term (*) [EOF] - // Factor = Factor "/" Term (*) ["*"] - // Factor = Factor "/" Term (*) ["+"] - // Factor = Factor "/" Term (*) ["-"] - // Factor = Factor "/" Term (*) ["/"] - // - // "/" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // "-" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // EOF -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // "*" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // "+" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // - pub fn __state27< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize, Tok, usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, - __sym2: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> - { - let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, Tok::Div(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action5(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action5(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - None => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action5(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Times(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action5(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action5(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 28 - // Factor = Factor "*" Term (*) [EOF] - // Factor = Factor "*" Term (*) ["*"] - // Factor = Factor "*" Term (*) ["+"] - // Factor = Factor "*" Term (*) ["-"] - // Factor = Factor "*" Term (*) ["/"] - // - // EOF -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) - // "-" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) - // "/" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) - // "*" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) - // "+" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) - // - pub fn __state28< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize, Tok, usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, - __sym2: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> - { - let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); - match __lookahead { - None => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Div(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Times(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 29 - // Expr = Expr "-" Factor (*) [EOF] - // Expr = Expr "-" Factor (*) ["+"] - // Expr = Expr "-" Factor (*) ["-"] - // Factor = Factor (*) "*" Term [EOF] - // Factor = Factor (*) "*" Term ["*"] - // Factor = Factor (*) "*" Term ["+"] - // Factor = Factor (*) "*" Term ["-"] - // Factor = Factor (*) "*" Term ["/"] - // Factor = Factor (*) "/" Term [EOF] - // Factor = Factor (*) "/" Term ["*"] - // Factor = Factor (*) "/" Term ["+"] - // Factor = Factor (*) "/" Term ["-"] - // Factor = Factor (*) "/" Term ["/"] - // - // EOF -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) - // "/" -> Shift(S14) - // "+" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) - // "-" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) - // "*" -> Shift(S15) - // - pub fn __state29< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize, Tok, usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, - __sym2: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> - { - let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, __tok @ Tok::Div(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym3 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state14(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); - } - Some((_, __tok @ Tok::Times(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym3 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state15(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); - } - None => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action1(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - Some((_, Tok::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action1(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action1(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 30 + // State 22 // Expr = Expr "+" Factor (*) [EOF] // Expr = Expr "+" Factor (*) ["+"] // Expr = Expr "+" Factor (*) ["-"] @@ -2248,12 +1649,12 @@ mod __parse__Expr { // Factor = Factor (*) "/" Term ["/"] // // "-" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) + // "/" -> Shift(S8) + // "*" -> Shift(S7) // "+" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) - // "/" -> Shift(S14) // EOF -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) - // "*" -> Shift(S15) // - pub fn __state30< + pub fn __state22< 'ast, __TOKENS: Iterator, >( @@ -2272,13 +1673,13 @@ mod __parse__Expr { let mut __lookbehind = Some(__loc); let mut __sym3 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state14(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); + __result = try!(__state8(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); } Some((_, __tok @ Tok::Times(..), __loc)) => { let mut __lookbehind = Some(__loc); let mut __sym3 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state15(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); + __result = try!(__state7(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); } Some((_, Tok::Minus(..), _)) => { let __sym0 = __sym0.take().unwrap(); @@ -2308,20 +1709,552 @@ mod __parse__Expr { return Ok(__result); } - // State 31 - // Term = "(" Expr ")" (*) [")"] + // State 23 + // Expr = Expr "-" Factor (*) [EOF] + // Expr = Expr "-" Factor (*) ["+"] + // Expr = Expr "-" Factor (*) ["-"] + // Factor = Factor (*) "*" Term [EOF] + // Factor = Factor (*) "*" Term ["*"] + // Factor = Factor (*) "*" Term ["+"] + // Factor = Factor (*) "*" Term ["-"] + // Factor = Factor (*) "*" Term ["/"] + // Factor = Factor (*) "/" Term [EOF] + // Factor = Factor (*) "/" Term ["*"] + // Factor = Factor (*) "/" Term ["+"] + // Factor = Factor (*) "/" Term ["-"] + // Factor = Factor (*) "/" Term ["/"] + // + // "/" -> Shift(S8) + // "-" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // EOF -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // "*" -> Shift(S7) + // "+" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // + pub fn __state23< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize, Tok, usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + __sym1: &mut Option, + __sym2: &mut Option<&'ast Node<'ast>>, + ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> + { + let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, __tok @ Tok::Div(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym3 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state8(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); + } + Some((_, __tok @ Tok::Times(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym3 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state7(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action1(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + None => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action1(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action1(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + + // State 24 + // ( ",")* = (*) ["("] + // ( ",")* = (*) [")"] + // ( ",")* = (*) ["*"] + // ( ",")* = (*) ["Num"] + // ( ",")* = (*) ( ",")* ( ",") ["("] + // ( ",")* = (*) ( ",")* ( ",") [")"] + // ( ",")* = (*) ( ",")* ( ",") ["*"] + // ( ",")* = (*) ( ",")* ( ",") ["Num"] + // Comma = (*) ( ",")* Expr? [")"] + // Factor = "*" "(" (*) Comma ")" [")"] + // Factor = "*" "(" (*) Comma ")" ["*"] + // Factor = "*" "(" (*) Comma ")" ["+"] + // Factor = "*" "(" (*) Comma ")" ["-"] + // Factor = "*" "(" (*) Comma ")" ["/"] + // + // "(" -> Reduce(( ",")* = => Call(ActionFn(13));) + // "Num" -> Reduce(( ",")* = => Call(ActionFn(13));) + // "*" -> Reduce(( ",")* = => Call(ActionFn(13));) + // ")" -> Reduce(( ",")* = => Call(ActionFn(13));) + // + // Comma -> S40 + // ( ",")* -> S21 + pub fn __state24< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize, Tok, usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + __sym1: &mut Option, + ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> + { + let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, Tok::LParen(..), _)) => { + let __nt = super::__action13(arena, ); + __result = (__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); + } + Some((_, Tok::Num(_), _)) => { + let __nt = super::__action13(arena, ); + __result = (__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); + } + Some((_, Tok::Times(..), _)) => { + let __nt = super::__action13(arena, ); + __result = (__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); + } + Some((_, Tok::RParen(..), _)) => { + let __nt = super::__action13(arena, ); + __result = (__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); + } + _ => { + return Err(__lookahead); + } + } + while __sym1.is_some() { + let (__lookbehind, __lookahead, __nt) = __result; + match __nt { + __Nonterminal::Comma_3cExpr_3e(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state40(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state21(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + _ => { + return Ok((__lookbehind, __lookahead, __nt)); + } + } + } + return Ok(__result); + } + + // State 25 + // Expr = Expr (*) "+" Factor [")"] + // Expr = Expr (*) "+" Factor ["+"] + // Expr = Expr (*) "+" Factor ["-"] + // Expr = Expr (*) "-" Factor [")"] + // Expr = Expr (*) "-" Factor ["+"] + // Expr = Expr (*) "-" Factor ["-"] + // Term = "(" Expr (*) ")" [")"] + // Term = "(" Expr (*) ")" ["*"] + // Term = "(" Expr (*) ")" ["+"] + // Term = "(" Expr (*) ")" ["-"] + // Term = "(" Expr (*) ")" ["/"] + // + // "+" -> Shift(S29) + // ")" -> Shift(S41) + // "-" -> Shift(S28) + // + pub fn __state25< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize, Tok, usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + __sym1: &mut Option<&'ast Node<'ast>>, + ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> + { + let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, __tok @ Tok::Plus(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state29(arena, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); + } + Some((_, __tok @ Tok::RParen(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state41(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + Some((_, __tok @ Tok::Minus(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state28(arena, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + + // State 26 + // Factor = Factor "/" (*) Term [")"] + // Factor = Factor "/" (*) Term ["*"] + // Factor = Factor "/" (*) Term ["+"] + // Factor = Factor "/" (*) Term ["-"] + // Factor = Factor "/" (*) Term ["/"] + // Term = (*) "(" Expr ")" [")"] + // Term = (*) "(" Expr ")" ["*"] + // Term = (*) "(" Expr ")" ["+"] + // Term = (*) "(" Expr ")" ["-"] + // Term = (*) "(" Expr ")" ["/"] + // Term = (*) "Num" [")"] + // Term = (*) "Num" ["*"] + // Term = (*) "Num" ["+"] + // Term = (*) "Num" ["-"] + // Term = (*) "Num" ["/"] + // + // "(" -> Shift(S14) + // "Num" -> Shift(S16) + // + // Term -> S42 + pub fn __state26< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize, Tok, usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + __sym1: &mut Option, + ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> + { + let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, __tok @ Tok::LParen(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state14(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + Some((_, Tok::Num(__tok0), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok0)); + let __lookahead = __tokens.next(); + __result = try!(__state16(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + _ => { + return Err(__lookahead); + } + } + while __sym1.is_some() { + let (__lookbehind, __lookahead, __nt) = __result; + match __nt { + __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state42(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + _ => { + return Ok((__lookbehind, __lookahead, __nt)); + } + } + } + return Ok(__result); + } + + // State 27 + // Factor = Factor "*" (*) Term [")"] + // Factor = Factor "*" (*) Term ["*"] + // Factor = Factor "*" (*) Term ["+"] + // Factor = Factor "*" (*) Term ["-"] + // Factor = Factor "*" (*) Term ["/"] + // Term = (*) "(" Expr ")" [")"] + // Term = (*) "(" Expr ")" ["*"] + // Term = (*) "(" Expr ")" ["+"] + // Term = (*) "(" Expr ")" ["-"] + // Term = (*) "(" Expr ")" ["/"] + // Term = (*) "Num" [")"] + // Term = (*) "Num" ["*"] + // Term = (*) "Num" ["+"] + // Term = (*) "Num" ["-"] + // Term = (*) "Num" ["/"] + // + // "(" -> Shift(S14) + // "Num" -> Shift(S16) + // + // Term -> S43 + pub fn __state27< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize, Tok, usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + __sym1: &mut Option, + ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> + { + let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, __tok @ Tok::LParen(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state14(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + Some((_, Tok::Num(__tok0), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok0)); + let __lookahead = __tokens.next(); + __result = try!(__state16(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + _ => { + return Err(__lookahead); + } + } + while __sym1.is_some() { + let (__lookbehind, __lookahead, __nt) = __result; + match __nt { + __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state43(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + _ => { + return Ok((__lookbehind, __lookahead, __nt)); + } + } + } + return Ok(__result); + } + + // State 28 + // Expr = Expr "-" (*) Factor [")"] + // Expr = Expr "-" (*) Factor ["+"] + // Expr = Expr "-" (*) Factor ["-"] + // Factor = (*) Factor "*" Term [")"] + // Factor = (*) Factor "*" Term ["*"] + // Factor = (*) Factor "*" Term ["+"] + // Factor = (*) Factor "*" Term ["-"] + // Factor = (*) Factor "*" Term ["/"] + // Factor = (*) Factor "/" Term [")"] + // Factor = (*) Factor "/" Term ["*"] + // Factor = (*) Factor "/" Term ["+"] + // Factor = (*) Factor "/" Term ["-"] + // Factor = (*) Factor "/" Term ["/"] + // Factor = (*) Term [")"] + // Factor = (*) Term ["*"] + // Factor = (*) Term ["+"] + // Factor = (*) Term ["-"] + // Factor = (*) Term ["/"] + // Factor = (*) "*" "(" Comma ")" [")"] + // Factor = (*) "*" "(" Comma ")" ["*"] + // Factor = (*) "*" "(" Comma ")" ["+"] + // Factor = (*) "*" "(" Comma ")" ["-"] + // Factor = (*) "*" "(" Comma ")" ["/"] + // Term = (*) "(" Expr ")" [")"] + // Term = (*) "(" Expr ")" ["*"] + // Term = (*) "(" Expr ")" ["+"] + // Term = (*) "(" Expr ")" ["-"] + // Term = (*) "(" Expr ")" ["/"] + // Term = (*) "Num" [")"] + // Term = (*) "Num" ["*"] + // Term = (*) "Num" ["+"] + // Term = (*) "Num" ["-"] + // Term = (*) "Num" ["/"] + // + // "Num" -> Shift(S16) + // "*" -> Shift(S13) + // "(" -> Shift(S14) + // + // Term -> S12 + // Factor -> S44 + pub fn __state28< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize, Tok, usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + __sym1: &mut Option, + ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> + { + let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, Tok::Num(__tok0), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok0)); + let __lookahead = __tokens.next(); + __result = try!(__state16(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + Some((_, __tok @ Tok::Times(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state13(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + Some((_, __tok @ Tok::LParen(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state14(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + _ => { + return Err(__lookahead); + } + } + while __sym1.is_some() { + let (__lookbehind, __lookahead, __nt) = __result; + match __nt { + __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state12(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + __Nonterminal::Factor(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state44(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + _ => { + return Ok((__lookbehind, __lookahead, __nt)); + } + } + } + return Ok(__result); + } + + // State 29 + // Expr = Expr "+" (*) Factor [")"] + // Expr = Expr "+" (*) Factor ["+"] + // Expr = Expr "+" (*) Factor ["-"] + // Factor = (*) Factor "*" Term [")"] + // Factor = (*) Factor "*" Term ["*"] + // Factor = (*) Factor "*" Term ["+"] + // Factor = (*) Factor "*" Term ["-"] + // Factor = (*) Factor "*" Term ["/"] + // Factor = (*) Factor "/" Term [")"] + // Factor = (*) Factor "/" Term ["*"] + // Factor = (*) Factor "/" Term ["+"] + // Factor = (*) Factor "/" Term ["-"] + // Factor = (*) Factor "/" Term ["/"] + // Factor = (*) Term [")"] + // Factor = (*) Term ["*"] + // Factor = (*) Term ["+"] + // Factor = (*) Term ["-"] + // Factor = (*) Term ["/"] + // Factor = (*) "*" "(" Comma ")" [")"] + // Factor = (*) "*" "(" Comma ")" ["*"] + // Factor = (*) "*" "(" Comma ")" ["+"] + // Factor = (*) "*" "(" Comma ")" ["-"] + // Factor = (*) "*" "(" Comma ")" ["/"] + // Term = (*) "(" Expr ")" [")"] + // Term = (*) "(" Expr ")" ["*"] + // Term = (*) "(" Expr ")" ["+"] + // Term = (*) "(" Expr ")" ["-"] + // Term = (*) "(" Expr ")" ["/"] + // Term = (*) "Num" [")"] + // Term = (*) "Num" ["*"] + // Term = (*) "Num" ["+"] + // Term = (*) "Num" ["-"] + // Term = (*) "Num" ["/"] + // + // "Num" -> Shift(S16) + // "(" -> Shift(S14) + // "*" -> Shift(S13) + // + // Term -> S12 + // Factor -> S45 + pub fn __state29< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize, Tok, usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + __sym1: &mut Option, + ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> + { + let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, Tok::Num(__tok0), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok0)); + let __lookahead = __tokens.next(); + __result = try!(__state16(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + Some((_, __tok @ Tok::LParen(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state14(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + Some((_, __tok @ Tok::Times(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state13(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + _ => { + return Err(__lookahead); + } + } + while __sym1.is_some() { + let (__lookbehind, __lookahead, __nt) = __result; + match __nt { + __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state12(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + __Nonterminal::Factor(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state45(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + _ => { + return Ok((__lookbehind, __lookahead, __nt)); + } + } + } + return Ok(__result); + } + + // State 30 + // Term = "(" Expr ")" (*) [EOF] // Term = "(" Expr ")" (*) ["*"] // Term = "(" Expr ")" (*) ["+"] // Term = "(" Expr ")" (*) ["-"] // Term = "(" Expr ")" (*) ["/"] // - // "-" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) - // ")" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) // "+" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) - // "/" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) + // "-" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) + // EOF -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) // "*" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) + // "/" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) // - pub fn __state31< + pub fn __state30< 'ast, __TOKENS: Iterator, >( @@ -2336,20 +2269,6 @@ mod __parse__Expr { { let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); match __lookahead { - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action9(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - Some((_, Tok::RParen(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action9(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } Some((_, Tok::Plus(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); @@ -2357,7 +2276,14 @@ mod __parse__Expr { let __nt = super::__action9(arena, __sym0, __sym1, __sym2); return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); } - Some((_, Tok::Div(..), _)) => { + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action9(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + None => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); @@ -2371,22 +2297,33 @@ mod __parse__Expr { let __nt = super::__action9(arena, __sym0, __sym1, __sym2); return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); } + Some((_, Tok::Div(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action9(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } _ => { return Err(__lookahead); } } } - // State 32 - // Factor = "*" "(" Comma (*) ")" [")"] - // Factor = "*" "(" Comma (*) ")" ["*"] - // Factor = "*" "(" Comma (*) ")" ["+"] - // Factor = "*" "(" Comma (*) ")" ["-"] - // Factor = "*" "(" Comma (*) ")" ["/"] + // State 31 + // Factor = "*" "(" Comma ")" (*) [EOF] + // Factor = "*" "(" Comma ")" (*) ["*"] + // Factor = "*" "(" Comma ")" (*) ["+"] + // Factor = "*" "(" Comma ")" (*) ["-"] + // Factor = "*" "(" Comma ")" (*) ["/"] // - // ")" -> Shift(S46) + // EOF -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) + // "*" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) + // "-" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) + // "+" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) + // "/" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) // - pub fn __state32< + pub fn __state31< 'ast, __TOKENS: Iterator, >( @@ -2397,305 +2334,49 @@ mod __parse__Expr { __sym0: &mut Option, __sym1: &mut Option, __sym2: &mut Option>>, + __sym3: &mut Option, ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> { let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); match __lookahead { - Some((_, __tok @ Tok::RParen(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym3 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state46(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2, __sym3)); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 33 - // Expr = Expr "-" Factor (*) [")"] - // Expr = Expr "-" Factor (*) ["+"] - // Expr = Expr "-" Factor (*) ["-"] - // Factor = Factor (*) "*" Term [")"] - // Factor = Factor (*) "*" Term ["*"] - // Factor = Factor (*) "*" Term ["+"] - // Factor = Factor (*) "*" Term ["-"] - // Factor = Factor (*) "*" Term ["/"] - // Factor = Factor (*) "/" Term [")"] - // Factor = Factor (*) "/" Term ["*"] - // Factor = Factor (*) "/" Term ["+"] - // Factor = Factor (*) "/" Term ["-"] - // Factor = Factor (*) "/" Term ["/"] - // - // "/" -> Shift(S23) - // "-" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) - // "+" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) - // ")" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) - // "*" -> Shift(S24) - // - pub fn __state33< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize, Tok, usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, - __sym2: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> - { - let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, __tok @ Tok::Div(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym3 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state23(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); - } - Some((_, __tok @ Tok::Times(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym3 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state24(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); - } - Some((_, Tok::Minus(..), _)) => { + None => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action1(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - Some((_, Tok::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action1(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - Some((_, Tok::RParen(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action1(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 34 - // Expr = Expr "+" Factor (*) [")"] - // Expr = Expr "+" Factor (*) ["+"] - // Expr = Expr "+" Factor (*) ["-"] - // Factor = Factor (*) "*" Term [")"] - // Factor = Factor (*) "*" Term ["*"] - // Factor = Factor (*) "*" Term ["+"] - // Factor = Factor (*) "*" Term ["-"] - // Factor = Factor (*) "*" Term ["/"] - // Factor = Factor (*) "/" Term [")"] - // Factor = Factor (*) "/" Term ["*"] - // Factor = Factor (*) "/" Term ["+"] - // Factor = Factor (*) "/" Term ["-"] - // Factor = Factor (*) "/" Term ["/"] - // - // "+" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) - // ")" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) - // "/" -> Shift(S23) - // "-" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) - // "*" -> Shift(S24) - // - pub fn __state34< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize, Tok, usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, - __sym2: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> - { - let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, __tok @ Tok::Div(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym3 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state23(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); - } - Some((_, __tok @ Tok::Times(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym3 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state24(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); - } - Some((_, Tok::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action2(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - Some((_, Tok::RParen(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action2(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action2(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 35 - // Factor = Factor "/" Term (*) [")"] - // Factor = Factor "/" Term (*) ["*"] - // Factor = Factor "/" Term (*) ["+"] - // Factor = Factor "/" Term (*) ["-"] - // Factor = Factor "/" Term (*) ["/"] - // - // "-" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // "+" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // "*" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // ")" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // "/" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // - pub fn __state35< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize, Tok, usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, - __sym2: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> - { - let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action5(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action5(arena, __sym0, __sym1, __sym2); + let __sym3 = __sym3.take().unwrap(); + let __nt = super::__action6(arena, __sym0, __sym1, __sym2, __sym3); return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } Some((_, Tok::Times(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action5(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::RParen(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action5(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Div(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action5(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 36 - // Factor = Factor "*" Term (*) [")"] - // Factor = Factor "*" Term (*) ["*"] - // Factor = Factor "*" Term (*) ["+"] - // Factor = Factor "*" Term (*) ["-"] - // Factor = Factor "*" Term (*) ["/"] - // - // "+" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) - // "*" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) - // ")" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) - // "/" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) - // "-" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) - // - pub fn __state36< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize, Tok, usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, - __sym2: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> - { - let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, Tok::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Times(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::RParen(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Div(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action4(arena, __sym0, __sym1, __sym2); + let __sym3 = __sym3.take().unwrap(); + let __nt = super::__action6(arena, __sym0, __sym1, __sym2, __sym3); return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } Some((_, Tok::Minus(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action4(arena, __sym0, __sym1, __sym2); + let __sym3 = __sym3.take().unwrap(); + let __nt = super::__action6(arena, __sym0, __sym1, __sym2, __sym3); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __sym3 = __sym3.take().unwrap(); + let __nt = super::__action6(arena, __sym0, __sym1, __sym2, __sym3); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Div(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __sym3 = __sym3.take().unwrap(); + let __nt = super::__action6(arena, __sym0, __sym1, __sym2, __sym3); return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } _ => { @@ -2704,7 +2385,7 @@ mod __parse__Expr { } } - // State 37 + // State 32 // Term = "Num" (*) [")"] // Term = "Num" (*) ["*"] // Term = "Num" (*) ["+"] @@ -2712,14 +2393,14 @@ mod __parse__Expr { // Term = "Num" (*) ["-"] // Term = "Num" (*) ["/"] // - // ")" -> Reduce(Term = "Num" => Call(ActionFn(8));) - // "," -> Reduce(Term = "Num" => Call(ActionFn(8));) - // "*" -> Reduce(Term = "Num" => Call(ActionFn(8));) // "/" -> Reduce(Term = "Num" => Call(ActionFn(8));) // "+" -> Reduce(Term = "Num" => Call(ActionFn(8));) + // ")" -> Reduce(Term = "Num" => Call(ActionFn(8));) // "-" -> Reduce(Term = "Num" => Call(ActionFn(8));) + // "," -> Reduce(Term = "Num" => Call(ActionFn(8));) + // "*" -> Reduce(Term = "Num" => Call(ActionFn(8));) // - pub fn __state37< + pub fn __state32< 'ast, __TOKENS: Iterator, >( @@ -2732,11 +2413,26 @@ mod __parse__Expr { { let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); match __lookahead { + Some((_, Tok::Div(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action8(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action8(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } Some((_, Tok::RParen(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __nt = super::__action8(arena, __sym0); return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action8(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } Some((_, Tok::Comma(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __nt = super::__action8(arena, __sym0); @@ -2747,169 +2443,13 @@ mod __parse__Expr { let __nt = super::__action8(arena, __sym0); return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); } - Some((_, Tok::Div(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action8(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - Some((_, Tok::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action8(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action8(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } _ => { return Err(__lookahead); } } } - // State 38 - // Expr = Factor (*) [")"] - // Expr = Factor (*) ["+"] - // Expr = Factor (*) [","] - // Expr = Factor (*) ["-"] - // Factor = Factor (*) "*" Term [")"] - // Factor = Factor (*) "*" Term ["*"] - // Factor = Factor (*) "*" Term ["+"] - // Factor = Factor (*) "*" Term [","] - // Factor = Factor (*) "*" Term ["-"] - // Factor = Factor (*) "*" Term ["/"] - // Factor = Factor (*) "/" Term [")"] - // Factor = Factor (*) "/" Term ["*"] - // Factor = Factor (*) "/" Term ["+"] - // Factor = Factor (*) "/" Term [","] - // Factor = Factor (*) "/" Term ["-"] - // Factor = Factor (*) "/" Term ["/"] - // - // "-" -> Reduce(Expr = Factor => Call(ActionFn(3));) - // "+" -> Reduce(Expr = Factor => Call(ActionFn(3));) - // "," -> Reduce(Expr = Factor => Call(ActionFn(3));) - // "/" -> Shift(S47) - // "*" -> Shift(S48) - // ")" -> Reduce(Expr = Factor => Call(ActionFn(3));) - // - pub fn __state38< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize, Tok, usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> - { - let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, __tok @ Tok::Div(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym1 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state47(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); - } - Some((_, __tok @ Tok::Times(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym1 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state48(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); - } - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action3(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - Some((_, Tok::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action3(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - Some((_, Tok::Comma(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action3(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - Some((_, Tok::RParen(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action3(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 39 - // Factor = Term (*) [")"] - // Factor = Term (*) ["*"] - // Factor = Term (*) ["+"] - // Factor = Term (*) [","] - // Factor = Term (*) ["-"] - // Factor = Term (*) ["/"] - // - // "-" -> Reduce(Factor = Term => Call(ActionFn(7));) - // ")" -> Reduce(Factor = Term => Call(ActionFn(7));) - // "/" -> Reduce(Factor = Term => Call(ActionFn(7));) - // "," -> Reduce(Factor = Term => Call(ActionFn(7));) - // "*" -> Reduce(Factor = Term => Call(ActionFn(7));) - // "+" -> Reduce(Factor = Term => Call(ActionFn(7));) - // - pub fn __state39< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize, Tok, usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> - { - let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action7(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::RParen(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action7(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Div(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action7(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Comma(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action7(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Times(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action7(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action7(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 40 + // State 33 // ( ",")* = ( ",")* ( ",") (*) ["("] // ( ",")* = ( ",")* ( ",") (*) [")"] // ( ",")* = ( ",")* ( ",") (*) ["*"] @@ -2920,7 +2460,7 @@ mod __parse__Expr { // "(" -> Reduce(( ",")* = ( ",")*, ( ",") => Call(ActionFn(14));) // "*" -> Reduce(( ",")* = ( ",")*, ( ",") => Call(ActionFn(14));) // - pub fn __state40< + pub fn __state33< 'ast, __TOKENS: Iterator, >( @@ -2964,7 +2504,201 @@ mod __parse__Expr { } } - // State 41 + // State 34 + // Factor = Term (*) [")"] + // Factor = Term (*) ["*"] + // Factor = Term (*) ["+"] + // Factor = Term (*) [","] + // Factor = Term (*) ["-"] + // Factor = Term (*) ["/"] + // + // "," -> Reduce(Factor = Term => Call(ActionFn(7));) + // ")" -> Reduce(Factor = Term => Call(ActionFn(7));) + // "-" -> Reduce(Factor = Term => Call(ActionFn(7));) + // "+" -> Reduce(Factor = Term => Call(ActionFn(7));) + // "/" -> Reduce(Factor = Term => Call(ActionFn(7));) + // "*" -> Reduce(Factor = Term => Call(ActionFn(7));) + // + pub fn __state34< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize, Tok, usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> + { + let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, Tok::Comma(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action7(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::RParen(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action7(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action7(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action7(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Div(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action7(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Times(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action7(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 35 + // Factor = "*" (*) "(" Comma ")" [")"] + // Factor = "*" (*) "(" Comma ")" ["*"] + // Factor = "*" (*) "(" Comma ")" ["+"] + // Factor = "*" (*) "(" Comma ")" [","] + // Factor = "*" (*) "(" Comma ")" ["-"] + // Factor = "*" (*) "(" Comma ")" ["/"] + // + // "(" -> Shift(S46) + // + pub fn __state35< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize, Tok, usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> + { + let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, __tok @ Tok::LParen(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state46(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + + // State 36 + // Comma = ( ",")* Expr? (*) [")"] + // + // ")" -> Reduce(Comma = ( ",")*, Expr? => Call(ActionFn(10));) + // + pub fn __state36< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize, Tok, usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<::std::vec::Vec<&'ast Node<'ast>>>, + __sym1: &mut Option<::std::option::Option<&'ast Node<'ast>>>, + ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> + { + let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, Tok::RParen(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __nt = super::__action10(arena, __sym0, __sym1); + return Ok((__lookbehind, __lookahead, __Nonterminal::Comma_3cExpr_3e(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 37 + // ( ",") = Expr (*) "," ["("] + // ( ",") = Expr (*) "," [")"] + // ( ",") = Expr (*) "," ["*"] + // ( ",") = Expr (*) "," ["Num"] + // Expr = Expr (*) "+" Factor [")"] + // Expr = Expr (*) "+" Factor ["+"] + // Expr = Expr (*) "+" Factor [","] + // Expr = Expr (*) "+" Factor ["-"] + // Expr = Expr (*) "-" Factor [")"] + // Expr = Expr (*) "-" Factor ["+"] + // Expr = Expr (*) "-" Factor [","] + // Expr = Expr (*) "-" Factor ["-"] + // Expr? = Expr (*) [")"] + // + // "," -> Shift(S48) + // "+" -> Shift(S47) + // ")" -> Reduce(Expr? = Expr => Call(ActionFn(11));) + // "-" -> Shift(S49) + // + pub fn __state37< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize, Tok, usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> + { + let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, __tok @ Tok::Comma(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state48(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + } + Some((_, __tok @ Tok::Plus(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state47(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + } + Some((_, __tok @ Tok::Minus(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state49(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + } + Some((_, Tok::RParen(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action11(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr_3f(__nt))); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + + // State 38 // Expr = (*) Expr "+" Factor [")"] // Expr = (*) Expr "+" Factor ["+"] // Expr = (*) Expr "+" Factor ["-"] @@ -3011,14 +2745,14 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "(" -> Shift(S7) - // "Num" -> Shift(S11) - // "*" -> Shift(S8) + // "Num" -> Shift(S16) + // "*" -> Shift(S13) + // "(" -> Shift(S14) // - // Expr -> S49 - // Factor -> S12 - // Term -> S9 - pub fn __state41< + // Factor -> S15 + // Term -> S12 + // Expr -> S50 + pub fn __state38< 'ast, __TOKENS: Iterator, >( @@ -3031,23 +2765,23 @@ mod __parse__Expr { { let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); match __lookahead { - Some((_, __tok @ Tok::LParen(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym1 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state7(arena, __lookbehind, __lookahead, __tokens, __sym1)); - } Some((_, Tok::Num(__tok0), __loc)) => { let mut __lookbehind = Some(__loc); let mut __sym1 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state11(arena, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state16(arena, __lookbehind, __lookahead, __tokens, __sym1)); } Some((_, __tok @ Tok::Times(..), __loc)) => { let mut __lookbehind = Some(__loc); let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state8(arena, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state13(arena, __lookbehind, __lookahead, __tokens, __sym1)); + } + Some((_, __tok @ Tok::LParen(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state14(arena, __lookbehind, __lookahead, __tokens, __sym1)); } _ => { return Err(__lookahead); @@ -3056,17 +2790,17 @@ mod __parse__Expr { while __sym0.is_some() { let (__lookbehind, __lookahead, __nt) = __result; match __nt { - __Nonterminal::Expr(__nt) => { - let __sym1 = &mut Some(__nt); - __result = try!(__state49(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); - } __Nonterminal::Factor(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state12(arena, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state15(arena, __lookbehind, __lookahead, __tokens, __sym1)); } __Nonterminal::Term(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state9(arena, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state12(arena, __lookbehind, __lookahead, __tokens, __sym1)); + } + __Nonterminal::Expr(__nt) => { + let __sym1 = &mut Some(__nt); + __result = try!(__state50(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); } _ => { return Ok((__lookbehind, __lookahead, __nt)); @@ -3076,25 +2810,201 @@ mod __parse__Expr { return Ok(__result); } - // State 42 - // ( ",") = Expr (*) "," ["("] - // ( ",") = Expr (*) "," [")"] - // ( ",") = Expr (*) "," ["*"] - // ( ",") = Expr (*) "," ["Num"] - // Expr = Expr (*) "+" Factor [")"] - // Expr = Expr (*) "+" Factor ["+"] - // Expr = Expr (*) "+" Factor [","] - // Expr = Expr (*) "+" Factor ["-"] - // Expr = Expr (*) "-" Factor [")"] - // Expr = Expr (*) "-" Factor ["+"] - // Expr = Expr (*) "-" Factor [","] - // Expr = Expr (*) "-" Factor ["-"] - // Expr? = Expr (*) [")"] + // State 39 + // Expr = Factor (*) [")"] + // Expr = Factor (*) ["+"] + // Expr = Factor (*) [","] + // Expr = Factor (*) ["-"] + // Factor = Factor (*) "*" Term [")"] + // Factor = Factor (*) "*" Term ["*"] + // Factor = Factor (*) "*" Term ["+"] + // Factor = Factor (*) "*" Term [","] + // Factor = Factor (*) "*" Term ["-"] + // Factor = Factor (*) "*" Term ["/"] + // Factor = Factor (*) "/" Term [")"] + // Factor = Factor (*) "/" Term ["*"] + // Factor = Factor (*) "/" Term ["+"] + // Factor = Factor (*) "/" Term [","] + // Factor = Factor (*) "/" Term ["-"] + // Factor = Factor (*) "/" Term ["/"] // - // ")" -> Reduce(Expr? = Expr => Call(ActionFn(11));) - // "+" -> Shift(S50) - // "-" -> Shift(S52) - // "," -> Shift(S51) + // ")" -> Reduce(Expr = Factor => Call(ActionFn(3));) + // "/" -> Shift(S52) + // "-" -> Reduce(Expr = Factor => Call(ActionFn(3));) + // "," -> Reduce(Expr = Factor => Call(ActionFn(3));) + // "+" -> Reduce(Expr = Factor => Call(ActionFn(3));) + // "*" -> Shift(S51) + // + pub fn __state39< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize, Tok, usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> + { + let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, __tok @ Tok::Div(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state52(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + } + Some((_, __tok @ Tok::Times(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state51(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + } + Some((_, Tok::RParen(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action3(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action3(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + Some((_, Tok::Comma(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action3(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action3(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + + // State 40 + // Factor = "*" "(" Comma (*) ")" [")"] + // Factor = "*" "(" Comma (*) ")" ["*"] + // Factor = "*" "(" Comma (*) ")" ["+"] + // Factor = "*" "(" Comma (*) ")" ["-"] + // Factor = "*" "(" Comma (*) ")" ["/"] + // + // ")" -> Shift(S53) + // + pub fn __state40< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize, Tok, usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + __sym1: &mut Option, + __sym2: &mut Option>>, + ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> + { + let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, __tok @ Tok::RParen(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym3 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state53(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2, __sym3)); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + + // State 41 + // Term = "(" Expr ")" (*) [")"] + // Term = "(" Expr ")" (*) ["*"] + // Term = "(" Expr ")" (*) ["+"] + // Term = "(" Expr ")" (*) ["-"] + // Term = "(" Expr ")" (*) ["/"] + // + // ")" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) + // "-" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) + // "*" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) + // "/" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) + // "+" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) + // + pub fn __state41< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize, Tok, usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + __sym1: &mut Option<&'ast Node<'ast>>, + __sym2: &mut Option, + ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> + { + let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, Tok::RParen(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action9(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action9(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + Some((_, Tok::Times(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action9(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + Some((_, Tok::Div(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action9(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action9(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 42 + // Factor = Factor "/" Term (*) [")"] + // Factor = Factor "/" Term (*) ["*"] + // Factor = Factor "/" Term (*) ["+"] + // Factor = Factor "/" Term (*) ["-"] + // Factor = Factor "/" Term (*) ["/"] + // + // "+" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // "/" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // "-" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // ")" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // "*" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) // pub fn __state42< 'ast, @@ -3105,44 +3015,65 @@ mod __parse__Expr { __lookahead: Option<(usize, Tok, usize)>, __tokens: &mut __TOKENS, __sym0: &mut Option<&'ast Node<'ast>>, + __sym1: &mut Option, + __sym2: &mut Option<&'ast Node<'ast>>, ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> { let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); match __lookahead { - Some((_, __tok @ Tok::Plus(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym1 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state50(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action5(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } - Some((_, __tok @ Tok::Minus(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym1 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state52(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + Some((_, Tok::Div(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action5(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } - Some((_, __tok @ Tok::Comma(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym1 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state51(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action5(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } Some((_, Tok::RParen(..), _)) => { let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action11(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr_3f(__nt))); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action5(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Times(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action5(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } _ => { return Err(__lookahead); } } - return Ok(__result); } // State 43 - // Comma = ( ",")* Expr? (*) [")"] + // Factor = Factor "*" Term (*) [")"] + // Factor = Factor "*" Term (*) ["*"] + // Factor = Factor "*" Term (*) ["+"] + // Factor = Factor "*" Term (*) ["-"] + // Factor = Factor "*" Term (*) ["/"] // - // ")" -> Reduce(Comma = ( ",")*, Expr? => Call(ActionFn(10));) + // ")" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // "/" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // "+" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // "-" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // "*" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) // pub fn __state43< 'ast, @@ -3152,8 +3083,9 @@ mod __parse__Expr { __lookbehind: Option, __lookahead: Option<(usize, Tok, usize)>, __tokens: &mut __TOKENS, - __sym0: &mut Option<::std::vec::Vec<&'ast Node<'ast>>>, - __sym1: &mut Option<::std::option::Option<&'ast Node<'ast>>>, + __sym0: &mut Option<&'ast Node<'ast>>, + __sym1: &mut Option, + __sym2: &mut Option<&'ast Node<'ast>>, ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> { let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); @@ -3161,8 +3093,37 @@ mod __parse__Expr { Some((_, Tok::RParen(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); - let __nt = super::__action10(arena, __sym0, __sym1); - return Ok((__lookbehind, __lookahead, __Nonterminal::Comma_3cExpr_3e(__nt))); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action4(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Div(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action4(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action4(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action4(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Times(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action4(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } _ => { return Err(__lookahead); @@ -3171,14 +3132,25 @@ mod __parse__Expr { } // State 44 - // Factor = "*" (*) "(" Comma ")" [")"] - // Factor = "*" (*) "(" Comma ")" ["*"] - // Factor = "*" (*) "(" Comma ")" ["+"] - // Factor = "*" (*) "(" Comma ")" [","] - // Factor = "*" (*) "(" Comma ")" ["-"] - // Factor = "*" (*) "(" Comma ")" ["/"] + // Expr = Expr "-" Factor (*) [")"] + // Expr = Expr "-" Factor (*) ["+"] + // Expr = Expr "-" Factor (*) ["-"] + // Factor = Factor (*) "*" Term [")"] + // Factor = Factor (*) "*" Term ["*"] + // Factor = Factor (*) "*" Term ["+"] + // Factor = Factor (*) "*" Term ["-"] + // Factor = Factor (*) "*" Term ["/"] + // Factor = Factor (*) "/" Term [")"] + // Factor = Factor (*) "/" Term ["*"] + // Factor = Factor (*) "/" Term ["+"] + // Factor = Factor (*) "/" Term ["-"] + // Factor = Factor (*) "/" Term ["/"] // - // "(" -> Shift(S53) + // "+" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // "/" -> Shift(S26) + // ")" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // "-" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // "*" -> Shift(S27) // pub fn __state44< 'ast, @@ -3188,16 +3160,45 @@ mod __parse__Expr { __lookbehind: Option, __lookahead: Option<(usize, Tok, usize)>, __tokens: &mut __TOKENS, - __sym0: &mut Option, + __sym0: &mut Option<&'ast Node<'ast>>, + __sym1: &mut Option, + __sym2: &mut Option<&'ast Node<'ast>>, ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> { let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); match __lookahead { - Some((_, __tok @ Tok::LParen(..), __loc)) => { + Some((_, __tok @ Tok::Div(..), __loc)) => { let mut __lookbehind = Some(__loc); - let mut __sym1 = &mut Some((__tok)); + let mut __sym3 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state53(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + __result = try!(__state26(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); + } + Some((_, __tok @ Tok::Times(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym3 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state27(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action1(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + Some((_, Tok::RParen(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action1(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action1(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); } _ => { return Err(__lookahead); @@ -3207,17 +3208,25 @@ mod __parse__Expr { } // State 45 - // Factor = "*" "(" Comma ")" (*) [EOF] - // Factor = "*" "(" Comma ")" (*) ["*"] - // Factor = "*" "(" Comma ")" (*) ["+"] - // Factor = "*" "(" Comma ")" (*) ["-"] - // Factor = "*" "(" Comma ")" (*) ["/"] + // Expr = Expr "+" Factor (*) [")"] + // Expr = Expr "+" Factor (*) ["+"] + // Expr = Expr "+" Factor (*) ["-"] + // Factor = Factor (*) "*" Term [")"] + // Factor = Factor (*) "*" Term ["*"] + // Factor = Factor (*) "*" Term ["+"] + // Factor = Factor (*) "*" Term ["-"] + // Factor = Factor (*) "*" Term ["/"] + // Factor = Factor (*) "/" Term [")"] + // Factor = Factor (*) "/" Term ["*"] + // Factor = Factor (*) "/" Term ["+"] + // Factor = Factor (*) "/" Term ["-"] + // Factor = Factor (*) "/" Term ["/"] // - // "+" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) - // "-" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) - // "/" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) - // EOF -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) - // "*" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) + // "+" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) + // "/" -> Shift(S26) + // "*" -> Shift(S27) + // "-" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) + // ")" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) // pub fn __state45< 'ast, @@ -3227,73 +3236,77 @@ mod __parse__Expr { __lookbehind: Option, __lookahead: Option<(usize, Tok, usize)>, __tokens: &mut __TOKENS, - __sym0: &mut Option, + __sym0: &mut Option<&'ast Node<'ast>>, __sym1: &mut Option, - __sym2: &mut Option>>, - __sym3: &mut Option, + __sym2: &mut Option<&'ast Node<'ast>>, ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> { let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); match __lookahead { + Some((_, __tok @ Tok::Div(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym3 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state26(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); + } + Some((_, __tok @ Tok::Times(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym3 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state27(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); + } Some((_, Tok::Plus(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); - let __sym3 = __sym3.take().unwrap(); - let __nt = super::__action6(arena, __sym0, __sym1, __sym2, __sym3); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + let __nt = super::__action2(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); } Some((_, Tok::Minus(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); - let __sym3 = __sym3.take().unwrap(); - let __nt = super::__action6(arena, __sym0, __sym1, __sym2, __sym3); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + let __nt = super::__action2(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); } - Some((_, Tok::Div(..), _)) => { + Some((_, Tok::RParen(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); - let __sym3 = __sym3.take().unwrap(); - let __nt = super::__action6(arena, __sym0, __sym1, __sym2, __sym3); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - None => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __sym3 = __sym3.take().unwrap(); - let __nt = super::__action6(arena, __sym0, __sym1, __sym2, __sym3); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Times(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __sym3 = __sym3.take().unwrap(); - let __nt = super::__action6(arena, __sym0, __sym1, __sym2, __sym3); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + let __nt = super::__action2(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); } _ => { return Err(__lookahead); } } + return Ok(__result); } // State 46 - // Factor = "*" "(" Comma ")" (*) [")"] - // Factor = "*" "(" Comma ")" (*) ["*"] - // Factor = "*" "(" Comma ")" (*) ["+"] - // Factor = "*" "(" Comma ")" (*) ["-"] - // Factor = "*" "(" Comma ")" (*) ["/"] + // ( ",")* = (*) ["("] + // ( ",")* = (*) [")"] + // ( ",")* = (*) ["*"] + // ( ",")* = (*) ["Num"] + // ( ",")* = (*) ( ",")* ( ",") ["("] + // ( ",")* = (*) ( ",")* ( ",") [")"] + // ( ",")* = (*) ( ",")* ( ",") ["*"] + // ( ",")* = (*) ( ",")* ( ",") ["Num"] + // Comma = (*) ( ",")* Expr? [")"] + // Factor = "*" "(" (*) Comma ")" [")"] + // Factor = "*" "(" (*) Comma ")" ["*"] + // Factor = "*" "(" (*) Comma ")" ["+"] + // Factor = "*" "(" (*) Comma ")" [","] + // Factor = "*" "(" (*) Comma ")" ["-"] + // Factor = "*" "(" (*) Comma ")" ["/"] // - // "*" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) - // "/" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) - // "+" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) - // ")" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) - // "-" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) + // "*" -> Reduce(( ",")* = => Call(ActionFn(13));) + // "(" -> Reduce(( ",")* = => Call(ActionFn(13));) + // ")" -> Reduce(( ",")* = => Call(ActionFn(13));) + // "Num" -> Reduce(( ",")* = => Call(ActionFn(13));) // + // ( ",")* -> S21 + // Comma -> S54 pub fn __state46< 'ast, __TOKENS: Iterator, @@ -3304,107 +3317,25 @@ mod __parse__Expr { __tokens: &mut __TOKENS, __sym0: &mut Option, __sym1: &mut Option, - __sym2: &mut Option>>, - __sym3: &mut Option, ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> { let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); match __lookahead { Some((_, Tok::Times(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __sym3 = __sym3.take().unwrap(); - let __nt = super::__action6(arena, __sym0, __sym1, __sym2, __sym3); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + let __nt = super::__action13(arena, ); + __result = (__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); } - Some((_, Tok::Div(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __sym3 = __sym3.take().unwrap(); - let __nt = super::__action6(arena, __sym0, __sym1, __sym2, __sym3); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __sym3 = __sym3.take().unwrap(); - let __nt = super::__action6(arena, __sym0, __sym1, __sym2, __sym3); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + Some((_, Tok::LParen(..), _)) => { + let __nt = super::__action13(arena, ); + __result = (__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); } Some((_, Tok::RParen(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __sym3 = __sym3.take().unwrap(); - let __nt = super::__action6(arena, __sym0, __sym1, __sym2, __sym3); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + let __nt = super::__action13(arena, ); + __result = (__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); } - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __sym3 = __sym3.take().unwrap(); - let __nt = super::__action6(arena, __sym0, __sym1, __sym2, __sym3); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 47 - // Factor = Factor "/" (*) Term [")"] - // Factor = Factor "/" (*) Term ["*"] - // Factor = Factor "/" (*) Term ["+"] - // Factor = Factor "/" (*) Term [","] - // Factor = Factor "/" (*) Term ["-"] - // Factor = Factor "/" (*) Term ["/"] - // Term = (*) "(" Expr ")" [")"] - // Term = (*) "(" Expr ")" ["*"] - // Term = (*) "(" Expr ")" ["+"] - // Term = (*) "(" Expr ")" [","] - // Term = (*) "(" Expr ")" ["-"] - // Term = (*) "(" Expr ")" ["/"] - // Term = (*) "Num" [")"] - // Term = (*) "Num" ["*"] - // Term = (*) "Num" ["+"] - // Term = (*) "Num" [","] - // Term = (*) "Num" ["-"] - // Term = (*) "Num" ["/"] - // - // "Num" -> Shift(S37) - // "(" -> Shift(S41) - // - // Term -> S54 - pub fn __state47< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize, Tok, usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, - ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> - { - let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, Tok::Num(__tok0), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state37(arena, __lookbehind, __lookahead, __tokens, __sym2)); - } - Some((_, __tok @ Tok::LParen(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state41(arena, __lookbehind, __lookahead, __tokens, __sym2)); + Some((_, Tok::Num(_), _)) => { + let __nt = super::__action13(arena, ); + __result = (__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); } _ => { return Err(__lookahead); @@ -3413,7 +3344,11 @@ mod __parse__Expr { while __sym1.is_some() { let (__lookbehind, __lookahead, __nt) = __result; match __nt { - __Nonterminal::Term(__nt) => { + __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state21(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + __Nonterminal::Comma_3cExpr_3e(__nt) => { let __sym2 = &mut Some(__nt); __result = try!(__state54(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); } @@ -3425,133 +3360,7 @@ mod __parse__Expr { return Ok(__result); } - // State 48 - // Factor = Factor "*" (*) Term [")"] - // Factor = Factor "*" (*) Term ["*"] - // Factor = Factor "*" (*) Term ["+"] - // Factor = Factor "*" (*) Term [","] - // Factor = Factor "*" (*) Term ["-"] - // Factor = Factor "*" (*) Term ["/"] - // Term = (*) "(" Expr ")" [")"] - // Term = (*) "(" Expr ")" ["*"] - // Term = (*) "(" Expr ")" ["+"] - // Term = (*) "(" Expr ")" [","] - // Term = (*) "(" Expr ")" ["-"] - // Term = (*) "(" Expr ")" ["/"] - // Term = (*) "Num" [")"] - // Term = (*) "Num" ["*"] - // Term = (*) "Num" ["+"] - // Term = (*) "Num" [","] - // Term = (*) "Num" ["-"] - // Term = (*) "Num" ["/"] - // - // "(" -> Shift(S41) - // "Num" -> Shift(S37) - // - // Term -> S55 - pub fn __state48< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize, Tok, usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, - ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> - { - let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, __tok @ Tok::LParen(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state41(arena, __lookbehind, __lookahead, __tokens, __sym2)); - } - Some((_, Tok::Num(__tok0), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state37(arena, __lookbehind, __lookahead, __tokens, __sym2)); - } - _ => { - return Err(__lookahead); - } - } - while __sym1.is_some() { - let (__lookbehind, __lookahead, __nt) = __result; - match __nt { - __Nonterminal::Term(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state55(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - _ => { - return Ok((__lookbehind, __lookahead, __nt)); - } - } - } - return Ok(__result); - } - - // State 49 - // Expr = Expr (*) "+" Factor [")"] - // Expr = Expr (*) "+" Factor ["+"] - // Expr = Expr (*) "+" Factor ["-"] - // Expr = Expr (*) "-" Factor [")"] - // Expr = Expr (*) "-" Factor ["+"] - // Expr = Expr (*) "-" Factor ["-"] - // Term = "(" Expr (*) ")" [")"] - // Term = "(" Expr (*) ")" ["*"] - // Term = "(" Expr (*) ")" ["+"] - // Term = "(" Expr (*) ")" [","] - // Term = "(" Expr (*) ")" ["-"] - // Term = "(" Expr (*) ")" ["/"] - // - // ")" -> Shift(S56) - // "+" -> Shift(S22) - // "-" -> Shift(S20) - // - pub fn __state49< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize, Tok, usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> - { - let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, __tok @ Tok::RParen(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state56(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - Some((_, __tok @ Tok::Plus(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state22(arena, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); - } - Some((_, __tok @ Tok::Minus(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state20(arena, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 50 + // State 47 // Expr = Expr "+" (*) Factor [")"] // Expr = Expr "+" (*) Factor ["+"] // Expr = Expr "+" (*) Factor [","] @@ -3593,13 +3402,13 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "*" -> Shift(S44) - // "(" -> Shift(S41) - // "Num" -> Shift(S37) + // "*" -> Shift(S35) + // "(" -> Shift(S38) + // "Num" -> Shift(S32) // - // Factor -> S57 - // Term -> S39 - pub fn __state50< + // Term -> S34 + // Factor -> S55 + pub fn __state47< 'ast, __TOKENS: Iterator, >( @@ -3617,19 +3426,19 @@ mod __parse__Expr { let mut __lookbehind = Some(__loc); let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state44(arena, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state35(arena, __lookbehind, __lookahead, __tokens, __sym2)); } Some((_, __tok @ Tok::LParen(..), __loc)) => { let mut __lookbehind = Some(__loc); let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state41(arena, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state38(arena, __lookbehind, __lookahead, __tokens, __sym2)); } Some((_, Tok::Num(__tok0), __loc)) => { let mut __lookbehind = Some(__loc); let mut __sym2 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state37(arena, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state32(arena, __lookbehind, __lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); @@ -3638,13 +3447,13 @@ mod __parse__Expr { while __sym1.is_some() { let (__lookbehind, __lookahead, __nt) = __result; match __nt { - __Nonterminal::Factor(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state57(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } __Nonterminal::Term(__nt) => { let __sym2 = &mut Some(__nt); - __result = try!(__state39(arena, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state34(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + __Nonterminal::Factor(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state55(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); } _ => { return Ok((__lookbehind, __lookahead, __nt)); @@ -3654,18 +3463,18 @@ mod __parse__Expr { return Ok(__result); } - // State 51 + // State 48 // ( ",") = Expr "," (*) ["("] // ( ",") = Expr "," (*) [")"] // ( ",") = Expr "," (*) ["*"] // ( ",") = Expr "," (*) ["Num"] // - // "(" -> Reduce(( ",") = Expr, "," => Call(ActionFn(15));) // "Num" -> Reduce(( ",") = Expr, "," => Call(ActionFn(15));) - // "*" -> Reduce(( ",") = Expr, "," => Call(ActionFn(15));) // ")" -> Reduce(( ",") = Expr, "," => Call(ActionFn(15));) + // "*" -> Reduce(( ",") = Expr, "," => Call(ActionFn(15));) + // "(" -> Reduce(( ",") = Expr, "," => Call(ActionFn(15));) // - pub fn __state51< + pub fn __state48< 'ast, __TOKENS: Iterator, >( @@ -3679,37 +3488,37 @@ mod __parse__Expr { { let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); match __lookahead { - Some((_, Tok::LParen(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __nt = super::__action15(arena, __sym0, __sym1); - return Ok((__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29(__nt))); - } Some((_, Tok::Num(_), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __nt = super::__action15(arena, __sym0, __sym1); return Ok((__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29(__nt))); } - Some((_, Tok::Times(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __nt = super::__action15(arena, __sym0, __sym1); - return Ok((__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29(__nt))); - } Some((_, Tok::RParen(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __nt = super::__action15(arena, __sym0, __sym1); return Ok((__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29(__nt))); } + Some((_, Tok::Times(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __nt = super::__action15(arena, __sym0, __sym1); + return Ok((__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29(__nt))); + } + Some((_, Tok::LParen(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __nt = super::__action15(arena, __sym0, __sym1); + return Ok((__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29(__nt))); + } _ => { return Err(__lookahead); } } } - // State 52 + // State 49 // Expr = Expr "-" (*) Factor [")"] // Expr = Expr "-" (*) Factor ["+"] // Expr = Expr "-" (*) Factor [","] @@ -3751,12 +3560,217 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "*" -> Shift(S44) - // "(" -> Shift(S41) - // "Num" -> Shift(S37) + // "Num" -> Shift(S32) + // "(" -> Shift(S38) + // "*" -> Shift(S35) // - // Factor -> S58 - // Term -> S39 + // Factor -> S56 + // Term -> S34 + pub fn __state49< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize, Tok, usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + __sym1: &mut Option, + ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> + { + let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, Tok::Num(__tok0), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok0)); + let __lookahead = __tokens.next(); + __result = try!(__state32(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + Some((_, __tok @ Tok::LParen(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state38(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + Some((_, __tok @ Tok::Times(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state35(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + _ => { + return Err(__lookahead); + } + } + while __sym1.is_some() { + let (__lookbehind, __lookahead, __nt) = __result; + match __nt { + __Nonterminal::Factor(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state56(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state34(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + _ => { + return Ok((__lookbehind, __lookahead, __nt)); + } + } + } + return Ok(__result); + } + + // State 50 + // Expr = Expr (*) "+" Factor [")"] + // Expr = Expr (*) "+" Factor ["+"] + // Expr = Expr (*) "+" Factor ["-"] + // Expr = Expr (*) "-" Factor [")"] + // Expr = Expr (*) "-" Factor ["+"] + // Expr = Expr (*) "-" Factor ["-"] + // Term = "(" Expr (*) ")" [")"] + // Term = "(" Expr (*) ")" ["*"] + // Term = "(" Expr (*) ")" ["+"] + // Term = "(" Expr (*) ")" [","] + // Term = "(" Expr (*) ")" ["-"] + // Term = "(" Expr (*) ")" ["/"] + // + // ")" -> Shift(S57) + // "+" -> Shift(S29) + // "-" -> Shift(S28) + // + pub fn __state50< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize, Tok, usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + __sym1: &mut Option<&'ast Node<'ast>>, + ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> + { + let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, __tok @ Tok::RParen(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state57(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + Some((_, __tok @ Tok::Plus(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state29(arena, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); + } + Some((_, __tok @ Tok::Minus(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state28(arena, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + + // State 51 + // Factor = Factor "*" (*) Term [")"] + // Factor = Factor "*" (*) Term ["*"] + // Factor = Factor "*" (*) Term ["+"] + // Factor = Factor "*" (*) Term [","] + // Factor = Factor "*" (*) Term ["-"] + // Factor = Factor "*" (*) Term ["/"] + // Term = (*) "(" Expr ")" [")"] + // Term = (*) "(" Expr ")" ["*"] + // Term = (*) "(" Expr ")" ["+"] + // Term = (*) "(" Expr ")" [","] + // Term = (*) "(" Expr ")" ["-"] + // Term = (*) "(" Expr ")" ["/"] + // Term = (*) "Num" [")"] + // Term = (*) "Num" ["*"] + // Term = (*) "Num" ["+"] + // Term = (*) "Num" [","] + // Term = (*) "Num" ["-"] + // Term = (*) "Num" ["/"] + // + // "(" -> Shift(S38) + // "Num" -> Shift(S32) + // + // Term -> S58 + pub fn __state51< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize, Tok, usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + __sym1: &mut Option, + ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> + { + let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, __tok @ Tok::LParen(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state38(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + Some((_, Tok::Num(__tok0), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok0)); + let __lookahead = __tokens.next(); + __result = try!(__state32(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + _ => { + return Err(__lookahead); + } + } + while __sym1.is_some() { + let (__lookbehind, __lookahead, __nt) = __result; + match __nt { + __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state58(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + _ => { + return Ok((__lookbehind, __lookahead, __nt)); + } + } + } + return Ok(__result); + } + + // State 52 + // Factor = Factor "/" (*) Term [")"] + // Factor = Factor "/" (*) Term ["*"] + // Factor = Factor "/" (*) Term ["+"] + // Factor = Factor "/" (*) Term [","] + // Factor = Factor "/" (*) Term ["-"] + // Factor = Factor "/" (*) Term ["/"] + // Term = (*) "(" Expr ")" [")"] + // Term = (*) "(" Expr ")" ["*"] + // Term = (*) "(" Expr ")" ["+"] + // Term = (*) "(" Expr ")" [","] + // Term = (*) "(" Expr ")" ["-"] + // Term = (*) "(" Expr ")" ["/"] + // Term = (*) "Num" [")"] + // Term = (*) "Num" ["*"] + // Term = (*) "Num" ["+"] + // Term = (*) "Num" [","] + // Term = (*) "Num" ["-"] + // Term = (*) "Num" ["/"] + // + // "Num" -> Shift(S32) + // "(" -> Shift(S38) + // + // Term -> S59 pub fn __state52< 'ast, __TOKENS: Iterator, @@ -3771,23 +3785,17 @@ mod __parse__Expr { { let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); match __lookahead { - Some((_, __tok @ Tok::Times(..), __loc)) => { + Some((_, Tok::Num(__tok0), __loc)) => { let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok)); + let mut __sym2 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state44(arena, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state32(arena, __lookbehind, __lookahead, __tokens, __sym2)); } Some((_, __tok @ Tok::LParen(..), __loc)) => { let mut __lookbehind = Some(__loc); let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state41(arena, __lookbehind, __lookahead, __tokens, __sym2)); - } - Some((_, Tok::Num(__tok0), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state37(arena, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state38(arena, __lookbehind, __lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); @@ -3796,13 +3804,9 @@ mod __parse__Expr { while __sym1.is_some() { let (__lookbehind, __lookahead, __nt) = __result; match __nt { - __Nonterminal::Factor(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state58(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } __Nonterminal::Term(__nt) => { let __sym2 = &mut Some(__nt); - __result = try!(__state39(arena, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state59(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); } _ => { return Ok((__lookbehind, __lookahead, __nt)); @@ -3813,29 +3817,18 @@ mod __parse__Expr { } // State 53 - // ( ",")* = (*) ["("] - // ( ",")* = (*) [")"] - // ( ",")* = (*) ["*"] - // ( ",")* = (*) ["Num"] - // ( ",")* = (*) ( ",")* ( ",") ["("] - // ( ",")* = (*) ( ",")* ( ",") [")"] - // ( ",")* = (*) ( ",")* ( ",") ["*"] - // ( ",")* = (*) ( ",")* ( ",") ["Num"] - // Comma = (*) ( ",")* Expr? [")"] - // Factor = "*" "(" (*) Comma ")" [")"] - // Factor = "*" "(" (*) Comma ")" ["*"] - // Factor = "*" "(" (*) Comma ")" ["+"] - // Factor = "*" "(" (*) Comma ")" [","] - // Factor = "*" "(" (*) Comma ")" ["-"] - // Factor = "*" "(" (*) Comma ")" ["/"] + // Factor = "*" "(" Comma ")" (*) [")"] + // Factor = "*" "(" Comma ")" (*) ["*"] + // Factor = "*" "(" Comma ")" (*) ["+"] + // Factor = "*" "(" Comma ")" (*) ["-"] + // Factor = "*" "(" Comma ")" (*) ["/"] // - // "Num" -> Reduce(( ",")* = => Call(ActionFn(13));) - // "(" -> Reduce(( ",")* = => Call(ActionFn(13));) - // "*" -> Reduce(( ",")* = => Call(ActionFn(13));) - // ")" -> Reduce(( ",")* = => Call(ActionFn(13));) + // "-" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) + // "/" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) + // "*" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) + // "+" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) + // ")" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) // - // Comma -> S59 - // ( ",")* -> S25 pub fn __state53< 'ast, __TOKENS: Iterator, @@ -3846,458 +3839,59 @@ mod __parse__Expr { __tokens: &mut __TOKENS, __sym0: &mut Option, __sym1: &mut Option, + __sym2: &mut Option>>, + __sym3: &mut Option, ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> { let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); match __lookahead { - Some((_, Tok::Num(_), _)) => { - let __nt = super::__action13(arena, ); - __result = (__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __sym3 = __sym3.take().unwrap(); + let __nt = super::__action6(arena, __sym0, __sym1, __sym2, __sym3); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } - Some((_, Tok::LParen(..), _)) => { - let __nt = super::__action13(arena, ); - __result = (__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); + Some((_, Tok::Div(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __sym3 = __sym3.take().unwrap(); + let __nt = super::__action6(arena, __sym0, __sym1, __sym2, __sym3); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } Some((_, Tok::Times(..), _)) => { - let __nt = super::__action13(arena, ); - __result = (__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __sym3 = __sym3.take().unwrap(); + let __nt = super::__action6(arena, __sym0, __sym1, __sym2, __sym3); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __sym3 = __sym3.take().unwrap(); + let __nt = super::__action6(arena, __sym0, __sym1, __sym2, __sym3); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } Some((_, Tok::RParen(..), _)) => { - let __nt = super::__action13(arena, ); - __result = (__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __sym3 = __sym3.take().unwrap(); + let __nt = super::__action6(arena, __sym0, __sym1, __sym2, __sym3); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } _ => { return Err(__lookahead); } } - while __sym1.is_some() { - let (__lookbehind, __lookahead, __nt) = __result; - match __nt { - __Nonterminal::Comma_3cExpr_3e(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state59(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state25(arena, __lookbehind, __lookahead, __tokens, __sym2)); - } - _ => { - return Ok((__lookbehind, __lookahead, __nt)); - } - } - } - return Ok(__result); } // State 54 - // Factor = Factor "/" Term (*) [")"] - // Factor = Factor "/" Term (*) ["*"] - // Factor = Factor "/" Term (*) ["+"] - // Factor = Factor "/" Term (*) [","] - // Factor = Factor "/" Term (*) ["-"] - // Factor = Factor "/" Term (*) ["/"] - // - // ")" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // "+" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // "-" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // "," -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // "*" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // "/" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // - pub fn __state54< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize, Tok, usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, - __sym2: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> - { - let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, Tok::RParen(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action5(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action5(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action5(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Comma(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action5(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Times(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action5(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Div(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action5(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 55 - // Factor = Factor "*" Term (*) [")"] - // Factor = Factor "*" Term (*) ["*"] - // Factor = Factor "*" Term (*) ["+"] - // Factor = Factor "*" Term (*) [","] - // Factor = Factor "*" Term (*) ["-"] - // Factor = Factor "*" Term (*) ["/"] - // - // "/" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) - // "-" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) - // ")" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) - // "*" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) - // "," -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) - // "+" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) - // - pub fn __state55< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize, Tok, usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, - __sym2: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> - { - let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, Tok::Div(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::RParen(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Times(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Comma(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 56 - // Term = "(" Expr ")" (*) [")"] - // Term = "(" Expr ")" (*) ["*"] - // Term = "(" Expr ")" (*) ["+"] - // Term = "(" Expr ")" (*) [","] - // Term = "(" Expr ")" (*) ["-"] - // Term = "(" Expr ")" (*) ["/"] - // - // "-" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) - // "+" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) - // ")" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) - // "," -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) - // "/" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) - // "*" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) - // - pub fn __state56< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize, Tok, usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option<&'ast Node<'ast>>, - __sym2: &mut Option, - ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> - { - let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action9(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - Some((_, Tok::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action9(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - Some((_, Tok::RParen(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action9(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - Some((_, Tok::Comma(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action9(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - Some((_, Tok::Div(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action9(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - Some((_, Tok::Times(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action9(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 57 - // Expr = Expr "+" Factor (*) [")"] - // Expr = Expr "+" Factor (*) ["+"] - // Expr = Expr "+" Factor (*) [","] - // Expr = Expr "+" Factor (*) ["-"] - // Factor = Factor (*) "*" Term [")"] - // Factor = Factor (*) "*" Term ["*"] - // Factor = Factor (*) "*" Term ["+"] - // Factor = Factor (*) "*" Term [","] - // Factor = Factor (*) "*" Term ["-"] - // Factor = Factor (*) "*" Term ["/"] - // Factor = Factor (*) "/" Term [")"] - // Factor = Factor (*) "/" Term ["*"] - // Factor = Factor (*) "/" Term ["+"] - // Factor = Factor (*) "/" Term [","] - // Factor = Factor (*) "/" Term ["-"] - // Factor = Factor (*) "/" Term ["/"] - // - // "," -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) - // "-" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) - // "+" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) - // "/" -> Shift(S47) - // ")" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) - // "*" -> Shift(S48) - // - pub fn __state57< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize, Tok, usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, - __sym2: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> - { - let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, __tok @ Tok::Div(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym3 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state47(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); - } - Some((_, __tok @ Tok::Times(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym3 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state48(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); - } - Some((_, Tok::Comma(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action2(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action2(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - Some((_, Tok::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action2(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - Some((_, Tok::RParen(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action2(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 58 - // Expr = Expr "-" Factor (*) [")"] - // Expr = Expr "-" Factor (*) ["+"] - // Expr = Expr "-" Factor (*) [","] - // Expr = Expr "-" Factor (*) ["-"] - // Factor = Factor (*) "*" Term [")"] - // Factor = Factor (*) "*" Term ["*"] - // Factor = Factor (*) "*" Term ["+"] - // Factor = Factor (*) "*" Term [","] - // Factor = Factor (*) "*" Term ["-"] - // Factor = Factor (*) "*" Term ["/"] - // Factor = Factor (*) "/" Term [")"] - // Factor = Factor (*) "/" Term ["*"] - // Factor = Factor (*) "/" Term ["+"] - // Factor = Factor (*) "/" Term [","] - // Factor = Factor (*) "/" Term ["-"] - // Factor = Factor (*) "/" Term ["/"] - // - // "," -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) - // "+" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) - // "-" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) - // ")" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) - // "*" -> Shift(S48) - // "/" -> Shift(S47) - // - pub fn __state58< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize, Tok, usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, - __sym2: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> - { - let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, __tok @ Tok::Times(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym3 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state48(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); - } - Some((_, __tok @ Tok::Div(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym3 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state47(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); - } - Some((_, Tok::Comma(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action1(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - Some((_, Tok::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action1(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action1(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - Some((_, Tok::RParen(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action1(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 59 // Factor = "*" "(" Comma (*) ")" [")"] // Factor = "*" "(" Comma (*) ")" ["*"] // Factor = "*" "(" Comma (*) ")" ["+"] @@ -4307,7 +3901,7 @@ mod __parse__Expr { // // ")" -> Shift(S60) // - pub fn __state59< + pub fn __state54< 'ast, __TOKENS: Iterator, >( @@ -4335,6 +3929,414 @@ mod __parse__Expr { return Ok(__result); } + // State 55 + // Expr = Expr "+" Factor (*) [")"] + // Expr = Expr "+" Factor (*) ["+"] + // Expr = Expr "+" Factor (*) [","] + // Expr = Expr "+" Factor (*) ["-"] + // Factor = Factor (*) "*" Term [")"] + // Factor = Factor (*) "*" Term ["*"] + // Factor = Factor (*) "*" Term ["+"] + // Factor = Factor (*) "*" Term [","] + // Factor = Factor (*) "*" Term ["-"] + // Factor = Factor (*) "*" Term ["/"] + // Factor = Factor (*) "/" Term [")"] + // Factor = Factor (*) "/" Term ["*"] + // Factor = Factor (*) "/" Term ["+"] + // Factor = Factor (*) "/" Term [","] + // Factor = Factor (*) "/" Term ["-"] + // Factor = Factor (*) "/" Term ["/"] + // + // ")" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) + // "*" -> Shift(S51) + // "+" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) + // "-" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) + // "/" -> Shift(S52) + // "," -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) + // + pub fn __state55< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize, Tok, usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + __sym1: &mut Option, + __sym2: &mut Option<&'ast Node<'ast>>, + ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> + { + let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, __tok @ Tok::Times(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym3 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state51(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); + } + Some((_, __tok @ Tok::Div(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym3 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state52(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); + } + Some((_, Tok::RParen(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action2(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action2(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action2(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + Some((_, Tok::Comma(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action2(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + + // State 56 + // Expr = Expr "-" Factor (*) [")"] + // Expr = Expr "-" Factor (*) ["+"] + // Expr = Expr "-" Factor (*) [","] + // Expr = Expr "-" Factor (*) ["-"] + // Factor = Factor (*) "*" Term [")"] + // Factor = Factor (*) "*" Term ["*"] + // Factor = Factor (*) "*" Term ["+"] + // Factor = Factor (*) "*" Term [","] + // Factor = Factor (*) "*" Term ["-"] + // Factor = Factor (*) "*" Term ["/"] + // Factor = Factor (*) "/" Term [")"] + // Factor = Factor (*) "/" Term ["*"] + // Factor = Factor (*) "/" Term ["+"] + // Factor = Factor (*) "/" Term [","] + // Factor = Factor (*) "/" Term ["-"] + // Factor = Factor (*) "/" Term ["/"] + // + // ")" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // "," -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // "-" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // "*" -> Shift(S51) + // "+" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // "/" -> Shift(S52) + // + pub fn __state56< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize, Tok, usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + __sym1: &mut Option, + __sym2: &mut Option<&'ast Node<'ast>>, + ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> + { + let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, __tok @ Tok::Times(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym3 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state51(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); + } + Some((_, __tok @ Tok::Div(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym3 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state52(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); + } + Some((_, Tok::RParen(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action1(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + Some((_, Tok::Comma(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action1(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action1(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action1(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + + // State 57 + // Term = "(" Expr ")" (*) [")"] + // Term = "(" Expr ")" (*) ["*"] + // Term = "(" Expr ")" (*) ["+"] + // Term = "(" Expr ")" (*) [","] + // Term = "(" Expr ")" (*) ["-"] + // Term = "(" Expr ")" (*) ["/"] + // + // "+" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) + // "-" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) + // "," -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) + // ")" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) + // "*" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) + // "/" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) + // + pub fn __state57< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize, Tok, usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + __sym1: &mut Option<&'ast Node<'ast>>, + __sym2: &mut Option, + ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> + { + let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action9(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action9(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + Some((_, Tok::Comma(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action9(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + Some((_, Tok::RParen(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action9(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + Some((_, Tok::Times(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action9(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + Some((_, Tok::Div(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action9(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 58 + // Factor = Factor "*" Term (*) [")"] + // Factor = Factor "*" Term (*) ["*"] + // Factor = Factor "*" Term (*) ["+"] + // Factor = Factor "*" Term (*) [","] + // Factor = Factor "*" Term (*) ["-"] + // Factor = Factor "*" Term (*) ["/"] + // + // "," -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // "*" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // "/" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // ")" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // "+" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // "-" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // + pub fn __state58< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize, Tok, usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + __sym1: &mut Option, + __sym2: &mut Option<&'ast Node<'ast>>, + ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> + { + let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, Tok::Comma(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action4(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Times(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action4(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Div(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action4(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::RParen(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action4(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action4(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action4(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 59 + // Factor = Factor "/" Term (*) [")"] + // Factor = Factor "/" Term (*) ["*"] + // Factor = Factor "/" Term (*) ["+"] + // Factor = Factor "/" Term (*) [","] + // Factor = Factor "/" Term (*) ["-"] + // Factor = Factor "/" Term (*) ["/"] + // + // "-" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // "/" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // "," -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // "*" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // ")" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // "+" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // + pub fn __state59< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize, Tok, usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + __sym1: &mut Option, + __sym2: &mut Option<&'ast Node<'ast>>, + ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >), Option<(usize, Tok, usize)>> + { + let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action5(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Div(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action5(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Comma(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action5(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Times(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action5(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::RParen(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action5(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action5(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + // State 60 // Factor = "*" "(" Comma ")" (*) [")"] // Factor = "*" "(" Comma ")" (*) ["*"] @@ -4343,12 +4345,12 @@ mod __parse__Expr { // Factor = "*" "(" Comma ")" (*) ["-"] // Factor = "*" "(" Comma ")" (*) ["/"] // + // "-" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) + // "/" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) // "+" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) - // "*" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) // ")" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) // "," -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) - // "/" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) - // "-" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) + // "*" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) // pub fn __state60< 'ast, @@ -4366,7 +4368,7 @@ mod __parse__Expr { { let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<'ast, >); match __lookahead { - Some((_, Tok::Plus(..), _)) => { + Some((_, Tok::Minus(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); @@ -4374,7 +4376,15 @@ mod __parse__Expr { let __nt = super::__action6(arena, __sym0, __sym1, __sym2, __sym3); return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } - Some((_, Tok::Times(..), _)) => { + Some((_, Tok::Div(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __sym3 = __sym3.take().unwrap(); + let __nt = super::__action6(arena, __sym0, __sym1, __sym2, __sym3); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Plus(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); @@ -4398,15 +4408,7 @@ mod __parse__Expr { let __nt = super::__action6(arena, __sym0, __sym1, __sym2, __sym3); return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } - Some((_, Tok::Div(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __sym3 = __sym3.take().unwrap(); - let __nt = super::__action6(arena, __sym0, __sym1, __sym2, __sym3); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Minus(..), _)) => { + Some((_, Tok::Times(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); diff --git a/lalrpop-test/src/loc.rs b/lalrpop-test/src/loc.rs index bef90a0..2744a5a 100644 --- a/lalrpop-test/src/loc.rs +++ b/lalrpop-test/src/loc.rs @@ -31,11 +31,13 @@ mod __parse__Items { #![allow(non_snake_case, non_camel_case_types, unused_mut, unused_variables, unused_imports)] use util::tok::Tok; + extern crate lalrpop_util as __lalrpop_util; + use self::__lalrpop_util::ParseError as __ParseError; pub enum __Nonterminal<> { - _40_3c(usize), _40_3e(usize), ____Items(Vec<(usize, usize)>), + _40_3c(usize), Spanned_3c_22_2b_22_3e((usize, usize)), Items(Vec<(usize, usize)>), } @@ -59,8 +61,8 @@ mod __parse__Items { // "-" -> Reduce(@< = => Lookahead;) // EOF -> Reduce(@< = => Lookahead;) // - // @< -> S1 - // Items -> S2 + // Items -> S1 + // @< -> S2 pub fn __state0< __TOKENS: Iterator, >( @@ -90,11 +92,11 @@ mod __parse__Items { loop { let (__lookbehind, __lookahead, __nt) = __result; match __nt { - __Nonterminal::_40_3c(__nt) => { + __Nonterminal::Items(__nt) => { let __sym0 = &mut Some(__nt); __result = try!(__state1(__lookbehind, __lookahead, __tokens, __sym0)); } - __Nonterminal::Items(__nt) => { + __Nonterminal::_40_3c(__nt) => { let __sym0 = &mut Some(__nt); __result = try!(__state2(__lookbehind, __lookahead, __tokens, __sym0)); } @@ -106,61 +108,6 @@ mod __parse__Items { } // State 1 - // @> = (*) [EOF] - // @> = (*) ["+"] - // @> = (*) ["-"] - // Items = @< (*) @> [EOF] - // Items = @< (*) @> ["+"] - // Items = @< (*) @> ["-"] - // - // "-" -> Reduce(@> = => Lookbehind;) - // EOF -> Reduce(@> = => Lookbehind;) - // "+" -> Reduce(@> = => Lookbehind;) - // - // @> -> S3 - pub fn __state1< - __TOKENS: Iterator, - >( - __lookbehind: Option, - __lookahead: Option<(usize, Tok, usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<>), Option<(usize, Tok, usize)>> - { - let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<>); - match __lookahead { - Some((_, Tok::Minus(..), _)) => { - let __nt = ::std::clone::Clone::clone(&__lookbehind).unwrap_or_default(); - __result = (__lookbehind, __lookahead, __Nonterminal::_40_3e(__nt)); - } - None => { - let __nt = ::std::clone::Clone::clone(&__lookbehind).unwrap_or_default(); - __result = (__lookbehind, __lookahead, __Nonterminal::_40_3e(__nt)); - } - Some((_, Tok::Plus(..), _)) => { - let __nt = ::std::clone::Clone::clone(&__lookbehind).unwrap_or_default(); - __result = (__lookbehind, __lookahead, __Nonterminal::_40_3e(__nt)); - } - _ => { - return Err(__lookahead); - } - } - while __sym0.is_some() { - let (__lookbehind, __lookahead, __nt) = __result; - match __nt { - __Nonterminal::_40_3e(__nt) => { - let __sym1 = &mut Some(__nt); - __result = try!(__state3(__lookbehind, __lookahead, __tokens, __sym0, __sym1)); - } - _ => { - return Ok((__lookbehind, __lookahead, __nt)); - } - } - } - return Ok(__result); - } - - // State 2 // @< = (*) ["+"] // Items = Items (*) Spanned<"+"> [EOF] // Items = Items (*) Spanned<"+"> ["+"] @@ -175,11 +122,11 @@ mod __parse__Items { // // EOF -> Reduce(__Items = Items => Call(ActionFn(0));) // "+" -> Reduce(@< = => Lookahead;) - // "-" -> Shift(S6) + // "-" -> Shift(S4) // - // Spanned<"+"> -> S4 + // Spanned<"+"> -> S3 // @< -> S5 - pub fn __state2< + pub fn __state1< __TOKENS: Iterator, >( __lookbehind: Option, @@ -194,7 +141,7 @@ mod __parse__Items { let mut __lookbehind = Some(__loc); let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state6(__lookbehind, __lookahead, __tokens, __sym0, __sym1)); + __result = try!(__state4(__lookbehind, __lookahead, __tokens, __sym0, __sym1)); } None => { let __sym0 = __sym0.take().unwrap(); @@ -214,7 +161,7 @@ mod __parse__Items { match __nt { __Nonterminal::Spanned_3c_22_2b_22_3e(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state4(__lookbehind, __lookahead, __tokens, __sym0, __sym1)); + __result = try!(__state3(__lookbehind, __lookahead, __tokens, __sym0, __sym1)); } __Nonterminal::_40_3c(__nt) => { let __sym1 = &mut Some(__nt); @@ -228,61 +175,71 @@ mod __parse__Items { return Ok(__result); } - // State 3 - // Items = @< @> (*) [EOF] - // Items = @< @> (*) ["+"] - // Items = @< @> (*) ["-"] + // State 2 + // @> = (*) [EOF] + // @> = (*) ["+"] + // @> = (*) ["-"] + // Items = @< (*) @> [EOF] + // Items = @< (*) @> ["+"] + // Items = @< (*) @> ["-"] // - // "+" -> Reduce(Items = @<, @> => Call(ActionFn(1));) - // "-" -> Reduce(Items = @<, @> => Call(ActionFn(1));) - // EOF -> Reduce(Items = @<, @> => Call(ActionFn(1));) + // "+" -> Reduce(@> = => Lookbehind;) + // EOF -> Reduce(@> = => Lookbehind;) + // "-" -> Reduce(@> = => Lookbehind;) // - pub fn __state3< + // @> -> S6 + pub fn __state2< __TOKENS: Iterator, >( __lookbehind: Option, __lookahead: Option<(usize, Tok, usize)>, __tokens: &mut __TOKENS, __sym0: &mut Option, - __sym1: &mut Option, ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<>), Option<(usize, Tok, usize)>> { let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<>); match __lookahead { Some((_, Tok::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __nt = super::__action1(__sym0, __sym1); - return Ok((__lookbehind, __lookahead, __Nonterminal::Items(__nt))); - } - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __nt = super::__action1(__sym0, __sym1); - return Ok((__lookbehind, __lookahead, __Nonterminal::Items(__nt))); + let __nt = ::std::clone::Clone::clone(&__lookbehind).unwrap_or_default(); + __result = (__lookbehind, __lookahead, __Nonterminal::_40_3e(__nt)); } None => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __nt = super::__action1(__sym0, __sym1); - return Ok((__lookbehind, __lookahead, __Nonterminal::Items(__nt))); + let __nt = ::std::clone::Clone::clone(&__lookbehind).unwrap_or_default(); + __result = (__lookbehind, __lookahead, __Nonterminal::_40_3e(__nt)); + } + Some((_, Tok::Minus(..), _)) => { + let __nt = ::std::clone::Clone::clone(&__lookbehind).unwrap_or_default(); + __result = (__lookbehind, __lookahead, __Nonterminal::_40_3e(__nt)); } _ => { return Err(__lookahead); } } + while __sym0.is_some() { + let (__lookbehind, __lookahead, __nt) = __result; + match __nt { + __Nonterminal::_40_3e(__nt) => { + let __sym1 = &mut Some(__nt); + __result = try!(__state6(__lookbehind, __lookahead, __tokens, __sym0, __sym1)); + } + _ => { + return Ok((__lookbehind, __lookahead, __nt)); + } + } + } + return Ok(__result); } - // State 4 + // State 3 // Items = Items Spanned<"+"> (*) [EOF] // Items = Items Spanned<"+"> (*) ["+"] // Items = Items Spanned<"+"> (*) ["-"] // - // "-" -> Reduce(Items = Items, Spanned<"+"> => Call(ActionFn(2));) // "+" -> Reduce(Items = Items, Spanned<"+"> => Call(ActionFn(2));) + // "-" -> Reduce(Items = Items, Spanned<"+"> => Call(ActionFn(2));) // EOF -> Reduce(Items = Items, Spanned<"+"> => Call(ActionFn(2));) // - pub fn __state4< + pub fn __state3< __TOKENS: Iterator, >( __lookbehind: Option, @@ -294,13 +251,13 @@ mod __parse__Items { { let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<>); match __lookahead { - Some((_, Tok::Minus(..), _)) => { + Some((_, Tok::Plus(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __nt = super::__action2(__sym0, __sym1); return Ok((__lookbehind, __lookahead, __Nonterminal::Items(__nt))); } - Some((_, Tok::Plus(..), _)) => { + Some((_, Tok::Minus(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __nt = super::__action2(__sym0, __sym1); @@ -318,6 +275,51 @@ mod __parse__Items { } } + // State 4 + // Items = Items "-" (*) [EOF] + // Items = Items "-" (*) ["+"] + // Items = Items "-" (*) ["-"] + // + // EOF -> Reduce(Items = Items, "-" => Call(ActionFn(3));) + // "-" -> Reduce(Items = Items, "-" => Call(ActionFn(3));) + // "+" -> Reduce(Items = Items, "-" => Call(ActionFn(3));) + // + pub fn __state4< + __TOKENS: Iterator, + >( + __lookbehind: Option, + __lookahead: Option<(usize, Tok, usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option>, + __sym1: &mut Option, + ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<>), Option<(usize, Tok, usize)>> + { + let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<>); + match __lookahead { + None => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __nt = super::__action3(__sym0, __sym1); + return Ok((__lookbehind, __lookahead, __Nonterminal::Items(__nt))); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __nt = super::__action3(__sym0, __sym1); + return Ok((__lookbehind, __lookahead, __Nonterminal::Items(__nt))); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __nt = super::__action3(__sym0, __sym1); + return Ok((__lookbehind, __lookahead, __Nonterminal::Items(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + // State 5 // Spanned<"+"> = @< (*) "+" @> [EOF] // Spanned<"+"> = @< (*) "+" @> ["+"] @@ -350,13 +352,13 @@ mod __parse__Items { } // State 6 - // Items = Items "-" (*) [EOF] - // Items = Items "-" (*) ["+"] - // Items = Items "-" (*) ["-"] + // Items = @< @> (*) [EOF] + // Items = @< @> (*) ["+"] + // Items = @< @> (*) ["-"] // - // "+" -> Reduce(Items = Items, "-" => Call(ActionFn(3));) - // EOF -> Reduce(Items = Items, "-" => Call(ActionFn(3));) - // "-" -> Reduce(Items = Items, "-" => Call(ActionFn(3));) + // EOF -> Reduce(Items = @<, @> => Call(ActionFn(1));) + // "+" -> Reduce(Items = @<, @> => Call(ActionFn(1));) + // "-" -> Reduce(Items = @<, @> => Call(ActionFn(1));) // pub fn __state6< __TOKENS: Iterator, @@ -364,28 +366,28 @@ mod __parse__Items { __lookbehind: Option, __lookahead: Option<(usize, Tok, usize)>, __tokens: &mut __TOKENS, - __sym0: &mut Option>, - __sym1: &mut Option, + __sym0: &mut Option, + __sym1: &mut Option, ) -> Result<(Option, Option<(usize, Tok, usize)>, __Nonterminal<>), Option<(usize, Tok, usize)>> { let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<>); match __lookahead { - Some((_, Tok::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __nt = super::__action3(__sym0, __sym1); - return Ok((__lookbehind, __lookahead, __Nonterminal::Items(__nt))); - } None => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); - let __nt = super::__action3(__sym0, __sym1); + let __nt = super::__action1(__sym0, __sym1); + return Ok((__lookbehind, __lookahead, __Nonterminal::Items(__nt))); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __nt = super::__action1(__sym0, __sym1); return Ok((__lookbehind, __lookahead, __Nonterminal::Items(__nt))); } Some((_, Tok::Minus(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); - let __nt = super::__action3(__sym0, __sym1); + let __nt = super::__action1(__sym0, __sym1); return Ok((__lookbehind, __lookahead, __Nonterminal::Items(__nt))); } _ => { @@ -402,9 +404,9 @@ mod __parse__Items { // Spanned<"+"> = @< "+" (*) @> ["+"] // Spanned<"+"> = @< "+" (*) @> ["-"] // + // EOF -> Reduce(@> = => Lookbehind;) // "-" -> Reduce(@> = => Lookbehind;) // "+" -> Reduce(@> = => Lookbehind;) - // EOF -> Reduce(@> = => Lookbehind;) // // @> -> S8 pub fn __state7< @@ -419,6 +421,10 @@ mod __parse__Items { { let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<>); match __lookahead { + None => { + let __nt = ::std::clone::Clone::clone(&__lookbehind).unwrap_or_default(); + __result = (__lookbehind, __lookahead, __Nonterminal::_40_3e(__nt)); + } Some((_, Tok::Minus(..), _)) => { let __nt = ::std::clone::Clone::clone(&__lookbehind).unwrap_or_default(); __result = (__lookbehind, __lookahead, __Nonterminal::_40_3e(__nt)); @@ -427,10 +433,6 @@ mod __parse__Items { let __nt = ::std::clone::Clone::clone(&__lookbehind).unwrap_or_default(); __result = (__lookbehind, __lookahead, __Nonterminal::_40_3e(__nt)); } - None => { - let __nt = ::std::clone::Clone::clone(&__lookbehind).unwrap_or_default(); - __result = (__lookbehind, __lookahead, __Nonterminal::_40_3e(__nt)); - } _ => { return Err(__lookahead); } @@ -455,9 +457,9 @@ mod __parse__Items { // Spanned<"+"> = @< "+" @> (*) ["+"] // Spanned<"+"> = @< "+" @> (*) ["-"] // + // "-" -> Reduce(Spanned<"+"> = @<, "+", @> => Call(ActionFn(4));) // EOF -> Reduce(Spanned<"+"> = @<, "+", @> => Call(ActionFn(4));) // "+" -> Reduce(Spanned<"+"> = @<, "+", @> => Call(ActionFn(4));) - // "-" -> Reduce(Spanned<"+"> = @<, "+", @> => Call(ActionFn(4));) // pub fn __state8< __TOKENS: Iterator, @@ -472,6 +474,13 @@ mod __parse__Items { { let mut __result: (Option, Option<(usize, Tok, usize)>, __Nonterminal<>); match __lookahead { + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action4(__sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Spanned_3c_22_2b_22_3e(__nt))); + } None => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); @@ -486,13 +495,6 @@ mod __parse__Items { let __nt = super::__action4(__sym0, __sym1, __sym2); return Ok((__lookbehind, __lookahead, __Nonterminal::Spanned_3c_22_2b_22_3e(__nt))); } - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action4(__sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Spanned_3c_22_2b_22_3e(__nt))); - } _ => { return Err(__lookahead); } diff --git a/lalrpop-test/src/main.rs b/lalrpop-test/src/main.rs index 14101e7..113b617 100644 --- a/lalrpop-test/src/main.rs +++ b/lalrpop-test/src/main.rs @@ -1,8 +1,23 @@ -mod expr; -mod expr_arena; -mod expr_arena_ast; -mod loc; +/// demonstration from the Greene text; one of the simplest grammars +/// that still ensures we get parse tree correct mod sub; + +/// more interesting demonstration of parsing full expressions +mod expr; + +/// test that passes in lifetime/type/formal parameters and threads +/// them through, building an AST from the result +mod expr_arena; + +/// definitions of the AST +mod expr_arena_ast; + +/// test that exercises locations and spans +mod loc; + +/// test that uses `super` in paths in various places +mod use_super; + mod util; /// This constant is here so that some of the generator parsers can @@ -98,3 +113,8 @@ fn loc_empty() { util::test_loc(|v| loc::parse_Items(v), "", vec![(0, 0)]); } +#[test] +fn use_super_test1() { + util::test(|v| use_super::parse_S(v), "()", 0); +} + diff --git a/lalrpop-test/src/sub.rs b/lalrpop-test/src/sub.rs index 8821fe0..14064cc 100644 --- a/lalrpop-test/src/sub.rs +++ b/lalrpop-test/src/sub.rs @@ -32,12 +32,14 @@ mod __parse__S { #![allow(non_snake_case, non_camel_case_types, unused_mut, unused_variables, unused_imports)] use util::tok::Tok; + extern crate lalrpop_util as __lalrpop_util; + use self::__lalrpop_util::ParseError as __ParseError; pub enum __Nonterminal<> { - E(i32), - S(i32), T(i32), + S(i32), ____S(i32), + E(i32), } // State 0 @@ -52,12 +54,12 @@ mod __parse__S { // T = (*) "Num" ["-"] // __S = (*) S [EOF] // - // "(" -> Shift(S5) - // "Num" -> Shift(S2) + // "Num" -> Shift(S5) + // "(" -> Shift(S4) // // E -> S1 - // T -> S3 - // S -> S4 + // T -> S2 + // S -> S3 pub fn __state0< __TOKENS: Iterator, >( @@ -68,17 +70,17 @@ mod __parse__S { { let mut __result: (Option<()>, Option<((), Tok, ())>, __Nonterminal<>); match __lookahead { - Some((_, __tok @ Tok::LParen(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym0 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state5(__lookbehind, __lookahead, __tokens, __sym0)); - } Some((_, Tok::Num(__tok0), __loc)) => { let mut __lookbehind = Some(__loc); let mut __sym0 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state2(__lookbehind, __lookahead, __tokens, __sym0)); + __result = try!(__state5(__lookbehind, __lookahead, __tokens, __sym0)); + } + Some((_, __tok @ Tok::LParen(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym0 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state4(__lookbehind, __lookahead, __tokens, __sym0)); } _ => { return Err(__lookahead); @@ -93,11 +95,11 @@ mod __parse__S { } __Nonterminal::T(__nt) => { let __sym0 = &mut Some(__nt); - __result = try!(__state3(__lookbehind, __lookahead, __tokens, __sym0)); + __result = try!(__state2(__lookbehind, __lookahead, __tokens, __sym0)); } __Nonterminal::S(__nt) => { let __sym0 = &mut Some(__nt); - __result = try!(__state4(__lookbehind, __lookahead, __tokens, __sym0)); + __result = try!(__state3(__lookbehind, __lookahead, __tokens, __sym0)); } _ => { return Ok((__lookbehind, __lookahead, __nt)); @@ -111,8 +113,8 @@ mod __parse__S { // E = E (*) "-" T ["-"] // S = E (*) [EOF] // - // "-" -> Shift(S6) // EOF -> Reduce(S = E => Call(ActionFn(1));) + // "-" -> Shift(S6) // pub fn __state1< __TOKENS: Iterator, @@ -144,11 +146,11 @@ mod __parse__S { } // State 2 - // T = "Num" (*) [EOF] - // T = "Num" (*) ["-"] + // E = T (*) [EOF] + // E = T (*) ["-"] // - // "-" -> Reduce(T = "Num" => Call(ActionFn(4));) - // EOF -> Reduce(T = "Num" => Call(ActionFn(4));) + // EOF -> Reduce(E = T => Call(ActionFn(3));) + // "-" -> Reduce(E = T => Call(ActionFn(3));) // pub fn __state2< __TOKENS: Iterator, @@ -161,15 +163,15 @@ mod __parse__S { { let mut __result: (Option<()>, Option<((), Tok, ())>, __Nonterminal<>); match __lookahead { - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action4(__sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::T(__nt))); - } None => { let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action4(__sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::T(__nt))); + let __nt = super::__action3(__sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::E(__nt))); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action3(__sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::E(__nt))); } _ => { return Err(__lookahead); @@ -178,45 +180,11 @@ mod __parse__S { } // State 3 - // E = T (*) [EOF] - // E = T (*) ["-"] - // - // EOF -> Reduce(E = T => Call(ActionFn(3));) - // "-" -> Reduce(E = T => Call(ActionFn(3));) - // - pub fn __state3< - __TOKENS: Iterator, - >( - __lookbehind: Option<()>, - __lookahead: Option<((), Tok, ())>, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - ) -> Result<(Option<()>, Option<((), Tok, ())>, __Nonterminal<>), Option<((), Tok, ())>> - { - let mut __result: (Option<()>, Option<((), Tok, ())>, __Nonterminal<>); - match __lookahead { - None => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action3(__sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::E(__nt))); - } - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action3(__sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::E(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 4 // __S = S (*) [EOF] // // EOF -> Reduce(__S = S => Call(ActionFn(0));) // - pub fn __state4< + pub fn __state3< __TOKENS: Iterator, >( __lookbehind: Option<()>, @@ -238,7 +206,7 @@ mod __parse__S { } } - // State 5 + // State 4 // E = (*) E "-" T [")"] // E = (*) E "-" T ["-"] // E = (*) T [")"] @@ -251,11 +219,11 @@ mod __parse__S { // T = (*) "Num" ["-"] // // "(" -> Shift(S10) - // "Num" -> Shift(S7) + // "Num" -> Shift(S8) // - // E -> S8 - // T -> S9 - pub fn __state5< + // T -> S7 + // E -> S9 + pub fn __state4< __TOKENS: Iterator, >( __lookbehind: Option<()>, @@ -276,7 +244,7 @@ mod __parse__S { let mut __lookbehind = Some(__loc); let mut __sym1 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state7(__lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state8(__lookbehind, __lookahead, __tokens, __sym1)); } _ => { return Err(__lookahead); @@ -285,13 +253,13 @@ mod __parse__S { while __sym0.is_some() { let (__lookbehind, __lookahead, __nt) = __result; match __nt { - __Nonterminal::E(__nt) => { - let __sym1 = &mut Some(__nt); - __result = try!(__state8(__lookbehind, __lookahead, __tokens, __sym0, __sym1)); - } __Nonterminal::T(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state9(__lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state7(__lookbehind, __lookahead, __tokens, __sym1)); + } + __Nonterminal::E(__nt) => { + let __sym1 = &mut Some(__nt); + __result = try!(__state9(__lookbehind, __lookahead, __tokens, __sym0, __sym1)); } _ => { return Ok((__lookbehind, __lookahead, __nt)); @@ -301,6 +269,40 @@ mod __parse__S { return Ok(__result); } + // State 5 + // T = "Num" (*) [EOF] + // T = "Num" (*) ["-"] + // + // EOF -> Reduce(T = "Num" => Call(ActionFn(4));) + // "-" -> Reduce(T = "Num" => Call(ActionFn(4));) + // + pub fn __state5< + __TOKENS: Iterator, + >( + __lookbehind: Option<()>, + __lookahead: Option<((), Tok, ())>, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + ) -> Result<(Option<()>, Option<((), Tok, ())>, __Nonterminal<>), Option<((), Tok, ())>> + { + let mut __result: (Option<()>, Option<((), Tok, ())>, __Nonterminal<>); + match __lookahead { + None => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action4(__sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::T(__nt))); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action4(__sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::T(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + // State 6 // E = E "-" (*) T [EOF] // E = E "-" (*) T ["-"] @@ -309,8 +311,8 @@ mod __parse__S { // T = (*) "Num" [EOF] // T = (*) "Num" ["-"] // - // "Num" -> Shift(S2) - // "(" -> Shift(S5) + // "(" -> Shift(S4) + // "Num" -> Shift(S5) // // T -> S11 pub fn __state6< @@ -325,16 +327,16 @@ mod __parse__S { { let mut __result: (Option<()>, Option<((), Tok, ())>, __Nonterminal<>); match __lookahead { - Some((_, Tok::Num(__tok0), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state2(__lookbehind, __lookahead, __tokens, __sym2)); - } Some((_, __tok @ Tok::LParen(..), __loc)) => { let mut __lookbehind = Some(__loc); let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); + __result = try!(__state4(__lookbehind, __lookahead, __tokens, __sym2)); + } + Some((_, Tok::Num(__tok0), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok0)); + let __lookahead = __tokens.next(); __result = try!(__state5(__lookbehind, __lookahead, __tokens, __sym2)); } _ => { @@ -357,13 +359,47 @@ mod __parse__S { } // State 7 + // E = T (*) [")"] + // E = T (*) ["-"] + // + // "-" -> Reduce(E = T => Call(ActionFn(3));) + // ")" -> Reduce(E = T => Call(ActionFn(3));) + // + pub fn __state7< + __TOKENS: Iterator, + >( + __lookbehind: Option<()>, + __lookahead: Option<((), Tok, ())>, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + ) -> Result<(Option<()>, Option<((), Tok, ())>, __Nonterminal<>), Option<((), Tok, ())>> + { + let mut __result: (Option<()>, Option<((), Tok, ())>, __Nonterminal<>); + match __lookahead { + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action3(__sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::E(__nt))); + } + Some((_, Tok::RParen(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action3(__sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::E(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 8 // T = "Num" (*) [")"] // T = "Num" (*) ["-"] // // "-" -> Reduce(T = "Num" => Call(ActionFn(4));) // ")" -> Reduce(T = "Num" => Call(ActionFn(4));) // - pub fn __state7< + pub fn __state8< __TOKENS: Iterator, >( __lookbehind: Option<()>, @@ -390,7 +426,7 @@ mod __parse__S { } } - // State 8 + // State 9 // E = E (*) "-" T [")"] // E = E (*) "-" T ["-"] // T = "(" E (*) ")" [EOF] @@ -399,7 +435,7 @@ mod __parse__S { // ")" -> Shift(S13) // "-" -> Shift(S12) // - pub fn __state8< + pub fn __state9< __TOKENS: Iterator, >( __lookbehind: Option<()>, @@ -430,40 +466,6 @@ mod __parse__S { return Ok(__result); } - // State 9 - // E = T (*) [")"] - // E = T (*) ["-"] - // - // ")" -> Reduce(E = T => Call(ActionFn(3));) - // "-" -> Reduce(E = T => Call(ActionFn(3));) - // - pub fn __state9< - __TOKENS: Iterator, - >( - __lookbehind: Option<()>, - __lookahead: Option<((), Tok, ())>, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - ) -> Result<(Option<()>, Option<((), Tok, ())>, __Nonterminal<>), Option<((), Tok, ())>> - { - let mut __result: (Option<()>, Option<((), Tok, ())>, __Nonterminal<>); - match __lookahead { - Some((_, Tok::RParen(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action3(__sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::E(__nt))); - } - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action3(__sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::E(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - // State 10 // E = (*) E "-" T [")"] // E = (*) E "-" T ["-"] @@ -476,10 +478,10 @@ mod __parse__S { // T = (*) "Num" [")"] // T = (*) "Num" ["-"] // - // "Num" -> Shift(S7) // "(" -> Shift(S10) + // "Num" -> Shift(S8) // - // T -> S9 + // T -> S7 // E -> S14 pub fn __state10< __TOKENS: Iterator, @@ -492,18 +494,18 @@ mod __parse__S { { let mut __result: (Option<()>, Option<((), Tok, ())>, __Nonterminal<>); match __lookahead { - Some((_, Tok::Num(__tok0), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym1 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state7(__lookbehind, __lookahead, __tokens, __sym1)); - } Some((_, __tok @ Tok::LParen(..), __loc)) => { let mut __lookbehind = Some(__loc); let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); __result = try!(__state10(__lookbehind, __lookahead, __tokens, __sym1)); } + Some((_, Tok::Num(__tok0), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym1 = &mut Some((__tok0)); + let __lookahead = __tokens.next(); + __result = try!(__state8(__lookbehind, __lookahead, __tokens, __sym1)); + } _ => { return Err(__lookahead); } @@ -513,7 +515,7 @@ mod __parse__S { match __nt { __Nonterminal::T(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state9(__lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state7(__lookbehind, __lookahead, __tokens, __sym1)); } __Nonterminal::E(__nt) => { let __sym1 = &mut Some(__nt); @@ -531,8 +533,8 @@ mod __parse__S { // E = E "-" T (*) [EOF] // E = E "-" T (*) ["-"] // - // EOF -> Reduce(E = E, "-", T => Call(ActionFn(2));) // "-" -> Reduce(E = E, "-", T => Call(ActionFn(2));) + // EOF -> Reduce(E = E, "-", T => Call(ActionFn(2));) // pub fn __state11< __TOKENS: Iterator, @@ -547,14 +549,14 @@ mod __parse__S { { let mut __result: (Option<()>, Option<((), Tok, ())>, __Nonterminal<>); match __lookahead { - None => { + Some((_, Tok::Minus(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); let __nt = super::__action2(__sym0, __sym1, __sym2); return Ok((__lookbehind, __lookahead, __Nonterminal::E(__nt))); } - Some((_, Tok::Minus(..), _)) => { + None => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); @@ -575,8 +577,8 @@ mod __parse__S { // T = (*) "Num" [")"] // T = (*) "Num" ["-"] // - // "Num" -> Shift(S7) // "(" -> Shift(S10) + // "Num" -> Shift(S8) // // T -> S15 pub fn __state12< @@ -591,18 +593,18 @@ mod __parse__S { { let mut __result: (Option<()>, Option<((), Tok, ())>, __Nonterminal<>); match __lookahead { - Some((_, Tok::Num(__tok0), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state7(__lookbehind, __lookahead, __tokens, __sym2)); - } Some((_, __tok @ Tok::LParen(..), __loc)) => { let mut __lookbehind = Some(__loc); let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); __result = try!(__state10(__lookbehind, __lookahead, __tokens, __sym2)); } + Some((_, Tok::Num(__tok0), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok0)); + let __lookahead = __tokens.next(); + __result = try!(__state8(__lookbehind, __lookahead, __tokens, __sym2)); + } _ => { return Err(__lookahead); } @@ -626,8 +628,8 @@ mod __parse__S { // T = "(" E ")" (*) [EOF] // T = "(" E ")" (*) ["-"] // - // "-" -> Reduce(T = "(", E, ")" => Call(ActionFn(5));) // EOF -> Reduce(T = "(", E, ")" => Call(ActionFn(5));) + // "-" -> Reduce(T = "(", E, ")" => Call(ActionFn(5));) // pub fn __state13< __TOKENS: Iterator, @@ -642,14 +644,14 @@ mod __parse__S { { let mut __result: (Option<()>, Option<((), Tok, ())>, __Nonterminal<>); match __lookahead { - Some((_, Tok::Minus(..), _)) => { + None => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); let __nt = super::__action5(__sym0, __sym1, __sym2); return Ok((__lookbehind, __lookahead, __Nonterminal::T(__nt))); } - None => { + Some((_, Tok::Minus(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); diff --git a/lalrpop-test/src/use_super.lalrpop b/lalrpop-test/src/use_super.lalrpop new file mode 100644 index 0000000..3d93a8a --- /dev/null +++ b/lalrpop-test/src/use_super.lalrpop @@ -0,0 +1,14 @@ +grammar; + +use super::util::tok::Tok; + +extern token { + enum Tok { + "(" => Tok::LParen(..), + ")" => Tok::RParen(..), + } +} + +pub S: i32 = { + "(" ")" => super::ZERO; +}; diff --git a/lalrpop-test/src/use_super.rs b/lalrpop-test/src/use_super.rs new file mode 100644 index 0000000..22737b7 --- /dev/null +++ b/lalrpop-test/src/use_super.rs @@ -0,0 +1,185 @@ +#![allow(unused_imports)] +use super::util::tok::Tok; + +#[allow(non_snake_case)] +pub fn parse_S< + __TOKENS: IntoIterator, +>( + __tokens: __TOKENS, +) -> Result> +{ + let mut __tokens = __tokens.into_iter(); + let mut __tokens = __tokens.map(|t| ((), t, ())); + let __lookahead = __tokens.next(); + match __parse__S::__state0(None, __lookahead, &mut __tokens) { + Err(None) => { + Err(None) + } + Err(Some(__lookahead)) => { + Err(Some(__lookahead.1)) + } + Ok((_, Some(__lookahead), _)) => { + Err(Some(__lookahead.1)) + } + Ok((_, None, __parse__S::__Nonterminal::____S(__nt))) => { + Ok(__nt) + } + Ok(_) => unreachable!(), + } +} + +mod __parse__S { + #![allow(non_snake_case, non_camel_case_types, unused_mut, unused_variables, unused_imports)] + + use super::super::util::tok::Tok; + extern crate lalrpop_util as __lalrpop_util; + use self::__lalrpop_util::ParseError as __ParseError; + + pub enum __Nonterminal<> { + S(i32), + ____S(i32), + } + + // State 0 + // S = (*) "(" ")" [EOF] + // __S = (*) S [EOF] + // + // "(" -> Shift(S2) + // + // S -> S1 + pub fn __state0< + __TOKENS: Iterator, + >( + __lookbehind: Option<()>, + __lookahead: Option<((), Tok, ())>, + __tokens: &mut __TOKENS, + ) -> Result<(Option<()>, Option<((), Tok, ())>, __Nonterminal<>), Option<((), Tok, ())>> + { + let mut __result: (Option<()>, Option<((), Tok, ())>, __Nonterminal<>); + match __lookahead { + Some((_, __tok @ Tok::LParen(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym0 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state2(__lookbehind, __lookahead, __tokens, __sym0)); + } + _ => { + return Err(__lookahead); + } + } + loop { + let (__lookbehind, __lookahead, __nt) = __result; + match __nt { + __Nonterminal::S(__nt) => { + let __sym0 = &mut Some(__nt); + __result = try!(__state1(__lookbehind, __lookahead, __tokens, __sym0)); + } + _ => { + return Ok((__lookbehind, __lookahead, __nt)); + } + } + } + } + + // State 1 + // __S = S (*) [EOF] + // + // EOF -> Reduce(__S = S => Call(ActionFn(0));) + // + pub fn __state1< + __TOKENS: Iterator, + >( + __lookbehind: Option<()>, + __lookahead: Option<((), Tok, ())>, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + ) -> Result<(Option<()>, Option<((), Tok, ())>, __Nonterminal<>), Option<((), Tok, ())>> + { + let mut __result: (Option<()>, Option<((), Tok, ())>, __Nonterminal<>); + match __lookahead { + None => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action0(__sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::____S(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 2 + // S = "(" (*) ")" [EOF] + // + // ")" -> Shift(S3) + // + pub fn __state2< + __TOKENS: Iterator, + >( + __lookbehind: Option<()>, + __lookahead: Option<((), Tok, ())>, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + ) -> Result<(Option<()>, Option<((), Tok, ())>, __Nonterminal<>), Option<((), Tok, ())>> + { + let mut __result: (Option<()>, Option<((), Tok, ())>, __Nonterminal<>); + match __lookahead { + Some((_, __tok @ Tok::RParen(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state3(__lookbehind, __lookahead, __tokens, __sym0, __sym1)); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + + // State 3 + // S = "(" ")" (*) [EOF] + // + // EOF -> Reduce(S = "(", ")" => Call(ActionFn(1));) + // + pub fn __state3< + __TOKENS: Iterator, + >( + __lookbehind: Option<()>, + __lookahead: Option<((), Tok, ())>, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + __sym1: &mut Option, + ) -> Result<(Option<()>, Option<((), Tok, ())>, __Nonterminal<>), Option<((), Tok, ())>> + { + let mut __result: (Option<()>, Option<((), Tok, ())>, __Nonterminal<>); + match __lookahead { + None => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __nt = super::__action1(__sym0, __sym1); + return Ok((__lookbehind, __lookahead, __Nonterminal::S(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } +} + +pub fn __action0< +>( + __0: i32, +) -> i32 +{ + (__0) +} + +pub fn __action1< +>( + __0: Tok, + __1: Tok, +) -> i32 +{ + super::ZERO +} diff --git a/lalrpop/src/lr1/ascent.rs b/lalrpop/src/lr1/ascent.rs index 33d2b71..3b1673d 100644 --- a/lalrpop/src/lr1/ascent.rs +++ b/lalrpop/src/lr1/ascent.rs @@ -84,9 +84,21 @@ impl<'ascent,'grammar,W:Write> RecursiveAscent<'ascent,'grammar,W> { } fn write_uses(&mut self) -> io::Result<()> { + // things the user wrote for u in &self.grammar.uses { - rust!(self.out, "use {};", u); + if u.starts_with("super::") { + rust!(self.out, "use super::{};", u); + } else { + rust!(self.out, "use {};", u); + } } + + // stuff that we plan to use + rust!(self.out, "extern crate lalrpop_util as {}lalrpop_util;", + self.prefix); + rust!(self.out, "use self::{}lalrpop_util::ParseError as {}ParseError;", + self.prefix, self.prefix); + Ok(()) }