From c92619fe1565ff11d5ceb272ca53a44f48a17441 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Wed, 15 Jul 2015 19:38:15 -0400 Subject: [PATCH] implement associated types for extern tokens and track an (optional) location type --- lalrpop-test/src/expr.rs | 1764 +++++------ lalrpop-test/src/expr_arena.lalrpop | 6 +- lalrpop-test/src/expr_arena.rs | 3704 ++++++++++++------------ lalrpop-test/src/sub.rs | 408 +-- lalrpop/src/grammar/parse_tree.rs | 19 + lalrpop/src/grammar/repr.rs | 8 +- lalrpop/src/normalize/tyinfer/mod.rs | 29 +- lalrpop/src/normalize/validate/mod.rs | 22 +- lalrpop/src/normalize/validate/test.rs | 7 + lalrpop/src/parser/mod.rs | 13 +- lalrpop/src/parser/test.rs | 9 + 11 files changed, 3031 insertions(+), 2958 deletions(-) diff --git a/lalrpop-test/src/expr.rs b/lalrpop-test/src/expr.rs index d2b338d..b098c91 100644 --- a/lalrpop-test/src/expr.rs +++ b/lalrpop-test/src/expr.rs @@ -23,10 +23,10 @@ mod __parse__Expr { use util::tok::Tok; pub enum __Nonterminal<> { - ____Expr(i32), + Expr(i32), Term(i32), Factor(i32), - Expr(i32), + ____Expr(i32), } // State 0 @@ -67,11 +67,11 @@ mod __parse__Expr { // __Expr = (*) Expr [EOF] // // "Num" -> Shift(S2) - // "(" -> Shift(S4) + // "(" -> Shift(S1) // - // Factor -> S5 - // Term -> S1 - // Expr -> S3 + // Term -> S5 + // Expr -> S4 + // Factor -> S3 pub fn __state0< __TOKENS: Iterator, >( @@ -90,7 +90,7 @@ mod __parse__Expr { Some(__tok @ Tok::LParen(..)) => { let mut __sym0 = &mut Some(__tok); let __lookahead = __tokens.next(); - __result = try!(__state4(scale, __lookahead, __tokens, __sym0)); + __result = try!(__state1(scale, __lookahead, __tokens, __sym0)); } _ => { return Err(__lookahead); @@ -99,15 +99,15 @@ mod __parse__Expr { loop { let (__lookahead, __nt) = __result; match __nt { - __Nonterminal::Factor(__nt) => { + __Nonterminal::Term(__nt) => { let __sym0 = &mut Some(__nt); __result = try!(__state5(scale, __lookahead, __tokens, __sym0)); } - __Nonterminal::Term(__nt) => { - let __sym0 = &mut Some(__nt); - __result = try!(__state1(scale, __lookahead, __tokens, __sym0)); - } __Nonterminal::Expr(__nt) => { + let __sym0 = &mut Some(__nt); + __result = try!(__state4(scale, __lookahead, __tokens, __sym0)); + } + __Nonterminal::Factor(__nt) => { let __sym0 = &mut Some(__nt); __result = try!(__state3(scale, __lookahead, __tokens, __sym0)); } @@ -119,162 +119,6 @@ mod __parse__Expr { } // State 1 - // Factor = Term (*) [EOF] - // Factor = Term (*) ["*"] - // Factor = Term (*) ["+"] - // Factor = Term (*) ["-"] - // Factor = Term (*) ["/"] - // - // "*" -> Reduce(Factor = Term => ActionFn(6);) - // "/" -> Reduce(Factor = Term => ActionFn(6);) - // "-" -> Reduce(Factor = Term => ActionFn(6);) - // EOF -> Reduce(Factor = Term => ActionFn(6);) - // "+" -> Reduce(Factor = Term => ActionFn(6);) - // - pub fn __state1< - __TOKENS: Iterator, - >( - scale: i32, - mut __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - ) -> Result<(Option, __Nonterminal<>), Option> - { - let mut __result: (Option, __Nonterminal<>); - match __lookahead { - Some(Tok::Times(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action6(scale, __sym0); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Div(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action6(scale, __sym0); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Minus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action6(scale, __sym0); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - None => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action6(scale, __sym0); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Plus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action6(scale, __sym0); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 2 - // Term = "Num" (*) [EOF] - // Term = "Num" (*) ["*"] - // Term = "Num" (*) ["+"] - // Term = "Num" (*) ["-"] - // Term = "Num" (*) ["/"] - // - // "/" -> Reduce(Term = "Num" => ActionFn(7);) - // "-" -> Reduce(Term = "Num" => ActionFn(7);) - // "+" -> Reduce(Term = "Num" => ActionFn(7);) - // "*" -> Reduce(Term = "Num" => ActionFn(7);) - // EOF -> Reduce(Term = "Num" => ActionFn(7);) - // - pub fn __state2< - __TOKENS: Iterator, - >( - scale: i32, - mut __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - ) -> Result<(Option, __Nonterminal<>), Option> - { - let mut __result: (Option, __Nonterminal<>); - match __lookahead { - Some(Tok::Div(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(scale, __sym0); - return Ok((__lookahead, __Nonterminal::Term(__nt))); - } - Some(Tok::Minus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(scale, __sym0); - return Ok((__lookahead, __Nonterminal::Term(__nt))); - } - Some(Tok::Plus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(scale, __sym0); - return Ok((__lookahead, __Nonterminal::Term(__nt))); - } - Some(Tok::Times(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(scale, __sym0); - return Ok((__lookahead, __Nonterminal::Term(__nt))); - } - None => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(scale, __sym0); - return Ok((__lookahead, __Nonterminal::Term(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // 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] - // - // "-" -> Shift(S6) - // "+" -> Shift(S7) - // EOF -> Reduce(__Expr = Expr => ActionFn(0);) - // - pub fn __state3< - __TOKENS: Iterator, - >( - scale: i32, - mut __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - ) -> Result<(Option, __Nonterminal<>), Option> - { - let mut __result: (Option, __Nonterminal<>); - match __lookahead { - Some(__tok @ Tok::Minus(..)) => { - let mut __sym1 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state6(scale, __lookahead, __tokens, __sym0, __sym1)); - } - Some(__tok @ Tok::Plus(..)) => { - let mut __sym1 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state7(scale, __lookahead, __tokens, __sym0, __sym1)); - } - None => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action0(scale, __sym0); - return Ok((__lookahead, __Nonterminal::____Expr(__nt))); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 4 // Expr = (*) Expr "+" Factor [")"] // Expr = (*) Expr "+" Factor ["+"] // Expr = (*) Expr "+" Factor ["-"] @@ -316,12 +160,12 @@ mod __parse__Expr { // Term = (*) "Num" ["/"] // // "Num" -> Shift(S9) - // "(" -> Shift(S11) + // "(" -> Shift(S7) // - // Term -> S10 - // Expr -> S12 - // Factor -> S8 - pub fn __state4< + // Expr -> S10 + // Term -> S8 + // Factor -> S6 + pub fn __state1< __TOKENS: Iterator, >( scale: i32, @@ -340,7 +184,7 @@ mod __parse__Expr { Some(__tok @ Tok::LParen(..)) => { let mut __sym1 = &mut Some(__tok); let __lookahead = __tokens.next(); - __result = try!(__state11(scale, __lookahead, __tokens, __sym1)); + __result = try!(__state7(scale, __lookahead, __tokens, __sym1)); } _ => { return Err(__lookahead); @@ -349,17 +193,17 @@ mod __parse__Expr { while __sym0.is_some() { let (__lookahead, __nt) = __result; match __nt { - __Nonterminal::Term(__nt) => { - let __sym1 = &mut Some(__nt); - __result = try!(__state10(scale, __lookahead, __tokens, __sym1)); - } __Nonterminal::Expr(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state12(scale, __lookahead, __tokens, __sym0, __sym1)); + __result = try!(__state10(scale, __lookahead, __tokens, __sym0, __sym1)); + } + __Nonterminal::Term(__nt) => { + let __sym1 = &mut Some(__nt); + __result = try!(__state8(scale, __lookahead, __tokens, __sym1)); } __Nonterminal::Factor(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state8(scale, __lookahead, __tokens, __sym1)); + __result = try!(__state6(scale, __lookahead, __tokens, __sym1)); } _ => { return Ok((__lookahead, __nt)); @@ -369,7 +213,62 @@ mod __parse__Expr { return Ok(__result); } - // State 5 + // State 2 + // Term = "Num" (*) [EOF] + // Term = "Num" (*) ["*"] + // Term = "Num" (*) ["+"] + // Term = "Num" (*) ["-"] + // Term = "Num" (*) ["/"] + // + // "+" -> Reduce(Term = "Num" => ActionFn(7);) + // EOF -> Reduce(Term = "Num" => ActionFn(7);) + // "-" -> Reduce(Term = "Num" => ActionFn(7);) + // "/" -> Reduce(Term = "Num" => ActionFn(7);) + // "*" -> Reduce(Term = "Num" => ActionFn(7);) + // + pub fn __state2< + __TOKENS: Iterator, + >( + scale: i32, + mut __lookahead: Option, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + ) -> Result<(Option, __Nonterminal<>), Option> + { + let mut __result: (Option, __Nonterminal<>); + match __lookahead { + Some(Tok::Plus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action7(scale, __sym0); + return Ok((__lookahead, __Nonterminal::Term(__nt))); + } + None => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action7(scale, __sym0); + return Ok((__lookahead, __Nonterminal::Term(__nt))); + } + Some(Tok::Minus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action7(scale, __sym0); + return Ok((__lookahead, __Nonterminal::Term(__nt))); + } + Some(Tok::Div(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action7(scale, __sym0); + return Ok((__lookahead, __Nonterminal::Term(__nt))); + } + Some(Tok::Times(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action7(scale, __sym0); + return Ok((__lookahead, __Nonterminal::Term(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 3 // Expr = Factor (*) [EOF] // Expr = Factor (*) ["+"] // Expr = Factor (*) ["-"] @@ -384,11 +283,113 @@ mod __parse__Expr { // Factor = Factor (*) "/" Term ["-"] // Factor = Factor (*) "/" Term ["/"] // - // "*" -> Shift(S14) - // "-" -> Reduce(Expr = Factor => ActionFn(3);) + // "/" -> Shift(S12) // "+" -> Reduce(Expr = Factor => ActionFn(3);) - // "/" -> Shift(S13) // EOF -> Reduce(Expr = Factor => ActionFn(3);) + // "-" -> Reduce(Expr = Factor => ActionFn(3);) + // "*" -> Shift(S11) + // + pub fn __state3< + __TOKENS: Iterator, + >( + scale: i32, + mut __lookahead: Option, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + ) -> Result<(Option, __Nonterminal<>), Option> + { + let mut __result: (Option, __Nonterminal<>); + match __lookahead { + Some(__tok @ Tok::Div(..)) => { + let mut __sym1 = &mut Some(__tok); + let __lookahead = __tokens.next(); + __result = try!(__state12(scale, __lookahead, __tokens, __sym0, __sym1)); + } + Some(__tok @ Tok::Times(..)) => { + let mut __sym1 = &mut Some(__tok); + let __lookahead = __tokens.next(); + __result = try!(__state11(scale, __lookahead, __tokens, __sym0, __sym1)); + } + Some(Tok::Plus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action3(scale, __sym0); + return Ok((__lookahead, __Nonterminal::Expr(__nt))); + } + None => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action3(scale, __sym0); + return Ok((__lookahead, __Nonterminal::Expr(__nt))); + } + Some(Tok::Minus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action3(scale, __sym0); + return Ok((__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(S14) + // "+" -> Shift(S13) + // EOF -> Reduce(__Expr = Expr => ActionFn(0);) + // + pub fn __state4< + __TOKENS: Iterator, + >( + scale: i32, + mut __lookahead: Option, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + ) -> Result<(Option, __Nonterminal<>), Option> + { + let mut __result: (Option, __Nonterminal<>); + match __lookahead { + Some(__tok @ Tok::Minus(..)) => { + let mut __sym1 = &mut Some(__tok); + let __lookahead = __tokens.next(); + __result = try!(__state14(scale, __lookahead, __tokens, __sym0, __sym1)); + } + Some(__tok @ Tok::Plus(..)) => { + let mut __sym1 = &mut Some(__tok); + let __lookahead = __tokens.next(); + __result = try!(__state13(scale, __lookahead, __tokens, __sym0, __sym1)); + } + None => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action0(scale, __sym0); + return Ok((__lookahead, __Nonterminal::____Expr(__nt))); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + + // State 5 + // Factor = Term (*) [EOF] + // Factor = Term (*) ["*"] + // Factor = Term (*) ["+"] + // Factor = Term (*) ["-"] + // Factor = Term (*) ["/"] + // + // "+" -> Reduce(Factor = Term => ActionFn(6);) + // "*" -> Reduce(Factor = Term => ActionFn(6);) + // "-" -> Reduce(Factor = Term => ActionFn(6);) + // "/" -> Reduce(Factor = Term => ActionFn(6);) + // EOF -> Reduce(Factor = Term => ActionFn(6);) // pub fn __state5< __TOKENS: Iterator, @@ -401,199 +402,38 @@ mod __parse__Expr { { let mut __result: (Option, __Nonterminal<>); match __lookahead { - Some(__tok @ Tok::Times(..)) => { - let mut __sym1 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state14(scale, __lookahead, __tokens, __sym0, __sym1)); + Some(Tok::Plus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action6(scale, __sym0); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); } - Some(__tok @ Tok::Div(..)) => { - let mut __sym1 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state13(scale, __lookahead, __tokens, __sym0, __sym1)); + Some(Tok::Times(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action6(scale, __sym0); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); } Some(Tok::Minus(..)) => { let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action3(scale, __sym0); - return Ok((__lookahead, __Nonterminal::Expr(__nt))); + let __nt = super::__actions::__action6(scale, __sym0); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); } - Some(Tok::Plus(..)) => { + Some(Tok::Div(..)) => { let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action3(scale, __sym0); - return Ok((__lookahead, __Nonterminal::Expr(__nt))); + let __nt = super::__actions::__action6(scale, __sym0); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); } None => { let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action3(scale, __sym0); - return Ok((__lookahead, __Nonterminal::Expr(__nt))); + let __nt = super::__actions::__action6(scale, __sym0); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); } _ => { return Err(__lookahead); } } - return Ok(__result); } // State 6 - // 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(S2) - // "(" -> Shift(S4) - // - // Factor -> S15 - // Term -> S1 - pub fn __state6< - __TOKENS: Iterator, - >( - scale: i32, - mut __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option, - ) -> Result<(Option, __Nonterminal<>), Option> - { - let mut __result: (Option, __Nonterminal<>); - match __lookahead { - Some(Tok::Num(__tok0)) => { - let mut __sym2 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state2(scale, __lookahead, __tokens, __sym2)); - } - Some(__tok @ Tok::LParen(..)) => { - let mut __sym2 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state4(scale, __lookahead, __tokens, __sym2)); - } - _ => { - return Err(__lookahead); - } - } - while __sym1.is_some() { - let (__lookahead, __nt) = __result; - match __nt { - __Nonterminal::Factor(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state15(scale, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - __Nonterminal::Term(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state1(scale, __lookahead, __tokens, __sym2)); - } - _ => { - return Ok((__lookahead, __nt)); - } - } - } - return Ok(__result); - } - - // State 7 - // 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(S2) - // "(" -> Shift(S4) - // - // Term -> S1 - // Factor -> S16 - pub fn __state7< - __TOKENS: Iterator, - >( - scale: i32, - mut __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option, - ) -> Result<(Option, __Nonterminal<>), Option> - { - let mut __result: (Option, __Nonterminal<>); - match __lookahead { - Some(Tok::Num(__tok0)) => { - let mut __sym2 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state2(scale, __lookahead, __tokens, __sym2)); - } - Some(__tok @ Tok::LParen(..)) => { - let mut __sym2 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state4(scale, __lookahead, __tokens, __sym2)); - } - _ => { - return Err(__lookahead); - } - } - while __sym1.is_some() { - let (__lookahead, __nt) = __result; - match __nt { - __Nonterminal::Term(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state1(scale, __lookahead, __tokens, __sym2)); - } - __Nonterminal::Factor(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state16(scale, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - _ => { - return Ok((__lookahead, __nt)); - } - } - } - return Ok(__result); - } - - // State 8 // Expr = Factor (*) [")"] // Expr = Factor (*) ["+"] // Expr = Factor (*) ["-"] @@ -608,13 +448,13 @@ mod __parse__Expr { // Factor = Factor (*) "/" Term ["-"] // Factor = Factor (*) "/" Term ["/"] // - // "/" -> Shift(S17) - // "*" -> Shift(S18) + // "*" -> Shift(S16) // "-" -> Reduce(Expr = Factor => ActionFn(3);) - // "+" -> Reduce(Expr = Factor => ActionFn(3);) + // "/" -> Shift(S15) // ")" -> Reduce(Expr = Factor => ActionFn(3);) + // "+" -> Reduce(Expr = Factor => ActionFn(3);) // - pub fn __state8< + pub fn __state6< __TOKENS: Iterator, >( scale: i32, @@ -625,27 +465,27 @@ mod __parse__Expr { { let mut __result: (Option, __Nonterminal<>); match __lookahead { - Some(__tok @ Tok::Div(..)) => { - let mut __sym1 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state17(scale, __lookahead, __tokens, __sym0, __sym1)); - } Some(__tok @ Tok::Times(..)) => { let mut __sym1 = &mut Some(__tok); let __lookahead = __tokens.next(); - __result = try!(__state18(scale, __lookahead, __tokens, __sym0, __sym1)); + __result = try!(__state16(scale, __lookahead, __tokens, __sym0, __sym1)); + } + Some(__tok @ Tok::Div(..)) => { + let mut __sym1 = &mut Some(__tok); + let __lookahead = __tokens.next(); + __result = try!(__state15(scale, __lookahead, __tokens, __sym0, __sym1)); } Some(Tok::Minus(..)) => { let __sym0 = __sym0.take().unwrap(); let __nt = super::__actions::__action3(scale, __sym0); return Ok((__lookahead, __Nonterminal::Expr(__nt))); } - Some(Tok::Plus(..)) => { + Some(Tok::RParen(..)) => { let __sym0 = __sym0.take().unwrap(); let __nt = super::__actions::__action3(scale, __sym0); return Ok((__lookahead, __Nonterminal::Expr(__nt))); } - Some(Tok::RParen(..)) => { + Some(Tok::Plus(..)) => { let __sym0 = __sym0.take().unwrap(); let __nt = super::__actions::__action3(scale, __sym0); return Ok((__lookahead, __Nonterminal::Expr(__nt))); @@ -657,117 +497,7 @@ mod __parse__Expr { return Ok(__result); } - // State 9 - // Term = "Num" (*) [")"] - // Term = "Num" (*) ["*"] - // Term = "Num" (*) ["+"] - // Term = "Num" (*) ["-"] - // Term = "Num" (*) ["/"] - // - // "+" -> Reduce(Term = "Num" => ActionFn(7);) - // "-" -> Reduce(Term = "Num" => ActionFn(7);) - // ")" -> Reduce(Term = "Num" => ActionFn(7);) - // "/" -> Reduce(Term = "Num" => ActionFn(7);) - // "*" -> Reduce(Term = "Num" => ActionFn(7);) - // - pub fn __state9< - __TOKENS: Iterator, - >( - scale: i32, - mut __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - ) -> Result<(Option, __Nonterminal<>), Option> - { - let mut __result: (Option, __Nonterminal<>); - match __lookahead { - Some(Tok::Plus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(scale, __sym0); - return Ok((__lookahead, __Nonterminal::Term(__nt))); - } - Some(Tok::Minus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(scale, __sym0); - return Ok((__lookahead, __Nonterminal::Term(__nt))); - } - Some(Tok::RParen(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(scale, __sym0); - return Ok((__lookahead, __Nonterminal::Term(__nt))); - } - Some(Tok::Div(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(scale, __sym0); - return Ok((__lookahead, __Nonterminal::Term(__nt))); - } - Some(Tok::Times(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(scale, __sym0); - return Ok((__lookahead, __Nonterminal::Term(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 10 - // Factor = Term (*) [")"] - // Factor = Term (*) ["*"] - // Factor = Term (*) ["+"] - // Factor = Term (*) ["-"] - // Factor = Term (*) ["/"] - // - // "+" -> Reduce(Factor = Term => ActionFn(6);) - // "/" -> Reduce(Factor = Term => ActionFn(6);) - // "-" -> Reduce(Factor = Term => ActionFn(6);) - // "*" -> Reduce(Factor = Term => ActionFn(6);) - // ")" -> Reduce(Factor = Term => ActionFn(6);) - // - pub fn __state10< - __TOKENS: Iterator, - >( - scale: i32, - mut __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - ) -> Result<(Option, __Nonterminal<>), Option> - { - let mut __result: (Option, __Nonterminal<>); - match __lookahead { - Some(Tok::Plus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action6(scale, __sym0); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Div(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action6(scale, __sym0); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Minus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action6(scale, __sym0); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Times(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action6(scale, __sym0); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::RParen(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action6(scale, __sym0); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 11 + // State 7 // Expr = (*) Expr "+" Factor [")"] // Expr = (*) Expr "+" Factor ["+"] // Expr = (*) Expr "+" Factor ["-"] @@ -808,13 +538,13 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "(" -> Shift(S11) + // "(" -> Shift(S7) // "Num" -> Shift(S9) // - // Factor -> S8 - // Term -> S10 - // Expr -> S19 - pub fn __state11< + // Factor -> S6 + // Expr -> S17 + // Term -> S8 + pub fn __state7< __TOKENS: Iterator, >( scale: i32, @@ -828,7 +558,7 @@ mod __parse__Expr { Some(__tok @ Tok::LParen(..)) => { let mut __sym1 = &mut Some(__tok); let __lookahead = __tokens.next(); - __result = try!(__state11(scale, __lookahead, __tokens, __sym1)); + __result = try!(__state7(scale, __lookahead, __tokens, __sym1)); } Some(Tok::Num(__tok0)) => { let mut __sym1 = &mut Some((__tok0)); @@ -844,15 +574,15 @@ mod __parse__Expr { match __nt { __Nonterminal::Factor(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state8(scale, __lookahead, __tokens, __sym1)); - } - __Nonterminal::Term(__nt) => { - let __sym1 = &mut Some(__nt); - __result = try!(__state10(scale, __lookahead, __tokens, __sym1)); + __result = try!(__state6(scale, __lookahead, __tokens, __sym1)); } __Nonterminal::Expr(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state19(scale, __lookahead, __tokens, __sym0, __sym1)); + __result = try!(__state17(scale, __lookahead, __tokens, __sym0, __sym1)); + } + __Nonterminal::Term(__nt) => { + let __sym1 = &mut Some(__nt); + __result = try!(__state8(scale, __lookahead, __tokens, __sym1)); } _ => { return Ok((__lookahead, __nt)); @@ -862,7 +592,117 @@ mod __parse__Expr { return Ok(__result); } - // State 12 + // State 8 + // Factor = Term (*) [")"] + // Factor = Term (*) ["*"] + // Factor = Term (*) ["+"] + // Factor = Term (*) ["-"] + // Factor = Term (*) ["/"] + // + // "+" -> Reduce(Factor = Term => ActionFn(6);) + // "/" -> Reduce(Factor = Term => ActionFn(6);) + // ")" -> Reduce(Factor = Term => ActionFn(6);) + // "*" -> Reduce(Factor = Term => ActionFn(6);) + // "-" -> Reduce(Factor = Term => ActionFn(6);) + // + pub fn __state8< + __TOKENS: Iterator, + >( + scale: i32, + mut __lookahead: Option, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + ) -> Result<(Option, __Nonterminal<>), Option> + { + let mut __result: (Option, __Nonterminal<>); + match __lookahead { + Some(Tok::Plus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action6(scale, __sym0); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + Some(Tok::Div(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action6(scale, __sym0); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + Some(Tok::RParen(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action6(scale, __sym0); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + Some(Tok::Times(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action6(scale, __sym0); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + Some(Tok::Minus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action6(scale, __sym0); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 9 + // Term = "Num" (*) [")"] + // Term = "Num" (*) ["*"] + // Term = "Num" (*) ["+"] + // Term = "Num" (*) ["-"] + // Term = "Num" (*) ["/"] + // + // "*" -> Reduce(Term = "Num" => ActionFn(7);) + // "+" -> Reduce(Term = "Num" => ActionFn(7);) + // ")" -> Reduce(Term = "Num" => ActionFn(7);) + // "-" -> Reduce(Term = "Num" => ActionFn(7);) + // "/" -> Reduce(Term = "Num" => ActionFn(7);) + // + pub fn __state9< + __TOKENS: Iterator, + >( + scale: i32, + mut __lookahead: Option, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + ) -> Result<(Option, __Nonterminal<>), Option> + { + let mut __result: (Option, __Nonterminal<>); + match __lookahead { + Some(Tok::Times(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action7(scale, __sym0); + return Ok((__lookahead, __Nonterminal::Term(__nt))); + } + Some(Tok::Plus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action7(scale, __sym0); + return Ok((__lookahead, __Nonterminal::Term(__nt))); + } + Some(Tok::RParen(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action7(scale, __sym0); + return Ok((__lookahead, __Nonterminal::Term(__nt))); + } + Some(Tok::Minus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action7(scale, __sym0); + return Ok((__lookahead, __Nonterminal::Term(__nt))); + } + Some(Tok::Div(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action7(scale, __sym0); + return Ok((__lookahead, __Nonterminal::Term(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 10 // Expr = Expr (*) "+" Factor [")"] // Expr = Expr (*) "+" Factor ["+"] // Expr = Expr (*) "+" Factor ["-"] @@ -875,11 +715,11 @@ mod __parse__Expr { // Term = "(" Expr (*) ")" ["-"] // Term = "(" Expr (*) ")" ["/"] // - // "-" -> Shift(S22) - // "+" -> Shift(S21) - // ")" -> Shift(S20) + // "-" -> Shift(S20) + // ")" -> Shift(S18) + // "+" -> Shift(S19) // - pub fn __state12< + pub fn __state10< __TOKENS: Iterator, >( scale: i32, @@ -894,88 +734,26 @@ mod __parse__Expr { Some(__tok @ Tok::Minus(..)) => { let mut __sym2 = &mut Some(__tok); let __lookahead = __tokens.next(); - __result = try!(__state22(scale, __lookahead, __tokens, __sym1, __sym2)); - } - Some(__tok @ Tok::Plus(..)) => { - let mut __sym2 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state21(scale, __lookahead, __tokens, __sym1, __sym2)); + __result = try!(__state20(scale, __lookahead, __tokens, __sym1, __sym2)); } Some(__tok @ Tok::RParen(..)) => { let mut __sym2 = &mut Some(__tok); let __lookahead = __tokens.next(); - __result = try!(__state20(scale, __lookahead, __tokens, __sym0, __sym1, __sym2)); + __result = try!(__state18(scale, __lookahead, __tokens, __sym0, __sym1, __sym2)); } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 13 - // 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(S4) - // "Num" -> Shift(S2) - // - // Term -> S23 - pub fn __state13< - __TOKENS: Iterator, - >( - scale: i32, - mut __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option, - ) -> Result<(Option, __Nonterminal<>), Option> - { - let mut __result: (Option, __Nonterminal<>); - match __lookahead { - Some(__tok @ Tok::LParen(..)) => { + Some(__tok @ Tok::Plus(..)) => { let mut __sym2 = &mut Some(__tok); let __lookahead = __tokens.next(); - __result = try!(__state4(scale, __lookahead, __tokens, __sym2)); - } - Some(Tok::Num(__tok0)) => { - let mut __sym2 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state2(scale, __lookahead, __tokens, __sym2)); + __result = try!(__state19(scale, __lookahead, __tokens, __sym1, __sym2)); } _ => { return Err(__lookahead); } } - while __sym1.is_some() { - let (__lookahead, __nt) = __result; - match __nt { - __Nonterminal::Term(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state23(scale, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - _ => { - return Ok((__lookahead, __nt)); - } - } - } return Ok(__result); } - // State 14 + // State 11 // Factor = Factor "*" (*) Term [EOF] // Factor = Factor "*" (*) Term ["*"] // Factor = Factor "*" (*) Term ["+"] @@ -992,10 +770,228 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "(" -> Shift(S4) + // "Num" -> Shift(S2) + // "(" -> Shift(S1) + // + // Term -> S21 + pub fn __state11< + __TOKENS: Iterator, + >( + scale: i32, + mut __lookahead: Option, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + __sym1: &mut Option, + ) -> Result<(Option, __Nonterminal<>), Option> + { + let mut __result: (Option, __Nonterminal<>); + match __lookahead { + Some(Tok::Num(__tok0)) => { + let mut __sym2 = &mut Some((__tok0)); + let __lookahead = __tokens.next(); + __result = try!(__state2(scale, __lookahead, __tokens, __sym2)); + } + Some(__tok @ Tok::LParen(..)) => { + let mut __sym2 = &mut Some(__tok); + let __lookahead = __tokens.next(); + __result = try!(__state1(scale, __lookahead, __tokens, __sym2)); + } + _ => { + return Err(__lookahead); + } + } + while __sym1.is_some() { + let (__lookahead, __nt) = __result; + match __nt { + __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state21(scale, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + _ => { + return Ok((__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" ["/"] + // + // "Num" -> Shift(S2) + // "(" -> Shift(S1) + // + // Term -> S22 + pub fn __state12< + __TOKENS: Iterator, + >( + scale: i32, + mut __lookahead: Option, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + __sym1: &mut Option, + ) -> Result<(Option, __Nonterminal<>), Option> + { + let mut __result: (Option, __Nonterminal<>); + match __lookahead { + Some(Tok::Num(__tok0)) => { + let mut __sym2 = &mut Some((__tok0)); + let __lookahead = __tokens.next(); + __result = try!(__state2(scale, __lookahead, __tokens, __sym2)); + } + Some(__tok @ Tok::LParen(..)) => { + let mut __sym2 = &mut Some(__tok); + let __lookahead = __tokens.next(); + __result = try!(__state1(scale, __lookahead, __tokens, __sym2)); + } + _ => { + return Err(__lookahead); + } + } + while __sym1.is_some() { + let (__lookahead, __nt) = __result; + match __nt { + __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state22(scale, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + _ => { + return Ok((__lookahead, __nt)); + } + } + } + return Ok(__result); + } + + // 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" ["/"] + // + // "(" -> Shift(S1) // "Num" -> Shift(S2) // - // Term -> S24 + // Factor -> S23 + // Term -> S5 + pub fn __state13< + __TOKENS: Iterator, + >( + scale: i32, + mut __lookahead: Option, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + __sym1: &mut Option, + ) -> Result<(Option, __Nonterminal<>), Option> + { + let mut __result: (Option, __Nonterminal<>); + match __lookahead { + Some(__tok @ Tok::LParen(..)) => { + let mut __sym2 = &mut Some(__tok); + let __lookahead = __tokens.next(); + __result = try!(__state1(scale, __lookahead, __tokens, __sym2)); + } + Some(Tok::Num(__tok0)) => { + let mut __sym2 = &mut Some((__tok0)); + let __lookahead = __tokens.next(); + __result = try!(__state2(scale, __lookahead, __tokens, __sym2)); + } + _ => { + return Err(__lookahead); + } + } + while __sym1.is_some() { + let (__lookahead, __nt) = __result; + match __nt { + __Nonterminal::Factor(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state23(scale, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state5(scale, __lookahead, __tokens, __sym2)); + } + _ => { + return Ok((__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" ["/"] + // + // "(" -> Shift(S1) + // "Num" -> Shift(S2) + // + // Term -> S5 + // Factor -> S24 pub fn __state14< __TOKENS: Iterator, >( @@ -1011,7 +1007,7 @@ mod __parse__Expr { Some(__tok @ Tok::LParen(..)) => { let mut __sym2 = &mut Some(__tok); let __lookahead = __tokens.next(); - __result = try!(__state4(scale, __lookahead, __tokens, __sym2)); + __result = try!(__state1(scale, __lookahead, __tokens, __sym2)); } Some(Tok::Num(__tok0)) => { let mut __sym2 = &mut Some((__tok0)); @@ -1026,6 +1022,10 @@ mod __parse__Expr { let (__lookahead, __nt) = __result; match __nt { __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state5(scale, __lookahead, __tokens, __sym2)); + } + __Nonterminal::Factor(__nt) => { let __sym2 = &mut Some(__nt); __result = try!(__state24(scale, __lookahead, __tokens, __sym0, __sym1, __sym2)); } @@ -1038,150 +1038,6 @@ mod __parse__Expr { } // State 15 - // 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(S13) - // EOF -> Reduce(Expr = Expr, "-", Factor => ActionFn(1);) - // "-" -> Reduce(Expr = Expr, "-", Factor => ActionFn(1);) - // "+" -> Reduce(Expr = Expr, "-", Factor => ActionFn(1);) - // "*" -> Shift(S14) - // - pub fn __state15< - __TOKENS: Iterator, - >( - scale: i32, - mut __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option, - __sym2: &mut Option, - ) -> Result<(Option, __Nonterminal<>), Option> - { - let mut __result: (Option, __Nonterminal<>); - match __lookahead { - Some(__tok @ Tok::Div(..)) => { - let mut __sym3 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state13(scale, __lookahead, __tokens, __sym2, __sym3)); - } - Some(__tok @ Tok::Times(..)) => { - let mut __sym3 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state14(scale, __lookahead, __tokens, __sym2, __sym3)); - } - None => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action1(scale, __sym0, __sym1, __sym2); - return Ok((__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::__actions::__action1(scale, __sym0, __sym1, __sym2); - return Ok((__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::__actions::__action1(scale, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Expr(__nt))); - } - _ => { - return Err(__lookahead); - } - } - 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 ["/"] - // - // "*" -> Shift(S14) - // "/" -> Shift(S13) - // "+" -> Reduce(Expr = Expr, "+", Factor => ActionFn(2);) - // EOF -> Reduce(Expr = Expr, "+", Factor => ActionFn(2);) - // "-" -> Reduce(Expr = Expr, "+", Factor => ActionFn(2);) - // - pub fn __state16< - __TOKENS: Iterator, - >( - scale: i32, - mut __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option, - __sym2: &mut Option, - ) -> Result<(Option, __Nonterminal<>), Option> - { - let mut __result: (Option, __Nonterminal<>); - match __lookahead { - Some(__tok @ Tok::Times(..)) => { - let mut __sym3 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state14(scale, __lookahead, __tokens, __sym2, __sym3)); - } - Some(__tok @ Tok::Div(..)) => { - let mut __sym3 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state13(scale, __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::__actions::__action2(scale, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Expr(__nt))); - } - None => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action2(scale, __sym0, __sym1, __sym2); - return Ok((__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::__actions::__action2(scale, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Expr(__nt))); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 17 // Factor = Factor "/" (*) Term [")"] // Factor = Factor "/" (*) Term ["*"] // Factor = Factor "/" (*) Term ["+"] @@ -1198,11 +1054,11 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // + // "(" -> Shift(S7) // "Num" -> Shift(S9) - // "(" -> Shift(S11) // // Term -> S25 - pub fn __state17< + pub fn __state15< __TOKENS: Iterator, >( scale: i32, @@ -1214,16 +1070,16 @@ mod __parse__Expr { { let mut __result: (Option, __Nonterminal<>); match __lookahead { + Some(__tok @ Tok::LParen(..)) => { + let mut __sym2 = &mut Some(__tok); + let __lookahead = __tokens.next(); + __result = try!(__state7(scale, __lookahead, __tokens, __sym2)); + } Some(Tok::Num(__tok0)) => { let mut __sym2 = &mut Some((__tok0)); let __lookahead = __tokens.next(); __result = try!(__state9(scale, __lookahead, __tokens, __sym2)); } - Some(__tok @ Tok::LParen(..)) => { - let mut __sym2 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state11(scale, __lookahead, __tokens, __sym2)); - } _ => { return Err(__lookahead); } @@ -1243,7 +1099,7 @@ mod __parse__Expr { return Ok(__result); } - // State 18 + // State 16 // Factor = Factor "*" (*) Term [")"] // Factor = Factor "*" (*) Term ["*"] // Factor = Factor "*" (*) Term ["+"] @@ -1260,11 +1116,11 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // + // "(" -> Shift(S7) // "Num" -> Shift(S9) - // "(" -> Shift(S11) // // Term -> S26 - pub fn __state18< + pub fn __state16< __TOKENS: Iterator, >( scale: i32, @@ -1276,16 +1132,16 @@ mod __parse__Expr { { let mut __result: (Option, __Nonterminal<>); match __lookahead { + Some(__tok @ Tok::LParen(..)) => { + let mut __sym2 = &mut Some(__tok); + let __lookahead = __tokens.next(); + __result = try!(__state7(scale, __lookahead, __tokens, __sym2)); + } Some(Tok::Num(__tok0)) => { let mut __sym2 = &mut Some((__tok0)); let __lookahead = __tokens.next(); __result = try!(__state9(scale, __lookahead, __tokens, __sym2)); } - Some(__tok @ Tok::LParen(..)) => { - let mut __sym2 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state11(scale, __lookahead, __tokens, __sym2)); - } _ => { return Err(__lookahead); } @@ -1305,7 +1161,7 @@ mod __parse__Expr { return Ok(__result); } - // State 19 + // State 17 // Expr = Expr (*) "+" Factor [")"] // Expr = Expr (*) "+" Factor ["+"] // Expr = Expr (*) "+" Factor ["-"] @@ -1318,11 +1174,11 @@ mod __parse__Expr { // Term = "(" Expr (*) ")" ["-"] // Term = "(" Expr (*) ")" ["/"] // - // "-" -> Shift(S22) + // "-" -> Shift(S20) // ")" -> Shift(S27) - // "+" -> Shift(S21) + // "+" -> Shift(S19) // - pub fn __state19< + pub fn __state17< __TOKENS: Iterator, >( scale: i32, @@ -1337,7 +1193,7 @@ mod __parse__Expr { Some(__tok @ Tok::Minus(..)) => { let mut __sym2 = &mut Some(__tok); let __lookahead = __tokens.next(); - __result = try!(__state22(scale, __lookahead, __tokens, __sym1, __sym2)); + __result = try!(__state20(scale, __lookahead, __tokens, __sym1, __sym2)); } Some(__tok @ Tok::RParen(..)) => { let mut __sym2 = &mut Some(__tok); @@ -1347,7 +1203,7 @@ mod __parse__Expr { Some(__tok @ Tok::Plus(..)) => { let mut __sym2 = &mut Some(__tok); let __lookahead = __tokens.next(); - __result = try!(__state21(scale, __lookahead, __tokens, __sym1, __sym2)); + __result = try!(__state19(scale, __lookahead, __tokens, __sym1, __sym2)); } _ => { return Err(__lookahead); @@ -1356,7 +1212,7 @@ mod __parse__Expr { return Ok(__result); } - // State 20 + // State 18 // Term = "(" Expr ")" (*) [EOF] // Term = "(" Expr ")" (*) ["*"] // Term = "(" Expr ")" (*) ["+"] @@ -1364,12 +1220,12 @@ mod __parse__Expr { // Term = "(" Expr ")" (*) ["/"] // // "-" -> Reduce(Term = "(", Expr, ")" => ActionFn(8);) - // EOF -> Reduce(Term = "(", Expr, ")" => ActionFn(8);) // "+" -> Reduce(Term = "(", Expr, ")" => ActionFn(8);) // "/" -> Reduce(Term = "(", Expr, ")" => ActionFn(8);) // "*" -> Reduce(Term = "(", Expr, ")" => ActionFn(8);) + // EOF -> Reduce(Term = "(", Expr, ")" => ActionFn(8);) // - pub fn __state20< + pub fn __state18< __TOKENS: Iterator, >( scale: i32, @@ -1389,13 +1245,6 @@ mod __parse__Expr { let __nt = super::__actions::__action8(scale, __sym0, __sym1, __sym2); return Ok((__lookahead, __Nonterminal::Term(__nt))); } - None => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action8(scale, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Term(__nt))); - } Some(Tok::Plus(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); @@ -1417,13 +1266,20 @@ mod __parse__Expr { let __nt = super::__actions::__action8(scale, __sym0, __sym1, __sym2); return Ok((__lookahead, __Nonterminal::Term(__nt))); } + None => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action8(scale, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Term(__nt))); + } _ => { return Err(__lookahead); } } } - // State 21 + // State 19 // Expr = Expr "+" (*) Factor [")"] // Expr = Expr "+" (*) Factor ["+"] // Expr = Expr "+" (*) Factor ["-"] @@ -1454,11 +1310,11 @@ mod __parse__Expr { // Term = (*) "Num" ["/"] // // "Num" -> Shift(S9) - // "(" -> Shift(S11) + // "(" -> Shift(S7) // - // Term -> S10 + // Term -> S8 // Factor -> S28 - pub fn __state21< + pub fn __state19< __TOKENS: Iterator, >( scale: i32, @@ -1478,7 +1334,7 @@ mod __parse__Expr { Some(__tok @ Tok::LParen(..)) => { let mut __sym2 = &mut Some(__tok); let __lookahead = __tokens.next(); - __result = try!(__state11(scale, __lookahead, __tokens, __sym2)); + __result = try!(__state7(scale, __lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); @@ -1489,7 +1345,7 @@ mod __parse__Expr { match __nt { __Nonterminal::Term(__nt) => { let __sym2 = &mut Some(__nt); - __result = try!(__state10(scale, __lookahead, __tokens, __sym2)); + __result = try!(__state8(scale, __lookahead, __tokens, __sym2)); } __Nonterminal::Factor(__nt) => { let __sym2 = &mut Some(__nt); @@ -1503,7 +1359,7 @@ mod __parse__Expr { return Ok(__result); } - // State 22 + // State 20 // Expr = Expr "-" (*) Factor [")"] // Expr = Expr "-" (*) Factor ["+"] // Expr = Expr "-" (*) Factor ["-"] @@ -1533,12 +1389,12 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "(" -> Shift(S11) + // "(" -> Shift(S7) // "Num" -> Shift(S9) // - // Term -> S10 // Factor -> S29 - pub fn __state22< + // Term -> S8 + pub fn __state20< __TOKENS: Iterator, >( scale: i32, @@ -1553,7 +1409,7 @@ mod __parse__Expr { Some(__tok @ Tok::LParen(..)) => { let mut __sym2 = &mut Some(__tok); let __lookahead = __tokens.next(); - __result = try!(__state11(scale, __lookahead, __tokens, __sym2)); + __result = try!(__state7(scale, __lookahead, __tokens, __sym2)); } Some(Tok::Num(__tok0)) => { let mut __sym2 = &mut Some((__tok0)); @@ -1567,14 +1423,14 @@ mod __parse__Expr { while __sym1.is_some() { let (__lookahead, __nt) = __result; match __nt { - __Nonterminal::Term(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state10(scale, __lookahead, __tokens, __sym2)); - } __Nonterminal::Factor(__nt) => { let __sym2 = &mut Some(__nt); __result = try!(__state29(scale, __lookahead, __tokens, __sym0, __sym1, __sym2)); } + __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state8(scale, __lookahead, __tokens, __sym2)); + } _ => { return Ok((__lookahead, __nt)); } @@ -1583,18 +1439,160 @@ mod __parse__Expr { return Ok(__result); } - // State 23 + // State 21 + // Factor = Factor "*" Term (*) [EOF] + // Factor = Factor "*" Term (*) ["*"] + // Factor = Factor "*" Term (*) ["+"] + // Factor = Factor "*" Term (*) ["-"] + // Factor = Factor "*" Term (*) ["/"] + // + // EOF -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) + // "*" -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) + // "/" -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) + // "-" -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) + // "+" -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) + // + pub fn __state21< + __TOKENS: Iterator, + >( + scale: i32, + mut __lookahead: Option, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + __sym1: &mut Option, + __sym2: &mut Option, + ) -> Result<(Option, __Nonterminal<>), Option> + { + let mut __result: (Option, __Nonterminal<>); + match __lookahead { + None => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action4(scale, __sym0, __sym1, __sym2); + return Ok((__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::__actions::__action4(scale, __sym0, __sym1, __sym2); + return Ok((__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::__actions::__action4(scale, __sym0, __sym1, __sym2); + return Ok((__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::__actions::__action4(scale, __sym0, __sym1, __sym2); + return Ok((__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::__actions::__action4(scale, __sym0, __sym1, __sym2); + return Ok((__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 => ActionFn(5);) + // EOF -> Reduce(Factor = Factor, "/", Term => ActionFn(5);) // "-" -> Reduce(Factor = Factor, "/", Term => ActionFn(5);) // "/" -> Reduce(Factor = Factor, "/", Term => ActionFn(5);) // "+" -> Reduce(Factor = Factor, "/", Term => ActionFn(5);) - // EOF -> Reduce(Factor = Factor, "/", Term => ActionFn(5);) - // "*" -> Reduce(Factor = Factor, "/", Term => ActionFn(5);) + // + pub fn __state22< + __TOKENS: Iterator, + >( + scale: i32, + mut __lookahead: Option, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + __sym1: &mut Option, + __sym2: &mut Option, + ) -> Result<(Option, __Nonterminal<>), Option> + { + let mut __result: (Option, __Nonterminal<>); + match __lookahead { + Some(Tok::Times(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action5(scale, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + None => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action5(scale, __sym0, __sym1, __sym2); + return Ok((__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::__actions::__action5(scale, __sym0, __sym1, __sym2); + return Ok((__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::__actions::__action5(scale, __sym0, __sym1, __sym2); + return Ok((__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::__actions::__action5(scale, __sym0, __sym1, __sym2); + return Ok((__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 ["/"] + // + // "/" -> Shift(S12) + // EOF -> Reduce(Expr = Expr, "+", Factor => ActionFn(2);) + // "+" -> Reduce(Expr = Expr, "+", Factor => ActionFn(2);) + // "-" -> Reduce(Expr = Expr, "+", Factor => ActionFn(2);) + // "*" -> Shift(S11) // pub fn __state23< __TOKENS: Iterator, @@ -1609,59 +1607,64 @@ mod __parse__Expr { { let mut __result: (Option, __Nonterminal<>); match __lookahead { - Some(Tok::Minus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action5(scale, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); + Some(__tok @ Tok::Div(..)) => { + let mut __sym3 = &mut Some(__tok); + let __lookahead = __tokens.next(); + __result = try!(__state12(scale, __lookahead, __tokens, __sym2, __sym3)); } - Some(Tok::Div(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action5(scale, __sym0, __sym1, __sym2); - return Ok((__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::__actions::__action5(scale, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); + Some(__tok @ Tok::Times(..)) => { + let mut __sym3 = &mut Some(__tok); + let __lookahead = __tokens.next(); + __result = try!(__state11(scale, __lookahead, __tokens, __sym2, __sym3)); } None => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action5(scale, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); + let __nt = super::__actions::__action2(scale, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Expr(__nt))); } - Some(Tok::Times(..)) => { + Some(Tok::Plus(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action5(scale, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); + let __nt = super::__actions::__action2(scale, __sym0, __sym1, __sym2); + return Ok((__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::__actions::__action2(scale, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Expr(__nt))); } _ => { return Err(__lookahead); } } + return Ok(__result); } // State 24 - // Factor = Factor "*" Term (*) [EOF] - // Factor = Factor "*" Term (*) ["*"] - // Factor = Factor "*" Term (*) ["+"] - // Factor = Factor "*" Term (*) ["-"] - // Factor = Factor "*" Term (*) ["/"] + // 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(Factor = Factor, "*", Term => ActionFn(4);) - // "*" -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) - // EOF -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) - // "-" -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) - // "/" -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) + // "/" -> Shift(S12) + // "+" -> Reduce(Expr = Expr, "-", Factor => ActionFn(1);) + // "*" -> Shift(S11) + // "-" -> Reduce(Expr = Expr, "-", Factor => ActionFn(1);) + // EOF -> Reduce(Expr = Expr, "-", Factor => ActionFn(1);) // pub fn __state24< __TOKENS: Iterator, @@ -1676,45 +1679,42 @@ mod __parse__Expr { { let mut __result: (Option, __Nonterminal<>); match __lookahead { + Some(__tok @ Tok::Div(..)) => { + let mut __sym3 = &mut Some(__tok); + let __lookahead = __tokens.next(); + __result = try!(__state12(scale, __lookahead, __tokens, __sym2, __sym3)); + } + Some(__tok @ Tok::Times(..)) => { + let mut __sym3 = &mut Some(__tok); + let __lookahead = __tokens.next(); + __result = try!(__state11(scale, __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::__actions::__action4(scale, __sym0, __sym1, __sym2); - return Ok((__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::__actions::__action4(scale, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - None => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action4(scale, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); + let __nt = super::__actions::__action1(scale, __sym0, __sym1, __sym2); + return Ok((__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::__actions::__action4(scale, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); + let __nt = super::__actions::__action1(scale, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Expr(__nt))); } - Some(Tok::Div(..)) => { + None => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action4(scale, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); + let __nt = super::__actions::__action1(scale, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Expr(__nt))); } _ => { return Err(__lookahead); } } + return Ok(__result); } // State 25 @@ -1724,11 +1724,11 @@ mod __parse__Expr { // Factor = Factor "/" Term (*) ["-"] // Factor = Factor "/" Term (*) ["/"] // - // ")" -> Reduce(Factor = Factor, "/", Term => ActionFn(5);) // "+" -> Reduce(Factor = Factor, "/", Term => ActionFn(5);) + // "*" -> Reduce(Factor = Factor, "/", Term => ActionFn(5);) + // ")" -> Reduce(Factor = Factor, "/", Term => ActionFn(5);) // "/" -> Reduce(Factor = Factor, "/", Term => ActionFn(5);) // "-" -> Reduce(Factor = Factor, "/", Term => ActionFn(5);) - // "*" -> Reduce(Factor = Factor, "/", Term => ActionFn(5);) // pub fn __state25< __TOKENS: Iterator, @@ -1743,14 +1743,21 @@ mod __parse__Expr { { let mut __result: (Option, __Nonterminal<>); match __lookahead { - Some(Tok::RParen(..)) => { + Some(Tok::Plus(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); let __nt = super::__actions::__action5(scale, __sym0, __sym1, __sym2); return Ok((__lookahead, __Nonterminal::Factor(__nt))); } - Some(Tok::Plus(..)) => { + Some(Tok::Times(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action5(scale, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + Some(Tok::RParen(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); @@ -1771,13 +1778,6 @@ mod __parse__Expr { let __nt = super::__actions::__action5(scale, __sym0, __sym1, __sym2); return Ok((__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::__actions::__action5(scale, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } _ => { return Err(__lookahead); } @@ -1791,11 +1791,11 @@ mod __parse__Expr { // Factor = Factor "*" Term (*) ["-"] // Factor = Factor "*" Term (*) ["/"] // + // "*" -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) // "/" -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) // ")" -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) - // "-" -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) - // "*" -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) // "+" -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) + // "-" -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) // pub fn __state26< __TOKENS: Iterator, @@ -1810,6 +1810,13 @@ mod __parse__Expr { { let mut __result: (Option, __Nonterminal<>); match __lookahead { + Some(Tok::Times(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action4(scale, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } Some(Tok::Div(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); @@ -1824,20 +1831,6 @@ mod __parse__Expr { let __nt = super::__actions::__action4(scale, __sym0, __sym1, __sym2); return Ok((__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::__actions::__action4(scale, __sym0, __sym1, __sym2); - return Ok((__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::__actions::__action4(scale, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } Some(Tok::Plus(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); @@ -1845,6 +1838,13 @@ mod __parse__Expr { let __nt = super::__actions::__action4(scale, __sym0, __sym1, __sym2); return Ok((__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::__actions::__action4(scale, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } _ => { return Err(__lookahead); } @@ -1858,11 +1858,11 @@ mod __parse__Expr { // Term = "(" Expr ")" (*) ["-"] // Term = "(" Expr ")" (*) ["/"] // - // "/" -> Reduce(Term = "(", Expr, ")" => ActionFn(8);) - // "-" -> Reduce(Term = "(", Expr, ")" => ActionFn(8);) + // "+" -> Reduce(Term = "(", Expr, ")" => ActionFn(8);) // ")" -> Reduce(Term = "(", Expr, ")" => ActionFn(8);) // "*" -> Reduce(Term = "(", Expr, ")" => ActionFn(8);) - // "+" -> Reduce(Term = "(", Expr, ")" => ActionFn(8);) + // "-" -> Reduce(Term = "(", Expr, ")" => ActionFn(8);) + // "/" -> Reduce(Term = "(", Expr, ")" => ActionFn(8);) // pub fn __state27< __TOKENS: Iterator, @@ -1877,14 +1877,7 @@ mod __parse__Expr { { let mut __result: (Option, __Nonterminal<>); match __lookahead { - Some(Tok::Div(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action8(scale, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Term(__nt))); - } - Some(Tok::Minus(..)) => { + Some(Tok::Plus(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); @@ -1905,7 +1898,14 @@ mod __parse__Expr { let __nt = super::__actions::__action8(scale, __sym0, __sym1, __sym2); return Ok((__lookahead, __Nonterminal::Term(__nt))); } - Some(Tok::Plus(..)) => { + Some(Tok::Minus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action8(scale, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Term(__nt))); + } + Some(Tok::Div(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); @@ -1933,11 +1933,11 @@ mod __parse__Expr { // Factor = Factor (*) "/" Term ["-"] // Factor = Factor (*) "/" Term ["/"] // - // "*" -> Shift(S18) - // "-" -> Reduce(Expr = Expr, "+", Factor => ActionFn(2);) - // "/" -> Shift(S17) - // "+" -> Reduce(Expr = Expr, "+", Factor => ActionFn(2);) + // "/" -> Shift(S15) // ")" -> Reduce(Expr = Expr, "+", Factor => ActionFn(2);) + // "-" -> Reduce(Expr = Expr, "+", Factor => ActionFn(2);) + // "*" -> Shift(S16) + // "+" -> Reduce(Expr = Expr, "+", Factor => ActionFn(2);) // pub fn __state28< __TOKENS: Iterator, @@ -1952,15 +1952,22 @@ mod __parse__Expr { { let mut __result: (Option, __Nonterminal<>); match __lookahead { - Some(__tok @ Tok::Times(..)) => { - let mut __sym3 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state18(scale, __lookahead, __tokens, __sym2, __sym3)); - } Some(__tok @ Tok::Div(..)) => { let mut __sym3 = &mut Some(__tok); let __lookahead = __tokens.next(); - __result = try!(__state17(scale, __lookahead, __tokens, __sym2, __sym3)); + __result = try!(__state15(scale, __lookahead, __tokens, __sym2, __sym3)); + } + Some(__tok @ Tok::Times(..)) => { + let mut __sym3 = &mut Some(__tok); + let __lookahead = __tokens.next(); + __result = try!(__state16(scale, __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::__actions::__action2(scale, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Expr(__nt))); } Some(Tok::Minus(..)) => { let __sym0 = __sym0.take().unwrap(); @@ -1976,13 +1983,6 @@ mod __parse__Expr { let __nt = super::__actions::__action2(scale, __sym0, __sym1, __sym2); return Ok((__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::__actions::__action2(scale, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Expr(__nt))); - } _ => { return Err(__lookahead); } @@ -2005,10 +2005,10 @@ mod __parse__Expr { // Factor = Factor (*) "/" Term ["-"] // Factor = Factor (*) "/" Term ["/"] // + // "/" -> Shift(S15) // "-" -> Reduce(Expr = Expr, "-", Factor => ActionFn(1);) - // "*" -> Shift(S18) // "+" -> Reduce(Expr = Expr, "-", Factor => ActionFn(1);) - // "/" -> Shift(S17) + // "*" -> Shift(S16) // ")" -> Reduce(Expr = Expr, "-", Factor => ActionFn(1);) // pub fn __state29< @@ -2024,15 +2024,15 @@ mod __parse__Expr { { let mut __result: (Option, __Nonterminal<>); match __lookahead { - Some(__tok @ Tok::Times(..)) => { - let mut __sym3 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state18(scale, __lookahead, __tokens, __sym2, __sym3)); - } Some(__tok @ Tok::Div(..)) => { let mut __sym3 = &mut Some(__tok); let __lookahead = __tokens.next(); - __result = try!(__state17(scale, __lookahead, __tokens, __sym2, __sym3)); + __result = try!(__state15(scale, __lookahead, __tokens, __sym2, __sym3)); + } + Some(__tok @ Tok::Times(..)) => { + let mut __sym3 = &mut Some(__tok); + let __lookahead = __tokens.next(); + __result = try!(__state16(scale, __lookahead, __tokens, __sym2, __sym3)); } Some(Tok::Minus(..)) => { let __sym0 = __sym0.take().unwrap(); diff --git a/lalrpop-test/src/expr_arena.lalrpop b/lalrpop-test/src/expr_arena.lalrpop index ed6f54a..84ba571 100644 --- a/lalrpop-test/src/expr_arena.lalrpop +++ b/lalrpop-test/src/expr_arena.lalrpop @@ -1,9 +1,11 @@ -grammar<'ast>(arena: &'ast Arena<'ast>); - use expr_arena_ast::{Arena, Node, Op}; use util::tok::Tok; +grammar<'ast>(arena: &'ast Arena<'ast>); + extern token { + type Location = u32; + enum Tok { "(" => Tok::LParen(..), ")" => Tok::RParen(..), diff --git a/lalrpop-test/src/expr_arena.rs b/lalrpop-test/src/expr_arena.rs index 282c1d6..8eac297 100644 --- a/lalrpop-test/src/expr_arena.rs +++ b/lalrpop-test/src/expr_arena.rs @@ -26,14 +26,14 @@ mod __parse__Expr { use util::tok::Tok; pub enum __Nonterminal<'ast, > { - Expr_3f(::std::option::Option<&'ast Node<'ast>>), - Term(&'ast Node<'ast>), - _28_3cExpr_3e_20_22_2c_22_29_2a(::std::vec::Vec<&'ast Node<'ast>>), - Comma_3cExpr_3e(Vec<&'ast Node<'ast>>), _28_3cExpr_3e_20_22_2c_22_29(&'ast Node<'ast>), - ____Expr(&'ast Node<'ast>), + Comma_3cExpr_3e(Vec<&'ast Node<'ast>>), + _28_3cExpr_3e_20_22_2c_22_29_2a(::std::vec::Vec<&'ast Node<'ast>>), Expr(&'ast Node<'ast>), Factor(&'ast Node<'ast>), + Term(&'ast Node<'ast>), + ____Expr(&'ast Node<'ast>), + Expr_3f(::std::option::Option<&'ast Node<'ast>>), } // State 0 @@ -78,13 +78,13 @@ mod __parse__Expr { // Term = (*) "Num" ["/"] // __Expr = (*) Expr [EOF] // - // "*" -> Shift(S6) + // "*" -> Shift(S5) // "(" -> Shift(S3) - // "Num" -> Shift(S1) + // "Num" -> Shift(S6) // - // Expr -> S2 - // Factor -> S4 - // Term -> S5 + // Expr -> S4 + // Term -> S2 + // Factor -> S1 pub fn __state0< 'ast, __TOKENS: Iterator, @@ -99,7 +99,7 @@ mod __parse__Expr { Some(__tok @ Tok::Times(..)) => { let mut __sym0 = &mut Some(__tok); let __lookahead = __tokens.next(); - __result = try!(__state6(arena, __lookahead, __tokens, __sym0)); + __result = try!(__state5(arena, __lookahead, __tokens, __sym0)); } Some(__tok @ Tok::LParen(..)) => { let mut __sym0 = &mut Some(__tok); @@ -109,7 +109,7 @@ mod __parse__Expr { Some(Tok::Num(__tok0)) => { let mut __sym0 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state1(arena, __lookahead, __tokens, __sym0)); + __result = try!(__state6(arena, __lookahead, __tokens, __sym0)); } _ => { return Err(__lookahead); @@ -119,16 +119,16 @@ mod __parse__Expr { let (__lookahead, __nt) = __result; match __nt { __Nonterminal::Expr(__nt) => { - let __sym0 = &mut Some(__nt); - __result = try!(__state2(arena, __lookahead, __tokens, __sym0)); - } - __Nonterminal::Factor(__nt) => { let __sym0 = &mut Some(__nt); __result = try!(__state4(arena, __lookahead, __tokens, __sym0)); } __Nonterminal::Term(__nt) => { let __sym0 = &mut Some(__nt); - __result = try!(__state5(arena, __lookahead, __tokens, __sym0)); + __result = try!(__state2(arena, __lookahead, __tokens, __sym0)); + } + __Nonterminal::Factor(__nt) => { + let __sym0 = &mut Some(__nt); + __result = try!(__state1(arena, __lookahead, __tokens, __sym0)); } _ => { return Ok((__lookahead, __nt)); @@ -138,17 +138,25 @@ mod __parse__Expr { } // State 1 - // Term = "Num" (*) [EOF] - // Term = "Num" (*) ["*"] - // Term = "Num" (*) ["+"] - // Term = "Num" (*) ["-"] - // Term = "Num" (*) ["/"] + // 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(Term = "Num" => ActionFn(8);) - // "+" -> Reduce(Term = "Num" => ActionFn(8);) - // "-" -> Reduce(Term = "Num" => ActionFn(8);) - // "*" -> Reduce(Term = "Num" => ActionFn(8);) - // "/" -> Reduce(Term = "Num" => ActionFn(8);) + // "/" -> Shift(S8) + // EOF -> Reduce(Expr = Factor => ActionFn(3);) + // "*" -> Shift(S7) + // "+" -> Reduce(Expr = Factor => ActionFn(3);) + // "-" -> Reduce(Expr = Factor => ActionFn(3);) // pub fn __state1< 'ast, @@ -157,54 +165,55 @@ mod __parse__Expr { arena: &'ast Arena<'ast>, mut __lookahead: Option, __tokens: &mut __TOKENS, - __sym0: &mut Option, + __sym0: &mut Option<&'ast Node<'ast>>, ) -> Result<(Option, __Nonterminal<'ast, >), Option> { let mut __result: (Option, __Nonterminal<'ast, >); match __lookahead { + Some(__tok @ Tok::Div(..)) => { + let mut __sym1 = &mut Some(__tok); + let __lookahead = __tokens.next(); + __result = try!(__state8(arena, __lookahead, __tokens, __sym0, __sym1)); + } + Some(__tok @ Tok::Times(..)) => { + let mut __sym1 = &mut Some(__tok); + let __lookahead = __tokens.next(); + __result = try!(__state7(arena, __lookahead, __tokens, __sym0, __sym1)); + } None => { let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action8(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Term(__nt))); + let __nt = super::__actions::__action3(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Expr(__nt))); } Some(Tok::Plus(..)) => { let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action8(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Term(__nt))); + let __nt = super::__actions::__action3(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Expr(__nt))); } Some(Tok::Minus(..)) => { let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action8(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Term(__nt))); - } - Some(Tok::Times(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action8(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Term(__nt))); - } - Some(Tok::Div(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action8(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Term(__nt))); + let __nt = super::__actions::__action3(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Expr(__nt))); } _ => { return Err(__lookahead); } } + return Ok(__result); } // State 2 - // Expr = Expr (*) "+" Factor [EOF] - // Expr = Expr (*) "+" Factor ["+"] - // Expr = Expr (*) "+" Factor ["-"] - // Expr = Expr (*) "-" Factor [EOF] - // Expr = Expr (*) "-" Factor ["+"] - // Expr = Expr (*) "-" Factor ["-"] - // __Expr = Expr (*) [EOF] + // Factor = Term (*) [EOF] + // Factor = Term (*) ["*"] + // Factor = Term (*) ["+"] + // Factor = Term (*) ["-"] + // Factor = Term (*) ["/"] // - // "-" -> Shift(S7) - // EOF -> Reduce(__Expr = Expr => ActionFn(0);) - // "+" -> Shift(S8) + // EOF -> Reduce(Factor = Term => ActionFn(7);) + // "/" -> Reduce(Factor = Term => ActionFn(7);) + // "-" -> Reduce(Factor = Term => ActionFn(7);) + // "+" -> Reduce(Factor = Term => ActionFn(7);) + // "*" -> Reduce(Factor = Term => ActionFn(7);) // pub fn __state2< 'ast, @@ -218,26 +227,35 @@ mod __parse__Expr { { let mut __result: (Option, __Nonterminal<'ast, >); match __lookahead { - Some(__tok @ Tok::Minus(..)) => { - let mut __sym1 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state7(arena, __lookahead, __tokens, __sym0, __sym1)); - } - Some(__tok @ Tok::Plus(..)) => { - let mut __sym1 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state8(arena, __lookahead, __tokens, __sym0, __sym1)); - } None => { let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action0(arena, __sym0); - return Ok((__lookahead, __Nonterminal::____Expr(__nt))); + let __nt = super::__actions::__action7(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + Some(Tok::Div(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action7(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + Some(Tok::Minus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action7(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + Some(Tok::Plus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action7(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + Some(Tok::Times(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action7(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); } _ => { return Err(__lookahead); } } - return Ok(__result); } // State 3 @@ -286,13 +304,13 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "Num" -> Shift(S12) - // "(" -> Shift(S14) - // "*" -> Shift(S10) + // "*" -> Shift(S9) + // "Num" -> Shift(S14) + // "(" -> Shift(S13) // - // Term -> S9 - // Factor -> S11 - // Expr -> S13 + // Factor -> S10 + // Expr -> S11 + // Term -> S12 pub fn __state3< 'ast, __TOKENS: Iterator, @@ -305,20 +323,20 @@ mod __parse__Expr { { let mut __result: (Option, __Nonterminal<'ast, >); match __lookahead { + Some(__tok @ Tok::Times(..)) => { + let mut __sym1 = &mut Some(__tok); + let __lookahead = __tokens.next(); + __result = try!(__state9(arena, __lookahead, __tokens, __sym1)); + } Some(Tok::Num(__tok0)) => { let mut __sym1 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state12(arena, __lookahead, __tokens, __sym1)); + __result = try!(__state14(arena, __lookahead, __tokens, __sym1)); } Some(__tok @ Tok::LParen(..)) => { let mut __sym1 = &mut Some(__tok); let __lookahead = __tokens.next(); - __result = try!(__state14(arena, __lookahead, __tokens, __sym1)); - } - Some(__tok @ Tok::Times(..)) => { - let mut __sym1 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state10(arena, __lookahead, __tokens, __sym1)); + __result = try!(__state13(arena, __lookahead, __tokens, __sym1)); } _ => { return Err(__lookahead); @@ -327,17 +345,17 @@ mod __parse__Expr { while __sym0.is_some() { let (__lookahead, __nt) = __result; match __nt { - __Nonterminal::Term(__nt) => { - let __sym1 = &mut Some(__nt); - __result = try!(__state9(arena, __lookahead, __tokens, __sym1)); - } __Nonterminal::Factor(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state11(arena, __lookahead, __tokens, __sym1)); + __result = try!(__state10(arena, __lookahead, __tokens, __sym1)); } __Nonterminal::Expr(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state13(arena, __lookahead, __tokens, __sym0, __sym1)); + __result = try!(__state11(arena, __lookahead, __tokens, __sym0, __sym1)); + } + __Nonterminal::Term(__nt) => { + let __sym1 = &mut Some(__nt); + __result = try!(__state12(arena, __lookahead, __tokens, __sym1)); } _ => { return Ok((__lookahead, __nt)); @@ -348,25 +366,17 @@ mod __parse__Expr { } // 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 ["/"] + // Expr = Expr (*) "+" Factor [EOF] + // Expr = Expr (*) "+" Factor ["+"] + // Expr = Expr (*) "+" Factor ["-"] + // Expr = Expr (*) "-" Factor [EOF] + // Expr = Expr (*) "-" Factor ["+"] + // Expr = Expr (*) "-" Factor ["-"] + // __Expr = Expr (*) [EOF] // - // "/" -> Shift(S16) - // "+" -> Reduce(Expr = Factor => ActionFn(3);) - // "-" -> Reduce(Expr = Factor => ActionFn(3);) - // "*" -> Shift(S15) - // EOF -> Reduce(Expr = Factor => ActionFn(3);) + // "-" -> Shift(S16) + // EOF -> Reduce(__Expr = Expr => ActionFn(0);) + // "+" -> Shift(S15) // pub fn __state4< 'ast, @@ -380,30 +390,20 @@ mod __parse__Expr { { let mut __result: (Option, __Nonterminal<'ast, >); match __lookahead { - Some(__tok @ Tok::Div(..)) => { + Some(__tok @ Tok::Minus(..)) => { let mut __sym1 = &mut Some(__tok); let __lookahead = __tokens.next(); __result = try!(__state16(arena, __lookahead, __tokens, __sym0, __sym1)); } - Some(__tok @ Tok::Times(..)) => { + Some(__tok @ Tok::Plus(..)) => { let mut __sym1 = &mut Some(__tok); let __lookahead = __tokens.next(); __result = try!(__state15(arena, __lookahead, __tokens, __sym0, __sym1)); } - Some(Tok::Plus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action3(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Expr(__nt))); - } - Some(Tok::Minus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action3(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Expr(__nt))); - } None => { let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action3(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Expr(__nt))); + let __nt = super::__actions::__action0(arena, __sym0); + return Ok((__lookahead, __Nonterminal::____Expr(__nt))); } _ => { return Err(__lookahead); @@ -413,62 +413,6 @@ mod __parse__Expr { } // State 5 - // Factor = Term (*) [EOF] - // Factor = Term (*) ["*"] - // Factor = Term (*) ["+"] - // Factor = Term (*) ["-"] - // Factor = Term (*) ["/"] - // - // "/" -> Reduce(Factor = Term => ActionFn(7);) - // "*" -> Reduce(Factor = Term => ActionFn(7);) - // "-" -> Reduce(Factor = Term => ActionFn(7);) - // "+" -> Reduce(Factor = Term => ActionFn(7);) - // EOF -> Reduce(Factor = Term => ActionFn(7);) - // - pub fn __state5< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - mut __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> - { - let mut __result: (Option, __Nonterminal<'ast, >); - match __lookahead { - Some(Tok::Div(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Times(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Minus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Plus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - None => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 6 // Factor = "*" (*) "(" Comma ")" [EOF] // Factor = "*" (*) "(" Comma ")" ["*"] // Factor = "*" (*) "(" Comma ")" ["+"] @@ -477,7 +421,7 @@ mod __parse__Expr { // // "(" -> Shift(S17) // - pub fn __state6< + pub fn __state5< 'ast, __TOKENS: Iterator, >( @@ -501,30 +445,68 @@ mod __parse__Expr { return Ok(__result); } + // State 6 + // Term = "Num" (*) [EOF] + // Term = "Num" (*) ["*"] + // Term = "Num" (*) ["+"] + // Term = "Num" (*) ["-"] + // Term = "Num" (*) ["/"] + // + // "+" -> Reduce(Term = "Num" => ActionFn(8);) + // "-" -> Reduce(Term = "Num" => ActionFn(8);) + // "/" -> Reduce(Term = "Num" => ActionFn(8);) + // EOF -> Reduce(Term = "Num" => ActionFn(8);) + // "*" -> Reduce(Term = "Num" => ActionFn(8);) + // + pub fn __state6< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + mut __lookahead: Option, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + ) -> Result<(Option, __Nonterminal<'ast, >), Option> + { + let mut __result: (Option, __Nonterminal<'ast, >); + match __lookahead { + Some(Tok::Plus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action8(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Term(__nt))); + } + Some(Tok::Minus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action8(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Term(__nt))); + } + Some(Tok::Div(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action8(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Term(__nt))); + } + None => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action8(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Term(__nt))); + } + Some(Tok::Times(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action8(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Term(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + // State 7 - // 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 ")" ["/"] + // Factor = Factor "*" (*) Term [EOF] + // Factor = Factor "*" (*) Term ["*"] + // Factor = Factor "*" (*) Term ["+"] + // Factor = Factor "*" (*) Term ["-"] + // Factor = Factor "*" (*) Term ["/"] // Term = (*) "(" Expr ")" [EOF] // Term = (*) "(" Expr ")" ["*"] // Term = (*) "(" Expr ")" ["+"] @@ -536,12 +518,10 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "*" -> Shift(S6) - // "Num" -> Shift(S1) + // "Num" -> Shift(S6) // "(" -> Shift(S3) // - // Factor -> S18 - // Term -> S5 + // Term -> S18 pub fn __state7< 'ast, __TOKENS: Iterator, @@ -555,15 +535,10 @@ mod __parse__Expr { { let mut __result: (Option, __Nonterminal<'ast, >); match __lookahead { - Some(__tok @ Tok::Times(..)) => { - let mut __sym2 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state6(arena, __lookahead, __tokens, __sym2)); - } Some(Tok::Num(__tok0)) => { let mut __sym2 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state1(arena, __lookahead, __tokens, __sym2)); + __result = try!(__state6(arena, __lookahead, __tokens, __sym2)); } Some(__tok @ Tok::LParen(..)) => { let mut __sym2 = &mut Some(__tok); @@ -577,13 +552,9 @@ mod __parse__Expr { while __sym1.is_some() { let (__lookahead, __nt) = __result; match __nt { - __Nonterminal::Factor(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state18(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } __Nonterminal::Term(__nt) => { let __sym2 = &mut Some(__nt); - __result = try!(__state5(arena, __lookahead, __tokens, __sym2)); + __result = try!(__state18(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); } _ => { return Ok((__lookahead, __nt)); @@ -594,29 +565,11 @@ mod __parse__Expr { } // State 8 - // 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 ")" ["/"] + // Factor = Factor "/" (*) Term [EOF] + // Factor = Factor "/" (*) Term ["*"] + // Factor = Factor "/" (*) Term ["+"] + // Factor = Factor "/" (*) Term ["-"] + // Factor = Factor "/" (*) Term ["/"] // Term = (*) "(" Expr ")" [EOF] // Term = (*) "(" Expr ")" ["*"] // Term = (*) "(" Expr ")" ["+"] @@ -629,11 +582,9 @@ mod __parse__Expr { // Term = (*) "Num" ["/"] // // "(" -> Shift(S3) - // "Num" -> Shift(S1) - // "*" -> Shift(S6) + // "Num" -> Shift(S6) // - // Term -> S5 - // Factor -> S19 + // Term -> S19 pub fn __state8< 'ast, __TOKENS: Iterator, @@ -655,11 +606,6 @@ mod __parse__Expr { Some(Tok::Num(__tok0)) => { let mut __sym2 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state1(arena, __lookahead, __tokens, __sym2)); - } - Some(__tok @ Tok::Times(..)) => { - let mut __sym2 = &mut Some(__tok); - let __lookahead = __tokens.next(); __result = try!(__state6(arena, __lookahead, __tokens, __sym2)); } _ => { @@ -670,10 +616,6 @@ mod __parse__Expr { let (__lookahead, __nt) = __result; match __nt { __Nonterminal::Term(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state5(arena, __lookahead, __tokens, __sym2)); - } - __Nonterminal::Factor(__nt) => { let __sym2 = &mut Some(__nt); __result = try!(__state19(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); } @@ -686,62 +628,6 @@ mod __parse__Expr { } // State 9 - // Factor = Term (*) [")"] - // Factor = Term (*) ["*"] - // Factor = Term (*) ["+"] - // Factor = Term (*) ["-"] - // Factor = Term (*) ["/"] - // - // "-" -> Reduce(Factor = Term => ActionFn(7);) - // "+" -> Reduce(Factor = Term => ActionFn(7);) - // "*" -> Reduce(Factor = Term => ActionFn(7);) - // "/" -> Reduce(Factor = Term => ActionFn(7);) - // ")" -> Reduce(Factor = Term => ActionFn(7);) - // - pub fn __state9< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - mut __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> - { - let mut __result: (Option, __Nonterminal<'ast, >); - match __lookahead { - Some(Tok::Minus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Plus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Times(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Div(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::RParen(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 10 // Factor = "*" (*) "(" Comma ")" [")"] // Factor = "*" (*) "(" Comma ")" ["*"] // Factor = "*" (*) "(" Comma ")" ["+"] @@ -750,7 +636,7 @@ mod __parse__Expr { // // "(" -> Shift(S20) // - pub fn __state10< + pub fn __state9< 'ast, __TOKENS: Iterator, >( @@ -774,7 +660,7 @@ mod __parse__Expr { return Ok(__result); } - // State 11 + // State 10 // Expr = Factor (*) [")"] // Expr = Factor (*) ["+"] // Expr = Factor (*) ["-"] @@ -789,13 +675,13 @@ mod __parse__Expr { // Factor = Factor (*) "/" Term ["-"] // Factor = Factor (*) "/" Term ["/"] // + // "+" -> Reduce(Expr = Factor => ActionFn(3);) // "-" -> Reduce(Expr = Factor => ActionFn(3);) + // "*" -> Shift(S22) // "/" -> Shift(S21) // ")" -> Reduce(Expr = Factor => ActionFn(3);) - // "+" -> Reduce(Expr = Factor => ActionFn(3);) - // "*" -> Shift(S22) // - pub fn __state11< + pub fn __state10< 'ast, __TOKENS: Iterator, >( @@ -807,15 +693,20 @@ mod __parse__Expr { { let mut __result: (Option, __Nonterminal<'ast, >); match __lookahead { + Some(__tok @ Tok::Times(..)) => { + let mut __sym1 = &mut Some(__tok); + let __lookahead = __tokens.next(); + __result = try!(__state22(arena, __lookahead, __tokens, __sym0, __sym1)); + } Some(__tok @ Tok::Div(..)) => { let mut __sym1 = &mut Some(__tok); let __lookahead = __tokens.next(); __result = try!(__state21(arena, __lookahead, __tokens, __sym0, __sym1)); } - Some(__tok @ Tok::Times(..)) => { - let mut __sym1 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state22(arena, __lookahead, __tokens, __sym0, __sym1)); + Some(Tok::Plus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action3(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Expr(__nt))); } Some(Tok::Minus(..)) => { let __sym0 = __sym0.take().unwrap(); @@ -827,11 +718,6 @@ mod __parse__Expr { let __nt = super::__actions::__action3(arena, __sym0); return Ok((__lookahead, __Nonterminal::Expr(__nt))); } - Some(Tok::Plus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action3(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Expr(__nt))); - } _ => { return Err(__lookahead); } @@ -839,63 +725,7 @@ mod __parse__Expr { return Ok(__result); } - // State 12 - // Term = "Num" (*) [")"] - // Term = "Num" (*) ["*"] - // Term = "Num" (*) ["+"] - // Term = "Num" (*) ["-"] - // Term = "Num" (*) ["/"] - // - // "*" -> Reduce(Term = "Num" => ActionFn(8);) - // ")" -> Reduce(Term = "Num" => ActionFn(8);) - // "/" -> Reduce(Term = "Num" => ActionFn(8);) - // "-" -> Reduce(Term = "Num" => ActionFn(8);) - // "+" -> Reduce(Term = "Num" => ActionFn(8);) - // - pub fn __state12< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - mut __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> - { - let mut __result: (Option, __Nonterminal<'ast, >); - match __lookahead { - Some(Tok::Times(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action8(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Term(__nt))); - } - Some(Tok::RParen(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action8(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Term(__nt))); - } - Some(Tok::Div(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action8(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Term(__nt))); - } - Some(Tok::Minus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action8(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Term(__nt))); - } - Some(Tok::Plus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action8(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Term(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 13 + // State 11 // Expr = Expr (*) "+" Factor [")"] // Expr = Expr (*) "+" Factor ["+"] // Expr = Expr (*) "+" Factor ["-"] @@ -908,11 +738,11 @@ mod __parse__Expr { // Term = "(" Expr (*) ")" ["-"] // Term = "(" Expr (*) ")" ["/"] // - // "-" -> Shift(S24) - // "+" -> Shift(S23) - // ")" -> Shift(S25) + // "-" -> Shift(S23) + // ")" -> Shift(S24) + // "+" -> Shift(S25) // - pub fn __state13< + pub fn __state11< 'ast, __TOKENS: Iterator, >( @@ -926,11 +756,6 @@ mod __parse__Expr { let mut __result: (Option, __Nonterminal<'ast, >); match __lookahead { Some(__tok @ Tok::Minus(..)) => { - let mut __sym2 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state24(arena, __lookahead, __tokens, __sym1, __sym2)); - } - Some(__tok @ Tok::Plus(..)) => { let mut __sym2 = &mut Some(__tok); let __lookahead = __tokens.next(); __result = try!(__state23(arena, __lookahead, __tokens, __sym1, __sym2)); @@ -938,7 +763,12 @@ mod __parse__Expr { Some(__tok @ Tok::RParen(..)) => { let mut __sym2 = &mut Some(__tok); let __lookahead = __tokens.next(); - __result = try!(__state25(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); + __result = try!(__state24(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + Some(__tok @ Tok::Plus(..)) => { + let mut __sym2 = &mut Some(__tok); + let __lookahead = __tokens.next(); + __result = try!(__state25(arena, __lookahead, __tokens, __sym1, __sym2)); } _ => { return Err(__lookahead); @@ -947,7 +777,63 @@ mod __parse__Expr { return Ok(__result); } - // State 14 + // State 12 + // Factor = Term (*) [")"] + // Factor = Term (*) ["*"] + // Factor = Term (*) ["+"] + // Factor = Term (*) ["-"] + // Factor = Term (*) ["/"] + // + // "*" -> Reduce(Factor = Term => ActionFn(7);) + // ")" -> Reduce(Factor = Term => ActionFn(7);) + // "-" -> Reduce(Factor = Term => ActionFn(7);) + // "+" -> Reduce(Factor = Term => ActionFn(7);) + // "/" -> Reduce(Factor = Term => ActionFn(7);) + // + pub fn __state12< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + mut __lookahead: Option, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + ) -> Result<(Option, __Nonterminal<'ast, >), Option> + { + let mut __result: (Option, __Nonterminal<'ast, >); + match __lookahead { + Some(Tok::Times(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action7(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + Some(Tok::RParen(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action7(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + Some(Tok::Minus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action7(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + Some(Tok::Plus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action7(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + Some(Tok::Div(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action7(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 13 // Expr = (*) Expr "+" Factor [")"] // Expr = (*) Expr "+" Factor ["+"] // Expr = (*) Expr "+" Factor ["-"] @@ -993,14 +879,14 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "(" -> Shift(S14) - // "Num" -> Shift(S12) - // "*" -> Shift(S10) + // "(" -> Shift(S13) + // "*" -> Shift(S9) + // "Num" -> Shift(S14) // - // Factor -> S11 - // Term -> S9 // Expr -> S26 - pub fn __state14< + // Term -> S12 + // Factor -> S10 + pub fn __state13< 'ast, __TOKENS: Iterator, >( @@ -1015,17 +901,17 @@ mod __parse__Expr { Some(__tok @ Tok::LParen(..)) => { let mut __sym1 = &mut Some(__tok); let __lookahead = __tokens.next(); - __result = try!(__state14(arena, __lookahead, __tokens, __sym1)); - } - Some(Tok::Num(__tok0)) => { - let mut __sym1 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state12(arena, __lookahead, __tokens, __sym1)); + __result = try!(__state13(arena, __lookahead, __tokens, __sym1)); } Some(__tok @ Tok::Times(..)) => { let mut __sym1 = &mut Some(__tok); let __lookahead = __tokens.next(); - __result = try!(__state10(arena, __lookahead, __tokens, __sym1)); + __result = try!(__state9(arena, __lookahead, __tokens, __sym1)); + } + Some(Tok::Num(__tok0)) => { + let mut __sym1 = &mut Some((__tok0)); + let __lookahead = __tokens.next(); + __result = try!(__state14(arena, __lookahead, __tokens, __sym1)); } _ => { return Err(__lookahead); @@ -1034,18 +920,18 @@ mod __parse__Expr { while __sym0.is_some() { let (__lookahead, __nt) = __result; match __nt { - __Nonterminal::Factor(__nt) => { - let __sym1 = &mut Some(__nt); - __result = try!(__state11(arena, __lookahead, __tokens, __sym1)); - } - __Nonterminal::Term(__nt) => { - let __sym1 = &mut Some(__nt); - __result = try!(__state9(arena, __lookahead, __tokens, __sym1)); - } __Nonterminal::Expr(__nt) => { let __sym1 = &mut Some(__nt); __result = try!(__state26(arena, __lookahead, __tokens, __sym0, __sym1)); } + __Nonterminal::Term(__nt) => { + let __sym1 = &mut Some(__nt); + __result = try!(__state12(arena, __lookahead, __tokens, __sym1)); + } + __Nonterminal::Factor(__nt) => { + let __sym1 = &mut Some(__nt); + __result = try!(__state10(arena, __lookahead, __tokens, __sym1)); + } _ => { return Ok((__lookahead, __nt)); } @@ -1054,12 +940,86 @@ mod __parse__Expr { return Ok(__result); } + // State 14 + // Term = "Num" (*) [")"] + // Term = "Num" (*) ["*"] + // Term = "Num" (*) ["+"] + // Term = "Num" (*) ["-"] + // Term = "Num" (*) ["/"] + // + // "+" -> Reduce(Term = "Num" => ActionFn(8);) + // "*" -> Reduce(Term = "Num" => ActionFn(8);) + // "-" -> Reduce(Term = "Num" => ActionFn(8);) + // "/" -> Reduce(Term = "Num" => ActionFn(8);) + // ")" -> Reduce(Term = "Num" => ActionFn(8);) + // + pub fn __state14< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + mut __lookahead: Option, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + ) -> Result<(Option, __Nonterminal<'ast, >), Option> + { + let mut __result: (Option, __Nonterminal<'ast, >); + match __lookahead { + Some(Tok::Plus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action8(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Term(__nt))); + } + Some(Tok::Times(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action8(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Term(__nt))); + } + Some(Tok::Minus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action8(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Term(__nt))); + } + Some(Tok::Div(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action8(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Term(__nt))); + } + Some(Tok::RParen(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action8(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Term(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + // State 15 - // Factor = Factor "*" (*) Term [EOF] - // Factor = Factor "*" (*) Term ["*"] - // Factor = Factor "*" (*) Term ["+"] - // Factor = Factor "*" (*) Term ["-"] - // Factor = Factor "*" (*) Term ["/"] + // 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 ")" ["+"] @@ -1071,10 +1031,12 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // + // "Num" -> Shift(S6) + // "*" -> Shift(S5) // "(" -> Shift(S3) - // "Num" -> Shift(S1) // - // Term -> S27 + // Factor -> S27 + // Term -> S2 pub fn __state15< 'ast, __TOKENS: Iterator, @@ -1088,16 +1050,21 @@ mod __parse__Expr { { let mut __result: (Option, __Nonterminal<'ast, >); match __lookahead { + Some(Tok::Num(__tok0)) => { + let mut __sym2 = &mut Some((__tok0)); + let __lookahead = __tokens.next(); + __result = try!(__state6(arena, __lookahead, __tokens, __sym2)); + } + Some(__tok @ Tok::Times(..)) => { + let mut __sym2 = &mut Some(__tok); + let __lookahead = __tokens.next(); + __result = try!(__state5(arena, __lookahead, __tokens, __sym2)); + } Some(__tok @ Tok::LParen(..)) => { let mut __sym2 = &mut Some(__tok); let __lookahead = __tokens.next(); __result = try!(__state3(arena, __lookahead, __tokens, __sym2)); } - Some(Tok::Num(__tok0)) => { - let mut __sym2 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state1(arena, __lookahead, __tokens, __sym2)); - } _ => { return Err(__lookahead); } @@ -1105,10 +1072,14 @@ mod __parse__Expr { while __sym1.is_some() { let (__lookahead, __nt) = __result; match __nt { - __Nonterminal::Term(__nt) => { + __Nonterminal::Factor(__nt) => { let __sym2 = &mut Some(__nt); __result = try!(__state27(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); } + __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state2(arena, __lookahead, __tokens, __sym2)); + } _ => { return Ok((__lookahead, __nt)); } @@ -1118,11 +1089,29 @@ mod __parse__Expr { } // State 16 - // Factor = Factor "/" (*) Term [EOF] - // Factor = Factor "/" (*) Term ["*"] - // Factor = Factor "/" (*) Term ["+"] - // Factor = Factor "/" (*) Term ["-"] - // Factor = Factor "/" (*) Term ["/"] + // 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 ")" ["+"] @@ -1135,9 +1124,11 @@ mod __parse__Expr { // Term = (*) "Num" ["/"] // // "(" -> Shift(S3) - // "Num" -> Shift(S1) + // "*" -> Shift(S5) + // "Num" -> Shift(S6) // - // Term -> S28 + // Term -> S2 + // Factor -> S28 pub fn __state16< 'ast, __TOKENS: Iterator, @@ -1156,10 +1147,15 @@ mod __parse__Expr { let __lookahead = __tokens.next(); __result = try!(__state3(arena, __lookahead, __tokens, __sym2)); } + Some(__tok @ Tok::Times(..)) => { + let mut __sym2 = &mut Some(__tok); + let __lookahead = __tokens.next(); + __result = try!(__state5(arena, __lookahead, __tokens, __sym2)); + } Some(Tok::Num(__tok0)) => { let mut __sym2 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state1(arena, __lookahead, __tokens, __sym2)); + __result = try!(__state6(arena, __lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); @@ -1169,6 +1165,10 @@ mod __parse__Expr { let (__lookahead, __nt) = __result; match __nt { __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state2(arena, __lookahead, __tokens, __sym2)); + } + __Nonterminal::Factor(__nt) => { let __sym2 = &mut Some(__nt); __result = try!(__state28(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); } @@ -1196,13 +1196,13 @@ mod __parse__Expr { // Factor = "*" "(" (*) Comma ")" ["-"] // Factor = "*" "(" (*) Comma ")" ["/"] // - // "*" -> Reduce(( ",")* = => ActionFn(13);) // "(" -> Reduce(( ",")* = => ActionFn(13);) - // "Num" -> Reduce(( ",")* = => ActionFn(13);) + // "*" -> Reduce(( ",")* = => ActionFn(13);) // ")" -> Reduce(( ",")* = => ActionFn(13);) + // "Num" -> Reduce(( ",")* = => ActionFn(13);) // - // Comma -> S30 // ( ",")* -> S29 + // Comma -> S30 pub fn __state17< 'ast, __TOKENS: Iterator, @@ -1216,15 +1216,11 @@ mod __parse__Expr { { let mut __result: (Option, __Nonterminal<'ast, >); match __lookahead { - Some(Tok::Times(..)) => { - let __nt = super::__actions::__action13(arena, ); - __result = (__lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); - } Some(Tok::LParen(..)) => { let __nt = super::__actions::__action13(arena, ); __result = (__lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); } - Some(Tok::Num(_)) => { + Some(Tok::Times(..)) => { let __nt = super::__actions::__action13(arena, ); __result = (__lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); } @@ -1232,6 +1228,10 @@ mod __parse__Expr { let __nt = super::__actions::__action13(arena, ); __result = (__lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); } + Some(Tok::Num(_)) => { + let __nt = super::__actions::__action13(arena, ); + __result = (__lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); + } _ => { return Err(__lookahead); } @@ -1239,14 +1239,14 @@ mod __parse__Expr { while __sym1.is_some() { let (__lookahead, __nt) = __result; match __nt { - __Nonterminal::Comma_3cExpr_3e(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state30(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt) => { let __sym2 = &mut Some(__nt); __result = try!(__state29(arena, __lookahead, __tokens, __sym2)); } + __Nonterminal::Comma_3cExpr_3e(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state30(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } _ => { return Ok((__lookahead, __nt)); } @@ -1256,25 +1256,17 @@ mod __parse__Expr { } // State 18 - // 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 (*) [EOF] + // Factor = Factor "*" Term (*) ["*"] + // Factor = Factor "*" Term (*) ["+"] + // Factor = Factor "*" Term (*) ["-"] + // Factor = Factor "*" Term (*) ["/"] // - // "/" -> Shift(S16) - // EOF -> Reduce(Expr = Expr, "-", Factor => ActionFn(1);) - // "+" -> Reduce(Expr = Expr, "-", Factor => ActionFn(1);) - // "*" -> Shift(S15) - // "-" -> Reduce(Expr = Expr, "-", Factor => ActionFn(1);) + // "-" -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) + // "*" -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) + // EOF -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) + // "/" -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) + // "+" -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) // pub fn __state18< 'ast, @@ -1290,64 +1282,59 @@ mod __parse__Expr { { let mut __result: (Option, __Nonterminal<'ast, >); match __lookahead { - Some(__tok @ Tok::Div(..)) => { - let mut __sym3 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state16(arena, __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::__actions::__action4(arena, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); } - Some(__tok @ Tok::Times(..)) => { - let mut __sym3 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state15(arena, __lookahead, __tokens, __sym2, __sym3)); + Some(Tok::Times(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action4(arena, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); } None => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action1(arena, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Expr(__nt))); + let __nt = super::__actions::__action4(arena, __sym0, __sym1, __sym2); + return Ok((__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::__actions::__action4(arena, __sym0, __sym1, __sym2); + return Ok((__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::__actions::__action1(arena, __sym0, __sym1, __sym2); - return Ok((__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::__actions::__action1(arena, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Expr(__nt))); + let __nt = super::__actions::__action4(arena, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); } _ => { return Err(__lookahead); } } - return Ok(__result); } // State 19 - // 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 (*) [EOF] + // Factor = Factor "/" Term (*) ["*"] + // Factor = Factor "/" Term (*) ["+"] + // Factor = Factor "/" Term (*) ["-"] + // Factor = Factor "/" Term (*) ["/"] // - // "+" -> Reduce(Expr = Expr, "+", Factor => ActionFn(2);) - // "/" -> Shift(S16) - // "-" -> Reduce(Expr = Expr, "+", Factor => ActionFn(2);) - // "*" -> Shift(S15) - // EOF -> Reduce(Expr = Expr, "+", Factor => ActionFn(2);) + // "/" -> Reduce(Factor = Factor, "/", Term => ActionFn(5);) + // "-" -> Reduce(Factor = Factor, "/", Term => ActionFn(5);) + // EOF -> Reduce(Factor = Factor, "/", Term => ActionFn(5);) + // "*" -> Reduce(Factor = Factor, "/", Term => ActionFn(5);) + // "+" -> Reduce(Factor = Factor, "/", Term => ActionFn(5);) // pub fn __state19< 'ast, @@ -1363,42 +1350,45 @@ mod __parse__Expr { { let mut __result: (Option, __Nonterminal<'ast, >); match __lookahead { - Some(__tok @ Tok::Div(..)) => { - let mut __sym3 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state16(arena, __lookahead, __tokens, __sym2, __sym3)); - } - Some(__tok @ Tok::Times(..)) => { - let mut __sym3 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state15(arena, __lookahead, __tokens, __sym2, __sym3)); - } - Some(Tok::Plus(..)) => { + Some(Tok::Div(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action2(arena, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Expr(__nt))); + let __nt = super::__actions::__action5(arena, __sym0, __sym1, __sym2); + return Ok((__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::__actions::__action2(arena, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Expr(__nt))); + let __nt = super::__actions::__action5(arena, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); } None => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action2(arena, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Expr(__nt))); + let __nt = super::__actions::__action5(arena, __sym0, __sym1, __sym2); + return Ok((__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::__actions::__action5(arena, __sym0, __sym1, __sym2); + return Ok((__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::__actions::__action5(arena, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); } _ => { return Err(__lookahead); } } - return Ok(__result); } // State 20 @@ -1417,13 +1407,13 @@ mod __parse__Expr { // Factor = "*" "(" (*) Comma ")" ["-"] // Factor = "*" "(" (*) Comma ")" ["/"] // + // "Num" -> Reduce(( ",")* = => ActionFn(13);) // ")" -> Reduce(( ",")* = => ActionFn(13);) // "(" -> Reduce(( ",")* = => ActionFn(13);) - // "Num" -> Reduce(( ",")* = => ActionFn(13);) // "*" -> Reduce(( ",")* = => ActionFn(13);) // - // Comma -> S31 // ( ",")* -> S29 + // Comma -> S31 pub fn __state20< 'ast, __TOKENS: Iterator, @@ -1437,6 +1427,10 @@ mod __parse__Expr { { let mut __result: (Option, __Nonterminal<'ast, >); match __lookahead { + Some(Tok::Num(_)) => { + let __nt = super::__actions::__action13(arena, ); + __result = (__lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); + } Some(Tok::RParen(..)) => { let __nt = super::__actions::__action13(arena, ); __result = (__lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); @@ -1445,10 +1439,6 @@ mod __parse__Expr { let __nt = super::__actions::__action13(arena, ); __result = (__lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); } - Some(Tok::Num(_)) => { - let __nt = super::__actions::__action13(arena, ); - __result = (__lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); - } Some(Tok::Times(..)) => { let __nt = super::__actions::__action13(arena, ); __result = (__lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); @@ -1460,14 +1450,14 @@ mod __parse__Expr { while __sym1.is_some() { let (__lookahead, __nt) = __result; match __nt { - __Nonterminal::Comma_3cExpr_3e(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state31(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt) => { let __sym2 = &mut Some(__nt); __result = try!(__state29(arena, __lookahead, __tokens, __sym2)); } + __Nonterminal::Comma_3cExpr_3e(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state31(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } _ => { return Ok((__lookahead, __nt)); } @@ -1493,8 +1483,8 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "(" -> Shift(S14) - // "Num" -> Shift(S12) + // "Num" -> Shift(S14) + // "(" -> Shift(S13) // // Term -> S32 pub fn __state21< @@ -1510,15 +1500,15 @@ mod __parse__Expr { { let mut __result: (Option, __Nonterminal<'ast, >); match __lookahead { - Some(__tok @ Tok::LParen(..)) => { - let mut __sym2 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state14(arena, __lookahead, __tokens, __sym2)); - } Some(Tok::Num(__tok0)) => { let mut __sym2 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state12(arena, __lookahead, __tokens, __sym2)); + __result = try!(__state14(arena, __lookahead, __tokens, __sym2)); + } + Some(__tok @ Tok::LParen(..)) => { + let mut __sym2 = &mut Some(__tok); + let __lookahead = __tokens.next(); + __result = try!(__state13(arena, __lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); @@ -1556,8 +1546,8 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "Num" -> Shift(S12) - // "(" -> Shift(S14) + // "Num" -> Shift(S14) + // "(" -> Shift(S13) // // Term -> S33 pub fn __state22< @@ -1576,12 +1566,12 @@ mod __parse__Expr { Some(Tok::Num(__tok0)) => { let mut __sym2 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state12(arena, __lookahead, __tokens, __sym2)); + __result = try!(__state14(arena, __lookahead, __tokens, __sym2)); } Some(__tok @ Tok::LParen(..)) => { let mut __sym2 = &mut Some(__tok); let __lookahead = __tokens.next(); - __result = try!(__state14(arena, __lookahead, __tokens, __sym2)); + __result = try!(__state13(arena, __lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); @@ -1603,98 +1593,6 @@ mod __parse__Expr { } // State 23 - // 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(S14) - // "*" -> Shift(S10) - // "Num" -> Shift(S12) - // - // Term -> S9 - // Factor -> S34 - pub fn __state23< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - mut __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> - { - let mut __result: (Option, __Nonterminal<'ast, >); - match __lookahead { - Some(__tok @ Tok::LParen(..)) => { - let mut __sym2 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state14(arena, __lookahead, __tokens, __sym2)); - } - Some(__tok @ Tok::Times(..)) => { - let mut __sym2 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state10(arena, __lookahead, __tokens, __sym2)); - } - Some(Tok::Num(__tok0)) => { - let mut __sym2 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state12(arena, __lookahead, __tokens, __sym2)); - } - _ => { - return Err(__lookahead); - } - } - while __sym1.is_some() { - let (__lookahead, __nt) = __result; - match __nt { - __Nonterminal::Term(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state9(arena, __lookahead, __tokens, __sym2)); - } - __Nonterminal::Factor(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state34(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - _ => { - return Ok((__lookahead, __nt)); - } - } - } - return Ok(__result); - } - - // State 24 // Expr = Expr "-" (*) Factor [")"] // Expr = Expr "-" (*) Factor ["+"] // Expr = Expr "-" (*) Factor ["-"] @@ -1729,15 +1627,175 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "*" -> Shift(S10) - // "(" -> Shift(S14) - // "Num" -> Shift(S12) + // "(" -> Shift(S13) + // "*" -> Shift(S9) + // "Num" -> Shift(S14) + // + // Factor -> S34 + // Term -> S12 + pub fn __state23< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + mut __lookahead: Option, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + __sym1: &mut Option, + ) -> Result<(Option, __Nonterminal<'ast, >), Option> + { + let mut __result: (Option, __Nonterminal<'ast, >); + match __lookahead { + Some(__tok @ Tok::LParen(..)) => { + let mut __sym2 = &mut Some(__tok); + let __lookahead = __tokens.next(); + __result = try!(__state13(arena, __lookahead, __tokens, __sym2)); + } + Some(__tok @ Tok::Times(..)) => { + let mut __sym2 = &mut Some(__tok); + let __lookahead = __tokens.next(); + __result = try!(__state9(arena, __lookahead, __tokens, __sym2)); + } + Some(Tok::Num(__tok0)) => { + let mut __sym2 = &mut Some((__tok0)); + let __lookahead = __tokens.next(); + __result = try!(__state14(arena, __lookahead, __tokens, __sym2)); + } + _ => { + return Err(__lookahead); + } + } + while __sym1.is_some() { + let (__lookahead, __nt) = __result; + match __nt { + __Nonterminal::Factor(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state34(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state12(arena, __lookahead, __tokens, __sym2)); + } + _ => { + return Ok((__lookahead, __nt)); + } + } + } + return Ok(__result); + } + + // State 24 + // Term = "(" Expr ")" (*) [EOF] + // Term = "(" Expr ")" (*) ["*"] + // Term = "(" Expr ")" (*) ["+"] + // Term = "(" Expr ")" (*) ["-"] + // Term = "(" Expr ")" (*) ["/"] + // + // "*" -> Reduce(Term = "(", Expr, ")" => ActionFn(9);) + // EOF -> Reduce(Term = "(", Expr, ")" => ActionFn(9);) + // "-" -> Reduce(Term = "(", Expr, ")" => ActionFn(9);) + // "/" -> Reduce(Term = "(", Expr, ")" => ActionFn(9);) + // "+" -> Reduce(Term = "(", Expr, ")" => ActionFn(9);) // - // Term -> S9 - // Factor -> S35 pub fn __state24< 'ast, __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + mut __lookahead: Option, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + __sym1: &mut Option<&'ast Node<'ast>>, + __sym2: &mut Option, + ) -> Result<(Option, __Nonterminal<'ast, >), Option> + { + let mut __result: (Option, __Nonterminal<'ast, >); + match __lookahead { + Some(Tok::Times(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action9(arena, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Term(__nt))); + } + None => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action9(arena, __sym0, __sym1, __sym2); + return Ok((__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::__actions::__action9(arena, __sym0, __sym1, __sym2); + return Ok((__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::__actions::__action9(arena, __sym0, __sym1, __sym2); + return Ok((__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::__actions::__action9(arena, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Term(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 25 + // 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(S9) + // "Num" -> Shift(S14) + // "(" -> Shift(S13) + // + // Factor -> S35 + // Term -> S12 + pub fn __state25< + 'ast, + __TOKENS: Iterator, >( arena: &'ast Arena<'ast>, mut __lookahead: Option, @@ -1751,17 +1809,17 @@ mod __parse__Expr { Some(__tok @ Tok::Times(..)) => { let mut __sym2 = &mut Some(__tok); let __lookahead = __tokens.next(); - __result = try!(__state10(arena, __lookahead, __tokens, __sym2)); - } - Some(__tok @ Tok::LParen(..)) => { - let mut __sym2 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state14(arena, __lookahead, __tokens, __sym2)); + __result = try!(__state9(arena, __lookahead, __tokens, __sym2)); } Some(Tok::Num(__tok0)) => { let mut __sym2 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state12(arena, __lookahead, __tokens, __sym2)); + __result = try!(__state14(arena, __lookahead, __tokens, __sym2)); + } + Some(__tok @ Tok::LParen(..)) => { + let mut __sym2 = &mut Some(__tok); + let __lookahead = __tokens.next(); + __result = try!(__state13(arena, __lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); @@ -1770,14 +1828,14 @@ mod __parse__Expr { while __sym1.is_some() { let (__lookahead, __nt) = __result; match __nt { - __Nonterminal::Term(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state9(arena, __lookahead, __tokens, __sym2)); - } __Nonterminal::Factor(__nt) => { let __sym2 = &mut Some(__nt); __result = try!(__state35(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); } + __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state12(arena, __lookahead, __tokens, __sym2)); + } _ => { return Ok((__lookahead, __nt)); } @@ -1786,74 +1844,6 @@ mod __parse__Expr { return Ok(__result); } - // State 25 - // Term = "(" Expr ")" (*) [EOF] - // Term = "(" Expr ")" (*) ["*"] - // Term = "(" Expr ")" (*) ["+"] - // Term = "(" Expr ")" (*) ["-"] - // Term = "(" Expr ")" (*) ["/"] - // - // "+" -> Reduce(Term = "(", Expr, ")" => ActionFn(9);) - // "/" -> Reduce(Term = "(", Expr, ")" => ActionFn(9);) - // EOF -> Reduce(Term = "(", Expr, ")" => ActionFn(9);) - // "-" -> Reduce(Term = "(", Expr, ")" => ActionFn(9);) - // "*" -> Reduce(Term = "(", Expr, ")" => ActionFn(9);) - // - pub fn __state25< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - mut __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option<&'ast Node<'ast>>, - __sym2: &mut Option, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> - { - let mut __result: (Option, __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::__actions::__action9(arena, __sym0, __sym1, __sym2); - return Ok((__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::__actions::__action9(arena, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Term(__nt))); - } - None => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action9(arena, __sym0, __sym1, __sym2); - return Ok((__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::__actions::__action9(arena, __sym0, __sym1, __sym2); - return Ok((__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::__actions::__action9(arena, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Term(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - // State 26 // Expr = Expr (*) "+" Factor [")"] // Expr = Expr (*) "+" Factor ["+"] @@ -1867,9 +1857,9 @@ mod __parse__Expr { // Term = "(" Expr (*) ")" ["-"] // Term = "(" Expr (*) ")" ["/"] // + // "-" -> Shift(S23) + // "+" -> Shift(S25) // ")" -> Shift(S36) - // "+" -> Shift(S23) - // "-" -> Shift(S24) // pub fn __state26< 'ast, @@ -1884,20 +1874,20 @@ mod __parse__Expr { { let mut __result: (Option, __Nonterminal<'ast, >); match __lookahead { - Some(__tok @ Tok::RParen(..)) => { - let mut __sym2 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state36(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - Some(__tok @ Tok::Plus(..)) => { + Some(__tok @ Tok::Minus(..)) => { let mut __sym2 = &mut Some(__tok); let __lookahead = __tokens.next(); __result = try!(__state23(arena, __lookahead, __tokens, __sym1, __sym2)); } - Some(__tok @ Tok::Minus(..)) => { + Some(__tok @ Tok::Plus(..)) => { let mut __sym2 = &mut Some(__tok); let __lookahead = __tokens.next(); - __result = try!(__state24(arena, __lookahead, __tokens, __sym1, __sym2)); + __result = try!(__state25(arena, __lookahead, __tokens, __sym1, __sym2)); + } + Some(__tok @ Tok::RParen(..)) => { + let mut __sym2 = &mut Some(__tok); + let __lookahead = __tokens.next(); + __result = try!(__state36(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); } _ => { return Err(__lookahead); @@ -1907,17 +1897,25 @@ mod __parse__Expr { } // State 27 - // Factor = Factor "*" Term (*) [EOF] - // Factor = Factor "*" Term (*) ["*"] - // Factor = Factor "*" Term (*) ["+"] - // Factor = Factor "*" Term (*) ["-"] - // Factor = Factor "*" Term (*) ["/"] + // 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(Factor = Factor, "*", Term => ActionFn(4);) - // "/" -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) - // "*" -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) - // "-" -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) - // "+" -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) + // "+" -> Reduce(Expr = Expr, "+", Factor => ActionFn(2);) + // "*" -> Shift(S7) + // "-" -> Reduce(Expr = Expr, "+", Factor => ActionFn(2);) + // EOF -> Reduce(Expr = Expr, "+", Factor => ActionFn(2);) + // "/" -> Shift(S8) // pub fn __state27< 'ast, @@ -1933,59 +1931,64 @@ mod __parse__Expr { { let mut __result: (Option, __Nonterminal<'ast, >); match __lookahead { - None => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); + Some(__tok @ Tok::Times(..)) => { + let mut __sym3 = &mut Some(__tok); + let __lookahead = __tokens.next(); + __result = try!(__state7(arena, __lookahead, __tokens, __sym2, __sym3)); } - Some(Tok::Div(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__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::__actions::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__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::__actions::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); + Some(__tok @ Tok::Div(..)) => { + let mut __sym3 = &mut Some(__tok); + let __lookahead = __tokens.next(); + __result = try!(__state8(arena, __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::__actions::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); + let __nt = super::__actions::__action2(arena, __sym0, __sym1, __sym2); + return Ok((__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::__actions::__action2(arena, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Expr(__nt))); + } + None => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action2(arena, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Expr(__nt))); } _ => { return Err(__lookahead); } } + return Ok(__result); } // State 28 - // Factor = Factor "/" Term (*) [EOF] - // Factor = Factor "/" Term (*) ["*"] - // Factor = Factor "/" Term (*) ["+"] - // Factor = Factor "/" Term (*) ["-"] - // Factor = Factor "/" Term (*) ["/"] + // 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(Factor = Factor, "/", Term => ActionFn(5);) - // "+" -> Reduce(Factor = Factor, "/", Term => ActionFn(5);) - // "*" -> Reduce(Factor = Factor, "/", Term => ActionFn(5);) - // EOF -> Reduce(Factor = Factor, "/", Term => ActionFn(5);) - // "-" -> Reduce(Factor = Factor, "/", Term => ActionFn(5);) + // "-" -> Reduce(Expr = Expr, "-", Factor => ActionFn(1);) + // "+" -> Reduce(Expr = Expr, "-", Factor => ActionFn(1);) + // EOF -> Reduce(Expr = Expr, "-", Factor => ActionFn(1);) + // "*" -> Shift(S7) + // "/" -> Shift(S8) // pub fn __state28< 'ast, @@ -2001,45 +2004,42 @@ mod __parse__Expr { { let mut __result: (Option, __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::__actions::__action5(arena, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); + Some(__tok @ Tok::Times(..)) => { + let mut __sym3 = &mut Some(__tok); + let __lookahead = __tokens.next(); + __result = try!(__state7(arena, __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::__actions::__action5(arena, __sym0, __sym1, __sym2); - return Ok((__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::__actions::__action5(arena, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - None => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action5(arena, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); + Some(__tok @ Tok::Div(..)) => { + let mut __sym3 = &mut Some(__tok); + let __lookahead = __tokens.next(); + __result = try!(__state8(arena, __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::__actions::__action5(arena, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); + let __nt = super::__actions::__action1(arena, __sym0, __sym1, __sym2); + return Ok((__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::__actions::__action1(arena, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Expr(__nt))); + } + None => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action1(arena, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Expr(__nt))); } _ => { return Err(__lookahead); } } + return Ok(__result); } // State 29 @@ -2103,16 +2103,16 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "*" -> Shift(S37) - // "Num" -> Shift(S42) + // "Num" -> Shift(S44) + // "*" -> Shift(S41) + // "(" -> Shift(S37) // ")" -> Reduce(Expr? = => ActionFn(12);) - // "(" -> Shift(S44) // - // Term -> S41 - // Expr -> S39 + // Term -> S39 // ( ",") -> S40 - // Expr? -> S43 + // Expr? -> S42 // Factor -> S38 + // Expr -> S43 pub fn __state29< 'ast, __TOKENS: Iterator, @@ -2125,20 +2125,20 @@ mod __parse__Expr { { let mut __result: (Option, __Nonterminal<'ast, >); match __lookahead { - Some(__tok @ Tok::Times(..)) => { - let mut __sym1 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state37(arena, __lookahead, __tokens, __sym1)); - } Some(Tok::Num(__tok0)) => { let mut __sym1 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state42(arena, __lookahead, __tokens, __sym1)); + __result = try!(__state44(arena, __lookahead, __tokens, __sym1)); + } + Some(__tok @ Tok::Times(..)) => { + let mut __sym1 = &mut Some(__tok); + let __lookahead = __tokens.next(); + __result = try!(__state41(arena, __lookahead, __tokens, __sym1)); } Some(__tok @ Tok::LParen(..)) => { let mut __sym1 = &mut Some(__tok); let __lookahead = __tokens.next(); - __result = try!(__state44(arena, __lookahead, __tokens, __sym1)); + __result = try!(__state37(arena, __lookahead, __tokens, __sym1)); } Some(Tok::RParen(..)) => { let __nt = super::__actions::__action12(arena, ); @@ -2152,10 +2152,6 @@ mod __parse__Expr { let (__lookahead, __nt) = __result; match __nt { __Nonterminal::Term(__nt) => { - let __sym1 = &mut Some(__nt); - __result = try!(__state41(arena, __lookahead, __tokens, __sym1)); - } - __Nonterminal::Expr(__nt) => { let __sym1 = &mut Some(__nt); __result = try!(__state39(arena, __lookahead, __tokens, __sym1)); } @@ -2165,12 +2161,16 @@ mod __parse__Expr { } __Nonterminal::Expr_3f(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state43(arena, __lookahead, __tokens, __sym0, __sym1)); + __result = try!(__state42(arena, __lookahead, __tokens, __sym0, __sym1)); } __Nonterminal::Factor(__nt) => { let __sym1 = &mut Some(__nt); __result = try!(__state38(arena, __lookahead, __tokens, __sym1)); } + __Nonterminal::Expr(__nt) => { + let __sym1 = &mut Some(__nt); + __result = try!(__state43(arena, __lookahead, __tokens, __sym1)); + } _ => { return Ok((__lookahead, __nt)); } @@ -2256,11 +2256,11 @@ mod __parse__Expr { // Factor = Factor "/" Term (*) ["-"] // Factor = Factor "/" Term (*) ["/"] // - // "*" -> Reduce(Factor = Factor, "/", Term => ActionFn(5);) - // "/" -> Reduce(Factor = Factor, "/", Term => ActionFn(5);) - // ")" -> Reduce(Factor = Factor, "/", Term => ActionFn(5);) // "-" -> Reduce(Factor = Factor, "/", Term => ActionFn(5);) + // ")" -> Reduce(Factor = Factor, "/", Term => ActionFn(5);) + // "/" -> Reduce(Factor = Factor, "/", Term => ActionFn(5);) // "+" -> Reduce(Factor = Factor, "/", Term => ActionFn(5);) + // "*" -> Reduce(Factor = Factor, "/", Term => ActionFn(5);) // pub fn __state32< 'ast, @@ -2276,14 +2276,7 @@ mod __parse__Expr { { let mut __result: (Option, __Nonterminal<'ast, >); match __lookahead { - Some(Tok::Times(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action5(arena, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Div(..)) => { + Some(Tok::Minus(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); @@ -2297,7 +2290,7 @@ mod __parse__Expr { let __nt = super::__actions::__action5(arena, __sym0, __sym1, __sym2); return Ok((__lookahead, __Nonterminal::Factor(__nt))); } - Some(Tok::Minus(..)) => { + Some(Tok::Div(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); @@ -2311,6 +2304,13 @@ mod __parse__Expr { let __nt = super::__actions::__action5(arena, __sym0, __sym1, __sym2); return Ok((__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::__actions::__action5(arena, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } _ => { return Err(__lookahead); } @@ -2324,11 +2324,11 @@ mod __parse__Expr { // Factor = Factor "*" Term (*) ["-"] // Factor = Factor "*" Term (*) ["/"] // - // "+" -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) // "-" -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) - // "/" -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) // "*" -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) + // "+" -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) // ")" -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) + // "/" -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) // pub fn __state33< 'ast, @@ -2344,13 +2344,6 @@ mod __parse__Expr { { let mut __result: (Option, __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::__actions::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } Some(Tok::Minus(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); @@ -2358,13 +2351,6 @@ mod __parse__Expr { let __nt = super::__actions::__action4(arena, __sym0, __sym1, __sym2); return Ok((__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::__actions::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } Some(Tok::Times(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); @@ -2372,6 +2358,13 @@ mod __parse__Expr { let __nt = super::__actions::__action4(arena, __sym0, __sym1, __sym2); return Ok((__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::__actions::__action4(arena, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } Some(Tok::RParen(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); @@ -2379,6 +2372,13 @@ mod __parse__Expr { let __nt = super::__actions::__action4(arena, __sym0, __sym1, __sym2); return Ok((__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::__actions::__action4(arena, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } _ => { return Err(__lookahead); } @@ -2386,9 +2386,9 @@ mod __parse__Expr { } // State 34 - // Expr = Expr "+" Factor (*) [")"] - // Expr = Expr "+" Factor (*) ["+"] - // Expr = Expr "+" Factor (*) ["-"] + // Expr = Expr "-" Factor (*) [")"] + // Expr = Expr "-" Factor (*) ["+"] + // Expr = Expr "-" Factor (*) ["-"] // Factor = Factor (*) "*" Term [")"] // Factor = Factor (*) "*" Term ["*"] // Factor = Factor (*) "*" Term ["+"] @@ -2400,11 +2400,11 @@ mod __parse__Expr { // Factor = Factor (*) "/" Term ["-"] // Factor = Factor (*) "/" Term ["/"] // + // "+" -> Reduce(Expr = Expr, "-", Factor => ActionFn(1);) // "*" -> Shift(S22) - // "-" -> Reduce(Expr = Expr, "+", Factor => ActionFn(2);) - // ")" -> Reduce(Expr = Expr, "+", Factor => ActionFn(2);) + // "-" -> Reduce(Expr = Expr, "-", Factor => ActionFn(1);) + // ")" -> Reduce(Expr = Expr, "-", Factor => ActionFn(1);) // "/" -> Shift(S21) - // "+" -> Reduce(Expr = Expr, "+", Factor => ActionFn(2);) // pub fn __state34< 'ast, @@ -2430,25 +2430,25 @@ mod __parse__Expr { let __lookahead = __tokens.next(); __result = try!(__state21(arena, __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::__actions::__action1(arena, __sym0, __sym1, __sym2); + return Ok((__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::__actions::__action2(arena, __sym0, __sym1, __sym2); + let __nt = super::__actions::__action1(arena, __sym0, __sym1, __sym2); return Ok((__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::__actions::__action2(arena, __sym0, __sym1, __sym2); - return Ok((__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::__actions::__action2(arena, __sym0, __sym1, __sym2); + let __nt = super::__actions::__action1(arena, __sym0, __sym1, __sym2); return Ok((__lookahead, __Nonterminal::Expr(__nt))); } _ => { @@ -2459,9 +2459,9 @@ mod __parse__Expr { } // State 35 - // Expr = Expr "-" Factor (*) [")"] - // Expr = Expr "-" Factor (*) ["+"] - // Expr = Expr "-" Factor (*) ["-"] + // Expr = Expr "+" Factor (*) [")"] + // Expr = Expr "+" Factor (*) ["+"] + // Expr = Expr "+" Factor (*) ["-"] // Factor = Factor (*) "*" Term [")"] // Factor = Factor (*) "*" Term ["*"] // Factor = Factor (*) "*" Term ["+"] @@ -2474,10 +2474,10 @@ mod __parse__Expr { // Factor = Factor (*) "/" Term ["/"] // // "/" -> Shift(S21) + // "+" -> Reduce(Expr = Expr, "+", Factor => ActionFn(2);) + // "-" -> Reduce(Expr = Expr, "+", Factor => ActionFn(2);) // "*" -> Shift(S22) - // "+" -> Reduce(Expr = Expr, "-", Factor => ActionFn(1);) - // ")" -> Reduce(Expr = Expr, "-", Factor => ActionFn(1);) - // "-" -> Reduce(Expr = Expr, "-", Factor => ActionFn(1);) + // ")" -> Reduce(Expr = Expr, "+", Factor => ActionFn(2);) // pub fn __state35< 'ast, @@ -2507,21 +2507,21 @@ mod __parse__Expr { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action1(arena, __sym0, __sym1, __sym2); - return Ok((__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::__actions::__action1(arena, __sym0, __sym1, __sym2); + let __nt = super::__actions::__action2(arena, __sym0, __sym1, __sym2); return Ok((__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::__actions::__action1(arena, __sym0, __sym1, __sym2); + let __nt = super::__actions::__action2(arena, __sym0, __sym1, __sym2); + return Ok((__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::__actions::__action2(arena, __sym0, __sym1, __sym2); return Ok((__lookahead, __Nonterminal::Expr(__nt))); } _ => { @@ -2539,10 +2539,10 @@ mod __parse__Expr { // Term = "(" Expr ")" (*) ["/"] // // ")" -> Reduce(Term = "(", Expr, ")" => ActionFn(9);) - // "-" -> Reduce(Term = "(", Expr, ")" => ActionFn(9);) // "/" -> Reduce(Term = "(", Expr, ")" => ActionFn(9);) - // "+" -> Reduce(Term = "(", Expr, ")" => ActionFn(9);) // "*" -> Reduce(Term = "(", Expr, ")" => ActionFn(9);) + // "+" -> Reduce(Term = "(", Expr, ")" => ActionFn(9);) + // "-" -> Reduce(Term = "(", Expr, ")" => ActionFn(9);) // pub fn __state36< 'ast, @@ -2565,14 +2565,14 @@ mod __parse__Expr { let __nt = super::__actions::__action9(arena, __sym0, __sym1, __sym2); return Ok((__lookahead, __Nonterminal::Term(__nt))); } - Some(Tok::Minus(..)) => { + Some(Tok::Div(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); let __nt = super::__actions::__action9(arena, __sym0, __sym1, __sym2); return Ok((__lookahead, __Nonterminal::Term(__nt))); } - Some(Tok::Div(..)) => { + Some(Tok::Times(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); @@ -2586,7 +2586,7 @@ mod __parse__Expr { let __nt = super::__actions::__action9(arena, __sym0, __sym1, __sym2); return Ok((__lookahead, __Nonterminal::Term(__nt))); } - Some(Tok::Times(..)) => { + Some(Tok::Minus(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); @@ -2600,383 +2600,6 @@ mod __parse__Expr { } // State 37 - // Factor = "*" (*) "(" Comma ")" [")"] - // Factor = "*" (*) "(" Comma ")" ["*"] - // Factor = "*" (*) "(" Comma ")" ["+"] - // Factor = "*" (*) "(" Comma ")" [","] - // Factor = "*" (*) "(" Comma ")" ["-"] - // Factor = "*" (*) "(" Comma ")" ["/"] - // - // "(" -> Shift(S47) - // - pub fn __state37< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - mut __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> - { - let mut __result: (Option, __Nonterminal<'ast, >); - match __lookahead { - Some(__tok @ Tok::LParen(..)) => { - let mut __sym1 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state47(arena, __lookahead, __tokens, __sym0, __sym1)); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // 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 => ActionFn(3);) - // "," -> Reduce(Expr = Factor => ActionFn(3);) - // "*" -> Shift(S48) - // "/" -> Shift(S49) - // ")" -> Reduce(Expr = Factor => ActionFn(3);) - // "-" -> Reduce(Expr = Factor => ActionFn(3);) - // - pub fn __state38< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - mut __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> - { - let mut __result: (Option, __Nonterminal<'ast, >); - match __lookahead { - Some(__tok @ Tok::Times(..)) => { - let mut __sym1 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state48(arena, __lookahead, __tokens, __sym0, __sym1)); - } - Some(__tok @ Tok::Div(..)) => { - let mut __sym1 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state49(arena, __lookahead, __tokens, __sym0, __sym1)); - } - Some(Tok::Plus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action3(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Expr(__nt))); - } - Some(Tok::Comma(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action3(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Expr(__nt))); - } - Some(Tok::RParen(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action3(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Expr(__nt))); - } - Some(Tok::Minus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action3(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Expr(__nt))); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 39 - // ( ",") = 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(S51) - // ")" -> Reduce(Expr? = Expr => ActionFn(11);) - // "+" -> Shift(S50) - // "-" -> Shift(S52) - // - pub fn __state39< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - mut __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> - { - let mut __result: (Option, __Nonterminal<'ast, >); - match __lookahead { - Some(__tok @ Tok::Comma(..)) => { - let mut __sym1 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state51(arena, __lookahead, __tokens, __sym0, __sym1)); - } - Some(__tok @ Tok::Plus(..)) => { - let mut __sym1 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state50(arena, __lookahead, __tokens, __sym0, __sym1)); - } - Some(__tok @ Tok::Minus(..)) => { - let mut __sym1 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state52(arena, __lookahead, __tokens, __sym0, __sym1)); - } - Some(Tok::RParen(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action11(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Expr_3f(__nt))); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 40 - // ( ",")* = ( ",")* ( ",") (*) ["("] - // ( ",")* = ( ",")* ( ",") (*) [")"] - // ( ",")* = ( ",")* ( ",") (*) ["*"] - // ( ",")* = ( ",")* ( ",") (*) ["Num"] - // - // "Num" -> Reduce(( ",")* = ( ",")*, ( ",") => ActionFn(14);) - // ")" -> Reduce(( ",")* = ( ",")*, ( ",") => ActionFn(14);) - // "(" -> Reduce(( ",")* = ( ",")*, ( ",") => ActionFn(14);) - // "*" -> Reduce(( ",")* = ( ",")*, ( ",") => ActionFn(14);) - // - pub fn __state40< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - mut __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option<::std::vec::Vec<&'ast Node<'ast>>>, - __sym1: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> - { - let mut __result: (Option, __Nonterminal<'ast, >); - match __lookahead { - Some(Tok::Num(_)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __nt = super::__actions::__action14(arena, __sym0, __sym1); - return Ok((__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 __nt = super::__actions::__action14(arena, __sym0, __sym1); - return Ok((__lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt))); - } - Some(Tok::LParen(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __nt = super::__actions::__action14(arena, __sym0, __sym1); - return Ok((__lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt))); - } - Some(Tok::Times(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __nt = super::__actions::__action14(arena, __sym0, __sym1); - return Ok((__lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 41 - // Factor = Term (*) [")"] - // Factor = Term (*) ["*"] - // Factor = Term (*) ["+"] - // Factor = Term (*) [","] - // Factor = Term (*) ["-"] - // Factor = Term (*) ["/"] - // - // ")" -> Reduce(Factor = Term => ActionFn(7);) - // "," -> Reduce(Factor = Term => ActionFn(7);) - // "/" -> Reduce(Factor = Term => ActionFn(7);) - // "*" -> Reduce(Factor = Term => ActionFn(7);) - // "-" -> Reduce(Factor = Term => ActionFn(7);) - // "+" -> Reduce(Factor = Term => ActionFn(7);) - // - pub fn __state41< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - mut __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> - { - let mut __result: (Option, __Nonterminal<'ast, >); - match __lookahead { - Some(Tok::RParen(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Comma(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Div(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Times(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Minus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Plus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 42 - // Term = "Num" (*) [")"] - // Term = "Num" (*) ["*"] - // Term = "Num" (*) ["+"] - // Term = "Num" (*) [","] - // Term = "Num" (*) ["-"] - // Term = "Num" (*) ["/"] - // - // "-" -> Reduce(Term = "Num" => ActionFn(8);) - // "*" -> Reduce(Term = "Num" => ActionFn(8);) - // ")" -> Reduce(Term = "Num" => ActionFn(8);) - // "/" -> Reduce(Term = "Num" => ActionFn(8);) - // "+" -> Reduce(Term = "Num" => ActionFn(8);) - // "," -> Reduce(Term = "Num" => ActionFn(8);) - // - pub fn __state42< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - mut __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> - { - let mut __result: (Option, __Nonterminal<'ast, >); - match __lookahead { - Some(Tok::Minus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action8(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Term(__nt))); - } - Some(Tok::Times(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action8(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Term(__nt))); - } - Some(Tok::RParen(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action8(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Term(__nt))); - } - Some(Tok::Div(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action8(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Term(__nt))); - } - Some(Tok::Plus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action8(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Term(__nt))); - } - Some(Tok::Comma(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action8(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Term(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 43 - // Comma = ( ",")* Expr? (*) [")"] - // - // ")" -> Reduce(Comma = ( ",")*, Expr? => ActionFn(10);) - // - pub fn __state43< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - mut __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option<::std::vec::Vec<&'ast Node<'ast>>>, - __sym1: &mut Option<::std::option::Option<&'ast Node<'ast>>>, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> - { - let mut __result: (Option, __Nonterminal<'ast, >); - match __lookahead { - Some(Tok::RParen(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __nt = super::__actions::__action10(arena, __sym0, __sym1); - return Ok((__lookahead, __Nonterminal::Comma_3cExpr_3e(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 44 // Expr = (*) Expr "+" Factor [")"] // Expr = (*) Expr "+" Factor ["+"] // Expr = (*) Expr "+" Factor ["-"] @@ -3023,14 +2646,14 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "*" -> Shift(S10) - // "Num" -> Shift(S12) - // "(" -> Shift(S14) + // "*" -> Shift(S9) + // "(" -> Shift(S13) + // "Num" -> Shift(S14) // - // Factor -> S11 - // Expr -> S53 - // Term -> S9 - pub fn __state44< + // Term -> S12 + // Expr -> S47 + // Factor -> S10 + pub fn __state37< 'ast, __TOKENS: Iterator, >( @@ -3045,16 +2668,16 @@ mod __parse__Expr { Some(__tok @ Tok::Times(..)) => { let mut __sym1 = &mut Some(__tok); let __lookahead = __tokens.next(); - __result = try!(__state10(arena, __lookahead, __tokens, __sym1)); - } - Some(Tok::Num(__tok0)) => { - let mut __sym1 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state12(arena, __lookahead, __tokens, __sym1)); + __result = try!(__state9(arena, __lookahead, __tokens, __sym1)); } Some(__tok @ Tok::LParen(..)) => { let mut __sym1 = &mut Some(__tok); let __lookahead = __tokens.next(); + __result = try!(__state13(arena, __lookahead, __tokens, __sym1)); + } + Some(Tok::Num(__tok0)) => { + let mut __sym1 = &mut Some((__tok0)); + let __lookahead = __tokens.next(); __result = try!(__state14(arena, __lookahead, __tokens, __sym1)); } _ => { @@ -3064,17 +2687,17 @@ mod __parse__Expr { while __sym0.is_some() { let (__lookahead, __nt) = __result; match __nt { - __Nonterminal::Factor(__nt) => { + __Nonterminal::Term(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state11(arena, __lookahead, __tokens, __sym1)); + __result = try!(__state12(arena, __lookahead, __tokens, __sym1)); } __Nonterminal::Expr(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state53(arena, __lookahead, __tokens, __sym0, __sym1)); + __result = try!(__state47(arena, __lookahead, __tokens, __sym0, __sym1)); } - __Nonterminal::Term(__nt) => { + __Nonterminal::Factor(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state9(arena, __lookahead, __tokens, __sym1)); + __result = try!(__state10(arena, __lookahead, __tokens, __sym1)); } _ => { return Ok((__lookahead, __nt)); @@ -3084,6 +2707,383 @@ mod __parse__Expr { return Ok(__result); } + // 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 ["/"] + // + // "/" -> Shift(S48) + // "," -> Reduce(Expr = Factor => ActionFn(3);) + // "*" -> Shift(S49) + // "+" -> Reduce(Expr = Factor => ActionFn(3);) + // "-" -> Reduce(Expr = Factor => ActionFn(3);) + // ")" -> Reduce(Expr = Factor => ActionFn(3);) + // + pub fn __state38< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + mut __lookahead: Option, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + ) -> Result<(Option, __Nonterminal<'ast, >), Option> + { + let mut __result: (Option, __Nonterminal<'ast, >); + match __lookahead { + Some(__tok @ Tok::Div(..)) => { + let mut __sym1 = &mut Some(__tok); + let __lookahead = __tokens.next(); + __result = try!(__state48(arena, __lookahead, __tokens, __sym0, __sym1)); + } + Some(__tok @ Tok::Times(..)) => { + let mut __sym1 = &mut Some(__tok); + let __lookahead = __tokens.next(); + __result = try!(__state49(arena, __lookahead, __tokens, __sym0, __sym1)); + } + Some(Tok::Comma(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action3(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Expr(__nt))); + } + Some(Tok::Plus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action3(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Expr(__nt))); + } + Some(Tok::Minus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action3(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Expr(__nt))); + } + Some(Tok::RParen(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action3(arena, __sym0); + return Ok((__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 => ActionFn(7);) + // "," -> Reduce(Factor = Term => ActionFn(7);) + // "-" -> Reduce(Factor = Term => ActionFn(7);) + // "+" -> Reduce(Factor = Term => ActionFn(7);) + // ")" -> Reduce(Factor = Term => ActionFn(7);) + // "*" -> Reduce(Factor = Term => ActionFn(7);) + // + pub fn __state39< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + mut __lookahead: Option, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + ) -> Result<(Option, __Nonterminal<'ast, >), Option> + { + let mut __result: (Option, __Nonterminal<'ast, >); + match __lookahead { + Some(Tok::Div(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action7(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + Some(Tok::Comma(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action7(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + Some(Tok::Minus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action7(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + Some(Tok::Plus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action7(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + Some(Tok::RParen(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action7(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + Some(Tok::Times(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action7(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 40 + // ( ",")* = ( ",")* ( ",") (*) ["("] + // ( ",")* = ( ",")* ( ",") (*) [")"] + // ( ",")* = ( ",")* ( ",") (*) ["*"] + // ( ",")* = ( ",")* ( ",") (*) ["Num"] + // + // "(" -> Reduce(( ",")* = ( ",")*, ( ",") => ActionFn(14);) + // "*" -> Reduce(( ",")* = ( ",")*, ( ",") => ActionFn(14);) + // ")" -> Reduce(( ",")* = ( ",")*, ( ",") => ActionFn(14);) + // "Num" -> Reduce(( ",")* = ( ",")*, ( ",") => ActionFn(14);) + // + pub fn __state40< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + mut __lookahead: Option, + __tokens: &mut __TOKENS, + __sym0: &mut Option<::std::vec::Vec<&'ast Node<'ast>>>, + __sym1: &mut Option<&'ast Node<'ast>>, + ) -> Result<(Option, __Nonterminal<'ast, >), Option> + { + let mut __result: (Option, __Nonterminal<'ast, >); + match __lookahead { + Some(Tok::LParen(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __nt = super::__actions::__action14(arena, __sym0, __sym1); + return Ok((__lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt))); + } + Some(Tok::Times(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __nt = super::__actions::__action14(arena, __sym0, __sym1); + return Ok((__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 __nt = super::__actions::__action14(arena, __sym0, __sym1); + return Ok((__lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt))); + } + Some(Tok::Num(_)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __nt = super::__actions::__action14(arena, __sym0, __sym1); + return Ok((__lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 41 + // Factor = "*" (*) "(" Comma ")" [")"] + // Factor = "*" (*) "(" Comma ")" ["*"] + // Factor = "*" (*) "(" Comma ")" ["+"] + // Factor = "*" (*) "(" Comma ")" [","] + // Factor = "*" (*) "(" Comma ")" ["-"] + // Factor = "*" (*) "(" Comma ")" ["/"] + // + // "(" -> Shift(S50) + // + pub fn __state41< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + mut __lookahead: Option, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + ) -> Result<(Option, __Nonterminal<'ast, >), Option> + { + let mut __result: (Option, __Nonterminal<'ast, >); + match __lookahead { + Some(__tok @ Tok::LParen(..)) => { + let mut __sym1 = &mut Some(__tok); + let __lookahead = __tokens.next(); + __result = try!(__state50(arena, __lookahead, __tokens, __sym0, __sym1)); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + + // State 42 + // Comma = ( ",")* Expr? (*) [")"] + // + // ")" -> Reduce(Comma = ( ",")*, Expr? => ActionFn(10);) + // + pub fn __state42< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + mut __lookahead: Option, + __tokens: &mut __TOKENS, + __sym0: &mut Option<::std::vec::Vec<&'ast Node<'ast>>>, + __sym1: &mut Option<::std::option::Option<&'ast Node<'ast>>>, + ) -> Result<(Option, __Nonterminal<'ast, >), Option> + { + let mut __result: (Option, __Nonterminal<'ast, >); + match __lookahead { + Some(Tok::RParen(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __nt = super::__actions::__action10(arena, __sym0, __sym1); + return Ok((__lookahead, __Nonterminal::Comma_3cExpr_3e(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 43 + // ( ",") = 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(S52) + // "," -> Shift(S53) + // ")" -> Reduce(Expr? = Expr => ActionFn(11);) + // "+" -> Shift(S51) + // + pub fn __state43< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + mut __lookahead: Option, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + ) -> Result<(Option, __Nonterminal<'ast, >), Option> + { + let mut __result: (Option, __Nonterminal<'ast, >); + match __lookahead { + Some(__tok @ Tok::Minus(..)) => { + let mut __sym1 = &mut Some(__tok); + let __lookahead = __tokens.next(); + __result = try!(__state52(arena, __lookahead, __tokens, __sym0, __sym1)); + } + Some(__tok @ Tok::Comma(..)) => { + let mut __sym1 = &mut Some(__tok); + let __lookahead = __tokens.next(); + __result = try!(__state53(arena, __lookahead, __tokens, __sym0, __sym1)); + } + Some(__tok @ Tok::Plus(..)) => { + let mut __sym1 = &mut Some(__tok); + let __lookahead = __tokens.next(); + __result = try!(__state51(arena, __lookahead, __tokens, __sym0, __sym1)); + } + Some(Tok::RParen(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action11(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Expr_3f(__nt))); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + + // State 44 + // Term = "Num" (*) [")"] + // Term = "Num" (*) ["*"] + // Term = "Num" (*) ["+"] + // Term = "Num" (*) [","] + // Term = "Num" (*) ["-"] + // Term = "Num" (*) ["/"] + // + // "," -> Reduce(Term = "Num" => ActionFn(8);) + // "-" -> Reduce(Term = "Num" => ActionFn(8);) + // "*" -> Reduce(Term = "Num" => ActionFn(8);) + // ")" -> Reduce(Term = "Num" => ActionFn(8);) + // "+" -> Reduce(Term = "Num" => ActionFn(8);) + // "/" -> Reduce(Term = "Num" => ActionFn(8);) + // + pub fn __state44< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + mut __lookahead: Option, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + ) -> Result<(Option, __Nonterminal<'ast, >), Option> + { + let mut __result: (Option, __Nonterminal<'ast, >); + match __lookahead { + Some(Tok::Comma(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action8(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Term(__nt))); + } + Some(Tok::Minus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action8(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Term(__nt))); + } + Some(Tok::Times(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action8(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Term(__nt))); + } + Some(Tok::RParen(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action8(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Term(__nt))); + } + Some(Tok::Plus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action8(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Term(__nt))); + } + Some(Tok::Div(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action8(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Term(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + // State 45 // Factor = "*" "(" Comma ")" (*) [EOF] // Factor = "*" "(" Comma ")" (*) ["*"] @@ -3091,11 +3091,11 @@ mod __parse__Expr { // Factor = "*" "(" Comma ")" (*) ["-"] // Factor = "*" "(" Comma ")" (*) ["/"] // - // EOF -> Reduce(Factor = "*", "(", Comma, ")" => ActionFn(6);) - // "-" -> Reduce(Factor = "*", "(", Comma, ")" => ActionFn(6);) - // "+" -> Reduce(Factor = "*", "(", Comma, ")" => ActionFn(6);) - // "/" -> Reduce(Factor = "*", "(", Comma, ")" => ActionFn(6);) // "*" -> Reduce(Factor = "*", "(", Comma, ")" => ActionFn(6);) + // "/" -> Reduce(Factor = "*", "(", Comma, ")" => ActionFn(6);) + // "-" -> Reduce(Factor = "*", "(", Comma, ")" => ActionFn(6);) + // EOF -> Reduce(Factor = "*", "(", Comma, ")" => ActionFn(6);) + // "+" -> Reduce(Factor = "*", "(", Comma, ")" => ActionFn(6);) // pub fn __state45< 'ast, @@ -3112,23 +3112,7 @@ mod __parse__Expr { { let mut __result: (Option, __Nonterminal<'ast, >); match __lookahead { - None => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __sym3 = __sym3.take().unwrap(); - let __nt = super::__actions::__action6(arena, __sym0, __sym1, __sym2, __sym3); - return Ok((__lookahead, __Nonterminal::Factor(__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::__actions::__action6(arena, __sym0, __sym1, __sym2, __sym3); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Plus(..)) => { + Some(Tok::Times(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); @@ -3144,7 +3128,23 @@ mod __parse__Expr { let __nt = super::__actions::__action6(arena, __sym0, __sym1, __sym2, __sym3); return Ok((__lookahead, __Nonterminal::Factor(__nt))); } - Some(Tok::Times(..)) => { + 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::__actions::__action6(arena, __sym0, __sym1, __sym2, __sym3); + return Ok((__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::__actions::__action6(arena, __sym0, __sym1, __sym2, __sym3); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + Some(Tok::Plus(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); @@ -3165,11 +3165,11 @@ mod __parse__Expr { // Factor = "*" "(" Comma ")" (*) ["-"] // Factor = "*" "(" Comma ")" (*) ["/"] // - // ")" -> Reduce(Factor = "*", "(", Comma, ")" => ActionFn(6);) - // "+" -> Reduce(Factor = "*", "(", Comma, ")" => ActionFn(6);) // "-" -> Reduce(Factor = "*", "(", Comma, ")" => ActionFn(6);) - // "/" -> Reduce(Factor = "*", "(", Comma, ")" => ActionFn(6);) // "*" -> Reduce(Factor = "*", "(", Comma, ")" => ActionFn(6);) + // "+" -> Reduce(Factor = "*", "(", Comma, ")" => ActionFn(6);) + // ")" -> Reduce(Factor = "*", "(", Comma, ")" => ActionFn(6);) + // "/" -> Reduce(Factor = "*", "(", Comma, ")" => ActionFn(6);) // pub fn __state46< 'ast, @@ -3186,7 +3186,15 @@ mod __parse__Expr { { let mut __result: (Option, __Nonterminal<'ast, >); match __lookahead { - Some(Tok::RParen(..)) => { + 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::__actions::__action6(arena, __sym0, __sym1, __sym2, __sym3); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + Some(Tok::Times(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); @@ -3202,7 +3210,7 @@ mod __parse__Expr { let __nt = super::__actions::__action6(arena, __sym0, __sym1, __sym2, __sym3); return Ok((__lookahead, __Nonterminal::Factor(__nt))); } - Some(Tok::Minus(..)) => { + Some(Tok::RParen(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); @@ -3218,14 +3226,6 @@ mod __parse__Expr { let __nt = super::__actions::__action6(arena, __sym0, __sym1, __sym2, __sym3); return Ok((__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::__actions::__action6(arena, __sym0, __sym1, __sym2, __sym3); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } _ => { return Err(__lookahead); } @@ -3233,29 +3233,23 @@ mod __parse__Expr { } // State 47 - // ( ",")* = (*) ["("] - // ( ",")* = (*) [")"] - // ( ",")* = (*) ["*"] - // ( ",")* = (*) ["Num"] - // ( ",")* = (*) ( ",")* ( ",") ["("] - // ( ",")* = (*) ( ",")* ( ",") [")"] - // ( ",")* = (*) ( ",")* ( ",") ["*"] - // ( ",")* = (*) ( ",")* ( ",") ["Num"] - // Comma = (*) ( ",")* Expr? [")"] - // Factor = "*" "(" (*) Comma ")" [")"] - // Factor = "*" "(" (*) Comma ")" ["*"] - // Factor = "*" "(" (*) Comma ")" ["+"] - // Factor = "*" "(" (*) Comma ")" [","] - // Factor = "*" "(" (*) Comma ")" ["-"] - // Factor = "*" "(" (*) Comma ")" ["/"] + // 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 (*) ")" ["/"] // - // "(" -> Reduce(( ",")* = => ActionFn(13);) - // "Num" -> Reduce(( ",")* = => ActionFn(13);) - // ")" -> Reduce(( ",")* = => ActionFn(13);) - // "*" -> Reduce(( ",")* = => ActionFn(13);) + // ")" -> Shift(S54) + // "-" -> Shift(S23) + // "+" -> Shift(S25) // - // Comma -> S54 - // ( ",")* -> S29 pub fn __state47< 'ast, __TOKENS: Iterator, @@ -3264,57 +3258,40 @@ mod __parse__Expr { mut __lookahead: Option, __tokens: &mut __TOKENS, __sym0: &mut Option, - __sym1: &mut Option, + __sym1: &mut Option<&'ast Node<'ast>>, ) -> Result<(Option, __Nonterminal<'ast, >), Option> { let mut __result: (Option, __Nonterminal<'ast, >); match __lookahead { - Some(Tok::LParen(..)) => { - let __nt = super::__actions::__action13(arena, ); - __result = (__lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); + Some(__tok @ Tok::RParen(..)) => { + let mut __sym2 = &mut Some(__tok); + let __lookahead = __tokens.next(); + __result = try!(__state54(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); } - Some(Tok::Num(_)) => { - let __nt = super::__actions::__action13(arena, ); - __result = (__lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); + Some(__tok @ Tok::Minus(..)) => { + let mut __sym2 = &mut Some(__tok); + let __lookahead = __tokens.next(); + __result = try!(__state23(arena, __lookahead, __tokens, __sym1, __sym2)); } - Some(Tok::RParen(..)) => { - let __nt = super::__actions::__action13(arena, ); - __result = (__lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); - } - Some(Tok::Times(..)) => { - let __nt = super::__actions::__action13(arena, ); - __result = (__lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); + Some(__tok @ Tok::Plus(..)) => { + let mut __sym2 = &mut Some(__tok); + let __lookahead = __tokens.next(); + __result = try!(__state25(arena, __lookahead, __tokens, __sym1, __sym2)); } _ => { return Err(__lookahead); } } - while __sym1.is_some() { - let (__lookahead, __nt) = __result; - match __nt { - __Nonterminal::Comma_3cExpr_3e(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state54(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state29(arena, __lookahead, __tokens, __sym2)); - } - _ => { - return Ok((__lookahead, __nt)); - } - } - } return Ok(__result); } // State 48 - // 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 ["/"] // Term = (*) "(" Expr ")" [")"] // Term = (*) "(" Expr ")" ["*"] // Term = (*) "(" Expr ")" ["+"] @@ -3328,8 +3305,8 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "Num" -> Shift(S42) - // "(" -> Shift(S44) + // "Num" -> Shift(S44) + // "(" -> Shift(S37) // // Term -> S55 pub fn __state48< @@ -3348,12 +3325,12 @@ mod __parse__Expr { Some(Tok::Num(__tok0)) => { let mut __sym2 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state42(arena, __lookahead, __tokens, __sym2)); + __result = try!(__state44(arena, __lookahead, __tokens, __sym2)); } Some(__tok @ Tok::LParen(..)) => { let mut __sym2 = &mut Some(__tok); let __lookahead = __tokens.next(); - __result = try!(__state44(arena, __lookahead, __tokens, __sym2)); + __result = try!(__state37(arena, __lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); @@ -3375,12 +3352,12 @@ mod __parse__Expr { } // State 49 - // 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 ["/"] // Term = (*) "(" Expr ")" [")"] // Term = (*) "(" Expr ")" ["*"] // Term = (*) "(" Expr ")" ["+"] @@ -3394,8 +3371,8 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "(" -> Shift(S44) - // "Num" -> Shift(S42) + // "(" -> Shift(S37) + // "Num" -> Shift(S44) // // Term -> S56 pub fn __state49< @@ -3414,12 +3391,12 @@ mod __parse__Expr { Some(__tok @ Tok::LParen(..)) => { let mut __sym2 = &mut Some(__tok); let __lookahead = __tokens.next(); - __result = try!(__state44(arena, __lookahead, __tokens, __sym2)); + __result = try!(__state37(arena, __lookahead, __tokens, __sym2)); } Some(Tok::Num(__tok0)) => { let mut __sym2 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state42(arena, __lookahead, __tokens, __sym2)); + __result = try!(__state44(arena, __lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); @@ -3441,6 +3418,82 @@ mod __parse__Expr { } // State 50 + // ( ",")* = (*) ["("] + // ( ",")* = (*) [")"] + // ( ",")* = (*) ["*"] + // ( ",")* = (*) ["Num"] + // ( ",")* = (*) ( ",")* ( ",") ["("] + // ( ",")* = (*) ( ",")* ( ",") [")"] + // ( ",")* = (*) ( ",")* ( ",") ["*"] + // ( ",")* = (*) ( ",")* ( ",") ["Num"] + // Comma = (*) ( ",")* Expr? [")"] + // Factor = "*" "(" (*) Comma ")" [")"] + // Factor = "*" "(" (*) Comma ")" ["*"] + // Factor = "*" "(" (*) Comma ")" ["+"] + // Factor = "*" "(" (*) Comma ")" [","] + // Factor = "*" "(" (*) Comma ")" ["-"] + // Factor = "*" "(" (*) Comma ")" ["/"] + // + // "(" -> Reduce(( ",")* = => ActionFn(13);) + // "Num" -> Reduce(( ",")* = => ActionFn(13);) + // "*" -> Reduce(( ",")* = => ActionFn(13);) + // ")" -> Reduce(( ",")* = => ActionFn(13);) + // + // Comma -> S57 + // ( ",")* -> S29 + pub fn __state50< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + mut __lookahead: Option, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + __sym1: &mut Option, + ) -> Result<(Option, __Nonterminal<'ast, >), Option> + { + let mut __result: (Option, __Nonterminal<'ast, >); + match __lookahead { + Some(Tok::LParen(..)) => { + let __nt = super::__actions::__action13(arena, ); + __result = (__lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); + } + Some(Tok::Num(_)) => { + let __nt = super::__actions::__action13(arena, ); + __result = (__lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); + } + Some(Tok::Times(..)) => { + let __nt = super::__actions::__action13(arena, ); + __result = (__lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); + } + Some(Tok::RParen(..)) => { + let __nt = super::__actions::__action13(arena, ); + __result = (__lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); + } + _ => { + return Err(__lookahead); + } + } + while __sym1.is_some() { + let (__lookahead, __nt) = __result; + match __nt { + __Nonterminal::Comma_3cExpr_3e(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state57(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state29(arena, __lookahead, __tokens, __sym2)); + } + _ => { + return Ok((__lookahead, __nt)); + } + } + } + return Ok(__result); + } + + // State 51 // Expr = Expr "+" (*) Factor [")"] // Expr = Expr "+" (*) Factor ["+"] // Expr = Expr "+" (*) Factor [","] @@ -3482,74 +3535,12 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "*" -> Shift(S37) - // "Num" -> Shift(S42) - // "(" -> Shift(S44) - // - // Term -> S41 - // Factor -> S57 - pub fn __state50< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - mut __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> - { - let mut __result: (Option, __Nonterminal<'ast, >); - match __lookahead { - Some(__tok @ Tok::Times(..)) => { - let mut __sym2 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state37(arena, __lookahead, __tokens, __sym2)); - } - Some(Tok::Num(__tok0)) => { - let mut __sym2 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state42(arena, __lookahead, __tokens, __sym2)); - } - Some(__tok @ Tok::LParen(..)) => { - let mut __sym2 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state44(arena, __lookahead, __tokens, __sym2)); - } - _ => { - return Err(__lookahead); - } - } - while __sym1.is_some() { - let (__lookahead, __nt) = __result; - match __nt { - __Nonterminal::Term(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state41(arena, __lookahead, __tokens, __sym2)); - } - __Nonterminal::Factor(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state57(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - _ => { - return Ok((__lookahead, __nt)); - } - } - } - return Ok(__result); - } - - // State 51 - // ( ",") = Expr "," (*) ["("] - // ( ",") = Expr "," (*) [")"] - // ( ",") = Expr "," (*) ["*"] - // ( ",") = Expr "," (*) ["Num"] - // - // "*" -> Reduce(( ",") = Expr, "," => ActionFn(15);) - // ")" -> Reduce(( ",") = Expr, "," => ActionFn(15);) - // "(" -> Reduce(( ",") = Expr, "," => ActionFn(15);) - // "Num" -> Reduce(( ",") = Expr, "," => ActionFn(15);) + // "Num" -> Shift(S44) + // "(" -> Shift(S37) + // "*" -> Shift(S41) // + // Term -> S39 + // Factor -> S58 pub fn __state51< 'ast, __TOKENS: Iterator, @@ -3563,34 +3554,42 @@ mod __parse__Expr { { let mut __result: (Option, __Nonterminal<'ast, >); match __lookahead { - Some(Tok::Times(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __nt = super::__actions::__action15(arena, __sym0, __sym1); - return Ok((__lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29(__nt))); + Some(Tok::Num(__tok0)) => { + let mut __sym2 = &mut Some((__tok0)); + let __lookahead = __tokens.next(); + __result = try!(__state44(arena, __lookahead, __tokens, __sym2)); } - Some(Tok::RParen(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __nt = super::__actions::__action15(arena, __sym0, __sym1); - return Ok((__lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29(__nt))); + Some(__tok @ Tok::LParen(..)) => { + let mut __sym2 = &mut Some(__tok); + let __lookahead = __tokens.next(); + __result = try!(__state37(arena, __lookahead, __tokens, __sym2)); } - Some(Tok::LParen(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __nt = super::__actions::__action15(arena, __sym0, __sym1); - return Ok((__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::__actions::__action15(arena, __sym0, __sym1); - return Ok((__lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29(__nt))); + Some(__tok @ Tok::Times(..)) => { + let mut __sym2 = &mut Some(__tok); + let __lookahead = __tokens.next(); + __result = try!(__state41(arena, __lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); } } + while __sym1.is_some() { + let (__lookahead, __nt) = __result; + match __nt { + __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state39(arena, __lookahead, __tokens, __sym2)); + } + __Nonterminal::Factor(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state58(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + _ => { + return Ok((__lookahead, __nt)); + } + } + } + return Ok(__result); } // State 52 @@ -3635,12 +3634,12 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "Num" -> Shift(S42) - // "*" -> Shift(S37) - // "(" -> Shift(S44) + // "Num" -> Shift(S44) + // "*" -> Shift(S41) + // "(" -> Shift(S37) // - // Factor -> S58 - // Term -> S41 + // Factor -> S59 + // Term -> S39 pub fn __state52< 'ast, __TOKENS: Iterator, @@ -3657,17 +3656,17 @@ mod __parse__Expr { Some(Tok::Num(__tok0)) => { let mut __sym2 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state42(arena, __lookahead, __tokens, __sym2)); + __result = try!(__state44(arena, __lookahead, __tokens, __sym2)); } Some(__tok @ Tok::Times(..)) => { let mut __sym2 = &mut Some(__tok); let __lookahead = __tokens.next(); - __result = try!(__state37(arena, __lookahead, __tokens, __sym2)); + __result = try!(__state41(arena, __lookahead, __tokens, __sym2)); } Some(__tok @ Tok::LParen(..)) => { let mut __sym2 = &mut Some(__tok); let __lookahead = __tokens.next(); - __result = try!(__state44(arena, __lookahead, __tokens, __sym2)); + __result = try!(__state37(arena, __lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); @@ -3678,11 +3677,11 @@ mod __parse__Expr { match __nt { __Nonterminal::Factor(__nt) => { let __sym2 = &mut Some(__nt); - __result = try!(__state58(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); + __result = try!(__state59(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); } __Nonterminal::Term(__nt) => { let __sym2 = &mut Some(__nt); - __result = try!(__state41(arena, __lookahead, __tokens, __sym2)); + __result = try!(__state39(arena, __lookahead, __tokens, __sym2)); } _ => { return Ok((__lookahead, __nt)); @@ -3693,22 +3692,15 @@ mod __parse__Expr { } // State 53 - // 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 (*) ")" ["/"] + // ( ",") = Expr "," (*) ["("] + // ( ",") = Expr "," (*) [")"] + // ( ",") = Expr "," (*) ["*"] + // ( ",") = Expr "," (*) ["Num"] // - // "+" -> Shift(S23) - // ")" -> Shift(S59) - // "-" -> Shift(S24) + // ")" -> Reduce(( ",") = Expr, "," => ActionFn(15);) + // "Num" -> Reduce(( ",") = Expr, "," => ActionFn(15);) + // "*" -> Reduce(( ",") = Expr, "," => ActionFn(15);) + // "(" -> Reduce(( ",") = Expr, "," => ActionFn(15);) // pub fn __state53< 'ast, @@ -3717,35 +3709,274 @@ mod __parse__Expr { arena: &'ast Arena<'ast>, mut __lookahead: Option, __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option<&'ast Node<'ast>>, + __sym0: &mut Option<&'ast Node<'ast>>, + __sym1: &mut Option, ) -> Result<(Option, __Nonterminal<'ast, >), Option> { let mut __result: (Option, __Nonterminal<'ast, >); match __lookahead { - Some(__tok @ Tok::Plus(..)) => { - let mut __sym2 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state23(arena, __lookahead, __tokens, __sym1, __sym2)); + Some(Tok::RParen(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __nt = super::__actions::__action15(arena, __sym0, __sym1); + return Ok((__lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29(__nt))); } - Some(__tok @ Tok::RParen(..)) => { - let mut __sym2 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state59(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); + Some(Tok::Num(_)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __nt = super::__actions::__action15(arena, __sym0, __sym1); + return Ok((__lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29(__nt))); } - Some(__tok @ Tok::Minus(..)) => { - let mut __sym2 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state24(arena, __lookahead, __tokens, __sym1, __sym2)); + Some(Tok::Times(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __nt = super::__actions::__action15(arena, __sym0, __sym1); + return Ok((__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::__actions::__action15(arena, __sym0, __sym1); + return Ok((__lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29(__nt))); } _ => { return Err(__lookahead); } } - return Ok(__result); } // State 54 + // Term = "(" Expr ")" (*) [")"] + // Term = "(" Expr ")" (*) ["*"] + // Term = "(" Expr ")" (*) ["+"] + // Term = "(" Expr ")" (*) [","] + // Term = "(" Expr ")" (*) ["-"] + // Term = "(" Expr ")" (*) ["/"] + // + // ")" -> Reduce(Term = "(", Expr, ")" => ActionFn(9);) + // "/" -> Reduce(Term = "(", Expr, ")" => ActionFn(9);) + // "+" -> Reduce(Term = "(", Expr, ")" => ActionFn(9);) + // "," -> Reduce(Term = "(", Expr, ")" => ActionFn(9);) + // "-" -> Reduce(Term = "(", Expr, ")" => ActionFn(9);) + // "*" -> Reduce(Term = "(", Expr, ")" => ActionFn(9);) + // + pub fn __state54< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + mut __lookahead: Option, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + __sym1: &mut Option<&'ast Node<'ast>>, + __sym2: &mut Option, + ) -> Result<(Option, __Nonterminal<'ast, >), Option> + { + let mut __result: (Option, __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::__actions::__action9(arena, __sym0, __sym1, __sym2); + return Ok((__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::__actions::__action9(arena, __sym0, __sym1, __sym2); + return Ok((__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::__actions::__action9(arena, __sym0, __sym1, __sym2); + return Ok((__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::__actions::__action9(arena, __sym0, __sym1, __sym2); + return Ok((__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::__actions::__action9(arena, __sym0, __sym1, __sym2); + return Ok((__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::__actions::__action9(arena, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Term(__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 => ActionFn(5);) + // "+" -> Reduce(Factor = Factor, "/", Term => ActionFn(5);) + // "-" -> Reduce(Factor = Factor, "/", Term => ActionFn(5);) + // "/" -> Reduce(Factor = Factor, "/", Term => ActionFn(5);) + // "*" -> Reduce(Factor = Factor, "/", Term => ActionFn(5);) + // ")" -> Reduce(Factor = Factor, "/", Term => ActionFn(5);) + // + pub fn __state55< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + mut __lookahead: Option, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + __sym1: &mut Option, + __sym2: &mut Option<&'ast Node<'ast>>, + ) -> Result<(Option, __Nonterminal<'ast, >), Option> + { + let mut __result: (Option, __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::__actions::__action5(arena, __sym0, __sym1, __sym2); + return Ok((__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::__actions::__action5(arena, __sym0, __sym1, __sym2); + return Ok((__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::__actions::__action5(arena, __sym0, __sym1, __sym2); + return Ok((__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::__actions::__action5(arena, __sym0, __sym1, __sym2); + return Ok((__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::__actions::__action5(arena, __sym0, __sym1, __sym2); + return Ok((__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::__actions::__action5(arena, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 56 + // Factor = Factor "*" Term (*) [")"] + // Factor = Factor "*" Term (*) ["*"] + // Factor = Factor "*" Term (*) ["+"] + // Factor = Factor "*" Term (*) [","] + // Factor = Factor "*" Term (*) ["-"] + // Factor = Factor "*" Term (*) ["/"] + // + // "*" -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) + // "-" -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) + // "," -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) + // "/" -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) + // "+" -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) + // ")" -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) + // + pub fn __state56< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + mut __lookahead: Option, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + __sym1: &mut Option, + __sym2: &mut Option<&'ast Node<'ast>>, + ) -> Result<(Option, __Nonterminal<'ast, >), Option> + { + let mut __result: (Option, __Nonterminal<'ast, >); + match __lookahead { + Some(Tok::Times(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action4(arena, __sym0, __sym1, __sym2); + return Ok((__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::__actions::__action4(arena, __sym0, __sym1, __sym2); + return Ok((__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::__actions::__action4(arena, __sym0, __sym1, __sym2); + return Ok((__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::__actions::__action4(arena, __sym0, __sym1, __sym2); + return Ok((__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::__actions::__action4(arena, __sym0, __sym1, __sym2); + return Ok((__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::__actions::__action4(arena, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 57 // Factor = "*" "(" Comma (*) ")" [")"] // Factor = "*" "(" Comma (*) ")" ["*"] // Factor = "*" "(" Comma (*) ")" ["+"] @@ -3755,7 +3986,7 @@ mod __parse__Expr { // // ")" -> Shift(S60) // - pub fn __state54< + pub fn __state57< 'ast, __TOKENS: Iterator, >( @@ -3781,161 +4012,7 @@ mod __parse__Expr { return Ok(__result); } - // State 55 - // Factor = Factor "*" Term (*) [")"] - // Factor = Factor "*" Term (*) ["*"] - // Factor = Factor "*" Term (*) ["+"] - // Factor = Factor "*" Term (*) [","] - // Factor = Factor "*" Term (*) ["-"] - // Factor = Factor "*" Term (*) ["/"] - // - // "-" -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) - // ")" -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) - // "*" -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) - // "+" -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) - // "," -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) - // "/" -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) - // - pub fn __state55< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - mut __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, - __sym2: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> - { - let mut __result: (Option, __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::__actions::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__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::__actions::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__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::__actions::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__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::__actions::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__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::__actions::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__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::__actions::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 56 - // Factor = Factor "/" Term (*) [")"] - // Factor = Factor "/" Term (*) ["*"] - // Factor = Factor "/" Term (*) ["+"] - // Factor = Factor "/" Term (*) [","] - // Factor = Factor "/" Term (*) ["-"] - // Factor = Factor "/" Term (*) ["/"] - // - // "/" -> Reduce(Factor = Factor, "/", Term => ActionFn(5);) - // "*" -> Reduce(Factor = Factor, "/", Term => ActionFn(5);) - // ")" -> Reduce(Factor = Factor, "/", Term => ActionFn(5);) - // "-" -> Reduce(Factor = Factor, "/", Term => ActionFn(5);) - // "+" -> Reduce(Factor = Factor, "/", Term => ActionFn(5);) - // "," -> Reduce(Factor = Factor, "/", Term => ActionFn(5);) - // - pub fn __state56< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - mut __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, - __sym2: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> - { - let mut __result: (Option, __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::__actions::__action5(arena, __sym0, __sym1, __sym2); - return Ok((__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::__actions::__action5(arena, __sym0, __sym1, __sym2); - return Ok((__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::__actions::__action5(arena, __sym0, __sym1, __sym2); - return Ok((__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::__actions::__action5(arena, __sym0, __sym1, __sym2); - return Ok((__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::__actions::__action5(arena, __sym0, __sym1, __sym2); - return Ok((__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::__actions::__action5(arena, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 57 + // State 58 // Expr = Expr "+" Factor (*) [")"] // Expr = Expr "+" Factor (*) ["+"] // Expr = Expr "+" Factor (*) [","] @@ -3953,96 +4030,12 @@ mod __parse__Expr { // Factor = Factor (*) "/" Term ["-"] // Factor = Factor (*) "/" Term ["/"] // - // ")" -> Reduce(Expr = Expr, "+", Factor => ActionFn(2);) // "," -> Reduce(Expr = Expr, "+", Factor => ActionFn(2);) + // ")" -> Reduce(Expr = Expr, "+", Factor => ActionFn(2);) + // "/" -> Shift(S48) + // "*" -> Shift(S49) // "+" -> Reduce(Expr = Expr, "+", Factor => ActionFn(2);) // "-" -> Reduce(Expr = Expr, "+", Factor => ActionFn(2);) - // "*" -> Shift(S48) - // "/" -> Shift(S49) - // - pub fn __state57< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - mut __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, - __sym2: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> - { - let mut __result: (Option, __Nonterminal<'ast, >); - match __lookahead { - Some(__tok @ Tok::Times(..)) => { - let mut __sym3 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state48(arena, __lookahead, __tokens, __sym2, __sym3)); - } - Some(__tok @ Tok::Div(..)) => { - let mut __sym3 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state49(arena, __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::__actions::__action2(arena, __sym0, __sym1, __sym2); - return Ok((__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::__actions::__action2(arena, __sym0, __sym1, __sym2); - return Ok((__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::__actions::__action2(arena, __sym0, __sym1, __sym2); - return Ok((__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::__actions::__action2(arena, __sym0, __sym1, __sym2); - return Ok((__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 => ActionFn(1);) - // "/" -> Shift(S49) - // "*" -> Shift(S48) - // "-" -> Reduce(Expr = Expr, "-", Factor => ActionFn(1);) - // "," -> Reduce(Expr = Expr, "-", Factor => ActionFn(1);) - // "+" -> Reduce(Expr = Expr, "-", Factor => ActionFn(1);) // pub fn __state58< 'ast, @@ -4061,9 +4054,93 @@ mod __parse__Expr { Some(__tok @ Tok::Div(..)) => { let mut __sym3 = &mut Some(__tok); let __lookahead = __tokens.next(); - __result = try!(__state49(arena, __lookahead, __tokens, __sym2, __sym3)); + __result = try!(__state48(arena, __lookahead, __tokens, __sym2, __sym3)); } Some(__tok @ Tok::Times(..)) => { + let mut __sym3 = &mut Some(__tok); + let __lookahead = __tokens.next(); + __result = try!(__state49(arena, __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::__actions::__action2(arena, __sym0, __sym1, __sym2); + return Ok((__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::__actions::__action2(arena, __sym0, __sym1, __sym2); + return Ok((__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::__actions::__action2(arena, __sym0, __sym1, __sym2); + return Ok((__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::__actions::__action2(arena, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Expr(__nt))); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + + // State 59 + // 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 => ActionFn(1);) + // "+" -> Reduce(Expr = Expr, "-", Factor => ActionFn(1);) + // "*" -> Shift(S49) + // "/" -> Shift(S48) + // "," -> Reduce(Expr = Expr, "-", Factor => ActionFn(1);) + // "-" -> Reduce(Expr = Expr, "-", Factor => ActionFn(1);) + // + pub fn __state59< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + mut __lookahead: Option, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + __sym1: &mut Option, + __sym2: &mut Option<&'ast Node<'ast>>, + ) -> Result<(Option, __Nonterminal<'ast, >), Option> + { + let mut __result: (Option, __Nonterminal<'ast, >); + match __lookahead { + Some(__tok @ Tok::Times(..)) => { + let mut __sym3 = &mut Some(__tok); + let __lookahead = __tokens.next(); + __result = try!(__state49(arena, __lookahead, __tokens, __sym2, __sym3)); + } + Some(__tok @ Tok::Div(..)) => { let mut __sym3 = &mut Some(__tok); let __lookahead = __tokens.next(); __result = try!(__state48(arena, __lookahead, __tokens, __sym2, __sym3)); @@ -4075,7 +4152,7 @@ mod __parse__Expr { let __nt = super::__actions::__action1(arena, __sym0, __sym1, __sym2); return Ok((__lookahead, __Nonterminal::Expr(__nt))); } - Some(Tok::Minus(..)) => { + Some(Tok::Plus(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); @@ -4089,7 +4166,7 @@ mod __parse__Expr { let __nt = super::__actions::__action1(arena, __sym0, __sym1, __sym2); return Ok((__lookahead, __Nonterminal::Expr(__nt))); } - Some(Tok::Plus(..)) => { + Some(Tok::Minus(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); @@ -4103,83 +4180,6 @@ mod __parse__Expr { return Ok(__result); } - // State 59 - // Term = "(" Expr ")" (*) [")"] - // Term = "(" Expr ")" (*) ["*"] - // Term = "(" Expr ")" (*) ["+"] - // Term = "(" Expr ")" (*) [","] - // Term = "(" Expr ")" (*) ["-"] - // Term = "(" Expr ")" (*) ["/"] - // - // "-" -> Reduce(Term = "(", Expr, ")" => ActionFn(9);) - // "," -> Reduce(Term = "(", Expr, ")" => ActionFn(9);) - // "+" -> Reduce(Term = "(", Expr, ")" => ActionFn(9);) - // ")" -> Reduce(Term = "(", Expr, ")" => ActionFn(9);) - // "*" -> Reduce(Term = "(", Expr, ")" => ActionFn(9);) - // "/" -> Reduce(Term = "(", Expr, ")" => ActionFn(9);) - // - pub fn __state59< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - mut __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option<&'ast Node<'ast>>, - __sym2: &mut Option, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> - { - let mut __result: (Option, __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::__actions::__action9(arena, __sym0, __sym1, __sym2); - return Ok((__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::__actions::__action9(arena, __sym0, __sym1, __sym2); - return Ok((__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::__actions::__action9(arena, __sym0, __sym1, __sym2); - return Ok((__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::__actions::__action9(arena, __sym0, __sym1, __sym2); - return Ok((__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::__actions::__action9(arena, __sym0, __sym1, __sym2); - return Ok((__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::__actions::__action9(arena, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Term(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - // State 60 // Factor = "*" "(" Comma ")" (*) [")"] // Factor = "*" "(" Comma ")" (*) ["*"] @@ -4188,12 +4188,12 @@ mod __parse__Expr { // Factor = "*" "(" Comma ")" (*) ["-"] // Factor = "*" "(" Comma ")" (*) ["/"] // - // "," -> Reduce(Factor = "*", "(", Comma, ")" => ActionFn(6);) - // "+" -> Reduce(Factor = "*", "(", Comma, ")" => ActionFn(6);) - // "-" -> Reduce(Factor = "*", "(", Comma, ")" => ActionFn(6);) // "*" -> Reduce(Factor = "*", "(", Comma, ")" => ActionFn(6);) + // "+" -> Reduce(Factor = "*", "(", Comma, ")" => ActionFn(6);) // "/" -> Reduce(Factor = "*", "(", Comma, ")" => ActionFn(6);) // ")" -> Reduce(Factor = "*", "(", Comma, ")" => ActionFn(6);) + // "-" -> Reduce(Factor = "*", "(", Comma, ")" => ActionFn(6);) + // "," -> Reduce(Factor = "*", "(", Comma, ")" => ActionFn(6);) // pub fn __state60< 'ast, @@ -4210,7 +4210,7 @@ mod __parse__Expr { { let mut __result: (Option, __Nonterminal<'ast, >); match __lookahead { - Some(Tok::Comma(..)) => { + Some(Tok::Times(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); @@ -4226,22 +4226,6 @@ mod __parse__Expr { let __nt = super::__actions::__action6(arena, __sym0, __sym1, __sym2, __sym3); return Ok((__lookahead, __Nonterminal::Factor(__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::__actions::__action6(arena, __sym0, __sym1, __sym2, __sym3); - return Ok((__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::__actions::__action6(arena, __sym0, __sym1, __sym2, __sym3); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } Some(Tok::Div(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); @@ -4258,6 +4242,22 @@ mod __parse__Expr { let __nt = super::__actions::__action6(arena, __sym0, __sym1, __sym2, __sym3); return Ok((__lookahead, __Nonterminal::Factor(__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::__actions::__action6(arena, __sym0, __sym1, __sym2, __sym3); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + Some(Tok::Comma(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __sym3 = __sym3.take().unwrap(); + let __nt = super::__actions::__action6(arena, __sym0, __sym1, __sym2, __sym3); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } _ => { return Err(__lookahead); } diff --git a/lalrpop-test/src/sub.rs b/lalrpop-test/src/sub.rs index c12536c..16a7ba8 100644 --- a/lalrpop-test/src/sub.rs +++ b/lalrpop-test/src/sub.rs @@ -24,8 +24,8 @@ mod __parse__S { pub enum __Nonterminal<> { E(i32), T(i32), - S(i32), ____S(i32), + S(i32), } // State 0 @@ -40,12 +40,12 @@ mod __parse__S { // T = (*) "Num" ["-"] // __S = (*) S [EOF] // - // "Num" -> Shift(S3) - // "(" -> Shift(S2) + // "(" -> Shift(S5) + // "Num" -> Shift(S4) // - // S -> S4 // E -> S1 - // T -> S5 + // T -> S2 + // S -> S3 pub fn __state0< __TOKENS: Iterator, >( @@ -55,15 +55,15 @@ mod __parse__S { { let mut __result: (Option, __Nonterminal<>); match __lookahead { - Some(Tok::Num(__tok0)) => { - let mut __sym0 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state3(__lookahead, __tokens, __sym0)); - } Some(__tok @ Tok::LParen(..)) => { let mut __sym0 = &mut Some(__tok); let __lookahead = __tokens.next(); - __result = try!(__state2(__lookahead, __tokens, __sym0)); + __result = try!(__state5(__lookahead, __tokens, __sym0)); + } + Some(Tok::Num(__tok0)) => { + let mut __sym0 = &mut Some((__tok0)); + let __lookahead = __tokens.next(); + __result = try!(__state4(__lookahead, __tokens, __sym0)); } _ => { return Err(__lookahead); @@ -72,17 +72,17 @@ mod __parse__S { loop { let (__lookahead, __nt) = __result; match __nt { - __Nonterminal::S(__nt) => { - let __sym0 = &mut Some(__nt); - __result = try!(__state4(__lookahead, __tokens, __sym0)); - } __Nonterminal::E(__nt) => { let __sym0 = &mut Some(__nt); __result = try!(__state1(__lookahead, __tokens, __sym0)); } __Nonterminal::T(__nt) => { let __sym0 = &mut Some(__nt); - __result = try!(__state5(__lookahead, __tokens, __sym0)); + __result = try!(__state2(__lookahead, __tokens, __sym0)); + } + __Nonterminal::S(__nt) => { + let __sym0 = &mut Some(__nt); + __result = try!(__state3(__lookahead, __tokens, __sym0)); } _ => { return Ok((__lookahead, __nt)); @@ -96,8 +96,8 @@ mod __parse__S { // E = E (*) "-" T ["-"] // S = E (*) [EOF] // - // "-" -> Shift(S6) // EOF -> Reduce(S = E => ActionFn(1);) + // "-" -> Shift(S6) // pub fn __state1< __TOKENS: Iterator, @@ -127,74 +127,14 @@ mod __parse__S { } // State 2 - // E = (*) E "-" T [")"] - // E = (*) E "-" T ["-"] - // E = (*) T [")"] - // E = (*) T ["-"] - // T = (*) "(" E ")" [")"] - // T = (*) "(" E ")" ["-"] - // T = "(" (*) E ")" [EOF] - // T = "(" (*) E ")" ["-"] - // T = (*) "Num" [")"] - // T = (*) "Num" ["-"] + // E = T (*) [EOF] + // E = T (*) ["-"] // - // "Num" -> Shift(S9) - // "(" -> Shift(S7) + // "-" -> Reduce(E = T => ActionFn(3);) + // EOF -> Reduce(E = T => ActionFn(3);) // - // T -> S8 - // E -> S10 pub fn __state2< __TOKENS: Iterator, - >( - mut __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - ) -> Result<(Option, __Nonterminal<>), Option> - { - let mut __result: (Option, __Nonterminal<>); - match __lookahead { - Some(Tok::Num(__tok0)) => { - let mut __sym1 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state9(__lookahead, __tokens, __sym1)); - } - Some(__tok @ Tok::LParen(..)) => { - let mut __sym1 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state7(__lookahead, __tokens, __sym1)); - } - _ => { - return Err(__lookahead); - } - } - while __sym0.is_some() { - let (__lookahead, __nt) = __result; - match __nt { - __Nonterminal::T(__nt) => { - let __sym1 = &mut Some(__nt); - __result = try!(__state8(__lookahead, __tokens, __sym1)); - } - __Nonterminal::E(__nt) => { - let __sym1 = &mut Some(__nt); - __result = try!(__state10(__lookahead, __tokens, __sym0, __sym1)); - } - _ => { - return Ok((__lookahead, __nt)); - } - } - } - return Ok(__result); - } - - // State 3 - // T = "Num" (*) [EOF] - // T = "Num" (*) ["-"] - // - // EOF -> Reduce(T = "Num" => ActionFn(4);) - // "-" -> Reduce(T = "Num" => ActionFn(4);) - // - pub fn __state3< - __TOKENS: Iterator, >( mut __lookahead: Option, __tokens: &mut __TOKENS, @@ -203,15 +143,15 @@ mod __parse__S { { let mut __result: (Option, __Nonterminal<>); match __lookahead { - None => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action4(__sym0); - return Ok((__lookahead, __Nonterminal::T(__nt))); - } Some(Tok::Minus(..)) => { let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action4(__sym0); - return Ok((__lookahead, __Nonterminal::T(__nt))); + let __nt = super::__actions::__action3(__sym0); + return Ok((__lookahead, __Nonterminal::E(__nt))); + } + None => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action3(__sym0); + return Ok((__lookahead, __Nonterminal::E(__nt))); } _ => { return Err(__lookahead); @@ -219,12 +159,12 @@ mod __parse__S { } } - // State 4 + // State 3 // __S = S (*) [EOF] // // EOF -> Reduce(__S = S => ActionFn(0);) // - pub fn __state4< + pub fn __state3< __TOKENS: Iterator, >( mut __lookahead: Option, @@ -245,14 +185,14 @@ mod __parse__S { } } - // State 5 - // E = T (*) [EOF] - // E = T (*) ["-"] + // State 4 + // T = "Num" (*) [EOF] + // T = "Num" (*) ["-"] // - // EOF -> Reduce(E = T => ActionFn(3);) - // "-" -> Reduce(E = T => ActionFn(3);) + // "-" -> Reduce(T = "Num" => ActionFn(4);) + // EOF -> Reduce(T = "Num" => ActionFn(4);) // - pub fn __state5< + pub fn __state4< __TOKENS: Iterator, >( mut __lookahead: Option, @@ -262,15 +202,15 @@ mod __parse__S { { let mut __result: (Option, __Nonterminal<>); match __lookahead { - None => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action3(__sym0); - return Ok((__lookahead, __Nonterminal::E(__nt))); - } Some(Tok::Minus(..)) => { let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action3(__sym0); - return Ok((__lookahead, __Nonterminal::E(__nt))); + let __nt = super::__actions::__action4(__sym0); + return Ok((__lookahead, __Nonterminal::T(__nt))); + } + None => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action4(__sym0); + return Ok((__lookahead, __Nonterminal::T(__nt))); } _ => { return Err(__lookahead); @@ -278,6 +218,66 @@ mod __parse__S { } } + // State 5 + // E = (*) E "-" T [")"] + // E = (*) E "-" T ["-"] + // E = (*) T [")"] + // E = (*) T ["-"] + // T = (*) "(" E ")" [")"] + // T = (*) "(" E ")" ["-"] + // T = "(" (*) E ")" [EOF] + // T = "(" (*) E ")" ["-"] + // T = (*) "Num" [")"] + // T = (*) "Num" ["-"] + // + // "(" -> Shift(S8) + // "Num" -> Shift(S10) + // + // T -> S7 + // E -> S9 + pub fn __state5< + __TOKENS: Iterator, + >( + mut __lookahead: Option, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + ) -> Result<(Option, __Nonterminal<>), Option> + { + let mut __result: (Option, __Nonterminal<>); + match __lookahead { + Some(__tok @ Tok::LParen(..)) => { + let mut __sym1 = &mut Some(__tok); + let __lookahead = __tokens.next(); + __result = try!(__state8(__lookahead, __tokens, __sym1)); + } + Some(Tok::Num(__tok0)) => { + let mut __sym1 = &mut Some((__tok0)); + let __lookahead = __tokens.next(); + __result = try!(__state10(__lookahead, __tokens, __sym1)); + } + _ => { + return Err(__lookahead); + } + } + while __sym0.is_some() { + let (__lookahead, __nt) = __result; + match __nt { + __Nonterminal::T(__nt) => { + let __sym1 = &mut Some(__nt); + __result = try!(__state7(__lookahead, __tokens, __sym1)); + } + __Nonterminal::E(__nt) => { + let __sym1 = &mut Some(__nt); + __result = try!(__state9(__lookahead, __tokens, __sym0, __sym1)); + } + _ => { + return Ok((__lookahead, __nt)); + } + } + } + return Ok(__result); + } + // State 6 // E = E "-" (*) T [EOF] // E = E "-" (*) T ["-"] @@ -286,8 +286,8 @@ mod __parse__S { // T = (*) "Num" [EOF] // T = (*) "Num" ["-"] // - // "Num" -> Shift(S3) - // "(" -> Shift(S2) + // "Num" -> Shift(S4) + // "(" -> Shift(S5) // // T -> S11 pub fn __state6< @@ -304,12 +304,12 @@ mod __parse__S { Some(Tok::Num(__tok0)) => { let mut __sym2 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state3(__lookahead, __tokens, __sym2)); + __result = try!(__state4(__lookahead, __tokens, __sym2)); } Some(__tok @ Tok::LParen(..)) => { let mut __sym2 = &mut Some(__tok); let __lookahead = __tokens.next(); - __result = try!(__state2(__lookahead, __tokens, __sym2)); + __result = try!(__state5(__lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); @@ -331,6 +331,39 @@ mod __parse__S { } // State 7 + // E = T (*) [")"] + // E = T (*) ["-"] + // + // ")" -> Reduce(E = T => ActionFn(3);) + // "-" -> Reduce(E = T => ActionFn(3);) + // + pub fn __state7< + __TOKENS: Iterator, + >( + mut __lookahead: Option, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + ) -> Result<(Option, __Nonterminal<>), Option> + { + let mut __result: (Option, __Nonterminal<>); + match __lookahead { + Some(Tok::RParen(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action3(__sym0); + return Ok((__lookahead, __Nonterminal::E(__nt))); + } + Some(Tok::Minus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action3(__sym0); + return Ok((__lookahead, __Nonterminal::E(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 8 // E = (*) E "-" T [")"] // E = (*) E "-" T ["-"] // E = (*) T [")"] @@ -342,12 +375,12 @@ mod __parse__S { // T = (*) "Num" [")"] // T = (*) "Num" ["-"] // - // "Num" -> Shift(S9) - // "(" -> Shift(S7) + // "Num" -> Shift(S10) + // "(" -> Shift(S8) // - // T -> S8 // E -> S12 - pub fn __state7< + // T -> S7 + pub fn __state8< __TOKENS: Iterator, >( mut __lookahead: Option, @@ -360,12 +393,12 @@ mod __parse__S { Some(Tok::Num(__tok0)) => { let mut __sym1 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state9(__lookahead, __tokens, __sym1)); + __result = try!(__state10(__lookahead, __tokens, __sym1)); } Some(__tok @ Tok::LParen(..)) => { let mut __sym1 = &mut Some(__tok); let __lookahead = __tokens.next(); - __result = try!(__state7(__lookahead, __tokens, __sym1)); + __result = try!(__state8(__lookahead, __tokens, __sym1)); } _ => { return Err(__lookahead); @@ -374,14 +407,14 @@ mod __parse__S { while __sym0.is_some() { let (__lookahead, __nt) = __result; match __nt { - __Nonterminal::T(__nt) => { - let __sym1 = &mut Some(__nt); - __result = try!(__state8(__lookahead, __tokens, __sym1)); - } __Nonterminal::E(__nt) => { let __sym1 = &mut Some(__nt); __result = try!(__state12(__lookahead, __tokens, __sym0, __sym1)); } + __Nonterminal::T(__nt) => { + let __sym1 = &mut Some(__nt); + __result = try!(__state7(__lookahead, __tokens, __sym1)); + } _ => { return Ok((__lookahead, __nt)); } @@ -390,82 +423,16 @@ mod __parse__S { return Ok(__result); } - // State 8 - // E = T (*) [")"] - // E = T (*) ["-"] - // - // ")" -> Reduce(E = T => ActionFn(3);) - // "-" -> Reduce(E = T => ActionFn(3);) - // - pub fn __state8< - __TOKENS: Iterator, - >( - mut __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - ) -> Result<(Option, __Nonterminal<>), Option> - { - let mut __result: (Option, __Nonterminal<>); - match __lookahead { - Some(Tok::RParen(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action3(__sym0); - return Ok((__lookahead, __Nonterminal::E(__nt))); - } - Some(Tok::Minus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action3(__sym0); - return Ok((__lookahead, __Nonterminal::E(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - // State 9 - // T = "Num" (*) [")"] - // T = "Num" (*) ["-"] - // - // ")" -> Reduce(T = "Num" => ActionFn(4);) - // "-" -> Reduce(T = "Num" => ActionFn(4);) - // - pub fn __state9< - __TOKENS: Iterator, - >( - mut __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - ) -> Result<(Option, __Nonterminal<>), Option> - { - let mut __result: (Option, __Nonterminal<>); - match __lookahead { - Some(Tok::RParen(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action4(__sym0); - return Ok((__lookahead, __Nonterminal::T(__nt))); - } - Some(Tok::Minus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action4(__sym0); - return Ok((__lookahead, __Nonterminal::T(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 10 // E = E (*) "-" T [")"] // E = E (*) "-" T ["-"] // T = "(" E (*) ")" [EOF] // T = "(" E (*) ")" ["-"] // - // ")" -> Shift(S13) // "-" -> Shift(S14) + // ")" -> Shift(S13) // - pub fn __state10< + pub fn __state9< __TOKENS: Iterator, >( mut __lookahead: Option, @@ -476,16 +443,16 @@ mod __parse__S { { let mut __result: (Option, __Nonterminal<>); match __lookahead { - Some(__tok @ Tok::RParen(..)) => { - let mut __sym2 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state13(__lookahead, __tokens, __sym0, __sym1, __sym2)); - } Some(__tok @ Tok::Minus(..)) => { let mut __sym2 = &mut Some(__tok); let __lookahead = __tokens.next(); __result = try!(__state14(__lookahead, __tokens, __sym1, __sym2)); } + Some(__tok @ Tok::RParen(..)) => { + let mut __sym2 = &mut Some(__tok); + let __lookahead = __tokens.next(); + __result = try!(__state13(__lookahead, __tokens, __sym0, __sym1, __sym2)); + } _ => { return Err(__lookahead); } @@ -493,6 +460,39 @@ mod __parse__S { return Ok(__result); } + // State 10 + // T = "Num" (*) [")"] + // T = "Num" (*) ["-"] + // + // ")" -> Reduce(T = "Num" => ActionFn(4);) + // "-" -> Reduce(T = "Num" => ActionFn(4);) + // + pub fn __state10< + __TOKENS: Iterator, + >( + mut __lookahead: Option, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + ) -> Result<(Option, __Nonterminal<>), Option> + { + let mut __result: (Option, __Nonterminal<>); + match __lookahead { + Some(Tok::RParen(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action4(__sym0); + return Ok((__lookahead, __Nonterminal::T(__nt))); + } + Some(Tok::Minus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action4(__sym0); + return Ok((__lookahead, __Nonterminal::T(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + // State 11 // E = E "-" T (*) [EOF] // E = E "-" T (*) ["-"] @@ -573,8 +573,8 @@ mod __parse__S { // T = "(" E ")" (*) [EOF] // T = "(" E ")" (*) ["-"] // - // EOF -> Reduce(T = "(", E, ")" => ActionFn(5);) // "-" -> Reduce(T = "(", E, ")" => ActionFn(5);) + // EOF -> Reduce(T = "(", E, ")" => ActionFn(5);) // pub fn __state13< __TOKENS: Iterator, @@ -588,14 +588,14 @@ mod __parse__S { { let mut __result: (Option, __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::__actions::__action5(__sym0, __sym1, __sym2); return Ok((__lookahead, __Nonterminal::T(__nt))); } - Some(Tok::Minus(..)) => { + None => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); @@ -616,8 +616,8 @@ mod __parse__S { // T = (*) "Num" [")"] // T = (*) "Num" ["-"] // - // "(" -> Shift(S7) - // "Num" -> Shift(S9) + // "Num" -> Shift(S10) + // "(" -> Shift(S8) // // T -> S16 pub fn __state14< @@ -631,15 +631,15 @@ mod __parse__S { { let mut __result: (Option, __Nonterminal<>); match __lookahead { - Some(__tok @ Tok::LParen(..)) => { - let mut __sym2 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state7(__lookahead, __tokens, __sym2)); - } Some(Tok::Num(__tok0)) => { let mut __sym2 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state9(__lookahead, __tokens, __sym2)); + __result = try!(__state10(__lookahead, __tokens, __sym2)); + } + Some(__tok @ Tok::LParen(..)) => { + let mut __sym2 = &mut Some(__tok); + let __lookahead = __tokens.next(); + __result = try!(__state8(__lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); @@ -664,8 +664,8 @@ mod __parse__S { // T = "(" E ")" (*) [")"] // T = "(" E ")" (*) ["-"] // - // "-" -> Reduce(T = "(", E, ")" => ActionFn(5);) // ")" -> Reduce(T = "(", E, ")" => ActionFn(5);) + // "-" -> Reduce(T = "(", E, ")" => ActionFn(5);) // pub fn __state15< __TOKENS: Iterator, @@ -679,14 +679,14 @@ mod __parse__S { { let mut __result: (Option, __Nonterminal<>); match __lookahead { - Some(Tok::Minus(..)) => { + Some(Tok::RParen(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); let __nt = super::__actions::__action5(__sym0, __sym1, __sym2); return Ok((__lookahead, __Nonterminal::T(__nt))); } - Some(Tok::RParen(..)) => { + Some(Tok::Minus(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); diff --git a/lalrpop/src/grammar/parse_tree.rs b/lalrpop/src/grammar/parse_tree.rs index f1dc6ff..e92edc5 100644 --- a/lalrpop/src/grammar/parse_tree.rs +++ b/lalrpop/src/grammar/parse_tree.rs @@ -33,9 +33,20 @@ pub enum GrammarItem { #[derive(Clone, Debug, PartialEq, Eq)] pub struct ExternToken { + pub associated_types: Vec, pub enum_token: EnumToken, } +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct AssociatedType { + pub span: Span, + pub type_name: InternedString, + pub type_ref: TypeRef, +} + +/// Recognized associated type for the token location +pub const LOCATION: &'static str = "Location"; + #[derive(Clone, Debug, PartialEq, Eq)] pub struct EnumToken { pub type_name: TypeRef, @@ -322,6 +333,14 @@ impl Display for ExprSymbol { } } +impl ExternToken { + pub fn associated_type(&self, name: InternedString) -> Option<&AssociatedType> { + self.associated_types.iter() + .filter(|a| a.type_name == name) + .next() + } +} + impl ExprSymbol { pub fn canonical_form(&self) -> String { format!("{}", self) diff --git a/lalrpop/src/grammar/repr.rs b/lalrpop/src/grammar/repr.rs index 1a90084..6985682 100644 --- a/lalrpop/src/grammar/repr.rs +++ b/lalrpop/src/grammar/repr.rs @@ -99,14 +99,18 @@ pub struct NominalTypeRepr { #[derive(Clone, Debug)] pub struct Types { terminal_enum_type: NominalTypeRepr, + terminal_loc_type: Option, default_terminal_type: TypeRepr, terminal_types: Map, nonterminal_types: Map } impl Types { - pub fn new(terminal_enum_type: NominalTypeRepr) -> Types { - Types { terminal_enum_type: terminal_enum_type.clone(), + pub fn new(terminal_loc_type: Option, + terminal_enum_type: NominalTypeRepr) + -> Types { + Types { terminal_loc_type: terminal_loc_type, + terminal_enum_type: terminal_enum_type.clone(), terminal_types: map(), default_terminal_type: TypeRepr::Nominal(terminal_enum_type), nonterminal_types: map() } diff --git a/lalrpop/src/normalize/tyinfer/mod.rs b/lalrpop/src/normalize/tyinfer/mod.rs index a6198cf..0fc9f0f 100644 --- a/lalrpop/src/normalize/tyinfer/mod.rs +++ b/lalrpop/src/normalize/tyinfer/mod.rs @@ -3,13 +3,15 @@ use super::norm_util::{self, AlternativeAction, Symbols}; use std::collections::{HashMap}; use grammar::parse_tree::{Alternative, - EnumToken, + ExternToken, Grammar, GrammarItem, + LOCATION, NonterminalData, NonterminalString, Path, Span, SymbolKind, TypeRef}; use grammar::repr::{NominalTypeRepr, Types, TypeRepr}; +use intern::intern; #[cfg(test)] mod test; @@ -32,40 +34,43 @@ struct NT<'grammar> { alternatives: &'grammar Vec, } -fn extract_enum_token(grammar: &Grammar) -> NormResult<&EnumToken> { - let mut enum_tokens = +fn extract_extern_token(grammar: &Grammar) -> NormResult<&ExternToken> { + let mut extern_tokens = grammar.items .iter() .filter_map(|item| { match *item { - GrammarItem::ExternToken(ref data) => Some(&data.enum_token), + GrammarItem::ExternToken(ref data) => Some(data), _ => None, } }); - let enum_token = enum_tokens.next(); - let enum_token = match enum_token { + let extern_token = extern_tokens.next(); + let extern_token = match extern_token { Some(tt) => tt, None => return_err!(grammar.span, "no token type specified") }; - if let Some(_) = enum_tokens.next() { + if let Some(_) = extern_tokens.next() { return_err!(grammar.span, "multiple token types specified"); } - Ok(enum_token) + Ok(extern_token) } impl<'grammar> TypeInferencer<'grammar> { fn new(grammar: &'grammar Grammar) -> NormResult> { - let enum_token = try!(extract_enum_token(grammar)); + let extern_token = try!(extract_extern_token(grammar)); - let token_type = match enum_token.type_name.type_repr() { + let loc_type = extern_token.associated_type(intern(LOCATION)) + .map(|tr| tr.type_ref.type_repr()); + + let enum_type = match extern_token.enum_token.type_name.type_repr() { TypeRepr::Nominal(data) => data, _ => panic!("enum token without nominal type passed validation") }; - let mut types = Types::new(token_type); + let mut types = Types::new(loc_type, enum_type); // For each defined conversion, figure out the type of the // terminal and enter it into `types` by hand if it is not the @@ -76,7 +81,7 @@ impl<'grammar> TypeInferencer<'grammar> { // e.g. "(" => Lparen(..) ==> no custom type // "Num" => Num() ==> custom type is u32 // "Fraction" => Real(,) ==> custom type is (u32, u32) - for conversion in &enum_token.conversions { + for conversion in &extern_token.enum_token.conversions { let mut tys = Vec::new(); conversion.to.for_each_binding(&mut |ty| tys.push(ty.type_repr())); if tys.is_empty() { continue; } diff --git a/lalrpop/src/normalize/validate/mod.rs b/lalrpop/src/normalize/validate/mod.rs index a689138..87b3c64 100644 --- a/lalrpop/src/normalize/validate/mod.rs +++ b/lalrpop/src/normalize/validate/mod.rs @@ -4,9 +4,9 @@ use super::{NormResult, NormError}; use super::norm_util::{self, Symbols}; use grammar::parse_tree::*; -use intern::{read, InternedString}; +use intern::{intern, read, InternedString}; use regex::Regex; -use util::{Map, Multimap, Set}; +use util::{Map, Multimap, Sep, set, Set}; #[cfg(test)] mod test; @@ -65,6 +65,24 @@ impl<'grammar> Validator<'grammar> { match *item { GrammarItem::Use(..) => { } GrammarItem::ExternToken(ref data) => { + let allowed_names = vec![intern(LOCATION)]; + let mut new_names = set(); + for associated_type in &data.associated_types { + if !allowed_names.contains(&associated_type.type_name) { + return_err!( + associated_type.span, + "associated type `{}` not recognized, \ + try one of the following: {}", + associated_type.type_name, + Sep(", ", &allowed_names)); + } else if !new_names.insert(associated_type.type_name) { + return_err!( + associated_type.span, + "associated type `{}` already specified", + associated_type.type_name); + } + } + match data.enum_token.type_name { TypeRef::Id(_) | TypeRef::Nominal { .. } => { /* OK */ } _ => { diff --git a/lalrpop/src/normalize/validate/test.rs b/lalrpop/src/normalize/validate/test.rs index b795cbc..e28833f 100644 --- a/lalrpop/src/normalize/validate/test.rs +++ b/lalrpop/src/normalize/validate/test.rs @@ -59,3 +59,10 @@ fn named_symbols() { r#"named symbols (like `"Num"`) require a custom action"#, r#"grammar { Term = { >>"Num"<<<>; }; }"#); } + +#[test] +fn bad_assoc_type() { + check_err( + r#"named symbols (like `"Num"`) require a custom action"#, + r#"grammar { extern token { type Foo = i32; } }"#); +} diff --git a/lalrpop/src/parser/mod.rs b/lalrpop/src/parser/mod.rs index 5b6d7c5..a8a5d83 100644 --- a/lalrpop/src/parser/mod.rs +++ b/lalrpop/src/parser/mod.rs @@ -18,7 +18,8 @@ rusty_peg! { parser Parser<'input> { // Grammar GRAMMAR: Grammar = - ( "grammar" + ( + "grammar" @@ -27,7 +28,7 @@ rusty_peg! { type_parameters: tps.unwrap_or(vec![]), parameters: parameters.unwrap_or(vec![]), where_clauses: where_clauses.unwrap_or(vec![]), - items: i } + items: uses.into_iter().chain(i).collect() } }; GRAMMAR_TPS: Vec = @@ -247,11 +248,14 @@ rusty_peg! { EXTERN_TOKEN: GrammarItem = ("extern" "token" "{" + "enum" "{" "}" + "}") => { GrammarItem::ExternToken(ExternToken { + associated_types: a0.into_iter().chain(a1).collect(), enum_token: EnumToken { type_name: t, type_span: Span(lo, hi), @@ -260,6 +264,11 @@ rusty_peg! { }) }; + ASSOCIATED_TYPE: AssociatedType = + ( "type" "=" ";" ) => { + AssociatedType { span: Span(lo, hi), type_name: n, type_ref: t } + }; + CONVERSION: Conversion = ( "=>" ) => { Conversion { span: Span(lo, hi), from: from, to: to } diff --git a/lalrpop/src/parser/test.rs b/lalrpop/src/parser/test.rs index c7ef1ba..5850e92 100644 --- a/lalrpop/src/parser/test.rs +++ b/lalrpop/src/parser/test.rs @@ -90,6 +90,15 @@ fn token_expr() { super::parse_grammar(r#"grammar; extern token { enum Expr { "foo" => Bar } }"#).unwrap(); } +#[test] +fn assoc_types() { + super::parse_grammar(r#"grammar; + extern token { + type Foo = u32; + enum Expr { "foo" => Bar } + type Bar = i32; }"#).unwrap(); +} + #[test] fn map1() { super::parse_grammar(