From 59de01581707d8f10c2436d846623535082f4001 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Wed, 15 Jul 2015 13:31:38 -0400 Subject: [PATCH] tweak the escaping to actually be correctish --- lalrpop-test/src/expr.rs | 1930 +++++++-------- lalrpop-test/src/expr_arena.rs | 4130 ++++++++++++++++---------------- lalrpop-test/src/sub.rs | 480 ++-- lalrpop/src/util.rs | 7 +- 4 files changed, 3273 insertions(+), 3274 deletions(-) diff --git a/lalrpop-test/src/expr.rs b/lalrpop-test/src/expr.rs index 2e715c7..d2b338d 100644 --- a/lalrpop-test/src/expr.rs +++ b/lalrpop-test/src/expr.rs @@ -12,7 +12,7 @@ pub fn parse_Expr< let mut __tokens = __tokens.into_iter(); let __lookahead = __tokens.next(); match try!(__parse__Expr::__state0(scale, __lookahead, &mut __tokens)) { - (__lookahead, __parse__Expr::__Nonterminal::__Expr(__nt)) => Ok((__lookahead, __nt)), + (__lookahead, __parse__Expr::__Nonterminal::____Expr(__nt)) => Ok((__lookahead, __nt)), _ => unreachable!(), } } @@ -23,10 +23,10 @@ mod __parse__Expr { use util::tok::Tok; pub enum __Nonterminal<> { - Expr(i32), - Factor(i32), - __Expr(i32), + ____Expr(i32), Term(i32), + Factor(i32), + Expr(i32), } // State 0 @@ -66,12 +66,12 @@ mod __parse__Expr { // Term = (*) "Num" ["/"] // __Expr = (*) Expr [EOF] // - // "Num" -> Shift(S4) - // "(" -> Shift(S5) + // "Num" -> Shift(S2) + // "(" -> Shift(S4) // + // Factor -> S5 + // Term -> S1 // Expr -> S3 - // Term -> S2 - // Factor -> S1 pub fn __state0< __TOKENS: Iterator, >( @@ -85,12 +85,12 @@ mod __parse__Expr { Some(Tok::Num(__tok0)) => { let mut __sym0 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state4(scale, __lookahead, __tokens, __sym0)); + __result = try!(__state2(scale, __lookahead, __tokens, __sym0)); } Some(__tok @ Tok::LParen(..)) => { let mut __sym0 = &mut Some(__tok); let __lookahead = __tokens.next(); - __result = try!(__state5(scale, __lookahead, __tokens, __sym0)); + __result = try!(__state4(scale, __lookahead, __tokens, __sym0)); } _ => { return Err(__lookahead); @@ -99,18 +99,18 @@ mod __parse__Expr { loop { let (__lookahead, __nt) = __result; match __nt { - __Nonterminal::Expr(__nt) => { + __Nonterminal::Factor(__nt) => { let __sym0 = &mut Some(__nt); - __result = try!(__state3(scale, __lookahead, __tokens, __sym0)); + __result = try!(__state5(scale, __lookahead, __tokens, __sym0)); } __Nonterminal::Term(__nt) => { - let __sym0 = &mut Some(__nt); - __result = try!(__state2(scale, __lookahead, __tokens, __sym0)); - } - __Nonterminal::Factor(__nt) => { let __sym0 = &mut Some(__nt); __result = try!(__state1(scale, __lookahead, __tokens, __sym0)); } + __Nonterminal::Expr(__nt) => { + let __sym0 = &mut Some(__nt); + __result = try!(__state3(scale, __lookahead, __tokens, __sym0)); + } _ => { return Ok((__lookahead, __nt)); } @@ -119,25 +119,17 @@ mod __parse__Expr { } // State 1 - // Expr = Factor (*) [EOF] - // Expr = Factor (*) ["+"] - // Expr = Factor (*) ["-"] - // Factor = Factor (*) "*" Term [EOF] - // Factor = Factor (*) "*" Term ["*"] - // Factor = Factor (*) "*" Term ["+"] - // Factor = Factor (*) "*" Term ["-"] - // Factor = Factor (*) "*" Term ["/"] - // Factor = Factor (*) "/" Term [EOF] - // Factor = Factor (*) "/" Term ["*"] - // Factor = Factor (*) "/" Term ["+"] - // Factor = Factor (*) "/" Term ["-"] - // Factor = Factor (*) "/" Term ["/"] + // Factor = Term (*) [EOF] + // Factor = Term (*) ["*"] + // Factor = Term (*) ["+"] + // Factor = Term (*) ["-"] + // Factor = Term (*) ["/"] // - // "*" -> Shift(S7) - // EOF -> Reduce(Expr = Factor => ActionFn(3);) - // "/" -> Shift(S6) - // "-" -> Reduce(Expr = Factor => ActionFn(3);) - // "+" -> Reduce(Expr = Factor => ActionFn(3);) + // "*" -> 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, @@ -150,50 +142,49 @@ 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!(__state7(scale, __lookahead, __tokens, __sym0, __sym1)); - } - Some(__tok @ Tok::Div(..)) => { - let mut __sym1 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state6(scale, __lookahead, __tokens, __sym0, __sym1)); - } - None => { + Some(Tok::Times(..)) => { 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::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::__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::__action6(scale, __sym0); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); } Some(Tok::Plus(..)) => { 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 2 - // Factor = Term (*) [EOF] - // Factor = Term (*) ["*"] - // Factor = Term (*) ["+"] - // Factor = Term (*) ["-"] - // Factor = Term (*) ["/"] + // Term = "Num" (*) [EOF] + // Term = "Num" (*) ["*"] + // Term = "Num" (*) ["+"] + // Term = "Num" (*) ["-"] + // Term = "Num" (*) ["/"] // - // "+" -> Reduce(Factor = Term => ActionFn(6);) - // EOF -> Reduce(Factor = Term => ActionFn(6);) - // "*" -> Reduce(Factor = Term => ActionFn(6);) - // "-" -> Reduce(Factor = Term => ActionFn(6);) - // "/" -> Reduce(Factor = Term => ActionFn(6);) + // "/" -> 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, @@ -206,30 +197,30 @@ mod __parse__Expr { { let mut __result: (Option, __Nonterminal<>); match __lookahead { - Some(Tok::Plus(..)) => { + Some(Tok::Div(..)) => { 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::Times(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action6(scale, __sym0); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); + 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::__action6(scale, __sym0); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); + let __nt = super::__actions::__action7(scale, __sym0); + return Ok((__lookahead, __Nonterminal::Term(__nt))); } - Some(Tok::Div(..)) => { + Some(Tok::Plus(..)) => { let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action6(scale, __sym0); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); + 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); @@ -246,8 +237,8 @@ mod __parse__Expr { // Expr = Expr (*) "-" Factor ["-"] // __Expr = Expr (*) [EOF] // - // "-" -> Shift(S8) - // "+" -> Shift(S9) + // "-" -> Shift(S6) + // "+" -> Shift(S7) // EOF -> Reduce(__Expr = Expr => ActionFn(0);) // pub fn __state3< @@ -264,17 +255,17 @@ mod __parse__Expr { Some(__tok @ Tok::Minus(..)) => { let mut __sym1 = &mut Some(__tok); let __lookahead = __tokens.next(); - __result = try!(__state8(scale, __lookahead, __tokens, __sym0, __sym1)); + __result = try!(__state6(scale, __lookahead, __tokens, __sym0, __sym1)); } Some(__tok @ Tok::Plus(..)) => { let mut __sym1 = &mut Some(__tok); let __lookahead = __tokens.next(); - __result = try!(__state9(scale, __lookahead, __tokens, __sym0, __sym1)); + __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 Ok((__lookahead, __Nonterminal::____Expr(__nt))); } _ => { return Err(__lookahead); @@ -284,61 +275,6 @@ mod __parse__Expr { } // State 4 - // 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 __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::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::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::Times(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(scale, __sym0); - return Ok((__lookahead, __Nonterminal::Term(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 5 // Expr = (*) Expr "+" Factor [")"] // Expr = (*) Expr "+" Factor ["+"] // Expr = (*) Expr "+" Factor ["-"] @@ -379,13 +315,13 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "(" -> Shift(S10) - // "Num" -> Shift(S12) + // "Num" -> Shift(S9) + // "(" -> Shift(S11) // - // Factor -> S13 - // Expr -> S14 - // Term -> S11 - pub fn __state5< + // Term -> S10 + // Expr -> S12 + // Factor -> S8 + pub fn __state4< __TOKENS: Iterator, >( scale: i32, @@ -396,15 +332,15 @@ mod __parse__Expr { { let mut __result: (Option, __Nonterminal<>); match __lookahead { - Some(__tok @ Tok::LParen(..)) => { - let mut __sym1 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state10(scale, __lookahead, __tokens, __sym1)); - } Some(Tok::Num(__tok0)) => { let mut __sym1 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state12(scale, __lookahead, __tokens, __sym1)); + __result = try!(__state9(scale, __lookahead, __tokens, __sym1)); + } + Some(__tok @ Tok::LParen(..)) => { + let mut __sym1 = &mut Some(__tok); + let __lookahead = __tokens.next(); + __result = try!(__state11(scale, __lookahead, __tokens, __sym1)); } _ => { return Err(__lookahead); @@ -413,17 +349,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!(__state13(scale, __lookahead, __tokens, __sym1)); + __result = try!(__state10(scale, __lookahead, __tokens, __sym1)); } __Nonterminal::Expr(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state14(scale, __lookahead, __tokens, __sym0, __sym1)); + __result = try!(__state12(scale, __lookahead, __tokens, __sym0, __sym1)); } - __Nonterminal::Term(__nt) => { + __Nonterminal::Factor(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state11(scale, __lookahead, __tokens, __sym1)); + __result = try!(__state8(scale, __lookahead, __tokens, __sym1)); } _ => { return Ok((__lookahead, __nt)); @@ -433,131 +369,71 @@ mod __parse__Expr { return Ok(__result); } + // State 5 + // 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 ["/"] + // + // "*" -> Shift(S14) + // "-" -> Reduce(Expr = Factor => ActionFn(3);) + // "+" -> Reduce(Expr = Factor => ActionFn(3);) + // "/" -> Shift(S13) + // EOF -> Reduce(Expr = Factor => ActionFn(3);) + // + pub fn __state5< + __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::Times(..)) => { + let mut __sym1 = &mut Some(__tok); + let __lookahead = __tokens.next(); + __result = try!(__state14(scale, __lookahead, __tokens, __sym0, __sym1)); + } + Some(__tok @ Tok::Div(..)) => { + let mut __sym1 = &mut Some(__tok); + let __lookahead = __tokens.next(); + __result = try!(__state13(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(..)) => { + 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))); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + // State 6 - // Factor = Factor "/" (*) Term [EOF] - // Factor = Factor "/" (*) Term ["*"] - // Factor = Factor "/" (*) Term ["+"] - // Factor = Factor "/" (*) Term ["-"] - // Factor = Factor "/" (*) Term ["/"] - // Term = (*) "(" Expr ")" [EOF] - // Term = (*) "(" Expr ")" ["*"] - // Term = (*) "(" Expr ")" ["+"] - // Term = (*) "(" Expr ")" ["-"] - // Term = (*) "(" Expr ")" ["/"] - // Term = (*) "Num" [EOF] - // Term = (*) "Num" ["*"] - // Term = (*) "Num" ["+"] - // Term = (*) "Num" ["-"] - // Term = (*) "Num" ["/"] - // - // "Num" -> Shift(S4) - // "(" -> Shift(S5) - // - // Term -> S15 - 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!(__state4(scale, __lookahead, __tokens, __sym2)); - } - Some(__tok @ Tok::LParen(..)) => { - let mut __sym2 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state5(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!(__state15(scale, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - _ => { - return Ok((__lookahead, __nt)); - } - } - } - return Ok(__result); - } - - // State 7 - // Factor = Factor "*" (*) Term [EOF] - // Factor = Factor "*" (*) Term ["*"] - // Factor = Factor "*" (*) Term ["+"] - // Factor = Factor "*" (*) Term ["-"] - // Factor = Factor "*" (*) Term ["/"] - // Term = (*) "(" Expr ")" [EOF] - // Term = (*) "(" Expr ")" ["*"] - // Term = (*) "(" Expr ")" ["+"] - // Term = (*) "(" Expr ")" ["-"] - // Term = (*) "(" Expr ")" ["/"] - // Term = (*) "Num" [EOF] - // Term = (*) "Num" ["*"] - // Term = (*) "Num" ["+"] - // Term = (*) "Num" ["-"] - // Term = (*) "Num" ["/"] - // - // "(" -> Shift(S5) - // "Num" -> Shift(S4) - // - // Term -> 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 @ Tok::LParen(..)) => { - let mut __sym2 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state5(scale, __lookahead, __tokens, __sym2)); - } - Some(Tok::Num(__tok0)) => { - let mut __sym2 = &mut Some((__tok0)); - 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!(__state16(scale, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - _ => { - return Ok((__lookahead, __nt)); - } - } - } - return Ok(__result); - } - - // State 8 // Expr = Expr "-" (*) Factor [EOF] // Expr = Expr "-" (*) Factor ["+"] // Expr = Expr "-" (*) Factor ["-"] @@ -587,12 +463,12 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "(" -> Shift(S5) - // "Num" -> Shift(S4) + // "Num" -> Shift(S2) + // "(" -> Shift(S4) // - // Factor -> S17 - // Term -> S2 - pub fn __state8< + // Factor -> S15 + // Term -> S1 + pub fn __state6< __TOKENS: Iterator, >( scale: i32, @@ -604,14 +480,14 @@ 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!(__state5(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)); + } + Some(__tok @ Tok::LParen(..)) => { + let mut __sym2 = &mut Some(__tok); + let __lookahead = __tokens.next(); __result = try!(__state4(scale, __lookahead, __tokens, __sym2)); } _ => { @@ -623,11 +499,11 @@ mod __parse__Expr { match __nt { __Nonterminal::Factor(__nt) => { let __sym2 = &mut Some(__nt); - __result = try!(__state17(scale, __lookahead, __tokens, __sym0, __sym1, __sym2)); + __result = try!(__state15(scale, __lookahead, __tokens, __sym0, __sym1, __sym2)); } __Nonterminal::Term(__nt) => { let __sym2 = &mut Some(__nt); - __result = try!(__state2(scale, __lookahead, __tokens, __sym2)); + __result = try!(__state1(scale, __lookahead, __tokens, __sym2)); } _ => { return Ok((__lookahead, __nt)); @@ -637,7 +513,7 @@ mod __parse__Expr { return Ok(__result); } - // State 9 + // State 7 // Expr = Expr "+" (*) Factor [EOF] // Expr = Expr "+" (*) Factor ["+"] // Expr = Expr "+" (*) Factor ["-"] @@ -667,12 +543,12 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "(" -> Shift(S5) - // "Num" -> Shift(S4) + // "Num" -> Shift(S2) + // "(" -> Shift(S4) // - // Factor -> S18 - // Term -> S2 - pub fn __state9< + // Term -> S1 + // Factor -> S16 + pub fn __state7< __TOKENS: Iterator, >( scale: i32, @@ -684,14 +560,14 @@ 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!(__state5(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)); + } + Some(__tok @ Tok::LParen(..)) => { + let mut __sym2 = &mut Some(__tok); + let __lookahead = __tokens.next(); __result = try!(__state4(scale, __lookahead, __tokens, __sym2)); } _ => { @@ -701,13 +577,13 @@ mod __parse__Expr { while __sym1.is_some() { let (__lookahead, __nt) = __result; match __nt { - __Nonterminal::Factor(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state18(scale, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } __Nonterminal::Term(__nt) => { let __sym2 = &mut Some(__nt); - __result = try!(__state2(scale, __lookahead, __tokens, __sym2)); + __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)); @@ -717,7 +593,181 @@ mod __parse__Expr { return Ok(__result); } + // State 8 + // Expr = Factor (*) [")"] + // Expr = Factor (*) ["+"] + // Expr = Factor (*) ["-"] + // Factor = Factor (*) "*" Term [")"] + // Factor = Factor (*) "*" Term ["*"] + // Factor = Factor (*) "*" Term ["+"] + // Factor = Factor (*) "*" Term ["-"] + // Factor = Factor (*) "*" Term ["/"] + // Factor = Factor (*) "/" Term [")"] + // Factor = Factor (*) "/" Term ["*"] + // Factor = Factor (*) "/" Term ["+"] + // Factor = Factor (*) "/" Term ["-"] + // Factor = Factor (*) "/" Term ["/"] + // + // "/" -> Shift(S17) + // "*" -> Shift(S18) + // "-" -> Reduce(Expr = Factor => ActionFn(3);) + // "+" -> Reduce(Expr = Factor => ActionFn(3);) + // ")" -> Reduce(Expr = Factor => ActionFn(3);) + // + 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 @ 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)); + } + Some(Tok::Minus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action3(scale, __sym0); + return Ok((__lookahead, __Nonterminal::Expr(__nt))); + } + Some(Tok::Plus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action3(scale, __sym0); + return Ok((__lookahead, __Nonterminal::Expr(__nt))); + } + Some(Tok::RParen(..)) => { + 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 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 // Expr = (*) Expr "+" Factor [")"] // Expr = (*) Expr "+" Factor ["+"] // Expr = (*) Expr "+" Factor ["-"] @@ -758,13 +808,13 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "(" -> Shift(S10) - // "Num" -> Shift(S12) + // "(" -> Shift(S11) + // "Num" -> Shift(S9) // + // Factor -> S8 + // Term -> S10 // Expr -> S19 - // Term -> S11 - // Factor -> S13 - pub fn __state10< + pub fn __state11< __TOKENS: Iterator, >( scale: i32, @@ -778,12 +828,12 @@ mod __parse__Expr { Some(__tok @ Tok::LParen(..)) => { let mut __sym1 = &mut Some(__tok); let __lookahead = __tokens.next(); - __result = try!(__state10(scale, __lookahead, __tokens, __sym1)); + __result = try!(__state11(scale, __lookahead, __tokens, __sym1)); } Some(Tok::Num(__tok0)) => { let mut __sym1 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state12(scale, __lookahead, __tokens, __sym1)); + __result = try!(__state9(scale, __lookahead, __tokens, __sym1)); } _ => { return Err(__lookahead); @@ -792,17 +842,17 @@ mod __parse__Expr { while __sym0.is_some() { let (__lookahead, __nt) = __result; match __nt { - __Nonterminal::Expr(__nt) => { + __Nonterminal::Factor(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state19(scale, __lookahead, __tokens, __sym0, __sym1)); + __result = try!(__state8(scale, __lookahead, __tokens, __sym1)); } __Nonterminal::Term(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state11(scale, __lookahead, __tokens, __sym1)); + __result = try!(__state10(scale, __lookahead, __tokens, __sym1)); } - __Nonterminal::Factor(__nt) => { + __Nonterminal::Expr(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state13(scale, __lookahead, __tokens, __sym1)); + __result = try!(__state19(scale, __lookahead, __tokens, __sym0, __sym1)); } _ => { return Ok((__lookahead, __nt)); @@ -812,181 +862,7 @@ mod __parse__Expr { return Ok(__result); } - // State 11 - // 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 __state11< - __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::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))); - } - 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))); - } - _ => { - return Err(__lookahead); - } - } - } - // State 12 - // 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 __state12< - __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::RParen(..)) => { - 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::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))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 13 - // 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 ["/"] - // - // "-" -> Reduce(Expr = Factor => ActionFn(3);) - // ")" -> Reduce(Expr = Factor => ActionFn(3);) - // "+" -> Reduce(Expr = Factor => ActionFn(3);) - // "*" -> Shift(S21) - // "/" -> Shift(S20) - // - pub fn __state13< - __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::Times(..)) => { - let mut __sym1 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state21(scale, __lookahead, __tokens, __sym0, __sym1)); - } - Some(__tok @ Tok::Div(..)) => { - let mut __sym1 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state20(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::RParen(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action3(scale, __sym0); - return Ok((__lookahead, __Nonterminal::Expr(__nt))); - } - Some(Tok::Plus(..)) => { - 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 14 // Expr = Expr (*) "+" Factor [")"] // Expr = Expr (*) "+" Factor ["+"] // Expr = Expr (*) "+" Factor ["-"] @@ -999,11 +875,11 @@ mod __parse__Expr { // Term = "(" Expr (*) ")" ["-"] // Term = "(" Expr (*) ")" ["/"] // - // "-" -> Shift(S24) - // "+" -> Shift(S22) - // ")" -> Shift(S23) + // "-" -> Shift(S22) + // "+" -> Shift(S21) + // ")" -> Shift(S20) // - pub fn __state14< + pub fn __state12< __TOKENS: Iterator, >( scale: i32, @@ -1018,17 +894,17 @@ mod __parse__Expr { Some(__tok @ Tok::Minus(..)) => { let mut __sym2 = &mut Some(__tok); let __lookahead = __tokens.next(); - __result = try!(__state24(scale, __lookahead, __tokens, __sym1, __sym2)); + __result = try!(__state22(scale, __lookahead, __tokens, __sym1, __sym2)); } Some(__tok @ Tok::Plus(..)) => { let mut __sym2 = &mut Some(__tok); let __lookahead = __tokens.next(); - __result = try!(__state22(scale, __lookahead, __tokens, __sym1, __sym2)); + __result = try!(__state21(scale, __lookahead, __tokens, __sym1, __sym2)); } Some(__tok @ Tok::RParen(..)) => { let mut __sym2 = &mut Some(__tok); let __lookahead = __tokens.next(); - __result = try!(__state23(scale, __lookahead, __tokens, __sym0, __sym1, __sym2)); + __result = try!(__state20(scale, __lookahead, __tokens, __sym0, __sym1, __sym2)); } _ => { return Err(__lookahead); @@ -1037,141 +913,131 @@ mod __parse__Expr { 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(..)) => { + 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)); + } + _ => { + 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 + // 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 -> S24 + pub fn __state14< + __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!(__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)); + } + _ => { + return Err(__lookahead); + } + } + while __sym1.is_some() { + let (__lookahead, __nt) = __result; + match __nt { + __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state24(scale, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + _ => { + return Ok((__lookahead, __nt)); + } + } + } + return Ok(__result); + } + // State 15 - // 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);) - // "*" -> Reduce(Factor = Factor, "/", Term => ActionFn(5);) - // EOF -> Reduce(Factor = Factor, "/", Term => ActionFn(5);) - // - 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::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))); - } - 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))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 16 - // 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 __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 { - 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::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::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(); - 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))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 17 // Expr = Expr "-" Factor (*) [EOF] // Expr = Expr "-" Factor (*) ["+"] // Expr = Expr "-" Factor (*) ["-"] @@ -1186,13 +1052,13 @@ mod __parse__Expr { // Factor = Factor (*) "/" Term ["-"] // Factor = Factor (*) "/" Term ["/"] // - // "+" -> Reduce(Expr = Expr, "-", Factor => ActionFn(1);) - // "*" -> Shift(S7) - // "/" -> Shift(S6) + // "/" -> 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 __state17< + pub fn __state15< __TOKENS: Iterator, >( scale: i32, @@ -1205,22 +1071,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!(__state7(scale, __lookahead, __tokens, __sym2, __sym3)); - } Some(__tok @ Tok::Div(..)) => { let mut __sym3 = &mut Some(__tok); let __lookahead = __tokens.next(); - __result = try!(__state6(scale, __lookahead, __tokens, __sym2, __sym3)); + __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::__action1(scale, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Expr(__nt))); + 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(); @@ -1236,6 +1095,13 @@ mod __parse__Expr { 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); } @@ -1243,7 +1109,7 @@ mod __parse__Expr { return Ok(__result); } - // State 18 + // State 16 // Expr = Expr "+" Factor (*) [EOF] // Expr = Expr "+" Factor (*) ["+"] // Expr = Expr "+" Factor (*) ["-"] @@ -1258,13 +1124,13 @@ mod __parse__Expr { // Factor = Factor (*) "/" Term ["-"] // Factor = Factor (*) "/" Term ["/"] // - // "/" -> Shift(S6) - // EOF -> Reduce(Expr = Expr, "+", Factor => ActionFn(2);) - // "*" -> Shift(S7) + // "*" -> 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 __state18< + pub fn __state16< __TOKENS: Iterator, >( scale: i32, @@ -1277,24 +1143,24 @@ 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!(__state6(scale, __lookahead, __tokens, __sym2, __sym3)); - } Some(__tok @ Tok::Times(..)) => { let mut __sym3 = &mut Some(__tok); let __lookahead = __tokens.next(); - __result = try!(__state7(scale, __lookahead, __tokens, __sym2, __sym3)); + __result = try!(__state14(scale, __lookahead, __tokens, __sym2, __sym3)); } - None => { + 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))); } - Some(Tok::Plus(..)) => { + None => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); @@ -1315,58 +1181,7 @@ mod __parse__Expr { return Ok(__result); } - // State 19 - // Expr = Expr (*) "+" Factor [")"] - // Expr = Expr (*) "+" Factor ["+"] - // Expr = Expr (*) "+" Factor ["-"] - // Expr = Expr (*) "-" Factor [")"] - // Expr = Expr (*) "-" Factor ["+"] - // Expr = Expr (*) "-" Factor ["-"] - // Term = "(" Expr (*) ")" [")"] - // Term = "(" Expr (*) ")" ["*"] - // Term = "(" Expr (*) ")" ["+"] - // Term = "(" Expr (*) ")" ["-"] - // Term = "(" Expr (*) ")" ["/"] - // - // "+" -> Shift(S22) - // "-" -> Shift(S24) - // ")" -> Shift(S25) - // - pub fn __state19< - __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::Plus(..)) => { - let mut __sym2 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state22(scale, __lookahead, __tokens, __sym1, __sym2)); - } - Some(__tok @ Tok::Minus(..)) => { - let mut __sym2 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state24(scale, __lookahead, __tokens, __sym1, __sym2)); - } - Some(__tok @ Tok::RParen(..)) => { - let mut __sym2 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state25(scale, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 20 + // State 17 // Factor = Factor "/" (*) Term [")"] // Factor = Factor "/" (*) Term ["*"] // Factor = Factor "/" (*) Term ["+"] @@ -1383,11 +1198,11 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "Num" -> Shift(S12) - // "(" -> Shift(S10) + // "Num" -> Shift(S9) + // "(" -> Shift(S11) // - // Term -> S26 - pub fn __state20< + // Term -> S25 + pub fn __state17< __TOKENS: Iterator, >( scale: i32, @@ -1402,12 +1217,74 @@ mod __parse__Expr { Some(Tok::Num(__tok0)) => { let mut __sym2 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state12(scale, __lookahead, __tokens, __sym2)); + __result = try!(__state9(scale, __lookahead, __tokens, __sym2)); } Some(__tok @ Tok::LParen(..)) => { let mut __sym2 = &mut Some(__tok); let __lookahead = __tokens.next(); - __result = try!(__state10(scale, __lookahead, __tokens, __sym2)); + __result = try!(__state11(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!(__state25(scale, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + _ => { + return Ok((__lookahead, __nt)); + } + } + } + return Ok(__result); + } + + // State 18 + // Factor = Factor "*" (*) Term [")"] + // Factor = Factor "*" (*) Term ["*"] + // Factor = Factor "*" (*) Term ["+"] + // Factor = Factor "*" (*) Term ["-"] + // Factor = Factor "*" (*) Term ["/"] + // Term = (*) "(" Expr ")" [")"] + // Term = (*) "(" Expr ")" ["*"] + // Term = (*) "(" Expr ")" ["+"] + // Term = (*) "(" Expr ")" ["-"] + // Term = (*) "(" Expr ")" ["/"] + // Term = (*) "Num" [")"] + // Term = (*) "Num" ["*"] + // Term = (*) "Num" ["+"] + // Term = (*) "Num" ["-"] + // Term = (*) "Num" ["/"] + // + // "Num" -> Shift(S9) + // "(" -> Shift(S11) + // + // Term -> S26 + pub fn __state18< + __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!(__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); @@ -1428,69 +1305,125 @@ mod __parse__Expr { return Ok(__result); } - // State 21 - // Factor = Factor "*" (*) Term [")"] - // Factor = Factor "*" (*) Term ["*"] - // Factor = Factor "*" (*) Term ["+"] - // Factor = Factor "*" (*) Term ["-"] - // Factor = Factor "*" (*) Term ["/"] - // Term = (*) "(" Expr ")" [")"] - // Term = (*) "(" Expr ")" ["*"] - // Term = (*) "(" Expr ")" ["+"] - // Term = (*) "(" Expr ")" ["-"] - // Term = (*) "(" Expr ")" ["/"] - // Term = (*) "Num" [")"] - // Term = (*) "Num" ["*"] - // Term = (*) "Num" ["+"] - // Term = (*) "Num" ["-"] - // Term = (*) "Num" ["/"] + // State 19 + // Expr = Expr (*) "+" Factor [")"] + // Expr = Expr (*) "+" Factor ["+"] + // Expr = Expr (*) "+" Factor ["-"] + // Expr = Expr (*) "-" Factor [")"] + // Expr = Expr (*) "-" Factor ["+"] + // Expr = Expr (*) "-" Factor ["-"] + // Term = "(" Expr (*) ")" [")"] + // Term = "(" Expr (*) ")" ["*"] + // Term = "(" Expr (*) ")" ["+"] + // Term = "(" Expr (*) ")" ["-"] + // Term = "(" Expr (*) ")" ["/"] // - // "Num" -> Shift(S12) - // "(" -> Shift(S10) + // "-" -> Shift(S22) + // ")" -> Shift(S27) + // "+" -> Shift(S21) // - // Term -> S27 - pub fn __state21< + pub fn __state19< __TOKENS: Iterator, >( scale: i32, mut __lookahead: Option, __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option, + __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!(__state12(scale, __lookahead, __tokens, __sym2)); - } - Some(__tok @ Tok::LParen(..)) => { + Some(__tok @ Tok::Minus(..)) => { let mut __sym2 = &mut Some(__tok); let __lookahead = __tokens.next(); - __result = try!(__state10(scale, __lookahead, __tokens, __sym2)); + __result = try!(__state22(scale, __lookahead, __tokens, __sym1, __sym2)); + } + Some(__tok @ Tok::RParen(..)) => { + let mut __sym2 = &mut Some(__tok); + let __lookahead = __tokens.next(); + __result = try!(__state27(scale, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + Some(__tok @ Tok::Plus(..)) => { + let mut __sym2 = &mut Some(__tok); + let __lookahead = __tokens.next(); + __result = try!(__state21(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!(__state27(scale, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - _ => { - return Ok((__lookahead, __nt)); - } - } - } return Ok(__result); } - // State 22 + // State 20 + // Term = "(" Expr ")" (*) [EOF] + // Term = "(" Expr ")" (*) ["*"] + // Term = "(" Expr ")" (*) ["+"] + // Term = "(" 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);) + // + pub fn __state20< + __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::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))); + } + 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(); + 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(); + let __nt = super::__actions::__action8(scale, __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::__action8(scale, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Term(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 21 // Expr = Expr "+" (*) Factor [")"] // Expr = Expr "+" (*) Factor ["+"] // Expr = Expr "+" (*) Factor ["-"] @@ -1520,12 +1453,12 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "(" -> Shift(S10) - // "Num" -> Shift(S12) + // "Num" -> Shift(S9) + // "(" -> Shift(S11) // + // Term -> S10 // Factor -> S28 - // Term -> S11 - pub fn __state22< + pub fn __state21< __TOKENS: Iterator, >( scale: i32, @@ -1537,15 +1470,15 @@ 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!(__state10(scale, __lookahead, __tokens, __sym2)); - } Some(Tok::Num(__tok0)) => { let mut __sym2 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state12(scale, __lookahead, __tokens, __sym2)); + __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); @@ -1554,14 +1487,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!(__state28(scale, __lookahead, __tokens, __sym0, __sym1, __sym2)); } - __Nonterminal::Term(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state11(scale, __lookahead, __tokens, __sym2)); - } _ => { return Ok((__lookahead, __nt)); } @@ -1570,74 +1503,7 @@ mod __parse__Expr { return Ok(__result); } - // State 23 - // Term = "(" Expr ")" (*) [EOF] - // Term = "(" Expr ")" (*) ["*"] - // Term = "(" 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);) - // EOF -> Reduce(Term = "(", Expr, ")" => ActionFn(8);) - // - pub fn __state23< - __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::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::Plus(..)) => { - 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(..)) => { - 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::Times(..)) => { - 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))); - } - 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 24 + // State 22 // Expr = Expr "-" (*) Factor [")"] // Expr = Expr "-" (*) Factor ["+"] // Expr = Expr "-" (*) Factor ["-"] @@ -1667,12 +1533,12 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "Num" -> Shift(S12) - // "(" -> Shift(S10) + // "(" -> Shift(S11) + // "Num" -> Shift(S9) // - // Term -> S11 + // Term -> S10 // Factor -> S29 - pub fn __state24< + pub fn __state22< __TOKENS: Iterator, >( scale: i32, @@ -1684,15 +1550,15 @@ mod __parse__Expr { { let mut __result: (Option, __Nonterminal<>); match __lookahead { - Some(Tok::Num(__tok0)) => { - let mut __sym2 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state12(scale, __lookahead, __tokens, __sym2)); - } Some(__tok @ Tok::LParen(..)) => { let mut __sym2 = &mut Some(__tok); let __lookahead = __tokens.next(); - __result = try!(__state10(scale, __lookahead, __tokens, __sym2)); + __result = try!(__state11(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)); } _ => { return Err(__lookahead); @@ -1703,7 +1569,7 @@ mod __parse__Expr { match __nt { __Nonterminal::Term(__nt) => { let __sym2 = &mut Some(__nt); - __result = try!(__state11(scale, __lookahead, __tokens, __sym2)); + __result = try!(__state10(scale, __lookahead, __tokens, __sym2)); } __Nonterminal::Factor(__nt) => { let __sym2 = &mut Some(__nt); @@ -1717,18 +1583,152 @@ mod __parse__Expr { return Ok(__result); } - // State 25 - // Term = "(" Expr ")" (*) [")"] - // Term = "(" Expr ")" (*) ["*"] - // Term = "(" Expr ")" (*) ["+"] - // Term = "(" Expr ")" (*) ["-"] - // Term = "(" Expr ")" (*) ["/"] + // State 23 + // Factor = Factor "/" Term (*) [EOF] + // Factor = Factor "/" Term (*) ["*"] + // Factor = Factor "/" Term (*) ["+"] + // Factor = Factor "/" Term (*) ["-"] + // Factor = Factor "/" Term (*) ["/"] // - // "*" -> 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(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 __state23< + __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::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))); + } + 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::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); + } + } + } + + // State 24 + // 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);) + // + pub fn __state24< + __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::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))); + } + 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::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))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 25 + // 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);) // pub fn __state25< __TOKENS: Iterator, @@ -1736,47 +1736,47 @@ mod __parse__Expr { scale: i32, mut __lookahead: Option, __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option, - __sym2: &mut Option, + __sym0: &mut Option, + __sym1: &mut Option, + __sym2: &mut Option, ) -> Result<(Option, __Nonterminal<>), Option> { let mut __result: (Option, __Nonterminal<>); match __lookahead { - Some(Tok::Times(..)) => { + Some(Tok::RParen(..)) => { 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(..)) => { - 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))); + 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::__action8(scale, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Term(__nt))); + 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::__action8(scale, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Term(__nt))); + let __nt = super::__actions::__action5(scale, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); } - Some(Tok::RParen(..)) => { + 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))); + 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); @@ -1785,17 +1785,17 @@ mod __parse__Expr { } // State 26 - // Factor = Factor "/" Term (*) [")"] - // Factor = Factor "/" Term (*) ["*"] - // Factor = Factor "/" Term (*) ["+"] - // Factor = Factor "/" Term (*) ["-"] - // Factor = Factor "/" Term (*) ["/"] + // Factor = Factor "*" Term (*) [")"] + // Factor = Factor "*" Term (*) ["*"] + // Factor = Factor "*" Term (*) ["+"] + // Factor = Factor "*" Term (*) ["-"] + // Factor = Factor "*" Term (*) ["/"] // - // "/" -> Reduce(Factor = 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(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, @@ -1814,35 +1814,35 @@ mod __parse__Expr { 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::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::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::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); + let __nt = super::__actions::__action4(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(); - let __nt = super::__actions::__action5(scale, __sym0, __sym1, __sym2); + 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(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action4(scale, __sym0, __sym1, __sym2); return Ok((__lookahead, __Nonterminal::Factor(__nt))); } _ => { @@ -1852,17 +1852,17 @@ mod __parse__Expr { } // State 27 - // Factor = Factor "*" Term (*) [")"] - // Factor = Factor "*" Term (*) ["*"] - // Factor = Factor "*" Term (*) ["+"] - // Factor = Factor "*" Term (*) ["-"] - // Factor = Factor "*" Term (*) ["/"] + // Term = "(" Expr ")" (*) [")"] + // Term = "(" Expr ")" (*) ["*"] + // Term = "(" Expr ")" (*) ["+"] + // Term = "(" Expr ")" (*) ["-"] + // Term = "(" Expr ")" (*) ["/"] // - // "-" -> 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(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, @@ -1870,47 +1870,47 @@ mod __parse__Expr { scale: i32, mut __lookahead: Option, __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option, - __sym2: &mut Option, + __sym0: &mut Option, + __sym1: &mut Option, + __sym2: &mut Option, ) -> Result<(Option, __Nonterminal<>), Option> { 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(..)) => { 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))); + let __nt = super::__actions::__action8(scale, __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::__action4(scale, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); + let __nt = super::__actions::__action8(scale, __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::__action4(scale, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); + let __nt = super::__actions::__action8(scale, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Term(__nt))); } - Some(Tok::Div(..)) => { + 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))); + let __nt = super::__actions::__action8(scale, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Term(__nt))); } _ => { return Err(__lookahead); @@ -1933,10 +1933,10 @@ mod __parse__Expr { // Factor = Factor (*) "/" Term ["-"] // Factor = Factor (*) "/" Term ["/"] // - // "*" -> Shift(S21) - // "+" -> Reduce(Expr = Expr, "+", Factor => ActionFn(2);) - // "/" -> Shift(S20) + // "*" -> Shift(S18) // "-" -> Reduce(Expr = Expr, "+", Factor => ActionFn(2);) + // "/" -> Shift(S17) + // "+" -> Reduce(Expr = Expr, "+", Factor => ActionFn(2);) // ")" -> Reduce(Expr = Expr, "+", Factor => ActionFn(2);) // pub fn __state28< @@ -1955,21 +1955,21 @@ mod __parse__Expr { Some(__tok @ Tok::Times(..)) => { let mut __sym3 = &mut Some(__tok); let __lookahead = __tokens.next(); - __result = try!(__state21(scale, __lookahead, __tokens, __sym2, __sym3)); + __result = try!(__state18(scale, __lookahead, __tokens, __sym2, __sym3)); } Some(__tok @ Tok::Div(..)) => { let mut __sym3 = &mut Some(__tok); let __lookahead = __tokens.next(); - __result = try!(__state20(scale, __lookahead, __tokens, __sym2, __sym3)); + __result = try!(__state17(scale, __lookahead, __tokens, __sym2, __sym3)); } - 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::__action2(scale, __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(); @@ -2005,11 +2005,11 @@ mod __parse__Expr { // Factor = Factor (*) "/" Term ["-"] // Factor = Factor (*) "/" Term ["/"] // - // "*" -> Shift(S21) // "-" -> Reduce(Expr = Expr, "-", Factor => ActionFn(1);) - // "/" -> Shift(S20) - // ")" -> Reduce(Expr = Expr, "-", Factor => ActionFn(1);) + // "*" -> Shift(S18) // "+" -> Reduce(Expr = Expr, "-", Factor => ActionFn(1);) + // "/" -> Shift(S17) + // ")" -> Reduce(Expr = Expr, "-", Factor => ActionFn(1);) // pub fn __state29< __TOKENS: Iterator, @@ -2027,12 +2027,12 @@ mod __parse__Expr { Some(__tok @ Tok::Times(..)) => { let mut __sym3 = &mut Some(__tok); let __lookahead = __tokens.next(); - __result = try!(__state21(scale, __lookahead, __tokens, __sym2, __sym3)); + __result = try!(__state18(scale, __lookahead, __tokens, __sym2, __sym3)); } Some(__tok @ Tok::Div(..)) => { let mut __sym3 = &mut Some(__tok); let __lookahead = __tokens.next(); - __result = try!(__state20(scale, __lookahead, __tokens, __sym2, __sym3)); + __result = try!(__state17(scale, __lookahead, __tokens, __sym2, __sym3)); } Some(Tok::Minus(..)) => { let __sym0 = __sym0.take().unwrap(); @@ -2041,14 +2041,14 @@ mod __parse__Expr { let __nt = super::__actions::__action1(scale, __sym0, __sym1, __sym2); return Ok((__lookahead, __Nonterminal::Expr(__nt))); } - 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::__action1(scale, __sym0, __sym1, __sym2); return Ok((__lookahead, __Nonterminal::Expr(__nt))); } - Some(Tok::Plus(..)) => { + Some(Tok::RParen(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); diff --git a/lalrpop-test/src/expr_arena.rs b/lalrpop-test/src/expr_arena.rs index 89642fe..282c1d6 100644 --- a/lalrpop-test/src/expr_arena.rs +++ b/lalrpop-test/src/expr_arena.rs @@ -14,7 +14,7 @@ pub fn parse_Expr< let mut __tokens = __tokens.into_iter(); let __lookahead = __tokens.next(); match try!(__parse__Expr::__state0(arena, __lookahead, &mut __tokens)) { - (__lookahead, __parse__Expr::__Nonterminal::__Expr(__nt)) => Ok((__lookahead, __nt)), + (__lookahead, __parse__Expr::__Nonterminal::____Expr(__nt)) => Ok((__lookahead, __nt)), _ => unreachable!(), } } @@ -26,14 +26,14 @@ mod __parse__Expr { use util::tok::Tok; pub enum __Nonterminal<'ast, > { - Factor(&'ast Node<'ast>), - Expr(&'ast Node<'ast>), + Expr_3f(::std::option::Option<&'ast Node<'ast>>), Term(&'ast Node<'ast>), - Expr_(::std::option::Option<&'ast Node<'ast>>), - __Expr_______(::std::vec::Vec<&'ast Node<'ast>>), - Comma_Expr_(Vec<&'ast Node<'ast>>), - __Expr(&'ast Node<'ast>), - __Expr______(&'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>), + Expr(&'ast Node<'ast>), + Factor(&'ast Node<'ast>), } // State 0 @@ -78,13 +78,13 @@ mod __parse__Expr { // Term = (*) "Num" ["/"] // __Expr = (*) Expr [EOF] // - // "*" -> Shift(S5) - // "Num" -> Shift(S1) + // "*" -> Shift(S6) // "(" -> Shift(S3) + // "Num" -> Shift(S1) // - // Expr -> S6 - // Term -> S2 + // Expr -> S2 // Factor -> S4 + // Term -> S5 pub fn __state0< 'ast, __TOKENS: Iterator, @@ -99,18 +99,18 @@ mod __parse__Expr { Some(__tok @ Tok::Times(..)) => { let mut __sym0 = &mut Some(__tok); let __lookahead = __tokens.next(); - __result = try!(__state5(arena, __lookahead, __tokens, __sym0)); - } - 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)); } Some(__tok @ Tok::LParen(..)) => { let mut __sym0 = &mut Some(__tok); let __lookahead = __tokens.next(); __result = try!(__state3(arena, __lookahead, __tokens, __sym0)); } + Some(Tok::Num(__tok0)) => { + let mut __sym0 = &mut Some((__tok0)); + let __lookahead = __tokens.next(); + __result = try!(__state1(arena, __lookahead, __tokens, __sym0)); + } _ => { return Err(__lookahead); } @@ -119,10 +119,6 @@ mod __parse__Expr { let (__lookahead, __nt) = __result; match __nt { __Nonterminal::Expr(__nt) => { - let __sym0 = &mut Some(__nt); - __result = try!(__state6(arena, __lookahead, __tokens, __sym0)); - } - __Nonterminal::Term(__nt) => { let __sym0 = &mut Some(__nt); __result = try!(__state2(arena, __lookahead, __tokens, __sym0)); } @@ -130,6 +126,10 @@ mod __parse__Expr { 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)); + } _ => { return Ok((__lookahead, __nt)); } @@ -144,11 +144,11 @@ mod __parse__Expr { // Term = "Num" (*) ["-"] // Term = "Num" (*) ["/"] // - // "*" -> Reduce(Term = "Num" => ActionFn(8);) // 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);) + // "*" -> Reduce(Term = "Num" => ActionFn(8);) + // "/" -> Reduce(Term = "Num" => ActionFn(8);) // pub fn __state1< 'ast, @@ -162,17 +162,12 @@ mod __parse__Expr { { 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))); - } None => { let __sym0 = __sym0.take().unwrap(); let __nt = super::__actions::__action8(arena, __sym0); return Ok((__lookahead, __Nonterminal::Term(__nt))); } - Some(Tok::Div(..)) => { + Some(Tok::Plus(..)) => { let __sym0 = __sym0.take().unwrap(); let __nt = super::__actions::__action8(arena, __sym0); return Ok((__lookahead, __Nonterminal::Term(__nt))); @@ -182,7 +177,12 @@ mod __parse__Expr { let __nt = super::__actions::__action8(arena, __sym0); return Ok((__lookahead, __Nonterminal::Term(__nt))); } - Some(Tok::Plus(..)) => { + 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))); @@ -194,17 +194,17 @@ mod __parse__Expr { } // State 2 - // Factor = Term (*) [EOF] - // Factor = Term (*) ["*"] - // Factor = Term (*) ["+"] - // Factor = Term (*) ["-"] - // 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] // - // "-" -> Reduce(Factor = Term => ActionFn(7);) - // "*" -> Reduce(Factor = Term => ActionFn(7);) - // EOF -> Reduce(Factor = Term => ActionFn(7);) - // "+" -> Reduce(Factor = Term => ActionFn(7);) - // "/" -> Reduce(Factor = Term => ActionFn(7);) + // "-" -> Shift(S7) + // EOF -> Reduce(__Expr = Expr => ActionFn(0);) + // "+" -> Shift(S8) // pub fn __state2< 'ast, @@ -218,35 +218,26 @@ mod __parse__Expr { { 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 @ Tok::Minus(..)) => { + let mut __sym1 = &mut Some(__tok); + let __lookahead = __tokens.next(); + __result = try!(__state7(arena, __lookahead, __tokens, __sym0, __sym1)); } - Some(Tok::Times(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); + 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::__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))); + let __nt = super::__actions::__action0(arena, __sym0); + return Ok((__lookahead, __Nonterminal::____Expr(__nt))); } _ => { return Err(__lookahead); } } + return Ok(__result); } // State 3 @@ -295,13 +286,13 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "(" -> Shift(S12) - // "*" -> Shift(S8) - // "Num" -> Shift(S10) + // "Num" -> Shift(S12) + // "(" -> Shift(S14) + // "*" -> Shift(S10) // - // Factor -> S7 // Term -> S9 - // Expr -> S11 + // Factor -> S11 + // Expr -> S13 pub fn __state3< 'ast, __TOKENS: Iterator, @@ -314,18 +305,18 @@ mod __parse__Expr { { let mut __result: (Option, __Nonterminal<'ast, >); match __lookahead { - Some(__tok @ Tok::LParen(..)) => { - let mut __sym1 = &mut Some(__tok); + Some(Tok::Num(__tok0)) => { + let mut __sym1 = &mut Some((__tok0)); let __lookahead = __tokens.next(); __result = try!(__state12(arena, __lookahead, __tokens, __sym1)); } - Some(__tok @ Tok::Times(..)) => { + Some(__tok @ Tok::LParen(..)) => { let mut __sym1 = &mut Some(__tok); let __lookahead = __tokens.next(); - __result = try!(__state8(arena, __lookahead, __tokens, __sym1)); + __result = try!(__state14(arena, __lookahead, __tokens, __sym1)); } - Some(Tok::Num(__tok0)) => { - let mut __sym1 = &mut Some((__tok0)); + Some(__tok @ Tok::Times(..)) => { + let mut __sym1 = &mut Some(__tok); let __lookahead = __tokens.next(); __result = try!(__state10(arena, __lookahead, __tokens, __sym1)); } @@ -336,17 +327,17 @@ mod __parse__Expr { while __sym0.is_some() { let (__lookahead, __nt) = __result; match __nt { - __Nonterminal::Factor(__nt) => { - let __sym1 = &mut Some(__nt); - __result = try!(__state7(arena, __lookahead, __tokens, __sym1)); - } __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)); + } __Nonterminal::Expr(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state11(arena, __lookahead, __tokens, __sym0, __sym1)); + __result = try!(__state13(arena, __lookahead, __tokens, __sym0, __sym1)); } _ => { return Ok((__lookahead, __nt)); @@ -371,10 +362,10 @@ mod __parse__Expr { // Factor = Factor (*) "/" Term ["-"] // Factor = Factor (*) "/" Term ["/"] // + // "/" -> Shift(S16) // "+" -> Reduce(Expr = Factor => ActionFn(3);) - // "*" -> Shift(S13) // "-" -> Reduce(Expr = Factor => ActionFn(3);) - // "/" -> Shift(S14) + // "*" -> Shift(S15) // EOF -> Reduce(Expr = Factor => ActionFn(3);) // pub fn __state4< @@ -389,15 +380,15 @@ 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!(__state13(arena, __lookahead, __tokens, __sym0, __sym1)); - } Some(__tok @ Tok::Div(..)) => { let mut __sym1 = &mut Some(__tok); let __lookahead = __tokens.next(); - __result = try!(__state14(arena, __lookahead, __tokens, __sym0, __sym1)); + __result = try!(__state16(arena, __lookahead, __tokens, __sym0, __sym1)); + } + Some(__tok @ Tok::Times(..)) => { + 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(); @@ -422,15 +413,71 @@ 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 ")" ["+"] // Factor = "*" (*) "(" Comma ")" ["-"] // Factor = "*" (*) "(" Comma ")" ["/"] // - // "(" -> Shift(S15) + // "(" -> Shift(S17) // - pub fn __state5< + pub fn __state6< 'ast, __TOKENS: Iterator, >( @@ -443,57 +490,10 @@ mod __parse__Expr { let mut __result: (Option, __Nonterminal<'ast, >); match __lookahead { Some(__tok @ Tok::LParen(..)) => { - let mut __sym1 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state15(arena, __lookahead, __tokens, __sym0, __sym1)); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 6 - // Expr = Expr (*) "+" Factor [EOF] - // Expr = Expr (*) "+" Factor ["+"] - // Expr = Expr (*) "+" Factor ["-"] - // Expr = Expr (*) "-" Factor [EOF] - // Expr = Expr (*) "-" Factor ["+"] - // Expr = Expr (*) "-" Factor ["-"] - // __Expr = Expr (*) [EOF] - // - // EOF -> Reduce(__Expr = Expr => ActionFn(0);) - // "-" -> Shift(S16) - // "+" -> Shift(S17) - // - pub fn __state6< - '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!(__state16(arena, __lookahead, __tokens, __sym0, __sym1)); - } - Some(__tok @ Tok::Plus(..)) => { let mut __sym1 = &mut Some(__tok); let __lookahead = __tokens.next(); __result = try!(__state17(arena, __lookahead, __tokens, __sym0, __sym1)); } - None => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action0(arena, __sym0); - return Ok((__lookahead, __Nonterminal::__Expr(__nt))); - } _ => { return Err(__lookahead); } @@ -502,29 +502,205 @@ mod __parse__Expr { } // State 7 - // 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 ["/"] + // Expr = Expr "-" (*) Factor [EOF] + // Expr = Expr "-" (*) Factor ["+"] + // Expr = Expr "-" (*) Factor ["-"] + // Factor = (*) Factor "*" Term [EOF] + // Factor = (*) Factor "*" Term ["*"] + // Factor = (*) Factor "*" Term ["+"] + // Factor = (*) Factor "*" Term ["-"] + // Factor = (*) Factor "*" Term ["/"] + // Factor = (*) Factor "/" Term [EOF] + // Factor = (*) Factor "/" Term ["*"] + // Factor = (*) Factor "/" Term ["+"] + // Factor = (*) Factor "/" Term ["-"] + // Factor = (*) Factor "/" Term ["/"] + // Factor = (*) Term [EOF] + // Factor = (*) Term ["*"] + // Factor = (*) Term ["+"] + // Factor = (*) Term ["-"] + // Factor = (*) Term ["/"] + // Factor = (*) "*" "(" Comma ")" [EOF] + // Factor = (*) "*" "(" Comma ")" ["*"] + // Factor = (*) "*" "(" Comma ")" ["+"] + // Factor = (*) "*" "(" Comma ")" ["-"] + // Factor = (*) "*" "(" Comma ")" ["/"] + // Term = (*) "(" Expr ")" [EOF] + // Term = (*) "(" Expr ")" ["*"] + // Term = (*) "(" Expr ")" ["+"] + // Term = (*) "(" Expr ")" ["-"] + // Term = (*) "(" Expr ")" ["/"] + // Term = (*) "Num" [EOF] + // Term = (*) "Num" ["*"] + // Term = (*) "Num" ["+"] + // Term = (*) "Num" ["-"] + // Term = (*) "Num" ["/"] // - // "*" -> Shift(S18) - // "/" -> Shift(S19) - // ")" -> Reduce(Expr = Factor => ActionFn(3);) - // "+" -> Reduce(Expr = Factor => ActionFn(3);) - // "-" -> Reduce(Expr = Factor => ActionFn(3);) + // "*" -> Shift(S6) + // "Num" -> Shift(S1) + // "(" -> Shift(S3) // + // Factor -> S18 + // Term -> S5 pub fn __state7< '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!(__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)); + } + Some(__tok @ Tok::LParen(..)) => { + let mut __sym2 = &mut Some(__tok); + let __lookahead = __tokens.next(); + __result = try!(__state3(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!(__state18(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state5(arena, __lookahead, __tokens, __sym2)); + } + _ => { + return Ok((__lookahead, __nt)); + } + } + } + return Ok(__result); + } + + // 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 ")" ["/"] + // Term = (*) "(" Expr ")" [EOF] + // Term = (*) "(" Expr ")" ["*"] + // Term = (*) "(" Expr ")" ["+"] + // Term = (*) "(" Expr ")" ["-"] + // Term = (*) "(" Expr ")" ["/"] + // Term = (*) "Num" [EOF] + // Term = (*) "Num" ["*"] + // Term = (*) "Num" ["+"] + // Term = (*) "Num" ["-"] + // Term = (*) "Num" ["/"] + // + // "(" -> Shift(S3) + // "Num" -> Shift(S1) + // "*" -> Shift(S6) + // + // Term -> S5 + // Factor -> S19 + pub fn __state8< + '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!(__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)); + } + Some(__tok @ Tok::Times(..)) => { + let mut __sym2 = &mut Some(__tok); + let __lookahead = __tokens.next(); + __result = try!(__state6(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!(__state5(arena, __lookahead, __tokens, __sym2)); + } + __Nonterminal::Factor(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state19(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + _ => { + return Ok((__lookahead, __nt)); + } + } + } + return Ok(__result); + } + + // 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, @@ -534,39 +710,38 @@ 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!(__state18(arena, __lookahead, __tokens, __sym0, __sym1)); - } - Some(__tok @ Tok::Div(..)) => { - let mut __sym1 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state19(arena, __lookahead, __tokens, __sym0, __sym1)); - } - Some(Tok::RParen(..)) => { + Some(Tok::Minus(..)) => { let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action3(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Expr(__nt))); + 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::__action3(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Expr(__nt))); + let __nt = super::__actions::__action7(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); } - Some(Tok::Minus(..)) => { + Some(Tok::Times(..)) => { let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action3(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::RParen(..)) => { + 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 8 + // State 10 // Factor = "*" (*) "(" Comma ")" [")"] // Factor = "*" (*) "(" Comma ")" ["*"] // Factor = "*" (*) "(" Comma ")" ["+"] @@ -575,7 +750,7 @@ mod __parse__Expr { // // "(" -> Shift(S20) // - pub fn __state8< + pub fn __state10< 'ast, __TOKENS: Iterator, >( @@ -599,20 +774,28 @@ mod __parse__Expr { return Ok(__result); } - // State 9 - // Factor = Term (*) [")"] - // Factor = Term (*) ["*"] - // Factor = Term (*) ["+"] - // Factor = Term (*) ["-"] - // Factor = Term (*) ["/"] + // State 11 + // 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 ["/"] // - // "-" -> 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(Expr = Factor => ActionFn(3);) + // "/" -> Shift(S21) + // ")" -> Reduce(Expr = Factor => ActionFn(3);) + // "+" -> Reduce(Expr = Factor => ActionFn(3);) + // "*" -> Shift(S22) // - pub fn __state9< + pub fn __state11< 'ast, __TOKENS: Iterator, >( @@ -624,51 +807,52 @@ mod __parse__Expr { { let mut __result: (Option, __Nonterminal<'ast, >); match __lookahead { + 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::Minus(..)) => { 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))); + 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::__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))); + 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::__action7(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); + let __nt = super::__actions::__action3(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Expr(__nt))); } _ => { return Err(__lookahead); } } + return Ok(__result); } - // State 10 + // 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);) + // ")" -> Reduce(Term = "Num" => ActionFn(8);) + // "/" -> Reduce(Term = "Num" => ActionFn(8);) + // "-" -> Reduce(Term = "Num" => ActionFn(8);) + // "+" -> Reduce(Term = "Num" => ActionFn(8);) // - pub fn __state10< + pub fn __state12< 'ast, __TOKENS: Iterator, >( @@ -680,12 +864,7 @@ mod __parse__Expr { { let mut __result: (Option, __Nonterminal<'ast, >); match __lookahead { - Some(Tok::Div(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action8(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Term(__nt))); - } - Some(Tok::Plus(..)) => { + Some(Tok::Times(..)) => { let __sym0 = __sym0.take().unwrap(); let __nt = super::__actions::__action8(arena, __sym0); return Ok((__lookahead, __Nonterminal::Term(__nt))); @@ -695,12 +874,17 @@ mod __parse__Expr { 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::Times(..)) => { + Some(Tok::Plus(..)) => { let __sym0 = __sym0.take().unwrap(); let __nt = super::__actions::__action8(arena, __sym0); return Ok((__lookahead, __Nonterminal::Term(__nt))); @@ -711,7 +895,7 @@ mod __parse__Expr { } } - // State 11 + // State 13 // Expr = Expr (*) "+" Factor [")"] // Expr = Expr (*) "+" Factor ["+"] // Expr = Expr (*) "+" Factor ["-"] @@ -724,11 +908,11 @@ mod __parse__Expr { // Term = "(" Expr (*) ")" ["-"] // Term = "(" Expr (*) ")" ["/"] // - // "-" -> Shift(S21) - // ")" -> Shift(S22) + // "-" -> Shift(S24) // "+" -> Shift(S23) + // ")" -> Shift(S25) // - pub fn __state11< + pub fn __state13< 'ast, __TOKENS: Iterator, >( @@ -744,18 +928,18 @@ mod __parse__Expr { Some(__tok @ Tok::Minus(..)) => { let mut __sym2 = &mut Some(__tok); let __lookahead = __tokens.next(); - __result = try!(__state21(arena, __lookahead, __tokens, __sym1, __sym2)); - } - Some(__tok @ Tok::RParen(..)) => { - let mut __sym2 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state22(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); + __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)); } + Some(__tok @ Tok::RParen(..)) => { + let mut __sym2 = &mut Some(__tok); + let __lookahead = __tokens.next(); + __result = try!(__state25(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } _ => { return Err(__lookahead); } @@ -763,7 +947,7 @@ mod __parse__Expr { return Ok(__result); } - // State 12 + // State 14 // Expr = (*) Expr "+" Factor [")"] // Expr = (*) Expr "+" Factor ["+"] // Expr = (*) Expr "+" Factor ["-"] @@ -809,14 +993,14 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "(" -> Shift(S12) - // "*" -> Shift(S8) - // "Num" -> Shift(S10) + // "(" -> Shift(S14) + // "Num" -> Shift(S12) + // "*" -> Shift(S10) // + // Factor -> S11 // Term -> S9 - // Expr -> S24 - // Factor -> S7 - pub fn __state12< + // Expr -> S26 + pub fn __state14< 'ast, __TOKENS: Iterator, >( @@ -831,16 +1015,16 @@ 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)); } Some(__tok @ Tok::Times(..)) => { let mut __sym1 = &mut Some(__tok); let __lookahead = __tokens.next(); - __result = try!(__state8(arena, __lookahead, __tokens, __sym1)); - } - Some(Tok::Num(__tok0)) => { - let mut __sym1 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); __result = try!(__state10(arena, __lookahead, __tokens, __sym1)); } _ => { @@ -850,17 +1034,17 @@ 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!(__state24(arena, __lookahead, __tokens, __sym0, __sym1)); - } - __Nonterminal::Factor(__nt) => { - let __sym1 = &mut Some(__nt); - __result = try!(__state7(arena, __lookahead, __tokens, __sym1)); + __result = try!(__state26(arena, __lookahead, __tokens, __sym0, __sym1)); } _ => { return Ok((__lookahead, __nt)); @@ -870,7 +1054,7 @@ mod __parse__Expr { return Ok(__result); } - // State 13 + // State 15 // Factor = Factor "*" (*) Term [EOF] // Factor = Factor "*" (*) Term ["*"] // Factor = Factor "*" (*) Term ["+"] @@ -890,8 +1074,8 @@ mod __parse__Expr { // "(" -> Shift(S3) // "Num" -> Shift(S1) // - // Term -> S25 - pub fn __state13< + // Term -> S27 + pub fn __state15< 'ast, __TOKENS: Iterator, >( @@ -923,7 +1107,7 @@ mod __parse__Expr { match __nt { __Nonterminal::Term(__nt) => { let __sym2 = &mut Some(__nt); - __result = try!(__state25(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); + __result = try!(__state27(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); } _ => { return Ok((__lookahead, __nt)); @@ -933,7 +1117,7 @@ mod __parse__Expr { return Ok(__result); } - // State 14 + // State 16 // Factor = Factor "/" (*) Term [EOF] // Factor = Factor "/" (*) Term ["*"] // Factor = Factor "/" (*) Term ["+"] @@ -953,165 +1137,7 @@ mod __parse__Expr { // "(" -> Shift(S3) // "Num" -> Shift(S1) // - // Term -> S26 - pub fn __state14< - '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!(__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); - } - } - while __sym1.is_some() { - let (__lookahead, __nt) = __result; - match __nt { - __Nonterminal::Term(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state26(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - _ => { - return Ok((__lookahead, __nt)); - } - } - } - return Ok(__result); - } - - // State 15 - // ( ",")* = (*) ["("] - // ( ",")* = (*) [")"] - // ( ",")* = (*) ["*"] - // ( ",")* = (*) ["Num"] - // ( ",")* = (*) ( ",")* ( ",") ["("] - // ( ",")* = (*) ( ",")* ( ",") [")"] - // ( ",")* = (*) ( ",")* ( ",") ["*"] - // ( ",")* = (*) ( ",")* ( ",") ["Num"] - // Comma = (*) ( ",")* Expr? [")"] - // Factor = "*" "(" (*) Comma ")" [EOF] - // Factor = "*" "(" (*) Comma ")" ["*"] - // Factor = "*" "(" (*) Comma ")" ["+"] - // Factor = "*" "(" (*) Comma ")" ["-"] - // Factor = "*" "(" (*) Comma ")" ["/"] - // - // "(" -> Reduce(( ",")* = => ActionFn(13);) - // "*" -> Reduce(( ",")* = => ActionFn(13);) - // "Num" -> Reduce(( ",")* = => ActionFn(13);) - // ")" -> Reduce(( ",")* = => ActionFn(13);) - // - // ( ",")* -> S27 - // Comma -> S28 - pub fn __state15< - '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::__Expr_______(__nt)); - } - Some(Tok::Times(..)) => { - let __nt = super::__actions::__action13(arena, ); - __result = (__lookahead, __Nonterminal::__Expr_______(__nt)); - } - Some(Tok::Num(_)) => { - let __nt = super::__actions::__action13(arena, ); - __result = (__lookahead, __Nonterminal::__Expr_______(__nt)); - } - Some(Tok::RParen(..)) => { - let __nt = super::__actions::__action13(arena, ); - __result = (__lookahead, __Nonterminal::__Expr_______(__nt)); - } - _ => { - return Err(__lookahead); - } - } - while __sym1.is_some() { - let (__lookahead, __nt) = __result; - match __nt { - __Nonterminal::__Expr_______(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state27(arena, __lookahead, __tokens, __sym2)); - } - __Nonterminal::Comma_Expr_(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state28(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - _ => { - return Ok((__lookahead, __nt)); - } - } - } - return Ok(__result); - } - - // State 16 - // Expr = Expr "-" (*) Factor [EOF] - // Expr = Expr "-" (*) Factor ["+"] - // Expr = Expr "-" (*) Factor ["-"] - // Factor = (*) Factor "*" Term [EOF] - // Factor = (*) Factor "*" Term ["*"] - // Factor = (*) Factor "*" Term ["+"] - // Factor = (*) Factor "*" Term ["-"] - // Factor = (*) Factor "*" Term ["/"] - // Factor = (*) Factor "/" Term [EOF] - // Factor = (*) Factor "/" Term ["*"] - // Factor = (*) Factor "/" Term ["+"] - // Factor = (*) Factor "/" Term ["-"] - // Factor = (*) Factor "/" Term ["/"] - // Factor = (*) Term [EOF] - // Factor = (*) Term ["*"] - // Factor = (*) Term ["+"] - // Factor = (*) Term ["-"] - // Factor = (*) Term ["/"] - // Factor = (*) "*" "(" Comma ")" [EOF] - // Factor = (*) "*" "(" Comma ")" ["*"] - // Factor = (*) "*" "(" Comma ")" ["+"] - // Factor = (*) "*" "(" Comma ")" ["-"] - // Factor = (*) "*" "(" Comma ")" ["/"] - // Term = (*) "(" Expr ")" [EOF] - // Term = (*) "(" Expr ")" ["*"] - // Term = (*) "(" Expr ")" ["+"] - // Term = (*) "(" Expr ")" ["-"] - // Term = (*) "(" Expr ")" ["/"] - // Term = (*) "Num" [EOF] - // Term = (*) "Num" ["*"] - // Term = (*) "Num" ["+"] - // Term = (*) "Num" ["-"] - // Term = (*) "Num" ["/"] - // - // "(" -> Shift(S3) - // "Num" -> Shift(S1) - // "*" -> Shift(S5) - // - // Term -> S2 - // Factor -> S29 + // Term -> S28 pub fn __state16< 'ast, __TOKENS: Iterator, @@ -1135,11 +1161,6 @@ mod __parse__Expr { 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!(__state5(arena, __lookahead, __tokens, __sym2)); - } _ => { return Err(__lookahead); } @@ -1149,11 +1170,7 @@ mod __parse__Expr { 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!(__state29(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); + __result = try!(__state28(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); } _ => { return Ok((__lookahead, __nt)); @@ -1164,46 +1181,28 @@ mod __parse__Expr { } // State 17 - // Expr = Expr "+" (*) Factor [EOF] - // Expr = Expr "+" (*) Factor ["+"] - // Expr = Expr "+" (*) Factor ["-"] - // Factor = (*) Factor "*" Term [EOF] - // Factor = (*) Factor "*" Term ["*"] - // Factor = (*) Factor "*" Term ["+"] - // Factor = (*) Factor "*" Term ["-"] - // Factor = (*) Factor "*" Term ["/"] - // Factor = (*) Factor "/" Term [EOF] - // Factor = (*) Factor "/" Term ["*"] - // Factor = (*) Factor "/" Term ["+"] - // Factor = (*) Factor "/" Term ["-"] - // Factor = (*) Factor "/" Term ["/"] - // Factor = (*) Term [EOF] - // Factor = (*) Term ["*"] - // Factor = (*) Term ["+"] - // Factor = (*) Term ["-"] - // Factor = (*) Term ["/"] - // Factor = (*) "*" "(" Comma ")" [EOF] - // Factor = (*) "*" "(" Comma ")" ["*"] - // Factor = (*) "*" "(" Comma ")" ["+"] - // Factor = (*) "*" "(" Comma ")" ["-"] - // Factor = (*) "*" "(" Comma ")" ["/"] - // Term = (*) "(" Expr ")" [EOF] - // Term = (*) "(" Expr ")" ["*"] - // Term = (*) "(" Expr ")" ["+"] - // Term = (*) "(" Expr ")" ["-"] - // Term = (*) "(" Expr ")" ["/"] - // Term = (*) "Num" [EOF] - // Term = (*) "Num" ["*"] - // Term = (*) "Num" ["+"] - // Term = (*) "Num" ["-"] - // Term = (*) "Num" ["/"] + // ( ",")* = (*) ["("] + // ( ",")* = (*) [")"] + // ( ",")* = (*) ["*"] + // ( ",")* = (*) ["Num"] + // ( ",")* = (*) ( ",")* ( ",") ["("] + // ( ",")* = (*) ( ",")* ( ",") [")"] + // ( ",")* = (*) ( ",")* ( ",") ["*"] + // ( ",")* = (*) ( ",")* ( ",") ["Num"] + // Comma = (*) ( ",")* Expr? [")"] + // Factor = "*" "(" (*) Comma ")" [EOF] + // Factor = "*" "(" (*) Comma ")" ["*"] + // Factor = "*" "(" (*) Comma ")" ["+"] + // Factor = "*" "(" (*) Comma ")" ["-"] + // Factor = "*" "(" (*) Comma ")" ["/"] // - // "(" -> Shift(S3) - // "Num" -> Shift(S1) - // "*" -> Shift(S5) + // "*" -> Reduce(( ",")* = => ActionFn(13);) + // "(" -> Reduce(( ",")* = => ActionFn(13);) + // "Num" -> Reduce(( ",")* = => ActionFn(13);) + // ")" -> Reduce(( ",")* = => ActionFn(13);) // - // Factor -> S30 - // Term -> S2 + // Comma -> S30 + // ( ",")* -> S29 pub fn __state17< 'ast, __TOKENS: Iterator, @@ -1211,26 +1210,27 @@ mod __parse__Expr { arena: &'ast Arena<'ast>, mut __lookahead: Option, __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, + __sym0: &mut Option, __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!(__state3(arena, __lookahead, __tokens, __sym2)); + Some(Tok::Times(..)) => { + let __nt = super::__actions::__action13(arena, ); + __result = (__lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); } - Some(Tok::Num(__tok0)) => { - let mut __sym2 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state1(arena, __lookahead, __tokens, __sym2)); + 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::Times(..)) => { - let mut __sym2 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state5(arena, __lookahead, __tokens, __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::RParen(..)) => { + let __nt = super::__actions::__action13(arena, ); + __result = (__lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); } _ => { return Err(__lookahead); @@ -1239,13 +1239,13 @@ mod __parse__Expr { while __sym1.is_some() { let (__lookahead, __nt) = __result; match __nt { - __Nonterminal::Factor(__nt) => { + __Nonterminal::Comma_3cExpr_3e(__nt) => { let __sym2 = &mut Some(__nt); __result = try!(__state30(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); } - __Nonterminal::Term(__nt) => { + __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt) => { let __sym2 = &mut Some(__nt); - __result = try!(__state2(arena, __lookahead, __tokens, __sym2)); + __result = try!(__state29(arena, __lookahead, __tokens, __sym2)); } _ => { return Ok((__lookahead, __nt)); @@ -1256,26 +1256,26 @@ mod __parse__Expr { } // State 18 - // Factor = Factor "*" (*) Term [")"] - // Factor = Factor "*" (*) Term ["*"] - // Factor = Factor "*" (*) Term ["+"] - // Factor = Factor "*" (*) Term ["-"] - // Factor = Factor "*" (*) Term ["/"] - // Term = (*) "(" Expr ")" [")"] - // Term = (*) "(" Expr ")" ["*"] - // Term = (*) "(" Expr ")" ["+"] - // Term = (*) "(" Expr ")" ["-"] - // Term = (*) "(" Expr ")" ["/"] - // Term = (*) "Num" [")"] - // Term = (*) "Num" ["*"] - // Term = (*) "Num" ["+"] - // Term = (*) "Num" ["-"] - // Term = (*) "Num" ["/"] + // 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) - // "Num" -> Shift(S10) + // "/" -> Shift(S16) + // EOF -> Reduce(Expr = Expr, "-", Factor => ActionFn(1);) + // "+" -> Reduce(Expr = Expr, "-", Factor => ActionFn(1);) + // "*" -> Shift(S15) + // "-" -> Reduce(Expr = Expr, "-", Factor => ActionFn(1);) // - // Term -> S31 pub fn __state18< 'ast, __TOKENS: Iterator, @@ -1285,19 +1285,173 @@ mod __parse__Expr { __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::LParen(..)) => { - let mut __sym2 = &mut Some(__tok); + Some(__tok @ Tok::Div(..)) => { + let mut __sym3 = &mut Some(__tok); let __lookahead = __tokens.next(); - __result = try!(__state12(arena, __lookahead, __tokens, __sym2)); + __result = try!(__state16(arena, __lookahead, __tokens, __sym2, __sym3)); } - Some(Tok::Num(__tok0)) => { - let mut __sym2 = &mut Some((__tok0)); + Some(__tok @ Tok::Times(..)) => { + let mut __sym3 = &mut Some(__tok); let __lookahead = __tokens.next(); - __result = try!(__state10(arena, __lookahead, __tokens, __sym2)); + __result = try!(__state15(arena, __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(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))); + } + 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))); + } + _ => { + 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 ["/"] + // + // "+" -> Reduce(Expr = Expr, "+", Factor => ActionFn(2);) + // "/" -> Shift(S16) + // "-" -> Reduce(Expr = Expr, "+", Factor => ActionFn(2);) + // "*" -> Shift(S15) + // EOF -> Reduce(Expr = Expr, "+", Factor => ActionFn(2);) + // + pub fn __state19< + '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::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(..)) => { + 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))); + } + 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 20 + // ( ",")* = (*) ["("] + // ( ",")* = (*) [")"] + // ( ",")* = (*) ["*"] + // ( ",")* = (*) ["Num"] + // ( ",")* = (*) ( ",")* ( ",") ["("] + // ( ",")* = (*) ( ",")* ( ",") [")"] + // ( ",")* = (*) ( ",")* ( ",") ["*"] + // ( ",")* = (*) ( ",")* ( ",") ["Num"] + // Comma = (*) ( ",")* Expr? [")"] + // Factor = "*" "(" (*) Comma ")" [")"] + // Factor = "*" "(" (*) Comma ")" ["*"] + // Factor = "*" "(" (*) Comma ")" ["+"] + // Factor = "*" "(" (*) Comma ")" ["-"] + // Factor = "*" "(" (*) Comma ")" ["/"] + // + // ")" -> Reduce(( ",")* = => ActionFn(13);) + // "(" -> Reduce(( ",")* = => ActionFn(13);) + // "Num" -> Reduce(( ",")* = => ActionFn(13);) + // "*" -> Reduce(( ",")* = => ActionFn(13);) + // + // Comma -> S31 + // ( ",")* -> S29 + pub fn __state20< + '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::RParen(..)) => { + 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(_)) => { + 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)); } _ => { return Err(__lookahead); @@ -1306,10 +1460,14 @@ mod __parse__Expr { while __sym1.is_some() { let (__lookahead, __nt) = __result; match __nt { - __Nonterminal::Term(__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)); + } _ => { return Ok((__lookahead, __nt)); } @@ -1318,7 +1476,7 @@ mod __parse__Expr { return Ok(__result); } - // State 19 + // State 21 // Factor = Factor "/" (*) Term [")"] // Factor = Factor "/" (*) Term ["*"] // Factor = Factor "/" (*) Term ["+"] @@ -1335,11 +1493,11 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "Num" -> Shift(S10) - // "(" -> Shift(S12) + // "(" -> Shift(S14) + // "Num" -> Shift(S12) // // Term -> S32 - pub fn __state19< + pub fn __state21< 'ast, __TOKENS: Iterator, >( @@ -1352,14 +1510,14 @@ 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!(__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)); + } + Some(Tok::Num(__tok0)) => { + let mut __sym2 = &mut Some((__tok0)); + let __lookahead = __tokens.next(); __result = try!(__state12(arena, __lookahead, __tokens, __sym2)); } _ => { @@ -1381,105 +1539,12 @@ mod __parse__Expr { return Ok(__result); } - // State 20 - // ( ",")* = (*) ["("] - // ( ",")* = (*) [")"] - // ( ",")* = (*) ["*"] - // ( ",")* = (*) ["Num"] - // ( ",")* = (*) ( ",")* ( ",") ["("] - // ( ",")* = (*) ( ",")* ( ",") [")"] - // ( ",")* = (*) ( ",")* ( ",") ["*"] - // ( ",")* = (*) ( ",")* ( ",") ["Num"] - // Comma = (*) ( ",")* Expr? [")"] - // Factor = "*" "(" (*) Comma ")" [")"] - // Factor = "*" "(" (*) Comma ")" ["*"] - // Factor = "*" "(" (*) Comma ")" ["+"] - // Factor = "*" "(" (*) Comma ")" ["-"] - // Factor = "*" "(" (*) Comma ")" ["/"] - // - // "(" -> Reduce(( ",")* = => ActionFn(13);) - // "*" -> Reduce(( ",")* = => ActionFn(13);) - // "Num" -> Reduce(( ",")* = => ActionFn(13);) - // ")" -> Reduce(( ",")* = => ActionFn(13);) - // - // ( ",")* -> S27 - // Comma -> S33 - pub fn __state20< - '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::__Expr_______(__nt)); - } - Some(Tok::Times(..)) => { - let __nt = super::__actions::__action13(arena, ); - __result = (__lookahead, __Nonterminal::__Expr_______(__nt)); - } - Some(Tok::Num(_)) => { - let __nt = super::__actions::__action13(arena, ); - __result = (__lookahead, __Nonterminal::__Expr_______(__nt)); - } - Some(Tok::RParen(..)) => { - let __nt = super::__actions::__action13(arena, ); - __result = (__lookahead, __Nonterminal::__Expr_______(__nt)); - } - _ => { - return Err(__lookahead); - } - } - while __sym1.is_some() { - let (__lookahead, __nt) = __result; - match __nt { - __Nonterminal::__Expr_______(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state27(arena, __lookahead, __tokens, __sym2)); - } - __Nonterminal::Comma_Expr_(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state33(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - _ => { - return Ok((__lookahead, __nt)); - } - } - } - return Ok(__result); - } - - // State 21 - // 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 ")" ["/"] + // State 22 + // Factor = Factor "*" (*) Term [")"] + // Factor = Factor "*" (*) Term ["*"] + // Factor = Factor "*" (*) Term ["+"] + // Factor = Factor "*" (*) Term ["-"] + // Factor = Factor "*" (*) Term ["/"] // Term = (*) "(" Expr ")" [")"] // Term = (*) "(" Expr ")" ["*"] // Term = (*) "(" Expr ")" ["+"] @@ -1491,13 +1556,11 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "*" -> Shift(S8) - // "Num" -> Shift(S10) - // "(" -> Shift(S12) + // "Num" -> Shift(S12) + // "(" -> Shift(S14) // - // Factor -> S34 - // Term -> S9 - pub fn __state21< + // Term -> S33 + pub fn __state22< 'ast, __TOKENS: Iterator, >( @@ -1510,20 +1573,15 @@ 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!(__state8(arena, __lookahead, __tokens, __sym2)); - } Some(Tok::Num(__tok0)) => { let mut __sym2 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state10(arena, __lookahead, __tokens, __sym2)); + __result = try!(__state12(arena, __lookahead, __tokens, __sym2)); } Some(__tok @ Tok::LParen(..)) => { let mut __sym2 = &mut Some(__tok); let __lookahead = __tokens.next(); - __result = try!(__state12(arena, __lookahead, __tokens, __sym2)); + __result = try!(__state14(arena, __lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); @@ -1532,13 +1590,9 @@ mod __parse__Expr { 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!(__state9(arena, __lookahead, __tokens, __sym2)); + __result = try!(__state33(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); } _ => { return Ok((__lookahead, __nt)); @@ -1548,74 +1602,6 @@ mod __parse__Expr { return Ok(__result); } - // State 22 - // 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 __state22< - '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))); - } - 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))); - } - 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::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 23 // Expr = Expr "+" (*) Factor [")"] // Expr = Expr "+" (*) Factor ["+"] @@ -1651,13 +1637,105 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "*" -> Shift(S8) - // "Num" -> Shift(S10) - // "(" -> Shift(S12) + // "(" -> 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 ["-"] + // 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(S10) + // "(" -> Shift(S14) + // "Num" -> Shift(S12) // // Term -> S9 // Factor -> S35 - pub fn __state23< + pub fn __state24< 'ast, __TOKENS: Iterator, >( @@ -1673,16 +1751,16 @@ mod __parse__Expr { Some(__tok @ Tok::Times(..)) => { let mut __sym2 = &mut Some(__tok); let __lookahead = __tokens.next(); - __result = try!(__state8(arena, __lookahead, __tokens, __sym2)); - } - Some(Tok::Num(__tok0)) => { - let mut __sym2 = &mut Some((__tok0)); - 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)); + } + Some(Tok::Num(__tok0)) => { + let mut __sym2 = &mut Some((__tok0)); + let __lookahead = __tokens.next(); __result = try!(__state12(arena, __lookahead, __tokens, __sym2)); } _ => { @@ -1708,7 +1786,75 @@ mod __parse__Expr { return Ok(__result); } - // State 24 + // 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 ["+"] // Expr = Expr (*) "+" Factor ["-"] @@ -1721,11 +1867,11 @@ mod __parse__Expr { // Term = "(" Expr (*) ")" ["-"] // Term = "(" Expr (*) ")" ["/"] // - // "+" -> Shift(S23) - // "-" -> Shift(S21) // ")" -> Shift(S36) + // "+" -> Shift(S23) + // "-" -> Shift(S24) // - pub fn __state24< + pub fn __state26< 'ast, __TOKENS: Iterator, >( @@ -1738,6 +1884,11 @@ 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(..)) => { let mut __sym2 = &mut Some(__tok); let __lookahead = __tokens.next(); @@ -1746,12 +1897,7 @@ mod __parse__Expr { Some(__tok @ Tok::Minus(..)) => { let mut __sym2 = &mut Some(__tok); let __lookahead = __tokens.next(); - __result = try!(__state21(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)); + __result = try!(__state24(arena, __lookahead, __tokens, __sym1, __sym2)); } _ => { return Err(__lookahead); @@ -1760,20 +1906,20 @@ mod __parse__Expr { return Ok(__result); } - // State 25 + // State 27 // Factor = Factor "*" Term (*) [EOF] // Factor = Factor "*" Term (*) ["*"] // Factor = Factor "*" Term (*) ["+"] // Factor = Factor "*" Term (*) ["-"] // Factor = Factor "*" Term (*) ["/"] // - // "*" -> 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);) // "-" -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) // "+" -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) - // EOF -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) // - pub fn __state25< + pub fn __state27< 'ast, __TOKENS: Iterator, >( @@ -1787,7 +1933,7 @@ mod __parse__Expr { { let mut __result: (Option, __Nonterminal<'ast, >); match __lookahead { - Some(Tok::Times(..)) => { + None => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); @@ -1801,6 +1947,13 @@ mod __parse__Expr { 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(); @@ -1815,33 +1968,26 @@ mod __parse__Expr { 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::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } _ => { return Err(__lookahead); } } } - // State 26 + // State 28 // 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);) - // 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 __state26< + pub fn __state28< 'ast, __TOKENS: Iterator, >( @@ -1855,13 +2001,6 @@ mod __parse__Expr { { 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::__action5(arena, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } Some(Tok::Div(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); @@ -1869,20 +2008,6 @@ mod __parse__Expr { 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::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(); @@ -1890,13 +2015,34 @@ 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))); + } + 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::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))); + } _ => { return Err(__lookahead); } } } - // State 27 + // State 29 // ( ",") = (*) Expr "," ["("] // ( ",") = (*) Expr "," [")"] // ( ",") = (*) Expr "," ["*"] @@ -1957,17 +2103,17 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // ")" -> Reduce(Expr? = => ActionFn(12);) - // "(" -> Shift(S39) // "*" -> Shift(S37) - // "Num" -> Shift(S41) + // "Num" -> Shift(S42) + // ")" -> Reduce(Expr? = => ActionFn(12);) + // "(" -> Shift(S44) // - // Term -> S40 - // Expr? -> S38 - // ( ",") -> S42 - // Factor -> S44 - // Expr -> S43 - pub fn __state27< + // Term -> S41 + // Expr -> S39 + // ( ",") -> S40 + // Expr? -> S43 + // Factor -> S38 + pub fn __state29< 'ast, __TOKENS: Iterator, >( @@ -1979,11 +2125,6 @@ mod __parse__Expr { { let mut __result: (Option, __Nonterminal<'ast, >); match __lookahead { - Some(__tok @ Tok::LParen(..)) => { - let mut __sym1 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state39(arena, __lookahead, __tokens, __sym1)); - } Some(__tok @ Tok::Times(..)) => { let mut __sym1 = &mut Some(__tok); let __lookahead = __tokens.next(); @@ -1992,11 +2133,16 @@ mod __parse__Expr { Some(Tok::Num(__tok0)) => { let mut __sym1 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state41(arena, __lookahead, __tokens, __sym1)); + __result = try!(__state42(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)); } Some(Tok::RParen(..)) => { let __nt = super::__actions::__action12(arena, ); - __result = (__lookahead, __Nonterminal::Expr_(__nt)); + __result = (__lookahead, __Nonterminal::Expr_3f(__nt)); } _ => { return Err(__lookahead); @@ -2007,23 +2153,23 @@ mod __parse__Expr { match __nt { __Nonterminal::Term(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state40(arena, __lookahead, __tokens, __sym1)); - } - __Nonterminal::Expr_(__nt) => { - let __sym1 = &mut Some(__nt); - __result = try!(__state38(arena, __lookahead, __tokens, __sym0, __sym1)); - } - __Nonterminal::__Expr______(__nt) => { - let __sym1 = &mut Some(__nt); - __result = try!(__state42(arena, __lookahead, __tokens, __sym0, __sym1)); - } - __Nonterminal::Factor(__nt) => { - let __sym1 = &mut Some(__nt); - __result = try!(__state44(arena, __lookahead, __tokens, __sym1)); + __result = try!(__state41(arena, __lookahead, __tokens, __sym1)); } __Nonterminal::Expr(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state43(arena, __lookahead, __tokens, __sym1)); + __result = try!(__state39(arena, __lookahead, __tokens, __sym1)); + } + __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29(__nt) => { + let __sym1 = &mut Some(__nt); + __result = try!(__state40(arena, __lookahead, __tokens, __sym0, __sym1)); + } + __Nonterminal::Expr_3f(__nt) => { + let __sym1 = &mut Some(__nt); + __result = try!(__state43(arena, __lookahead, __tokens, __sym0, __sym1)); + } + __Nonterminal::Factor(__nt) => { + let __sym1 = &mut Some(__nt); + __result = try!(__state38(arena, __lookahead, __tokens, __sym1)); } _ => { return Ok((__lookahead, __nt)); @@ -2033,7 +2179,7 @@ mod __parse__Expr { return Ok(__result); } - // State 28 + // State 30 // Factor = "*" "(" Comma (*) ")" [EOF] // Factor = "*" "(" Comma (*) ")" ["*"] // Factor = "*" "(" Comma (*) ")" ["+"] @@ -2042,7 +2188,7 @@ mod __parse__Expr { // // ")" -> Shift(S45) // - pub fn __state28< + pub fn __state30< 'ast, __TOKENS: Iterator, >( @@ -2068,289 +2214,7 @@ mod __parse__Expr { return Ok(__result); } - // State 29 - // Expr = Expr "-" Factor (*) [EOF] - // Expr = Expr "-" Factor (*) ["+"] - // Expr = Expr "-" Factor (*) ["-"] - // Factor = Factor (*) "*" Term [EOF] - // Factor = Factor (*) "*" Term ["*"] - // Factor = Factor (*) "*" Term ["+"] - // Factor = Factor (*) "*" Term ["-"] - // Factor = Factor (*) "*" Term ["/"] - // Factor = Factor (*) "/" Term [EOF] - // Factor = Factor (*) "/" Term ["*"] - // Factor = Factor (*) "/" Term ["+"] - // Factor = Factor (*) "/" Term ["-"] - // Factor = Factor (*) "/" Term ["/"] - // - // "*" -> Shift(S13) - // "-" -> Reduce(Expr = Expr, "-", Factor => ActionFn(1);) - // "/" -> Shift(S14) - // EOF -> Reduce(Expr = Expr, "-", Factor => ActionFn(1);) - // "+" -> Reduce(Expr = Expr, "-", Factor => ActionFn(1);) - // - pub fn __state29< - '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!(__state13(arena, __lookahead, __tokens, __sym2, __sym3)); - } - Some(__tok @ Tok::Div(..)) => { - let mut __sym3 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state14(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::__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))); - } - 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))); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 30 - // 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) - // "-" -> Reduce(Expr = Expr, "+", Factor => ActionFn(2);) - // EOF -> Reduce(Expr = Expr, "+", Factor => ActionFn(2);) - // "*" -> Shift(S13) - // "+" -> Reduce(Expr = Expr, "+", Factor => ActionFn(2);) - // - pub fn __state30< - '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::Div(..)) => { - let mut __sym3 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state14(arena, __lookahead, __tokens, __sym2, __sym3)); - } - Some(__tok @ Tok::Times(..)) => { - let mut __sym3 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state13(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::__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))); - } - 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))); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - // State 31 - // 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);) - // - pub fn __state31< - '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::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::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::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))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 32 - // 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);) - // - pub fn __state32< - '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::__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::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 33 // Factor = "*" "(" Comma (*) ")" [")"] // Factor = "*" "(" Comma (*) ")" ["*"] // Factor = "*" "(" Comma (*) ")" ["+"] @@ -2359,7 +2223,7 @@ mod __parse__Expr { // // ")" -> Shift(S46) // - pub fn __state33< + pub fn __state31< 'ast, __TOKENS: Iterator, >( @@ -2385,10 +2249,146 @@ mod __parse__Expr { return Ok(__result); } + // State 32 + // 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);) + // + pub fn __state32< + '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::__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::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))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 33 + // 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);) + // + pub fn __state33< + '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::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(); + 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::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::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 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(S19) - // ")" -> Reduce(Expr = Expr, "-", Factor => ActionFn(1);) - // "-" -> Reduce(Expr = Expr, "-", Factor => ActionFn(1);) - // "*" -> Shift(S18) + // "*" -> Shift(S22) + // "-" -> Reduce(Expr = Expr, "+", Factor => ActionFn(2);) + // ")" -> Reduce(Expr = Expr, "+", Factor => ActionFn(2);) + // "/" -> Shift(S21) + // "+" -> Reduce(Expr = Expr, "+", Factor => ActionFn(2);) // pub fn __state34< 'ast, @@ -2420,35 +2420,35 @@ 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!(__state19(arena, __lookahead, __tokens, __sym2, __sym3)); - } Some(__tok @ Tok::Times(..)) => { let mut __sym3 = &mut Some(__tok); let __lookahead = __tokens.next(); - __result = try!(__state18(arena, __lookahead, __tokens, __sym2, __sym3)); + __result = try!(__state22(arena, __lookahead, __tokens, __sym2, __sym3)); } - Some(Tok::Plus(..)) => { + Some(__tok @ Tok::Div(..)) => { + let mut __sym3 = &mut Some(__tok); + let __lookahead = __tokens.next(); + __result = try!(__state21(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::__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::__action1(arena, __sym0, __sym1, __sym2); + let __nt = super::__actions::__action2(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(); - let __nt = super::__actions::__action1(arena, __sym0, __sym1, __sym2); + let __nt = super::__actions::__action2(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 ["+"] @@ -2473,11 +2473,11 @@ mod __parse__Expr { // Factor = Factor (*) "/" Term ["-"] // Factor = Factor (*) "/" Term ["/"] // - // "*" -> Shift(S18) - // "-" -> Reduce(Expr = Expr, "+", Factor => ActionFn(2);) - // ")" -> Reduce(Expr = Expr, "+", Factor => ActionFn(2);) - // "+" -> Reduce(Expr = Expr, "+", Factor => ActionFn(2);) - // "/" -> Shift(S19) + // "/" -> Shift(S21) + // "*" -> Shift(S22) + // "+" -> Reduce(Expr = Expr, "-", Factor => ActionFn(1);) + // ")" -> Reduce(Expr = Expr, "-", Factor => ActionFn(1);) + // "-" -> Reduce(Expr = Expr, "-", Factor => ActionFn(1);) // pub fn __state35< 'ast, @@ -2493,35 +2493,35 @@ mod __parse__Expr { { let mut __result: (Option, __Nonterminal<'ast, >); match __lookahead { - Some(__tok @ Tok::Times(..)) => { - let mut __sym3 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state18(arena, __lookahead, __tokens, __sym2, __sym3)); - } Some(__tok @ Tok::Div(..)) => { let mut __sym3 = &mut Some(__tok); let __lookahead = __tokens.next(); - __result = try!(__state19(arena, __lookahead, __tokens, __sym2, __sym3)); + __result = try!(__state21(arena, __lookahead, __tokens, __sym2, __sym3)); } - Some(Tok::Minus(..)) => { + Some(__tok @ Tok::Times(..)) => { + let mut __sym3 = &mut Some(__tok); + let __lookahead = __tokens.next(); + __result = try!(__state22(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::__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); + 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(); - let __nt = super::__actions::__action2(arena, __sym0, __sym1, __sym2); + let __nt = super::__actions::__action1(arena, __sym0, __sym1, __sym2); return Ok((__lookahead, __Nonterminal::Expr(__nt))); } _ => { @@ -2538,11 +2538,11 @@ mod __parse__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);) - // "-" -> Reduce(Term = "(", Expr, ")" => ActionFn(9);) // pub fn __state36< 'ast, @@ -2558,6 +2558,20 @@ mod __parse__Expr { { 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::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(); @@ -2579,20 +2593,6 @@ mod __parse__Expr { 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::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))); - } _ => { return Err(__lookahead); } @@ -2634,11 +2634,324 @@ mod __parse__Expr { } // 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 __state38< + pub fn __state43< 'ast, __TOKENS: Iterator, >( @@ -2655,7 +2968,7 @@ mod __parse__Expr { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __nt = super::__actions::__action10(arena, __sym0, __sym1); - return Ok((__lookahead, __Nonterminal::Comma_Expr_(__nt))); + return Ok((__lookahead, __Nonterminal::Comma_3cExpr_3e(__nt))); } _ => { return Err(__lookahead); @@ -2663,7 +2976,7 @@ mod __parse__Expr { } } - // State 39 + // State 44 // Expr = (*) Expr "+" Factor [")"] // Expr = (*) Expr "+" Factor ["+"] // Expr = (*) Expr "+" Factor ["-"] @@ -2710,14 +3023,14 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "*" -> Shift(S8) - // "Num" -> Shift(S10) - // "(" -> Shift(S12) + // "*" -> Shift(S10) + // "Num" -> Shift(S12) + // "(" -> Shift(S14) // - // Factor -> S7 - // Expr -> S48 + // Factor -> S11 + // Expr -> S53 // Term -> S9 - pub fn __state39< + pub fn __state44< 'ast, __TOKENS: Iterator, >( @@ -2732,17 +3045,17 @@ mod __parse__Expr { Some(__tok @ Tok::Times(..)) => { let mut __sym1 = &mut Some(__tok); let __lookahead = __tokens.next(); - __result = try!(__state8(arena, __lookahead, __tokens, __sym1)); + __result = try!(__state10(arena, __lookahead, __tokens, __sym1)); } Some(Tok::Num(__tok0)) => { let mut __sym1 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state10(arena, __lookahead, __tokens, __sym1)); + __result = try!(__state12(arena, __lookahead, __tokens, __sym1)); } Some(__tok @ Tok::LParen(..)) => { let mut __sym1 = &mut Some(__tok); let __lookahead = __tokens.next(); - __result = try!(__state12(arena, __lookahead, __tokens, __sym1)); + __result = try!(__state14(arena, __lookahead, __tokens, __sym1)); } _ => { return Err(__lookahead); @@ -2753,11 +3066,11 @@ mod __parse__Expr { match __nt { __Nonterminal::Factor(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state7(arena, __lookahead, __tokens, __sym1)); + __result = try!(__state11(arena, __lookahead, __tokens, __sym1)); } __Nonterminal::Expr(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state48(arena, __lookahead, __tokens, __sym0, __sym1)); + __result = try!(__state53(arena, __lookahead, __tokens, __sym0, __sym1)); } __Nonterminal::Term(__nt) => { let __sym1 = &mut Some(__nt); @@ -2771,319 +3084,6 @@ mod __parse__Expr { return Ok(__result); } - // State 40 - // 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 __state40< - '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::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::Times(..)) => { - 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 41 - // 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 __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::RParen(..)) => { - 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::Comma(..)) => { - 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 42 - // ( ",")* = ( ",")* ( ",") (*) ["("] - // ( ",")* = ( ",")* ( ",") (*) [")"] - // ( ",")* = ( ",")* ( ",") (*) ["*"] - // ( ",")* = ( ",")* ( ",") (*) ["Num"] - // - // ")" -> Reduce(( ",")* = ( ",")*, ( ",") => ActionFn(14);) - // "(" -> Reduce(( ",")* = ( ",")*, ( ",") => ActionFn(14);) - // "*" -> Reduce(( ",")* = ( ",")*, ( ",") => ActionFn(14);) - // "Num" -> Reduce(( ",")* = ( ",")*, ( ",") => ActionFn(14);) - // - 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<&'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::__action14(arena, __sym0, __sym1); - return Ok((__lookahead, __Nonterminal::__Expr_______(__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::__Expr_______(__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::__Expr_______(__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::__Expr_______(__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(S51) - // "+" -> Shift(S49) - // "-" -> Shift(S50) - // ")" -> Reduce(Expr? = Expr => ActionFn(11);) - // - 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::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!(__state49(arena, __lookahead, __tokens, __sym0, __sym1)); - } - Some(__tok @ Tok::Minus(..)) => { - let mut __sym1 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state50(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_(__nt))); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 44 - // 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);) - // "/" -> Shift(S53) - // "," -> Reduce(Expr = Factor => ActionFn(3);) - // "-" -> Reduce(Expr = Factor => ActionFn(3);) - // "*" -> Shift(S52) - // ")" -> Reduce(Expr = Factor => ActionFn(3);) - // - pub fn __state44< - '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!(__state53(arena, __lookahead, __tokens, __sym0, __sym1)); - } - Some(__tok @ Tok::Times(..)) => { - let mut __sym1 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state52(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::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 45 // Factor = "*" "(" Comma ")" (*) [EOF] // Factor = "*" "(" Comma ")" (*) ["*"] @@ -3092,10 +3092,10 @@ mod __parse__Expr { // 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);) // pub fn __state45< 'ast, @@ -3120,7 +3120,15 @@ 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))); + } + Some(Tok::Plus(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); @@ -3136,15 +3144,7 @@ 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::Plus(..)) => { + Some(Tok::Times(..)) => { 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);) // pub fn __state46< 'ast, @@ -3186,7 +3186,7 @@ mod __parse__Expr { { let mut __result: (Option, __Nonterminal<'ast, >); match __lookahead { - Some(Tok::Minus(..)) => { + Some(Tok::RParen(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); @@ -3194,7 +3194,15 @@ mod __parse__Expr { let __nt = super::__actions::__action6(arena, __sym0, __sym1, __sym2, __sym3); return Ok((__lookahead, __Nonterminal::Factor(__nt))); } - Some(Tok::RParen(..)) => { + Some(Tok::Plus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __sym3 = __sym3.take().unwrap(); + let __nt = super::__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(); @@ -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::Plus(..)) => { - 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); } @@ -3249,13 +3249,13 @@ mod __parse__Expr { // Factor = "*" "(" (*) Comma ")" ["-"] // Factor = "*" "(" (*) Comma ")" ["/"] // - // "*" -> Reduce(( ",")* = => ActionFn(13);) + // "(" -> Reduce(( ",")* = => ActionFn(13);) // "Num" -> Reduce(( ",")* = => ActionFn(13);) // ")" -> Reduce(( ",")* = => ActionFn(13);) - // "(" -> Reduce(( ",")* = => ActionFn(13);) + // "*" -> Reduce(( ",")* = => ActionFn(13);) // - // ( ",")* -> S27 // Comma -> S54 + // ( ",")* -> S29 pub fn __state47< 'ast, __TOKENS: Iterator, @@ -3269,21 +3269,21 @@ mod __parse__Expr { { let mut __result: (Option, __Nonterminal<'ast, >); match __lookahead { - Some(Tok::Times(..)) => { + Some(Tok::LParen(..)) => { let __nt = super::__actions::__action13(arena, ); - __result = (__lookahead, __Nonterminal::__Expr_______(__nt)); + __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::__Expr_______(__nt)); + __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::__Expr_______(__nt)); + __result = (__lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); } - Some(Tok::LParen(..)) => { + Some(Tok::Times(..)) => { let __nt = super::__actions::__action13(arena, ); - __result = (__lookahead, __Nonterminal::__Expr_______(__nt)); + __result = (__lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); } _ => { return Err(__lookahead); @@ -3292,14 +3292,14 @@ mod __parse__Expr { while __sym1.is_some() { let (__lookahead, __nt) = __result; match __nt { - __Nonterminal::__Expr_______(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state27(arena, __lookahead, __tokens, __sym2)); - } - __Nonterminal::Comma_Expr_(__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)); } @@ -3309,23 +3309,29 @@ mod __parse__Expr { } // State 48 - // 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 (*) ")" ["/"] + // Factor = Factor "*" (*) Term [")"] + // Factor = Factor "*" (*) Term ["*"] + // Factor = Factor "*" (*) Term ["+"] + // Factor = Factor "*" (*) Term [","] + // Factor = Factor "*" (*) Term ["-"] + // Factor = Factor "*" (*) Term ["/"] + // Term = (*) "(" Expr ")" [")"] + // Term = (*) "(" Expr ")" ["*"] + // Term = (*) "(" Expr ")" ["+"] + // Term = (*) "(" Expr ")" [","] + // Term = (*) "(" Expr ")" ["-"] + // Term = (*) "(" Expr ")" ["/"] + // Term = (*) "Num" [")"] + // Term = (*) "Num" ["*"] + // Term = (*) "Num" ["+"] + // Term = (*) "Num" [","] + // Term = (*) "Num" ["-"] + // Term = (*) "Num" ["/"] // - // ")" -> Shift(S55) - // "-" -> Shift(S21) - // "+" -> Shift(S23) + // "Num" -> Shift(S42) + // "(" -> Shift(S44) // + // Term -> S55 pub fn __state48< 'ast, __TOKENS: Iterator, @@ -3333,35 +3339,108 @@ 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::RParen(..)) => { - let mut __sym2 = &mut Some(__tok); + Some(Tok::Num(__tok0)) => { + let mut __sym2 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state55(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); + __result = try!(__state42(arena, __lookahead, __tokens, __sym2)); } - Some(__tok @ Tok::Minus(..)) => { + Some(__tok @ Tok::LParen(..)) => { let mut __sym2 = &mut Some(__tok); let __lookahead = __tokens.next(); - __result = try!(__state21(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)); + __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!(__state55(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + _ => { + return Ok((__lookahead, __nt)); + } + } + } return Ok(__result); } // State 49 + // Factor = Factor "/" (*) Term [")"] + // Factor = Factor "/" (*) Term ["*"] + // Factor = Factor "/" (*) Term ["+"] + // Factor = Factor "/" (*) Term [","] + // Factor = Factor "/" (*) Term ["-"] + // Factor = Factor "/" (*) Term ["/"] + // Term = (*) "(" Expr ")" [")"] + // Term = (*) "(" Expr ")" ["*"] + // Term = (*) "(" Expr ")" ["+"] + // Term = (*) "(" Expr ")" [","] + // Term = (*) "(" Expr ")" ["-"] + // Term = (*) "(" Expr ")" ["/"] + // Term = (*) "Num" [")"] + // Term = (*) "Num" ["*"] + // Term = (*) "Num" ["+"] + // Term = (*) "Num" [","] + // Term = (*) "Num" ["-"] + // Term = (*) "Num" ["/"] + // + // "(" -> Shift(S44) + // "Num" -> Shift(S42) + // + // Term -> S56 + pub fn __state49< + '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!(__state44(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)); + } + _ => { + return Err(__lookahead); + } + } + while __sym1.is_some() { + let (__lookahead, __nt) = __result; + match __nt { + __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state56(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + _ => { + return Ok((__lookahead, __nt)); + } + } + } + return Ok(__result); + } + + // State 50 // Expr = Expr "+" (*) Factor [")"] // Expr = Expr "+" (*) Factor ["+"] // Expr = Expr "+" (*) Factor [","] @@ -3404,12 +3483,12 @@ mod __parse__Expr { // Term = (*) "Num" ["/"] // // "*" -> Shift(S37) - // "(" -> Shift(S39) - // "Num" -> Shift(S41) + // "Num" -> Shift(S42) + // "(" -> Shift(S44) // - // Term -> S40 - // Factor -> S56 - pub fn __state49< + // Term -> S41 + // Factor -> S57 + pub fn __state50< 'ast, __TOKENS: Iterator, >( @@ -3427,15 +3506,15 @@ mod __parse__Expr { let __lookahead = __tokens.next(); __result = try!(__state37(arena, __lookahead, __tokens, __sym2)); } - Some(__tok @ Tok::LParen(..)) => { - let mut __sym2 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state39(arena, __lookahead, __tokens, __sym2)); - } Some(Tok::Num(__tok0)) => { let mut __sym2 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state41(arena, __lookahead, __tokens, __sym2)); + __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); @@ -3446,11 +3525,11 @@ mod __parse__Expr { match __nt { __Nonterminal::Term(__nt) => { let __sym2 = &mut Some(__nt); - __result = try!(__state40(arena, __lookahead, __tokens, __sym2)); + __result = try!(__state41(arena, __lookahead, __tokens, __sym2)); } __Nonterminal::Factor(__nt) => { let __sym2 = &mut Some(__nt); - __result = try!(__state56(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); + __result = try!(__state57(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); } _ => { return Ok((__lookahead, __nt)); @@ -3460,7 +3539,61 @@ mod __parse__Expr { return Ok(__result); } - // State 50 + // State 51 + // ( ",") = Expr "," (*) ["("] + // ( ",") = Expr "," (*) [")"] + // ( ",") = Expr "," (*) ["*"] + // ( ",") = Expr "," (*) ["Num"] + // + // "*" -> Reduce(( ",") = Expr, "," => ActionFn(15);) + // ")" -> Reduce(( ",") = Expr, "," => ActionFn(15);) + // "(" -> Reduce(( ",") = Expr, "," => ActionFn(15);) + // "Num" -> Reduce(( ",") = Expr, "," => ActionFn(15);) + // + pub fn __state51< + '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::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::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::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))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 52 // Expr = Expr "-" (*) Factor [")"] // Expr = Expr "-" (*) Factor ["+"] // Expr = Expr "-" (*) Factor [","] @@ -3502,141 +3635,12 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // + // "Num" -> Shift(S42) // "*" -> Shift(S37) - // "Num" -> Shift(S41) - // "(" -> Shift(S39) + // "(" -> Shift(S44) // - // Term -> S40 - // 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!(__state41(arena, __lookahead, __tokens, __sym2)); - } - Some(__tok @ Tok::LParen(..)) => { - let mut __sym2 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state39(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!(__state40(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);) - // "Num" -> Reduce(( ",") = Expr, "," => ActionFn(15);) - // "(" -> Reduce(( ",") = Expr, "," => ActionFn(15);) - // ")" -> Reduce(( ",") = Expr, "," => ActionFn(15);) - // - pub fn __state51< - '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::Times(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __nt = super::__actions::__action15(arena, __sym0, __sym1); - return Ok((__lookahead, __Nonterminal::__Expr______(__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::__Expr______(__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::__Expr______(__nt))); - } - 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::__Expr______(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 52 - // Factor = Factor "*" (*) Term [")"] - // Factor = Factor "*" (*) Term ["*"] - // Factor = Factor "*" (*) Term ["+"] - // Factor = Factor "*" (*) Term [","] - // Factor = Factor "*" (*) Term ["-"] - // Factor = Factor "*" (*) Term ["/"] - // Term = (*) "(" Expr ")" [")"] - // Term = (*) "(" Expr ")" ["*"] - // Term = (*) "(" Expr ")" ["+"] - // Term = (*) "(" Expr ")" [","] - // Term = (*) "(" Expr ")" ["-"] - // Term = (*) "(" Expr ")" ["/"] - // Term = (*) "Num" [")"] - // Term = (*) "Num" ["*"] - // Term = (*) "Num" ["+"] - // Term = (*) "Num" [","] - // Term = (*) "Num" ["-"] - // Term = (*) "Num" ["/"] - // - // "(" -> Shift(S39) - // "Num" -> Shift(S41) - // - // Term -> S58 + // Factor -> S58 + // Term -> S41 pub fn __state52< 'ast, __TOKENS: Iterator, @@ -3650,15 +3654,20 @@ 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!(__state39(arena, __lookahead, __tokens, __sym2)); - } Some(Tok::Num(__tok0)) => { let mut __sym2 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state41(arena, __lookahead, __tokens, __sym2)); + __result = try!(__state42(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)); + } + Some(__tok @ Tok::LParen(..)) => { + let mut __sym2 = &mut Some(__tok); + let __lookahead = __tokens.next(); + __result = try!(__state44(arena, __lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); @@ -3667,10 +3676,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!(__state58(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); } + __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state41(arena, __lookahead, __tokens, __sym2)); + } _ => { return Ok((__lookahead, __nt)); } @@ -3680,29 +3693,23 @@ mod __parse__Expr { } // State 53 - // Factor = Factor "/" (*) Term [")"] - // Factor = Factor "/" (*) Term ["*"] - // Factor = Factor "/" (*) Term ["+"] - // Factor = Factor "/" (*) Term [","] - // Factor = Factor "/" (*) Term ["-"] - // Factor = Factor "/" (*) Term ["/"] - // Term = (*) "(" Expr ")" [")"] - // Term = (*) "(" Expr ")" ["*"] - // Term = (*) "(" Expr ")" ["+"] - // Term = (*) "(" Expr ")" [","] - // Term = (*) "(" Expr ")" ["-"] - // Term = (*) "(" Expr ")" ["/"] - // Term = (*) "Num" [")"] - // Term = (*) "Num" ["*"] - // Term = (*) "Num" ["+"] - // Term = (*) "Num" [","] - // Term = (*) "Num" ["-"] - // Term = (*) "Num" ["/"] + // 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 (*) ")" ["/"] // - // "Num" -> Shift(S41) - // "(" -> Shift(S39) + // "+" -> Shift(S23) + // ")" -> Shift(S59) + // "-" -> Shift(S24) // - // Term -> S59 pub fn __state53< 'ast, __TOKENS: Iterator, @@ -3710,38 +3717,31 @@ mod __parse__Expr { arena: &'ast Arena<'ast>, mut __lookahead: Option, __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, + __sym0: &mut Option, + __sym1: &mut Option<&'ast Node<'ast>>, ) -> Result<(Option, __Nonterminal<'ast, >), Option> { let mut __result: (Option, __Nonterminal<'ast, >); match __lookahead { - Some(Tok::Num(__tok0)) => { - let mut __sym2 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state41(arena, __lookahead, __tokens, __sym2)); - } - Some(__tok @ Tok::LParen(..)) => { + Some(__tok @ Tok::Plus(..)) => { let mut __sym2 = &mut Some(__tok); let __lookahead = __tokens.next(); - __result = try!(__state39(arena, __lookahead, __tokens, __sym2)); + __result = try!(__state23(arena, __lookahead, __tokens, __sym1, __sym2)); + } + 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 @ Tok::Minus(..)) => { + let mut __sym2 = &mut Some(__tok); + let __lookahead = __tokens.next(); + __result = try!(__state24(arena, __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!(__state59(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - _ => { - return Ok((__lookahead, __nt)); - } - } - } return Ok(__result); } @@ -3782,6 +3782,328 @@ mod __parse__Expr { } // 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 + // 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(2);) + // "," -> Reduce(Expr = Expr, "+", Factor => ActionFn(2);) + // "+" -> 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, + __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::Div(..)) => { + let mut __sym3 = &mut Some(__tok); + let __lookahead = __tokens.next(); + __result = try!(__state49(arena, __lookahead, __tokens, __sym2, __sym3)); + } + Some(__tok @ Tok::Times(..)) => { + let mut __sym3 = &mut Some(__tok); + let __lookahead = __tokens.next(); + __result = try!(__state48(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::__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))); + } + Some(Tok::Comma(..)) => { + 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::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))); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + + // State 59 // Term = "(" Expr ")" (*) [")"] // Term = "(" Expr ")" (*) ["*"] // Term = "(" Expr ")" (*) ["+"] @@ -3790,13 +4112,13 @@ 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);) - // ")" -> Reduce(Term = "(", Expr, ")" => ActionFn(9);) - // "+" -> Reduce(Term = "(", Expr, ")" => ActionFn(9);) // - pub fn __state55< + pub fn __state59< 'ast, __TOKENS: Iterator, >( @@ -3817,6 +4139,27 @@ mod __parse__Expr { 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(); @@ -3831,349 +4174,6 @@ mod __parse__Expr { 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::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::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 56 - // Expr = Expr "+" Factor (*) [")"] - // Expr = Expr "+" Factor (*) ["+"] - // Expr = Expr "+" Factor (*) [","] - // Expr = Expr "+" Factor (*) ["-"] - // Factor = Factor (*) "*" Term [")"] - // Factor = Factor (*) "*" Term ["*"] - // Factor = Factor (*) "*" Term ["+"] - // Factor = Factor (*) "*" Term [","] - // Factor = Factor (*) "*" Term ["-"] - // Factor = Factor (*) "*" Term ["/"] - // Factor = Factor (*) "/" Term [")"] - // Factor = Factor (*) "/" Term ["*"] - // Factor = Factor (*) "/" Term ["+"] - // Factor = Factor (*) "/" Term [","] - // Factor = Factor (*) "/" Term ["-"] - // Factor = Factor (*) "/" Term ["/"] - // - // "*" -> Shift(S52) - // "/" -> Shift(S53) - // "-" -> Reduce(Expr = Expr, "+", Factor => ActionFn(2);) - // "," -> Reduce(Expr = Expr, "+", Factor => ActionFn(2);) - // ")" -> Reduce(Expr = Expr, "+", Factor => ActionFn(2);) - // "+" -> Reduce(Expr = Expr, "+", Factor => ActionFn(2);) - // - 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 @ Tok::Times(..)) => { - let mut __sym3 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state52(arena, __lookahead, __tokens, __sym2, __sym3)); - } - Some(__tok @ Tok::Div(..)) => { - let mut __sym3 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state53(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::__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::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))); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 57 - // Expr = Expr "-" Factor (*) [")"] - // Expr = Expr "-" Factor (*) ["+"] - // Expr = Expr "-" Factor (*) [","] - // Expr = Expr "-" Factor (*) ["-"] - // Factor = Factor (*) "*" Term [")"] - // Factor = Factor (*) "*" Term ["*"] - // Factor = Factor (*) "*" Term ["+"] - // Factor = Factor (*) "*" Term [","] - // Factor = Factor (*) "*" Term ["-"] - // Factor = Factor (*) "*" Term ["/"] - // Factor = Factor (*) "/" Term [")"] - // Factor = Factor (*) "/" Term ["*"] - // Factor = Factor (*) "/" Term ["+"] - // Factor = Factor (*) "/" Term [","] - // Factor = Factor (*) "/" Term ["-"] - // Factor = Factor (*) "/" Term ["/"] - // - // "/" -> Shift(S53) - // "," -> Reduce(Expr = Expr, "-", Factor => ActionFn(1);) - // "-" -> Reduce(Expr = Expr, "-", Factor => ActionFn(1);) - // "*" -> Shift(S52) - // ")" -> Reduce(Expr = Expr, "-", Factor => ActionFn(1);) - // "+" -> Reduce(Expr = Expr, "-", Factor => ActionFn(1);) - // - 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::Div(..)) => { - let mut __sym3 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state53(arena, __lookahead, __tokens, __sym2, __sym3)); - } - Some(__tok @ Tok::Times(..)) => { - let mut __sym3 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state52(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::__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))); - } - 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); - 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))); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 58 - // 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 __state58< - '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::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::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::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))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 59 - // Factor = Factor "/" Term (*) [")"] - // Factor = Factor "/" Term (*) ["*"] - // Factor = Factor "/" Term (*) ["+"] - // Factor = Factor "/" Term (*) [","] - // Factor = Factor "/" Term (*) ["-"] - // Factor = Factor "/" Term (*) ["/"] - // - // "," -> Reduce(Factor = Factor, "/", Term => 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 __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::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::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))); - } - 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::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))); - } _ => { return Err(__lookahead); } @@ -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::RParen(..)) => { + Some(Tok::Comma(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); @@ -4218,7 +4218,15 @@ mod __parse__Expr { let __nt = super::__actions::__action6(arena, __sym0, __sym1, __sym2, __sym3); return Ok((__lookahead, __Nonterminal::Factor(__nt))); } - Some(Tok::Comma(..)) => { + Some(Tok::Plus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __sym3 = __sym3.take().unwrap(); + let __nt = super::__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(); @@ -4242,15 +4250,7 @@ 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::Plus(..)) => { + Some(Tok::RParen(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); diff --git a/lalrpop-test/src/sub.rs b/lalrpop-test/src/sub.rs index 6c623c4..c12536c 100644 --- a/lalrpop-test/src/sub.rs +++ b/lalrpop-test/src/sub.rs @@ -11,7 +11,7 @@ pub fn parse_S< let mut __tokens = __tokens.into_iter(); let __lookahead = __tokens.next(); match try!(__parse__S::__state0(__lookahead, &mut __tokens)) { - (__lookahead, __parse__S::__Nonterminal::__S(__nt)) => Ok((__lookahead, __nt)), + (__lookahead, __parse__S::__Nonterminal::____S(__nt)) => Ok((__lookahead, __nt)), _ => unreachable!(), } } @@ -23,9 +23,9 @@ mod __parse__S { pub enum __Nonterminal<> { E(i32), - S(i32), T(i32), - __S(i32), + S(i32), + ____S(i32), } // State 0 @@ -40,12 +40,12 @@ mod __parse__S { // T = (*) "Num" ["-"] // __S = (*) S [EOF] // - // "(" -> Shift(S4) - // "Num" -> Shift(S5) + // "Num" -> Shift(S3) + // "(" -> Shift(S2) // - // S -> S1 - // T -> S2 - // E -> S3 + // S -> S4 + // E -> S1 + // T -> S5 pub fn __state0< __TOKENS: Iterator, >( @@ -55,15 +55,15 @@ mod __parse__S { { let mut __result: (Option, __Nonterminal<>); match __lookahead { - Some(__tok @ Tok::LParen(..)) => { - let mut __sym0 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state4(__lookahead, __tokens, __sym0)); - } Some(Tok::Num(__tok0)) => { let mut __sym0 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state5(__lookahead, __tokens, __sym0)); + __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)); } _ => { return Err(__lookahead); @@ -73,16 +73,16 @@ mod __parse__S { 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!(__state2(__lookahead, __tokens, __sym0)); - } - __Nonterminal::E(__nt) => { - let __sym0 = &mut Some(__nt); - __result = try!(__state3(__lookahead, __tokens, __sym0)); + __result = try!(__state5(__lookahead, __tokens, __sym0)); } _ => { return Ok((__lookahead, __nt)); @@ -92,65 +92,6 @@ mod __parse__S { } // State 1 - // __S = S (*) [EOF] - // - // EOF -> Reduce(__S = S => ActionFn(0);) - // - pub fn __state1< - __TOKENS: Iterator, - >( - mut __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - ) -> Result<(Option, __Nonterminal<>), Option> - { - let mut __result: (Option, __Nonterminal<>); - match __lookahead { - None => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action0(__sym0); - return Ok((__lookahead, __Nonterminal::__S(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 2 - // E = T (*) [EOF] - // E = T (*) ["-"] - // - // EOF -> Reduce(E = T => ActionFn(3);) - // "-" -> Reduce(E = T => ActionFn(3);) - // - 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 { - 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))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 3 // E = E (*) "-" T [EOF] // E = E (*) "-" T ["-"] // S = E (*) [EOF] @@ -158,7 +99,7 @@ mod __parse__S { // "-" -> Shift(S6) // EOF -> Reduce(S = E => ActionFn(1);) // - pub fn __state3< + pub fn __state1< __TOKENS: Iterator, >( mut __lookahead: Option, @@ -185,7 +126,7 @@ mod __parse__S { return Ok(__result); } - // State 4 + // State 2 // E = (*) E "-" T [")"] // E = (*) E "-" T ["-"] // E = (*) T [")"] @@ -197,12 +138,12 @@ mod __parse__S { // T = (*) "Num" [")"] // T = (*) "Num" ["-"] // - // "(" -> Shift(S8) - // "Num" -> Shift(S10) + // "Num" -> Shift(S9) + // "(" -> Shift(S7) // - // T -> S7 - // E -> S9 - pub fn __state4< + // T -> S8 + // E -> S10 + pub fn __state2< __TOKENS: Iterator, >( mut __lookahead: Option, @@ -212,15 +153,15 @@ mod __parse__S { { 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)); + __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); @@ -231,11 +172,11 @@ mod __parse__S { match __nt { __Nonterminal::T(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state7(__lookahead, __tokens, __sym1)); + __result = try!(__state8(__lookahead, __tokens, __sym1)); } __Nonterminal::E(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state9(__lookahead, __tokens, __sym0, __sym1)); + __result = try!(__state10(__lookahead, __tokens, __sym0, __sym1)); } _ => { return Ok((__lookahead, __nt)); @@ -245,12 +186,71 @@ mod __parse__S { return Ok(__result); } - // State 5 + // State 3 // T = "Num" (*) [EOF] // T = "Num" (*) ["-"] // - // "-" -> Reduce(T = "Num" => ActionFn(4);) // EOF -> Reduce(T = "Num" => ActionFn(4);) + // "-" -> Reduce(T = "Num" => ActionFn(4);) + // + pub fn __state3< + __TOKENS: Iterator, + >( + mut __lookahead: Option, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + ) -> Result<(Option, __Nonterminal<>), Option> + { + 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))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 4 + // __S = S (*) [EOF] + // + // EOF -> Reduce(__S = S => ActionFn(0);) + // + pub fn __state4< + __TOKENS: Iterator, + >( + mut __lookahead: Option, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + ) -> Result<(Option, __Nonterminal<>), Option> + { + let mut __result: (Option, __Nonterminal<>); + match __lookahead { + None => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action0(__sym0); + return Ok((__lookahead, __Nonterminal::____S(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 5 + // E = T (*) [EOF] + // E = T (*) ["-"] + // + // EOF -> Reduce(E = T => ActionFn(3);) + // "-" -> Reduce(E = T => ActionFn(3);) // pub fn __state5< __TOKENS: Iterator, @@ -262,15 +262,15 @@ mod __parse__S { { let mut __result: (Option, __Nonterminal<>); match __lookahead { - Some(Tok::Minus(..)) => { - let __sym0 = __sym0.take().unwrap(); - 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))); + 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); @@ -286,8 +286,8 @@ mod __parse__S { // T = (*) "Num" [EOF] // T = (*) "Num" ["-"] // - // "Num" -> Shift(S5) - // "(" -> Shift(S4) + // "Num" -> Shift(S3) + // "(" -> Shift(S2) // // 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!(__state5(__lookahead, __tokens, __sym2)); + __result = try!(__state3(__lookahead, __tokens, __sym2)); } Some(__tok @ Tok::LParen(..)) => { let mut __sym2 = &mut Some(__tok); let __lookahead = __tokens.next(); - __result = try!(__state4(__lookahead, __tokens, __sym2)); + __result = try!(__state2(__lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); @@ -331,39 +331,6 @@ 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::Minus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action3(__sym0); - return Ok((__lookahead, __Nonterminal::E(__nt))); - } - Some(Tok::RParen(..)) => { - 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 [")"] @@ -375,12 +342,12 @@ mod __parse__S { // T = (*) "Num" [")"] // T = (*) "Num" ["-"] // - // "Num" -> Shift(S10) - // "(" -> Shift(S8) + // "Num" -> Shift(S9) + // "(" -> Shift(S7) // - // T -> S7 + // T -> S8 // E -> S12 - pub fn __state8< + pub fn __state7< __TOKENS: Iterator, >( mut __lookahead: Option, @@ -393,12 +360,12 @@ mod __parse__S { Some(Tok::Num(__tok0)) => { let mut __sym1 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state10(__lookahead, __tokens, __sym1)); + __result = try!(__state9(__lookahead, __tokens, __sym1)); } Some(__tok @ Tok::LParen(..)) => { let mut __sym1 = &mut Some(__tok); let __lookahead = __tokens.next(); - __result = try!(__state8(__lookahead, __tokens, __sym1)); + __result = try!(__state7(__lookahead, __tokens, __sym1)); } _ => { return Err(__lookahead); @@ -409,7 +376,7 @@ mod __parse__S { match __nt { __Nonterminal::T(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state7(__lookahead, __tokens, __sym1)); + __result = try!(__state8(__lookahead, __tokens, __sym1)); } __Nonterminal::E(__nt) => { let __sym1 = &mut Some(__nt); @@ -423,16 +390,82 @@ 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) + // "-" -> Shift(S14) // - pub fn __state9< + pub fn __state10< __TOKENS: Iterator, >( mut __lookahead: Option, @@ -443,15 +476,15 @@ mod __parse__S { { let mut __result: (Option, __Nonterminal<>); match __lookahead { - Some(__tok @ Tok::Minus(..)) => { - let mut __sym2 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state13(__lookahead, __tokens, __sym1, __sym2)); - } Some(__tok @ Tok::RParen(..)) => { let mut __sym2 = &mut Some(__tok); let __lookahead = __tokens.next(); - __result = try!(__state14(__lookahead, __tokens, __sym0, __sym1, __sym2)); + __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)); } _ => { return Err(__lookahead); @@ -460,45 +493,12 @@ 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::Minus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action4(__sym0); - return Ok((__lookahead, __Nonterminal::T(__nt))); - } - Some(Tok::RParen(..)) => { - 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 (*) ["-"] // - // EOF -> Reduce(E = E, "-", T => ActionFn(2);) // "-" -> Reduce(E = E, "-", T => ActionFn(2);) + // EOF -> Reduce(E = E, "-", T => ActionFn(2);) // pub fn __state11< __TOKENS: Iterator, @@ -512,14 +512,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::__action2(__sym0, __sym1, __sym2); return Ok((__lookahead, __Nonterminal::E(__nt))); } - Some(Tok::Minus(..)) => { + None => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); @@ -539,7 +539,7 @@ mod __parse__S { // T = "(" E (*) ")" ["-"] // // ")" -> Shift(S15) - // "-" -> Shift(S13) + // "-" -> Shift(S14) // pub fn __state12< __TOKENS: Iterator, @@ -560,7 +560,7 @@ mod __parse__S { Some(__tok @ Tok::Minus(..)) => { let mut __sym2 = &mut Some(__tok); let __lookahead = __tokens.next(); - __result = try!(__state13(__lookahead, __tokens, __sym1, __sym2)); + __result = try!(__state14(__lookahead, __tokens, __sym1, __sym2)); } _ => { return Err(__lookahead); @@ -570,6 +570,45 @@ mod __parse__S { } // State 13 + // T = "(" E ")" (*) [EOF] + // T = "(" E ")" (*) ["-"] + // + // EOF -> Reduce(T = "(", E, ")" => ActionFn(5);) + // "-" -> Reduce(T = "(", E, ")" => ActionFn(5);) + // + pub fn __state13< + __TOKENS: Iterator, + >( + 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::__action5(__sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::T(__nt))); + } + 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))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 14 // E = E "-" (*) T [")"] // E = E "-" (*) T ["-"] // T = (*) "(" E ")" [")"] @@ -577,11 +616,11 @@ mod __parse__S { // T = (*) "Num" [")"] // T = (*) "Num" ["-"] // - // "(" -> Shift(S8) - // "Num" -> Shift(S10) + // "(" -> Shift(S7) + // "Num" -> Shift(S9) // // T -> S16 - pub fn __state13< + pub fn __state14< __TOKENS: Iterator, >( mut __lookahead: Option, @@ -595,12 +634,12 @@ mod __parse__S { Some(__tok @ Tok::LParen(..)) => { let mut __sym2 = &mut Some(__tok); let __lookahead = __tokens.next(); - __result = try!(__state8(__lookahead, __tokens, __sym2)); + __result = try!(__state7(__lookahead, __tokens, __sym2)); } Some(Tok::Num(__tok0)) => { let mut __sym2 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state10(__lookahead, __tokens, __sym2)); + __result = try!(__state9(__lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); @@ -621,51 +660,12 @@ mod __parse__S { return Ok(__result); } - // State 14 - // T = "(" E ")" (*) [EOF] - // T = "(" E ")" (*) ["-"] - // - // "-" -> Reduce(T = "(", E, ")" => ActionFn(5);) - // EOF -> Reduce(T = "(", E, ")" => ActionFn(5);) - // - pub fn __state14< - __TOKENS: Iterator, - >( - 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::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))); - } - None => { - 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))); - } - _ => { - return Err(__lookahead); - } - } - } - // State 15 // 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::RParen(..)) => { + 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(..)) => { + Some(Tok::RParen(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); diff --git a/lalrpop/src/util.rs b/lalrpop/src/util.rs index defb348..feb4474 100644 --- a/lalrpop/src/util.rs +++ b/lalrpop/src/util.rs @@ -26,10 +26,9 @@ impl Display for Escape { let tmp = format!("{}", self.0); for c in tmp.chars() { match c { - 'a' ... 'z' | '_' | '0' ... '9' | 'A' ... 'Z' => - try!(write!(fmt, "{}", c)), - _ => - try!(write!(fmt, "_")), // um, obviously not the best escaping :) + 'a' ... 'z' | '0' ... '9' | 'A' ... 'Z' => try!(write!(fmt, "{}", c)), + '_' => try!(write!(fmt, "__")), + _ => try!(write!(fmt, "_{:x}", c as usize)), } } Ok(())