From 8d1fed1e25fe2774d16599b7cfdd4a79a1d701f6 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Mon, 20 Jul 2015 05:43:07 -0400 Subject: [PATCH] change `parse_Foo` so that it expects to consume entire input; later we'll make a version called `resume_Foo` or something that lets you supply the initial state (lookbehind, lookahead, etc) in its entirety --- lalrpop-test/src/expr.rs | 2348 +++++++-------- lalrpop-test/src/expr_arena.rs | 5142 ++++++++++++++++---------------- lalrpop-test/src/loc.rs | 374 +-- lalrpop-test/src/sub.rs | 600 ++-- lalrpop-test/src/util/mod.rs | 19 +- lalrpop/src/lr1/ascent.rs | 18 +- 6 files changed, 4263 insertions(+), 4238 deletions(-) diff --git a/lalrpop-test/src/expr.rs b/lalrpop-test/src/expr.rs index 11d87ed..e6e5053 100644 --- a/lalrpop-test/src/expr.rs +++ b/lalrpop-test/src/expr.rs @@ -8,12 +8,18 @@ pub fn parse_Expr< >( scale: i32, __tokens: __TOKENS, -) -> Result<(Option, i32), Option> +) -> Result> { let mut __tokens = __tokens.into_iter(); let __lookahead = __tokens.next(); match try!(__parse__Expr::__state0(scale, None, __lookahead, &mut __tokens)) { - (_, __lookahead, __parse__Expr::__Nonterminal::____Expr(__nt)) => Ok((__lookahead, __nt)), + (_, __lookahead, __parse__Expr::__Nonterminal::____Expr(__nt)) => { + if __lookahead.is_some() { + Err(__lookahead) + } else { + Ok(__nt) + } + } _ => unreachable!(), } } @@ -25,9 +31,9 @@ mod __parse__Expr { pub enum __Nonterminal<> { Term(i32), - Factor(i32), ____Expr(i32), Expr(i32), + Factor(i32), } // State 0 @@ -67,12 +73,12 @@ mod __parse__Expr { // Term = (*) "Num" ["/"] // __Expr = (*) Expr [EOF] // - // "(" -> Shift(S3) - // "Num" -> Shift(S2) + // "Num" -> Shift(S5) + // "(" -> Shift(S4) // - // Term -> S1 - // Expr -> S5 - // Factor -> S4 + // Factor -> S1 + // Expr -> S3 + // Term -> S2 pub fn __state0< __TOKENS: Iterator, >( @@ -84,17 +90,17 @@ mod __parse__Expr { { let mut __result: (Option<()>, Option, __Nonterminal<>); match __lookahead { - Some(__tok @ Tok::LParen(..)) => { - let mut __lookbehind = None; - let mut __sym0 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state3(scale, __lookbehind, __lookahead, __tokens, __sym0)); - } Some(Tok::Num(__tok0)) => { let mut __lookbehind = None; let mut __sym0 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state2(scale, __lookbehind, __lookahead, __tokens, __sym0)); + __result = try!(__state5(scale, __lookbehind, __lookahead, __tokens, __sym0)); + } + Some(__tok @ Tok::LParen(..)) => { + let mut __lookbehind = None; + let mut __sym0 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state4(scale, __lookbehind, __lookahead, __tokens, __sym0)); } _ => { return Err(__lookahead); @@ -103,17 +109,17 @@ mod __parse__Expr { loop { let (__lookbehind, __lookahead, __nt) = __result; match __nt { - __Nonterminal::Term(__nt) => { + __Nonterminal::Factor(__nt) => { let __sym0 = &mut Some(__nt); __result = try!(__state1(scale, __lookbehind, __lookahead, __tokens, __sym0)); } __Nonterminal::Expr(__nt) => { let __sym0 = &mut Some(__nt); - __result = try!(__state5(scale, __lookbehind, __lookahead, __tokens, __sym0)); + __result = try!(__state3(scale, __lookbehind, __lookahead, __tokens, __sym0)); } - __Nonterminal::Factor(__nt) => { + __Nonterminal::Term(__nt) => { let __sym0 = &mut Some(__nt); - __result = try!(__state4(scale, __lookbehind, __lookahead, __tokens, __sym0)); + __result = try!(__state2(scale, __lookbehind, __lookahead, __tokens, __sym0)); } _ => { return Ok((__lookbehind, __lookahead, __nt)); @@ -123,17 +129,25 @@ mod __parse__Expr { } // State 1 - // Factor = Term (*) [EOF] - // Factor = Term (*) ["*"] - // Factor = Term (*) ["+"] - // Factor = Term (*) ["-"] - // Factor = Term (*) ["/"] + // Expr = Factor (*) [EOF] + // Expr = Factor (*) ["+"] + // Expr = Factor (*) ["-"] + // Factor = Factor (*) "*" Term [EOF] + // Factor = Factor (*) "*" Term ["*"] + // Factor = Factor (*) "*" Term ["+"] + // Factor = Factor (*) "*" Term ["-"] + // Factor = Factor (*) "*" Term ["/"] + // Factor = Factor (*) "/" Term [EOF] + // Factor = Factor (*) "/" Term ["*"] + // Factor = Factor (*) "/" Term ["+"] + // Factor = Factor (*) "/" Term ["-"] + // Factor = Factor (*) "/" Term ["/"] // - // "*" -> Reduce(Factor = Term => Call(ActionFn(6));) - // "+" -> Reduce(Factor = Term => Call(ActionFn(6));) - // EOF -> Reduce(Factor = Term => Call(ActionFn(6));) - // "-" -> Reduce(Factor = Term => Call(ActionFn(6));) - // "/" -> Reduce(Factor = Term => Call(ActionFn(6));) + // "-" -> Reduce(Expr = Factor => Call(ActionFn(3));) + // "/" -> Shift(S7) + // "+" -> Reduce(Expr = Factor => Call(ActionFn(3));) + // EOF -> Reduce(Expr = Factor => Call(ActionFn(3));) + // "*" -> Shift(S6) // pub fn __state1< __TOKENS: Iterator, @@ -147,49 +161,52 @@ mod __parse__Expr { { let mut __result: (Option<()>, Option, __Nonterminal<>); match __lookahead { - Some(Tok::Times(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action6(scale, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + Some(__tok @ Tok::Div(..)) => { + let mut __lookbehind = None; + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state7(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); } - Some(Tok::Plus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action6(scale, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - None => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action6(scale, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + Some(__tok @ Tok::Times(..)) => { + let mut __lookbehind = None; + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state6(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); } Some(Tok::Minus(..)) => { let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action6(scale, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + let __nt = super::__action3(scale, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); } - Some(Tok::Div(..)) => { + Some(Tok::Plus(..)) => { let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action6(scale, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + let __nt = super::__action3(scale, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + None => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action3(scale, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); } _ => { return Err(__lookahead); } } + return Ok(__result); } // State 2 - // Term = "Num" (*) [EOF] - // Term = "Num" (*) ["*"] - // Term = "Num" (*) ["+"] - // Term = "Num" (*) ["-"] - // Term = "Num" (*) ["/"] + // Factor = Term (*) [EOF] + // Factor = Term (*) ["*"] + // Factor = Term (*) ["+"] + // Factor = Term (*) ["-"] + // Factor = Term (*) ["/"] // - // "*" -> Reduce(Term = "Num" => Call(ActionFn(7));) - // "/" -> Reduce(Term = "Num" => Call(ActionFn(7));) - // EOF -> Reduce(Term = "Num" => Call(ActionFn(7));) - // "-" -> Reduce(Term = "Num" => Call(ActionFn(7));) - // "+" -> Reduce(Term = "Num" => Call(ActionFn(7));) + // EOF -> Reduce(Factor = Term => Call(ActionFn(6));) + // "/" -> Reduce(Factor = Term => Call(ActionFn(6));) + // "+" -> Reduce(Factor = Term => Call(ActionFn(6));) + // "-" -> Reduce(Factor = Term => Call(ActionFn(6));) + // "*" -> Reduce(Factor = Term => Call(ActionFn(6));) // pub fn __state2< __TOKENS: Iterator, @@ -203,30 +220,30 @@ mod __parse__Expr { { let mut __result: (Option<()>, Option, __Nonterminal<>); match __lookahead { - Some(Tok::Times(..)) => { + None => { let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action7(scale, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + let __nt = super::__action6(scale, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } Some(Tok::Div(..)) => { let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action7(scale, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - None => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action7(scale, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - Some(Tok::Minus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action7(scale, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + let __nt = super::__action6(scale, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } Some(Tok::Plus(..)) => { let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action7(scale, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + let __nt = super::__action6(scale, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some(Tok::Minus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action6(scale, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some(Tok::Times(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action6(scale, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } _ => { return Err(__lookahead); @@ -235,6 +252,55 @@ mod __parse__Expr { } // State 3 + // Expr = Expr (*) "+" Factor [EOF] + // Expr = Expr (*) "+" Factor ["+"] + // Expr = Expr (*) "+" Factor ["-"] + // Expr = Expr (*) "-" Factor [EOF] + // Expr = Expr (*) "-" Factor ["+"] + // Expr = Expr (*) "-" Factor ["-"] + // __Expr = Expr (*) [EOF] + // + // "+" -> Shift(S9) + // EOF -> Reduce(__Expr = Expr => Call(ActionFn(0));) + // "-" -> Shift(S8) + // + pub fn __state3< + __TOKENS: Iterator, + >( + scale: i32, + __lookbehind: Option<()>, + __lookahead: Option, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + ) -> Result<(Option<()>, Option, __Nonterminal<>), Option> + { + let mut __result: (Option<()>, Option, __Nonterminal<>); + match __lookahead { + Some(__tok @ Tok::Plus(..)) => { + let mut __lookbehind = None; + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state9(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + } + Some(__tok @ Tok::Minus(..)) => { + let mut __lookbehind = None; + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state8(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + } + None => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action0(scale, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::____Expr(__nt))); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + + // State 4 // Expr = (*) Expr "+" Factor [")"] // Expr = (*) Expr "+" Factor ["+"] // Expr = (*) Expr "+" Factor ["-"] @@ -275,13 +341,13 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "(" -> Shift(S8) - // "Num" -> Shift(S6) + // "(" -> Shift(S13) + // "Num" -> Shift(S12) // - // Expr -> S10 - // Factor -> S9 - // Term -> S7 - pub fn __state3< + // Expr -> S11 + // Term -> S10 + // Factor -> S14 + pub fn __state4< __TOKENS: Iterator, >( scale: i32, @@ -297,13 +363,13 @@ mod __parse__Expr { let mut __lookbehind = None; let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state8(scale, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state13(scale, __lookbehind, __lookahead, __tokens, __sym1)); } Some(Tok::Num(__tok0)) => { let mut __lookbehind = None; let mut __sym1 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state6(scale, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state12(scale, __lookbehind, __lookahead, __tokens, __sym1)); } _ => { return Err(__lookahead); @@ -314,15 +380,15 @@ mod __parse__Expr { match __nt { __Nonterminal::Expr(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state10(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); - } - __Nonterminal::Factor(__nt) => { - let __sym1 = &mut Some(__nt); - __result = try!(__state9(scale, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state11(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); } __Nonterminal::Term(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state7(scale, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state10(scale, __lookbehind, __lookahead, __tokens, __sym1)); + } + __Nonterminal::Factor(__nt) => { + let __sym1 = &mut Some(__nt); + __result = try!(__state14(scale, __lookbehind, __lookahead, __tokens, __sym1)); } _ => { return Ok((__lookbehind, __lookahead, __nt)); @@ -332,85 +398,18 @@ mod __parse__Expr { return Ok(__result); } - // State 4 - // Expr = Factor (*) [EOF] - // Expr = Factor (*) ["+"] - // Expr = Factor (*) ["-"] - // Factor = Factor (*) "*" Term [EOF] - // Factor = Factor (*) "*" Term ["*"] - // Factor = Factor (*) "*" Term ["+"] - // Factor = Factor (*) "*" Term ["-"] - // Factor = Factor (*) "*" Term ["/"] - // Factor = Factor (*) "/" Term [EOF] - // Factor = Factor (*) "/" Term ["*"] - // Factor = Factor (*) "/" Term ["+"] - // Factor = Factor (*) "/" Term ["-"] - // Factor = Factor (*) "/" Term ["/"] - // - // "/" -> Shift(S12) - // EOF -> Reduce(Expr = Factor => Call(ActionFn(3));) - // "+" -> Reduce(Expr = Factor => Call(ActionFn(3));) - // "*" -> Shift(S11) - // "-" -> Reduce(Expr = Factor => Call(ActionFn(3));) - // - pub fn __state4< - __TOKENS: Iterator, - >( - scale: i32, - __lookbehind: Option<()>, - __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - ) -> Result<(Option<()>, Option, __Nonterminal<>), Option> - { - let mut __result: (Option<()>, Option, __Nonterminal<>); - match __lookahead { - Some(__tok @ Tok::Div(..)) => { - let mut __lookbehind = None; - let mut __sym1 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state12(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); - } - Some(__tok @ Tok::Times(..)) => { - let mut __lookbehind = None; - let mut __sym1 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state11(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); - } - None => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action3(scale, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - Some(Tok::Plus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action3(scale, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - Some(Tok::Minus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action3(scale, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - // State 5 - // Expr = Expr (*) "+" Factor [EOF] - // Expr = Expr (*) "+" Factor ["+"] - // Expr = Expr (*) "+" Factor ["-"] - // Expr = Expr (*) "-" Factor [EOF] - // Expr = Expr (*) "-" Factor ["+"] - // Expr = Expr (*) "-" Factor ["-"] - // __Expr = Expr (*) [EOF] + // Term = "Num" (*) [EOF] + // Term = "Num" (*) ["*"] + // Term = "Num" (*) ["+"] + // Term = "Num" (*) ["-"] + // Term = "Num" (*) ["/"] // - // "-" -> Shift(S13) - // "+" -> Shift(S14) - // EOF -> Reduce(__Expr = Expr => Call(ActionFn(0));) + // "*" -> Reduce(Term = "Num" => Call(ActionFn(7));) + // EOF -> Reduce(Term = "Num" => Call(ActionFn(7));) + // "-" -> Reduce(Term = "Num" => Call(ActionFn(7));) + // "/" -> Reduce(Term = "Num" => Call(ActionFn(7));) + // "+" -> Reduce(Term = "Num" => Call(ActionFn(7));) // pub fn __state5< __TOKENS: Iterator, @@ -424,43 +423,58 @@ mod __parse__Expr { { let mut __result: (Option<()>, Option, __Nonterminal<>); match __lookahead { - Some(__tok @ Tok::Minus(..)) => { - let mut __lookbehind = None; - let mut __sym1 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state13(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); - } - Some(__tok @ Tok::Plus(..)) => { - let mut __lookbehind = None; - let mut __sym1 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state14(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + Some(Tok::Times(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action7(scale, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); } None => { let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action0(scale, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::____Expr(__nt))); + let __nt = super::__action7(scale, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + Some(Tok::Minus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action7(scale, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + Some(Tok::Div(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action7(scale, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + Some(Tok::Plus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action7(scale, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); } _ => { return Err(__lookahead); } } - return Ok(__result); } // State 6 - // Term = "Num" (*) [")"] - // Term = "Num" (*) ["*"] - // Term = "Num" (*) ["+"] - // Term = "Num" (*) ["-"] - // Term = "Num" (*) ["/"] + // Factor = Factor "*" (*) Term [EOF] + // Factor = Factor "*" (*) Term ["*"] + // Factor = Factor "*" (*) Term ["+"] + // Factor = Factor "*" (*) Term ["-"] + // Factor = Factor "*" (*) Term ["/"] + // Term = (*) "(" Expr ")" [EOF] + // Term = (*) "(" Expr ")" ["*"] + // Term = (*) "(" Expr ")" ["+"] + // Term = (*) "(" Expr ")" ["-"] + // Term = (*) "(" Expr ")" ["/"] + // Term = (*) "Num" [EOF] + // Term = (*) "Num" ["*"] + // Term = (*) "Num" ["+"] + // Term = (*) "Num" ["-"] + // Term = (*) "Num" ["/"] // - // "+" -> Reduce(Term = "Num" => Call(ActionFn(7));) - // "/" -> Reduce(Term = "Num" => Call(ActionFn(7));) - // "*" -> Reduce(Term = "Num" => Call(ActionFn(7));) - // "-" -> Reduce(Term = "Num" => Call(ActionFn(7));) - // ")" -> Reduce(Term = "Num" => Call(ActionFn(7));) + // "Num" -> Shift(S5) + // "(" -> Shift(S4) // + // Term -> S15 pub fn __state6< __TOKENS: Iterator, >( @@ -469,55 +483,287 @@ mod __parse__Expr { __lookahead: Option, __tokens: &mut __TOKENS, __sym0: &mut Option, + __sym1: &mut Option, ) -> Result<(Option<()>, Option, __Nonterminal<>), Option> { let mut __result: (Option<()>, Option, __Nonterminal<>); match __lookahead { - Some(Tok::Plus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action7(scale, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + Some(Tok::Num(__tok0)) => { + let mut __lookbehind = None; + let mut __sym2 = &mut Some((__tok0)); + let __lookahead = __tokens.next(); + __result = try!(__state5(scale, __lookbehind, __lookahead, __tokens, __sym2)); } - Some(Tok::Div(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action7(scale, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - Some(Tok::Times(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action7(scale, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - Some(Tok::Minus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action7(scale, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - Some(Tok::RParen(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action7(scale, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + Some(__tok @ Tok::LParen(..)) => { + let mut __lookbehind = None; + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state4(scale, __lookbehind, __lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); } } + while __sym1.is_some() { + let (__lookbehind, __lookahead, __nt) = __result; + match __nt { + __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state15(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + _ => { + return Ok((__lookbehind, __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(S4) + // "Num" -> Shift(S5) + // + // Term -> S16 + pub fn __state7< + __TOKENS: Iterator, + >( + scale: i32, + __lookbehind: Option<()>, + __lookahead: Option, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + __sym1: &mut Option, + ) -> Result<(Option<()>, Option, __Nonterminal<>), Option> + { + let mut __result: (Option<()>, Option, __Nonterminal<>); + match __lookahead { + Some(__tok @ Tok::LParen(..)) => { + let mut __lookbehind = None; + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state4(scale, __lookbehind, __lookahead, __tokens, __sym2)); + } + Some(Tok::Num(__tok0)) => { + let mut __lookbehind = None; + let mut __sym2 = &mut Some((__tok0)); + let __lookahead = __tokens.next(); + __result = try!(__state5(scale, __lookbehind, __lookahead, __tokens, __sym2)); + } + _ => { + return Err(__lookahead); + } + } + while __sym1.is_some() { + let (__lookbehind, __lookahead, __nt) = __result; + match __nt { + __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state16(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + _ => { + return Ok((__lookbehind, __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 ["/"] + // Term = (*) "(" Expr ")" [EOF] + // Term = (*) "(" Expr ")" ["*"] + // Term = (*) "(" Expr ")" ["+"] + // Term = (*) "(" Expr ")" ["-"] + // Term = (*) "(" Expr ")" ["/"] + // Term = (*) "Num" [EOF] + // Term = (*) "Num" ["*"] + // Term = (*) "Num" ["+"] + // Term = (*) "Num" ["-"] + // Term = (*) "Num" ["/"] + // + // "Num" -> Shift(S5) + // "(" -> Shift(S4) + // + // Term -> S2 + // Factor -> S17 + pub fn __state8< + __TOKENS: Iterator, + >( + scale: i32, + __lookbehind: Option<()>, + __lookahead: Option, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + __sym1: &mut Option, + ) -> Result<(Option<()>, Option, __Nonterminal<>), Option> + { + let mut __result: (Option<()>, Option, __Nonterminal<>); + match __lookahead { + Some(Tok::Num(__tok0)) => { + let mut __lookbehind = None; + let mut __sym2 = &mut Some((__tok0)); + let __lookahead = __tokens.next(); + __result = try!(__state5(scale, __lookbehind, __lookahead, __tokens, __sym2)); + } + Some(__tok @ Tok::LParen(..)) => { + let mut __lookbehind = None; + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state4(scale, __lookbehind, __lookahead, __tokens, __sym2)); + } + _ => { + return Err(__lookahead); + } + } + while __sym1.is_some() { + let (__lookbehind, __lookahead, __nt) = __result; + match __nt { + __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state2(scale, __lookbehind, __lookahead, __tokens, __sym2)); + } + __Nonterminal::Factor(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state17(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + _ => { + return Ok((__lookbehind, __lookahead, __nt)); + } + } + } + return Ok(__result); + } + + // State 9 + // Expr = Expr "+" (*) Factor [EOF] + // Expr = Expr "+" (*) Factor ["+"] + // Expr = Expr "+" (*) Factor ["-"] + // Factor = (*) Factor "*" Term [EOF] + // Factor = (*) Factor "*" Term ["*"] + // Factor = (*) Factor "*" Term ["+"] + // Factor = (*) Factor "*" Term ["-"] + // Factor = (*) Factor "*" Term ["/"] + // Factor = (*) Factor "/" Term [EOF] + // Factor = (*) Factor "/" Term ["*"] + // Factor = (*) Factor "/" Term ["+"] + // Factor = (*) Factor "/" Term ["-"] + // Factor = (*) Factor "/" Term ["/"] + // Factor = (*) Term [EOF] + // Factor = (*) Term ["*"] + // Factor = (*) Term ["+"] + // Factor = (*) Term ["-"] + // Factor = (*) Term ["/"] + // Term = (*) "(" Expr ")" [EOF] + // Term = (*) "(" Expr ")" ["*"] + // Term = (*) "(" Expr ")" ["+"] + // Term = (*) "(" Expr ")" ["-"] + // Term = (*) "(" Expr ")" ["/"] + // Term = (*) "Num" [EOF] + // Term = (*) "Num" ["*"] + // Term = (*) "Num" ["+"] + // Term = (*) "Num" ["-"] + // Term = (*) "Num" ["/"] + // + // "Num" -> Shift(S5) + // "(" -> Shift(S4) + // + // Term -> S2 + // Factor -> S18 + pub fn __state9< + __TOKENS: Iterator, + >( + scale: i32, + __lookbehind: Option<()>, + __lookahead: Option, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + __sym1: &mut Option, + ) -> Result<(Option<()>, Option, __Nonterminal<>), Option> + { + let mut __result: (Option<()>, Option, __Nonterminal<>); + match __lookahead { + Some(Tok::Num(__tok0)) => { + let mut __lookbehind = None; + let mut __sym2 = &mut Some((__tok0)); + let __lookahead = __tokens.next(); + __result = try!(__state5(scale, __lookbehind, __lookahead, __tokens, __sym2)); + } + Some(__tok @ Tok::LParen(..)) => { + let mut __lookbehind = None; + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state4(scale, __lookbehind, __lookahead, __tokens, __sym2)); + } + _ => { + return Err(__lookahead); + } + } + while __sym1.is_some() { + let (__lookbehind, __lookahead, __nt) = __result; + match __nt { + __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state2(scale, __lookbehind, __lookahead, __tokens, __sym2)); + } + __Nonterminal::Factor(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state18(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + _ => { + return Ok((__lookbehind, __lookahead, __nt)); + } + } + } + return Ok(__result); + } + + // State 10 // Factor = Term (*) [")"] // Factor = Term (*) ["*"] // Factor = Term (*) ["+"] // Factor = Term (*) ["-"] // Factor = Term (*) ["/"] // - // "/" -> Reduce(Factor = Term => Call(ActionFn(6));) // "-" -> Reduce(Factor = Term => Call(ActionFn(6));) - // "*" -> Reduce(Factor = Term => Call(ActionFn(6));) - // ")" -> Reduce(Factor = Term => Call(ActionFn(6));) + // "/" -> Reduce(Factor = Term => Call(ActionFn(6));) // "+" -> Reduce(Factor = Term => Call(ActionFn(6));) + // ")" -> Reduce(Factor = Term => Call(ActionFn(6));) + // "*" -> Reduce(Factor = Term => Call(ActionFn(6));) // - pub fn __state7< + pub fn __state10< __TOKENS: Iterator, >( scale: i32, @@ -529,17 +775,17 @@ mod __parse__Expr { { let mut __result: (Option<()>, Option, __Nonterminal<>); match __lookahead { - Some(Tok::Div(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action6(scale, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } Some(Tok::Minus(..)) => { let __sym0 = __sym0.take().unwrap(); let __nt = super::__action6(scale, __sym0); return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } - Some(Tok::Times(..)) => { + Some(Tok::Div(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action6(scale, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some(Tok::Plus(..)) => { let __sym0 = __sym0.take().unwrap(); let __nt = super::__action6(scale, __sym0); return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); @@ -549,7 +795,7 @@ mod __parse__Expr { let __nt = super::__action6(scale, __sym0); return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } - Some(Tok::Plus(..)) => { + Some(Tok::Times(..)) => { let __sym0 = __sym0.take().unwrap(); let __nt = super::__action6(scale, __sym0); return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); @@ -560,7 +806,118 @@ mod __parse__Expr { } } - // State 8 + // State 11 + // Expr = Expr (*) "+" Factor [")"] + // Expr = Expr (*) "+" Factor ["+"] + // Expr = Expr (*) "+" Factor ["-"] + // Expr = Expr (*) "-" Factor [")"] + // Expr = Expr (*) "-" Factor ["+"] + // Expr = Expr (*) "-" Factor ["-"] + // Term = "(" Expr (*) ")" [EOF] + // Term = "(" Expr (*) ")" ["*"] + // Term = "(" Expr (*) ")" ["+"] + // Term = "(" Expr (*) ")" ["-"] + // Term = "(" Expr (*) ")" ["/"] + // + // "-" -> Shift(S19) + // "+" -> Shift(S20) + // ")" -> Shift(S21) + // + pub fn __state11< + __TOKENS: Iterator, + >( + scale: i32, + __lookbehind: Option<()>, + __lookahead: Option, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + __sym1: &mut Option, + ) -> Result<(Option<()>, Option, __Nonterminal<>), Option> + { + let mut __result: (Option<()>, Option, __Nonterminal<>); + match __lookahead { + Some(__tok @ Tok::Minus(..)) => { + let mut __lookbehind = None; + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state19(scale, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); + } + Some(__tok @ Tok::Plus(..)) => { + let mut __lookbehind = None; + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state20(scale, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); + } + Some(__tok @ Tok::RParen(..)) => { + let mut __lookbehind = None; + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state21(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + + // State 12 + // Term = "Num" (*) [")"] + // Term = "Num" (*) ["*"] + // Term = "Num" (*) ["+"] + // Term = "Num" (*) ["-"] + // Term = "Num" (*) ["/"] + // + // "-" -> Reduce(Term = "Num" => Call(ActionFn(7));) + // "+" -> Reduce(Term = "Num" => Call(ActionFn(7));) + // "/" -> Reduce(Term = "Num" => Call(ActionFn(7));) + // "*" -> Reduce(Term = "Num" => Call(ActionFn(7));) + // ")" -> Reduce(Term = "Num" => Call(ActionFn(7));) + // + pub fn __state12< + __TOKENS: Iterator, + >( + scale: i32, + __lookbehind: Option<()>, + __lookahead: Option, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + ) -> Result<(Option<()>, Option, __Nonterminal<>), Option> + { + let mut __result: (Option<()>, Option, __Nonterminal<>); + match __lookahead { + Some(Tok::Minus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action7(scale, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + Some(Tok::Plus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action7(scale, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + Some(Tok::Div(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action7(scale, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + Some(Tok::Times(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action7(scale, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + Some(Tok::RParen(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action7(scale, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 13 // Expr = (*) Expr "+" Factor [")"] // Expr = (*) Expr "+" Factor ["+"] // Expr = (*) Expr "+" Factor ["-"] @@ -601,13 +958,13 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "(" -> Shift(S8) - // "Num" -> Shift(S6) + // "(" -> Shift(S13) + // "Num" -> Shift(S12) // - // Term -> S7 - // Expr -> S15 - // Factor -> S9 - pub fn __state8< + // Term -> S10 + // Expr -> S22 + // Factor -> S14 + pub fn __state13< __TOKENS: Iterator, >( scale: i32, @@ -623,13 +980,13 @@ mod __parse__Expr { let mut __lookbehind = None; let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state8(scale, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state13(scale, __lookbehind, __lookahead, __tokens, __sym1)); } Some(Tok::Num(__tok0)) => { let mut __lookbehind = None; let mut __sym1 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state6(scale, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state12(scale, __lookbehind, __lookahead, __tokens, __sym1)); } _ => { return Err(__lookahead); @@ -640,15 +997,15 @@ mod __parse__Expr { match __nt { __Nonterminal::Term(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state7(scale, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state10(scale, __lookbehind, __lookahead, __tokens, __sym1)); } __Nonterminal::Expr(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state15(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + __result = try!(__state22(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); } __Nonterminal::Factor(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state9(scale, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state14(scale, __lookbehind, __lookahead, __tokens, __sym1)); } _ => { return Ok((__lookbehind, __lookahead, __nt)); @@ -658,7 +1015,7 @@ mod __parse__Expr { return Ok(__result); } - // State 9 + // State 14 // Expr = Factor (*) [")"] // Expr = Factor (*) ["+"] // Expr = Factor (*) ["-"] @@ -674,12 +1031,12 @@ mod __parse__Expr { // Factor = Factor (*) "/" Term ["/"] // // "-" -> Reduce(Expr = Factor => Call(ActionFn(3));) - // ")" -> Reduce(Expr = Factor => Call(ActionFn(3));) - // "*" -> Shift(S16) - // "/" -> Shift(S17) + // "/" -> Shift(S23) + // "*" -> Shift(S24) // "+" -> Reduce(Expr = Factor => Call(ActionFn(3));) + // ")" -> Reduce(Expr = Factor => Call(ActionFn(3));) // - pub fn __state9< + pub fn __state14< __TOKENS: Iterator, >( scale: i32, @@ -691,87 +1048,32 @@ mod __parse__Expr { { let mut __result: (Option<()>, Option, __Nonterminal<>); match __lookahead { - Some(__tok @ Tok::Times(..)) => { - let mut __lookbehind = None; - let mut __sym1 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state16(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); - } Some(__tok @ Tok::Div(..)) => { let mut __lookbehind = None; let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state17(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + __result = try!(__state23(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + } + Some(__tok @ Tok::Times(..)) => { + let mut __lookbehind = None; + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state24(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); } Some(Tok::Minus(..)) => { let __sym0 = __sym0.take().unwrap(); let __nt = super::__action3(scale, __sym0); return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); } - Some(Tok::RParen(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action3(scale, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } Some(Tok::Plus(..)) => { let __sym0 = __sym0.take().unwrap(); let __nt = super::__action3(scale, __sym0); return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 10 - // Expr = Expr (*) "+" Factor [")"] - // Expr = Expr (*) "+" Factor ["+"] - // Expr = Expr (*) "+" Factor ["-"] - // Expr = Expr (*) "-" Factor [")"] - // Expr = Expr (*) "-" Factor ["+"] - // Expr = Expr (*) "-" Factor ["-"] - // Term = "(" Expr (*) ")" [EOF] - // Term = "(" Expr (*) ")" ["*"] - // Term = "(" Expr (*) ")" ["+"] - // Term = "(" Expr (*) ")" ["-"] - // Term = "(" Expr (*) ")" ["/"] - // - // "-" -> Shift(S19) - // ")" -> Shift(S20) - // "+" -> Shift(S18) - // - pub fn __state10< - __TOKENS: Iterator, - >( - scale: i32, - __lookbehind: Option<()>, - __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option, - ) -> Result<(Option<()>, Option, __Nonterminal<>), Option> - { - let mut __result: (Option<()>, Option, __Nonterminal<>); - match __lookahead { - Some(__tok @ Tok::Minus(..)) => { - let mut __lookbehind = None; - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state19(scale, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); - } - Some(__tok @ Tok::RParen(..)) => { - let mut __lookbehind = None; - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state20(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - Some(__tok @ Tok::Plus(..)) => { - let mut __lookbehind = None; - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state18(scale, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); + Some(Tok::RParen(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action3(scale, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); } _ => { return Err(__lookahead); @@ -780,318 +1082,18 @@ mod __parse__Expr { return Ok(__result); } - // State 11 - // Factor = Factor "*" (*) Term [EOF] - // Factor = Factor "*" (*) Term ["*"] - // Factor = Factor "*" (*) Term ["+"] - // Factor = Factor "*" (*) Term ["-"] - // Factor = Factor "*" (*) Term ["/"] - // Term = (*) "(" Expr ")" [EOF] - // Term = (*) "(" Expr ")" ["*"] - // Term = (*) "(" Expr ")" ["+"] - // Term = (*) "(" Expr ")" ["-"] - // Term = (*) "(" Expr ")" ["/"] - // Term = (*) "Num" [EOF] - // Term = (*) "Num" ["*"] - // Term = (*) "Num" ["+"] - // Term = (*) "Num" ["-"] - // Term = (*) "Num" ["/"] - // - // "(" -> Shift(S3) - // "Num" -> Shift(S2) - // - // Term -> S21 - pub fn __state11< - __TOKENS: Iterator, - >( - scale: i32, - __lookbehind: Option<()>, - __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option, - ) -> Result<(Option<()>, Option, __Nonterminal<>), Option> - { - let mut __result: (Option<()>, Option, __Nonterminal<>); - match __lookahead { - Some(__tok @ Tok::LParen(..)) => { - let mut __lookbehind = None; - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state3(scale, __lookbehind, __lookahead, __tokens, __sym2)); - } - Some(Tok::Num(__tok0)) => { - let mut __lookbehind = None; - let mut __sym2 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state2(scale, __lookbehind, __lookahead, __tokens, __sym2)); - } - _ => { - return Err(__lookahead); - } - } - while __sym1.is_some() { - let (__lookbehind, __lookahead, __nt) = __result; - match __nt { - __Nonterminal::Term(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state21(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - _ => { - return Ok((__lookbehind, __lookahead, __nt)); - } - } - } - return Ok(__result); - } - - // State 12 - // Factor = Factor "/" (*) Term [EOF] - // Factor = Factor "/" (*) Term ["*"] - // Factor = Factor "/" (*) Term ["+"] - // Factor = Factor "/" (*) Term ["-"] - // Factor = Factor "/" (*) Term ["/"] - // Term = (*) "(" Expr ")" [EOF] - // Term = (*) "(" Expr ")" ["*"] - // Term = (*) "(" Expr ")" ["+"] - // Term = (*) "(" Expr ")" ["-"] - // Term = (*) "(" Expr ")" ["/"] - // Term = (*) "Num" [EOF] - // Term = (*) "Num" ["*"] - // Term = (*) "Num" ["+"] - // Term = (*) "Num" ["-"] - // Term = (*) "Num" ["/"] - // - // "(" -> Shift(S3) - // "Num" -> Shift(S2) - // - // Term -> S22 - pub fn __state12< - __TOKENS: Iterator, - >( - scale: i32, - __lookbehind: Option<()>, - __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option, - ) -> Result<(Option<()>, Option, __Nonterminal<>), Option> - { - let mut __result: (Option<()>, Option, __Nonterminal<>); - match __lookahead { - Some(__tok @ Tok::LParen(..)) => { - let mut __lookbehind = None; - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state3(scale, __lookbehind, __lookahead, __tokens, __sym2)); - } - Some(Tok::Num(__tok0)) => { - let mut __lookbehind = None; - let mut __sym2 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state2(scale, __lookbehind, __lookahead, __tokens, __sym2)); - } - _ => { - return Err(__lookahead); - } - } - while __sym1.is_some() { - let (__lookbehind, __lookahead, __nt) = __result; - match __nt { - __Nonterminal::Term(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state22(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - _ => { - return Ok((__lookbehind, __lookahead, __nt)); - } - } - } - return Ok(__result); - } - - // State 13 - // Expr = Expr "-" (*) Factor [EOF] - // Expr = Expr "-" (*) Factor ["+"] - // Expr = Expr "-" (*) Factor ["-"] - // Factor = (*) Factor "*" Term [EOF] - // Factor = (*) Factor "*" Term ["*"] - // Factor = (*) Factor "*" Term ["+"] - // Factor = (*) Factor "*" Term ["-"] - // Factor = (*) Factor "*" Term ["/"] - // Factor = (*) Factor "/" Term [EOF] - // Factor = (*) Factor "/" Term ["*"] - // Factor = (*) Factor "/" Term ["+"] - // Factor = (*) Factor "/" Term ["-"] - // Factor = (*) Factor "/" Term ["/"] - // Factor = (*) Term [EOF] - // Factor = (*) Term ["*"] - // Factor = (*) Term ["+"] - // Factor = (*) Term ["-"] - // Factor = (*) Term ["/"] - // Term = (*) "(" Expr ")" [EOF] - // Term = (*) "(" Expr ")" ["*"] - // Term = (*) "(" Expr ")" ["+"] - // Term = (*) "(" Expr ")" ["-"] - // Term = (*) "(" Expr ")" ["/"] - // Term = (*) "Num" [EOF] - // Term = (*) "Num" ["*"] - // Term = (*) "Num" ["+"] - // Term = (*) "Num" ["-"] - // Term = (*) "Num" ["/"] - // - // "(" -> Shift(S3) - // "Num" -> Shift(S2) - // - // Factor -> S23 - // Term -> S1 - pub fn __state13< - __TOKENS: Iterator, - >( - scale: i32, - __lookbehind: Option<()>, - __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option, - ) -> Result<(Option<()>, Option, __Nonterminal<>), Option> - { - let mut __result: (Option<()>, Option, __Nonterminal<>); - match __lookahead { - Some(__tok @ Tok::LParen(..)) => { - let mut __lookbehind = None; - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state3(scale, __lookbehind, __lookahead, __tokens, __sym2)); - } - Some(Tok::Num(__tok0)) => { - let mut __lookbehind = None; - let mut __sym2 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state2(scale, __lookbehind, __lookahead, __tokens, __sym2)); - } - _ => { - return Err(__lookahead); - } - } - while __sym1.is_some() { - let (__lookbehind, __lookahead, __nt) = __result; - match __nt { - __Nonterminal::Factor(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state23(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - __Nonterminal::Term(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state1(scale, __lookbehind, __lookahead, __tokens, __sym2)); - } - _ => { - return Ok((__lookbehind, __lookahead, __nt)); - } - } - } - return Ok(__result); - } - - // State 14 - // Expr = Expr "+" (*) Factor [EOF] - // Expr = Expr "+" (*) Factor ["+"] - // Expr = Expr "+" (*) Factor ["-"] - // Factor = (*) Factor "*" Term [EOF] - // Factor = (*) Factor "*" Term ["*"] - // Factor = (*) Factor "*" Term ["+"] - // Factor = (*) Factor "*" Term ["-"] - // Factor = (*) Factor "*" Term ["/"] - // Factor = (*) Factor "/" Term [EOF] - // Factor = (*) Factor "/" Term ["*"] - // Factor = (*) Factor "/" Term ["+"] - // Factor = (*) Factor "/" Term ["-"] - // Factor = (*) Factor "/" Term ["/"] - // Factor = (*) Term [EOF] - // Factor = (*) Term ["*"] - // Factor = (*) Term ["+"] - // Factor = (*) Term ["-"] - // Factor = (*) Term ["/"] - // Term = (*) "(" Expr ")" [EOF] - // Term = (*) "(" Expr ")" ["*"] - // Term = (*) "(" Expr ")" ["+"] - // Term = (*) "(" Expr ")" ["-"] - // Term = (*) "(" Expr ")" ["/"] - // Term = (*) "Num" [EOF] - // Term = (*) "Num" ["*"] - // Term = (*) "Num" ["+"] - // Term = (*) "Num" ["-"] - // Term = (*) "Num" ["/"] - // - // "Num" -> Shift(S2) - // "(" -> Shift(S3) - // - // Term -> S1 - // Factor -> S24 - pub fn __state14< - __TOKENS: Iterator, - >( - scale: i32, - __lookbehind: Option<()>, - __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option, - ) -> Result<(Option<()>, Option, __Nonterminal<>), Option> - { - let mut __result: (Option<()>, Option, __Nonterminal<>); - match __lookahead { - Some(Tok::Num(__tok0)) => { - let mut __lookbehind = None; - let mut __sym2 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state2(scale, __lookbehind, __lookahead, __tokens, __sym2)); - } - Some(__tok @ Tok::LParen(..)) => { - let mut __lookbehind = None; - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state3(scale, __lookbehind, __lookahead, __tokens, __sym2)); - } - _ => { - return Err(__lookahead); - } - } - while __sym1.is_some() { - let (__lookbehind, __lookahead, __nt) = __result; - match __nt { - __Nonterminal::Term(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state1(scale, __lookbehind, __lookahead, __tokens, __sym2)); - } - __Nonterminal::Factor(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state24(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - _ => { - return Ok((__lookbehind, __lookahead, __nt)); - } - } - } - return Ok(__result); - } - // State 15 - // Expr = Expr (*) "+" Factor [")"] - // Expr = Expr (*) "+" Factor ["+"] - // Expr = Expr (*) "+" Factor ["-"] - // Expr = Expr (*) "-" Factor [")"] - // Expr = Expr (*) "-" Factor ["+"] - // Expr = Expr (*) "-" Factor ["-"] - // Term = "(" Expr (*) ")" [")"] - // Term = "(" Expr (*) ")" ["*"] - // Term = "(" Expr (*) ")" ["+"] - // Term = "(" Expr (*) ")" ["-"] - // Term = "(" Expr (*) ")" ["/"] + // Factor = Factor "*" Term (*) [EOF] + // Factor = Factor "*" Term (*) ["*"] + // Factor = Factor "*" Term (*) ["+"] + // Factor = Factor "*" Term (*) ["-"] + // Factor = Factor "*" Term (*) ["/"] // - // "+" -> Shift(S18) - // ")" -> Shift(S25) - // "-" -> Shift(S19) + // "+" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // "-" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // "/" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // "*" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // EOF -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) // pub fn __state15< __TOKENS: Iterator, @@ -1100,58 +1102,67 @@ mod __parse__Expr { __lookbehind: Option<()>, __lookahead: Option, __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option, + __sym0: &mut Option, + __sym1: &mut Option, + __sym2: &mut Option, ) -> Result<(Option<()>, Option, __Nonterminal<>), Option> { let mut __result: (Option<()>, Option, __Nonterminal<>); match __lookahead { - Some(__tok @ Tok::Plus(..)) => { - let mut __lookbehind = None; - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state18(scale, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); + Some(Tok::Plus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action4(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } - Some(__tok @ Tok::RParen(..)) => { - let mut __lookbehind = None; - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state25(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + Some(Tok::Minus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action4(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } - Some(__tok @ Tok::Minus(..)) => { - let mut __lookbehind = None; - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state19(scale, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); + Some(Tok::Div(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action4(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some(Tok::Times(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action4(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + None => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action4(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } _ => { return Err(__lookahead); } } - return Ok(__result); } // State 16 - // Factor = Factor "*" (*) Term [")"] - // Factor = Factor "*" (*) Term ["*"] - // Factor = Factor "*" (*) Term ["+"] - // Factor = Factor "*" (*) Term ["-"] - // Factor = Factor "*" (*) Term ["/"] - // Term = (*) "(" Expr ")" [")"] - // Term = (*) "(" Expr ")" ["*"] - // Term = (*) "(" Expr ")" ["+"] - // Term = (*) "(" Expr ")" ["-"] - // Term = (*) "(" Expr ")" ["/"] - // Term = (*) "Num" [")"] - // Term = (*) "Num" ["*"] - // Term = (*) "Num" ["+"] - // Term = (*) "Num" ["-"] - // Term = (*) "Num" ["/"] + // Factor = Factor "/" Term (*) [EOF] + // Factor = Factor "/" Term (*) ["*"] + // Factor = Factor "/" Term (*) ["+"] + // Factor = Factor "/" Term (*) ["-"] + // Factor = Factor "/" Term (*) ["/"] // - // "Num" -> Shift(S6) - // "(" -> Shift(S8) + // "*" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // "+" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // "-" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // "/" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // EOF -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) // - // Term -> S26 pub fn __state16< __TOKENS: Iterator, >( @@ -1161,62 +1172,73 @@ mod __parse__Expr { __tokens: &mut __TOKENS, __sym0: &mut Option, __sym1: &mut Option, + __sym2: &mut Option, ) -> Result<(Option<()>, Option, __Nonterminal<>), Option> { let mut __result: (Option<()>, Option, __Nonterminal<>); match __lookahead { - Some(Tok::Num(__tok0)) => { - let mut __lookbehind = None; - let mut __sym2 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state6(scale, __lookbehind, __lookahead, __tokens, __sym2)); + Some(Tok::Times(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action5(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } - Some(__tok @ Tok::LParen(..)) => { - let mut __lookbehind = None; - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state8(scale, __lookbehind, __lookahead, __tokens, __sym2)); + Some(Tok::Plus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action5(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some(Tok::Minus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action5(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some(Tok::Div(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action5(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + None => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action5(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } _ => { return Err(__lookahead); } } - while __sym1.is_some() { - let (__lookbehind, __lookahead, __nt) = __result; - match __nt { - __Nonterminal::Term(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state26(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - _ => { - return Ok((__lookbehind, __lookahead, __nt)); - } - } - } - return Ok(__result); } // State 17 - // 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(S8) - // "Num" -> Shift(S6) + // EOF -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // "*" -> Shift(S6) + // "-" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // "/" -> Shift(S7) + // "+" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) // - // Term -> S27 pub fn __state17< __TOKENS: Iterator, >( @@ -1226,76 +1248,72 @@ mod __parse__Expr { __tokens: &mut __TOKENS, __sym0: &mut Option, __sym1: &mut Option, + __sym2: &mut Option, ) -> Result<(Option<()>, Option, __Nonterminal<>), Option> { let mut __result: (Option<()>, Option, __Nonterminal<>); match __lookahead { - Some(__tok @ Tok::LParen(..)) => { + Some(__tok @ Tok::Times(..)) => { let mut __lookbehind = None; - let mut __sym2 = &mut Some((__tok)); + let mut __sym3 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state8(scale, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state6(scale, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); } - Some(Tok::Num(__tok0)) => { + Some(__tok @ Tok::Div(..)) => { let mut __lookbehind = None; - let mut __sym2 = &mut Some((__tok0)); + let mut __sym3 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state6(scale, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state7(scale, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); + } + None => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action1(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + Some(Tok::Minus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action1(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + Some(Tok::Plus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action1(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); } _ => { return Err(__lookahead); } } - while __sym1.is_some() { - let (__lookbehind, __lookahead, __nt) = __result; - match __nt { - __Nonterminal::Term(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state27(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - _ => { - return Ok((__lookbehind, __lookahead, __nt)); - } - } - } return Ok(__result); } // State 18 - // Expr = Expr "+" (*) Factor [")"] - // Expr = Expr "+" (*) Factor ["+"] - // Expr = Expr "+" (*) Factor ["-"] - // Factor = (*) Factor "*" Term [")"] - // Factor = (*) Factor "*" Term ["*"] - // Factor = (*) Factor "*" Term ["+"] - // Factor = (*) Factor "*" Term ["-"] - // Factor = (*) Factor "*" Term ["/"] - // Factor = (*) Factor "/" Term [")"] - // Factor = (*) Factor "/" Term ["*"] - // Factor = (*) Factor "/" Term ["+"] - // Factor = (*) Factor "/" Term ["-"] - // Factor = (*) Factor "/" Term ["/"] - // Factor = (*) Term [")"] - // Factor = (*) Term ["*"] - // Factor = (*) Term ["+"] - // Factor = (*) Term ["-"] - // Factor = (*) Term ["/"] - // Term = (*) "(" Expr ")" [")"] - // Term = (*) "(" Expr ")" ["*"] - // Term = (*) "(" Expr ")" ["+"] - // Term = (*) "(" Expr ")" ["-"] - // Term = (*) "(" Expr ")" ["/"] - // Term = (*) "Num" [")"] - // Term = (*) "Num" ["*"] - // Term = (*) "Num" ["+"] - // Term = (*) "Num" ["-"] - // Term = (*) "Num" ["/"] + // Expr = Expr "+" Factor (*) [EOF] + // Expr = Expr "+" Factor (*) ["+"] + // Expr = Expr "+" Factor (*) ["-"] + // Factor = Factor (*) "*" Term [EOF] + // Factor = Factor (*) "*" Term ["*"] + // Factor = Factor (*) "*" Term ["+"] + // Factor = Factor (*) "*" Term ["-"] + // Factor = Factor (*) "*" Term ["/"] + // Factor = Factor (*) "/" Term [EOF] + // Factor = Factor (*) "/" Term ["*"] + // Factor = Factor (*) "/" Term ["+"] + // Factor = Factor (*) "/" Term ["-"] + // Factor = Factor (*) "/" Term ["/"] // - // "Num" -> Shift(S6) - // "(" -> Shift(S8) + // "/" -> Shift(S7) + // "*" -> Shift(S6) + // "+" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) + // EOF -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) + // "-" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) // - // Factor -> S28 - // Term -> S7 pub fn __state18< __TOKENS: Iterator, >( @@ -1305,42 +1323,48 @@ mod __parse__Expr { __tokens: &mut __TOKENS, __sym0: &mut Option, __sym1: &mut Option, + __sym2: &mut Option, ) -> Result<(Option<()>, Option, __Nonterminal<>), Option> { let mut __result: (Option<()>, Option, __Nonterminal<>); match __lookahead { - Some(Tok::Num(__tok0)) => { + Some(__tok @ Tok::Div(..)) => { let mut __lookbehind = None; - let mut __sym2 = &mut Some((__tok0)); + let mut __sym3 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state6(scale, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state7(scale, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); } - Some(__tok @ Tok::LParen(..)) => { + Some(__tok @ Tok::Times(..)) => { let mut __lookbehind = None; - let mut __sym2 = &mut Some((__tok)); + let mut __sym3 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state8(scale, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state6(scale, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); + } + Some(Tok::Plus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action2(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + None => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action2(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + Some(Tok::Minus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action2(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); } _ => { return Err(__lookahead); } } - while __sym1.is_some() { - let (__lookbehind, __lookahead, __nt) = __result; - match __nt { - __Nonterminal::Factor(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state28(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - __Nonterminal::Term(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state7(scale, __lookbehind, __lookahead, __tokens, __sym2)); - } - _ => { - return Ok((__lookbehind, __lookahead, __nt)); - } - } - } return Ok(__result); } @@ -1374,11 +1398,11 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "Num" -> Shift(S6) - // "(" -> Shift(S8) + // "(" -> Shift(S13) + // "Num" -> Shift(S12) // - // Factor -> S29 - // Term -> S7 + // Term -> S10 + // Factor -> S25 pub fn __state19< __TOKENS: Iterator, >( @@ -1389,6 +1413,89 @@ mod __parse__Expr { __sym0: &mut Option, __sym1: &mut Option, ) -> Result<(Option<()>, Option, __Nonterminal<>), Option> + { + let mut __result: (Option<()>, Option, __Nonterminal<>); + match __lookahead { + Some(__tok @ Tok::LParen(..)) => { + let mut __lookbehind = None; + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state13(scale, __lookbehind, __lookahead, __tokens, __sym2)); + } + Some(Tok::Num(__tok0)) => { + let mut __lookbehind = None; + let mut __sym2 = &mut Some((__tok0)); + let __lookahead = __tokens.next(); + __result = try!(__state12(scale, __lookbehind, __lookahead, __tokens, __sym2)); + } + _ => { + return Err(__lookahead); + } + } + while __sym1.is_some() { + let (__lookbehind, __lookahead, __nt) = __result; + match __nt { + __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state10(scale, __lookbehind, __lookahead, __tokens, __sym2)); + } + __Nonterminal::Factor(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state25(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + _ => { + return Ok((__lookbehind, __lookahead, __nt)); + } + } + } + return Ok(__result); + } + + // State 20 + // Expr = Expr "+" (*) Factor [")"] + // Expr = Expr "+" (*) Factor ["+"] + // Expr = Expr "+" (*) Factor ["-"] + // Factor = (*) Factor "*" Term [")"] + // Factor = (*) Factor "*" Term ["*"] + // Factor = (*) Factor "*" Term ["+"] + // Factor = (*) Factor "*" Term ["-"] + // Factor = (*) Factor "*" Term ["/"] + // Factor = (*) Factor "/" Term [")"] + // Factor = (*) Factor "/" Term ["*"] + // Factor = (*) Factor "/" Term ["+"] + // Factor = (*) Factor "/" Term ["-"] + // Factor = (*) Factor "/" Term ["/"] + // Factor = (*) Term [")"] + // Factor = (*) Term ["*"] + // Factor = (*) Term ["+"] + // Factor = (*) Term ["-"] + // Factor = (*) Term ["/"] + // Term = (*) "(" Expr ")" [")"] + // Term = (*) "(" Expr ")" ["*"] + // Term = (*) "(" Expr ")" ["+"] + // Term = (*) "(" Expr ")" ["-"] + // Term = (*) "(" Expr ")" ["/"] + // Term = (*) "Num" [")"] + // Term = (*) "Num" ["*"] + // Term = (*) "Num" ["+"] + // Term = (*) "Num" ["-"] + // Term = (*) "Num" ["/"] + // + // "Num" -> Shift(S12) + // "(" -> Shift(S13) + // + // Factor -> S26 + // Term -> S10 + pub fn __state20< + __TOKENS: Iterator, + >( + scale: i32, + __lookbehind: Option<()>, + __lookahead: Option, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + __sym1: &mut Option, + ) -> Result<(Option<()>, Option, __Nonterminal<>), Option> { let mut __result: (Option<()>, Option, __Nonterminal<>); match __lookahead { @@ -1396,13 +1503,13 @@ mod __parse__Expr { let mut __lookbehind = None; let mut __sym2 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state6(scale, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state12(scale, __lookbehind, __lookahead, __tokens, __sym2)); } Some(__tok @ Tok::LParen(..)) => { let mut __lookbehind = None; let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state8(scale, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state13(scale, __lookbehind, __lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); @@ -1413,11 +1520,11 @@ mod __parse__Expr { match __nt { __Nonterminal::Factor(__nt) => { let __sym2 = &mut Some(__nt); - __result = try!(__state29(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + __result = try!(__state26(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); } __Nonterminal::Term(__nt) => { let __sym2 = &mut Some(__nt); - __result = try!(__state7(scale, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state10(scale, __lookbehind, __lookahead, __tokens, __sym2)); } _ => { return Ok((__lookbehind, __lookahead, __nt)); @@ -1427,20 +1534,20 @@ mod __parse__Expr { return Ok(__result); } - // State 20 + // State 21 // Term = "(" Expr ")" (*) [EOF] // Term = "(" Expr ")" (*) ["*"] // Term = "(" Expr ")" (*) ["+"] // Term = "(" Expr ")" (*) ["-"] // Term = "(" Expr ")" (*) ["/"] // + // EOF -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) + // "*" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) + // "+" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) // "/" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) // "-" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) - // "+" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) - // "*" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) - // EOF -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) // - pub fn __state20< + pub fn __state21< __TOKENS: Iterator, >( scale: i32, @@ -1454,21 +1561,7 @@ mod __parse__Expr { { let mut __result: (Option<()>, 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::__action8(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - Some(Tok::Minus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action8(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - Some(Tok::Plus(..)) => { + None => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); @@ -1482,80 +1575,26 @@ mod __parse__Expr { let __nt = super::__action8(scale, __sym0, __sym1, __sym2); return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); } - None => { + Some(Tok::Plus(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); let __nt = super::__action8(scale, __sym0, __sym1, __sym2); return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); } - _ => { - return Err(__lookahead); - } - } - } - - // State 21 - // Factor = Factor "*" Term (*) [EOF] - // Factor = Factor "*" Term (*) ["*"] - // Factor = Factor "*" Term (*) ["+"] - // Factor = Factor "*" Term (*) ["-"] - // Factor = Factor "*" Term (*) ["/"] - // - // "+" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) - // "-" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) - // EOF -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) - // "*" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) - // "/" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) - // - pub fn __state21< - __TOKENS: Iterator, - >( - scale: i32, - __lookbehind: Option<()>, - __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option, - __sym2: &mut Option, - ) -> Result<(Option<()>, Option, __Nonterminal<>), Option> - { - let mut __result: (Option<()>, Option, __Nonterminal<>); - match __lookahead { - Some(Tok::Plus(..)) => { + Some(Tok::Div(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action4(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + let __nt = super::__action8(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); } Some(Tok::Minus(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action4(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - None => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action4(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Times(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action4(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Div(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action4(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + let __nt = super::__action8(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); } _ => { return Err(__lookahead); @@ -1564,17 +1603,21 @@ mod __parse__Expr { } // State 22 - // Factor = Factor "/" Term (*) [EOF] - // Factor = Factor "/" Term (*) ["*"] - // Factor = Factor "/" Term (*) ["+"] - // Factor = Factor "/" Term (*) ["-"] - // Factor = Factor "/" Term (*) ["/"] + // 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 (*) ")" ["/"] // - // EOF -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // "*" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // "/" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // "+" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // "-" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // "+" -> Shift(S20) + // ")" -> Shift(S27) + // "-" -> Shift(S19) // pub fn __state22< __TOKENS: Iterator, @@ -1583,75 +1626,58 @@ mod __parse__Expr { __lookbehind: Option<()>, __lookahead: Option, __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option, - __sym2: &mut Option, + __sym0: &mut Option, + __sym1: &mut Option, ) -> Result<(Option<()>, Option, __Nonterminal<>), Option> { let mut __result: (Option<()>, Option, __Nonterminal<>); match __lookahead { - None => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action5(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + Some(__tok @ Tok::Plus(..)) => { + let mut __lookbehind = None; + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state20(scale, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); } - Some(Tok::Times(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action5(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + Some(__tok @ Tok::RParen(..)) => { + let mut __lookbehind = None; + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state27(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); } - Some(Tok::Div(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action5(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Plus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action5(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Minus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action5(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + Some(__tok @ Tok::Minus(..)) => { + let mut __lookbehind = None; + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state19(scale, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); } _ => { return Err(__lookahead); } } + return Ok(__result); } // State 23 - // Expr = Expr "-" Factor (*) [EOF] - // Expr = Expr "-" Factor (*) ["+"] - // Expr = Expr "-" Factor (*) ["-"] - // Factor = Factor (*) "*" Term [EOF] - // Factor = Factor (*) "*" Term ["*"] - // Factor = Factor (*) "*" Term ["+"] - // Factor = Factor (*) "*" Term ["-"] - // Factor = Factor (*) "*" Term ["/"] - // Factor = Factor (*) "/" Term [EOF] - // Factor = Factor (*) "/" Term ["*"] - // Factor = Factor (*) "/" Term ["+"] - // Factor = Factor (*) "/" Term ["-"] - // Factor = Factor (*) "/" Term ["/"] + // Factor = Factor "/" (*) Term [")"] + // Factor = Factor "/" (*) Term ["*"] + // Factor = Factor "/" (*) Term ["+"] + // Factor = Factor "/" (*) Term ["-"] + // Factor = Factor "/" (*) Term ["/"] + // Term = (*) "(" Expr ")" [")"] + // Term = (*) "(" Expr ")" ["*"] + // Term = (*) "(" Expr ")" ["+"] + // Term = (*) "(" Expr ")" ["-"] + // Term = (*) "(" Expr ")" ["/"] + // Term = (*) "Num" [")"] + // Term = (*) "Num" ["*"] + // Term = (*) "Num" ["+"] + // Term = (*) "Num" ["-"] + // Term = (*) "Num" ["/"] // - // "*" -> Shift(S11) - // EOF -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) - // "/" -> Shift(S12) - // "-" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) - // "+" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // "Num" -> Shift(S12) + // "(" -> Shift(S13) // + // Term -> S28 pub fn __state23< __TOKENS: Iterator, >( @@ -1661,73 +1687,128 @@ mod __parse__Expr { __tokens: &mut __TOKENS, __sym0: &mut Option, __sym1: &mut Option, - __sym2: &mut Option, ) -> Result<(Option<()>, Option, __Nonterminal<>), Option> { let mut __result: (Option<()>, Option, __Nonterminal<>); match __lookahead { - Some(__tok @ Tok::Times(..)) => { + Some(Tok::Num(__tok0)) => { let mut __lookbehind = None; - let mut __sym3 = &mut Some((__tok)); + let mut __sym2 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state11(scale, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); + __result = try!(__state12(scale, __lookbehind, __lookahead, __tokens, __sym2)); } - Some(__tok @ Tok::Div(..)) => { + Some(__tok @ Tok::LParen(..)) => { let mut __lookbehind = None; - let mut __sym3 = &mut Some((__tok)); + let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state12(scale, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); - } - None => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action1(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - Some(Tok::Minus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action1(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - Some(Tok::Plus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action1(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + __result = try!(__state13(scale, __lookbehind, __lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); } } + while __sym1.is_some() { + let (__lookbehind, __lookahead, __nt) = __result; + match __nt { + __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state28(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + _ => { + return Ok((__lookbehind, __lookahead, __nt)); + } + } + } return Ok(__result); } // State 24 - // Expr = Expr "+" Factor (*) [EOF] - // Expr = Expr "+" Factor (*) ["+"] - // Expr = Expr "+" Factor (*) ["-"] - // Factor = Factor (*) "*" Term [EOF] + // Factor = Factor "*" (*) Term [")"] + // Factor = Factor "*" (*) Term ["*"] + // Factor = Factor "*" (*) Term ["+"] + // Factor = Factor "*" (*) Term ["-"] + // Factor = Factor "*" (*) Term ["/"] + // Term = (*) "(" Expr ")" [")"] + // Term = (*) "(" Expr ")" ["*"] + // Term = (*) "(" Expr ")" ["+"] + // Term = (*) "(" Expr ")" ["-"] + // Term = (*) "(" Expr ")" ["/"] + // Term = (*) "Num" [")"] + // Term = (*) "Num" ["*"] + // Term = (*) "Num" ["+"] + // Term = (*) "Num" ["-"] + // Term = (*) "Num" ["/"] + // + // "(" -> Shift(S13) + // "Num" -> Shift(S12) + // + // Term -> S29 + pub fn __state24< + __TOKENS: Iterator, + >( + scale: i32, + __lookbehind: Option<()>, + __lookahead: Option, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + __sym1: &mut Option, + ) -> Result<(Option<()>, Option, __Nonterminal<>), Option> + { + let mut __result: (Option<()>, Option, __Nonterminal<>); + match __lookahead { + Some(__tok @ Tok::LParen(..)) => { + let mut __lookbehind = None; + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state13(scale, __lookbehind, __lookahead, __tokens, __sym2)); + } + Some(Tok::Num(__tok0)) => { + let mut __lookbehind = None; + let mut __sym2 = &mut Some((__tok0)); + let __lookahead = __tokens.next(); + __result = try!(__state12(scale, __lookbehind, __lookahead, __tokens, __sym2)); + } + _ => { + return Err(__lookahead); + } + } + while __sym1.is_some() { + let (__lookbehind, __lookahead, __nt) = __result; + match __nt { + __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state29(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + _ => { + return Ok((__lookbehind, __lookahead, __nt)); + } + } + } + return Ok(__result); + } + + // State 25 + // Expr = Expr "-" Factor (*) [")"] + // Expr = Expr "-" Factor (*) ["+"] + // Expr = Expr "-" Factor (*) ["-"] + // Factor = Factor (*) "*" Term [")"] // Factor = Factor (*) "*" Term ["*"] // Factor = Factor (*) "*" Term ["+"] // Factor = Factor (*) "*" Term ["-"] // Factor = Factor (*) "*" Term ["/"] - // Factor = Factor (*) "/" Term [EOF] + // Factor = Factor (*) "/" Term [")"] // Factor = Factor (*) "/" Term ["*"] // Factor = Factor (*) "/" Term ["+"] // Factor = Factor (*) "/" Term ["-"] // Factor = Factor (*) "/" Term ["/"] // - // "/" -> Shift(S12) - // "-" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) - // "+" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) - // EOF -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) - // "*" -> Shift(S11) + // "*" -> Shift(S24) + // "/" -> Shift(S23) + // "-" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // "+" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // ")" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) // - pub fn __state24< + pub fn __state25< __TOKENS: Iterator, >( scale: i32, @@ -1741,37 +1822,37 @@ mod __parse__Expr { { let mut __result: (Option<()>, Option, __Nonterminal<>); match __lookahead { - Some(__tok @ Tok::Div(..)) => { - let mut __lookbehind = None; - let mut __sym3 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state12(scale, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); - } Some(__tok @ Tok::Times(..)) => { let mut __lookbehind = None; let mut __sym3 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state11(scale, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); + __result = try!(__state24(scale, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); + } + Some(__tok @ Tok::Div(..)) => { + let mut __lookbehind = None; + let mut __sym3 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state23(scale, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); } Some(Tok::Minus(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action2(scale, __sym0, __sym1, __sym2); + let __nt = super::__action1(scale, __sym0, __sym1, __sym2); return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); } Some(Tok::Plus(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action2(scale, __sym0, __sym1, __sym2); + let __nt = super::__action1(scale, __sym0, __sym1, __sym2); return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); } - None => { + Some(Tok::RParen(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action2(scale, __sym0, __sym1, __sym2); + let __nt = super::__action1(scale, __sym0, __sym1, __sym2); return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); } _ => { @@ -1781,86 +1862,26 @@ mod __parse__Expr { return Ok(__result); } - // State 25 - // Term = "(" Expr ")" (*) [")"] - // Term = "(" Expr ")" (*) ["*"] - // Term = "(" Expr ")" (*) ["+"] - // Term = "(" Expr ")" (*) ["-"] - // Term = "(" Expr ")" (*) ["/"] - // - // "+" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) - // "*" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) - // "-" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) - // "/" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) - // ")" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) - // - pub fn __state25< - __TOKENS: Iterator, - >( - scale: i32, - __lookbehind: Option<()>, - __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option, - __sym2: &mut Option, - ) -> Result<(Option<()>, Option, __Nonterminal<>), Option> - { - let mut __result: (Option<()>, 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::__action8(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - Some(Tok::Times(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action8(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - Some(Tok::Minus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action8(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - Some(Tok::Div(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action8(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - Some(Tok::RParen(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action8(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - // State 26 - // Factor = Factor "*" Term (*) [")"] - // Factor = Factor "*" Term (*) ["*"] - // Factor = Factor "*" Term (*) ["+"] - // Factor = Factor "*" Term (*) ["-"] - // Factor = Factor "*" Term (*) ["/"] + // Expr = Expr "+" Factor (*) [")"] + // Expr = Expr "+" Factor (*) ["+"] + // Expr = Expr "+" Factor (*) ["-"] + // Factor = Factor (*) "*" Term [")"] + // Factor = Factor (*) "*" Term ["*"] + // Factor = Factor (*) "*" Term ["+"] + // Factor = Factor (*) "*" Term ["-"] + // Factor = Factor (*) "*" Term ["/"] + // Factor = Factor (*) "/" Term [")"] + // Factor = Factor (*) "/" Term ["*"] + // Factor = Factor (*) "/" Term ["+"] + // Factor = Factor (*) "/" Term ["-"] + // Factor = Factor (*) "/" Term ["/"] // - // "/" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) - // ")" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) - // "-" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) - // "*" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) - // "+" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // "-" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) + // "*" -> Shift(S24) + // ")" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) + // "+" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) + // "/" -> Shift(S23) // pub fn __state26< __TOKENS: Iterator, @@ -1876,59 +1897,58 @@ mod __parse__Expr { { let mut __result: (Option<()>, 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::__action4(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + Some(__tok @ Tok::Times(..)) => { + let mut __lookbehind = None; + let mut __sym3 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state24(scale, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); } - Some(Tok::RParen(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action4(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + Some(__tok @ Tok::Div(..)) => { + let mut __lookbehind = None; + let mut __sym3 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state23(scale, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); } Some(Tok::Minus(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action4(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + let __nt = super::__action2(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); } - Some(Tok::Times(..)) => { + Some(Tok::RParen(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action4(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + let __nt = super::__action2(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); } Some(Tok::Plus(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action4(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + let __nt = super::__action2(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); } _ => { return Err(__lookahead); } } + return Ok(__result); } // State 27 - // Factor = Factor "/" Term (*) [")"] - // Factor = Factor "/" Term (*) ["*"] - // Factor = Factor "/" Term (*) ["+"] - // Factor = Factor "/" Term (*) ["-"] - // Factor = Factor "/" Term (*) ["/"] + // Term = "(" Expr ")" (*) [")"] + // Term = "(" Expr ")" (*) ["*"] + // Term = "(" Expr ")" (*) ["+"] + // Term = "(" Expr ")" (*) ["-"] + // Term = "(" Expr ")" (*) ["/"] // - // "*" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // "/" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // "+" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // "-" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // ")" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // "*" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) + // "+" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) + // "-" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) + // ")" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) + // "/" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) // pub fn __state27< __TOKENS: Iterator, @@ -1937,9 +1957,9 @@ mod __parse__Expr { __lookbehind: Option<()>, __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<()>, Option, __Nonterminal<>), Option> { let mut __result: (Option<()>, Option, __Nonterminal<>); @@ -1948,36 +1968,36 @@ mod __parse__Expr { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action5(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Div(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action5(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + let __nt = super::__action8(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); } Some(Tok::Plus(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action5(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + let __nt = super::__action8(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); } Some(Tok::Minus(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action5(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + let __nt = super::__action8(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); } Some(Tok::RParen(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action5(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + let __nt = super::__action8(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + Some(Tok::Div(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action8(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); } _ => { return Err(__lookahead); @@ -1986,25 +2006,17 @@ mod __parse__Expr { } // State 28 - // Expr = Expr "+" Factor (*) [")"] - // Expr = Expr "+" Factor (*) ["+"] - // Expr = Expr "+" Factor (*) ["-"] - // Factor = Factor (*) "*" Term [")"] - // Factor = Factor (*) "*" Term ["*"] - // Factor = Factor (*) "*" Term ["+"] - // Factor = Factor (*) "*" Term ["-"] - // Factor = Factor (*) "*" Term ["/"] - // Factor = Factor (*) "/" Term [")"] - // Factor = Factor (*) "/" Term ["*"] - // Factor = Factor (*) "/" Term ["+"] - // Factor = Factor (*) "/" Term ["-"] - // Factor = Factor (*) "/" Term ["/"] + // Factor = Factor "/" Term (*) [")"] + // Factor = Factor "/" Term (*) ["*"] + // Factor = Factor "/" Term (*) ["+"] + // Factor = Factor "/" Term (*) ["-"] + // Factor = Factor "/" Term (*) ["/"] // - // "+" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) - // "*" -> Shift(S16) - // "-" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) - // "/" -> Shift(S17) - // ")" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) + // "+" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // "-" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // "*" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // ")" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // "/" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) // pub fn __state28< __TOKENS: Iterator, @@ -2020,66 +2032,59 @@ mod __parse__Expr { { let mut __result: (Option<()>, Option, __Nonterminal<>); match __lookahead { - Some(__tok @ Tok::Times(..)) => { - let mut __lookbehind = None; - let mut __sym3 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state16(scale, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); - } - Some(__tok @ Tok::Div(..)) => { - let mut __lookbehind = None; - let mut __sym3 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state17(scale, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); - } Some(Tok::Plus(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action2(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + let __nt = super::__action5(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } Some(Tok::Minus(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action2(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + let __nt = super::__action5(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some(Tok::Times(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action5(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } Some(Tok::RParen(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action2(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + let __nt = super::__action5(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some(Tok::Div(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action5(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } _ => { return Err(__lookahead); } } - return Ok(__result); } // State 29 - // Expr = Expr "-" Factor (*) [")"] - // Expr = Expr "-" Factor (*) ["+"] - // Expr = Expr "-" Factor (*) ["-"] - // Factor = Factor (*) "*" Term [")"] - // Factor = Factor (*) "*" Term ["*"] - // Factor = Factor (*) "*" Term ["+"] - // Factor = Factor (*) "*" Term ["-"] - // Factor = Factor (*) "*" Term ["/"] - // Factor = Factor (*) "/" Term [")"] - // Factor = Factor (*) "/" Term ["*"] - // Factor = Factor (*) "/" Term ["+"] - // Factor = Factor (*) "/" Term ["-"] - // Factor = Factor (*) "/" Term ["/"] + // Factor = Factor "*" Term (*) [")"] + // Factor = Factor "*" Term (*) ["*"] + // Factor = Factor "*" Term (*) ["+"] + // Factor = Factor "*" Term (*) ["-"] + // Factor = Factor "*" Term (*) ["/"] // - // "+" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) - // "/" -> Shift(S17) - // ")" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) - // "-" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) - // "*" -> Shift(S16) + // "/" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // "-" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // "*" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // ")" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // "+" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) // pub fn __state29< __TOKENS: Iterator, @@ -2095,44 +2100,45 @@ mod __parse__Expr { { let mut __result: (Option<()>, Option, __Nonterminal<>); match __lookahead { - Some(__tok @ Tok::Div(..)) => { - let mut __lookbehind = None; - let mut __sym3 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state17(scale, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); - } - Some(__tok @ Tok::Times(..)) => { - let mut __lookbehind = None; - let mut __sym3 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state16(scale, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); - } - Some(Tok::Plus(..)) => { + Some(Tok::Div(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action1(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - Some(Tok::RParen(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action1(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + let __nt = super::__action4(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } Some(Tok::Minus(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action1(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + let __nt = super::__action4(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some(Tok::Times(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action4(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some(Tok::RParen(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action4(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some(Tok::Plus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action4(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } _ => { return Err(__lookahead); } } - return Ok(__result); } } diff --git a/lalrpop-test/src/expr_arena.rs b/lalrpop-test/src/expr_arena.rs index 15ed082..b844873 100644 --- a/lalrpop-test/src/expr_arena.rs +++ b/lalrpop-test/src/expr_arena.rs @@ -10,12 +10,18 @@ pub fn parse_Expr< >( arena: &'ast Arena<'ast>, __tokens: __TOKENS, -) -> Result<(Option<(usize,Tok,usize)>, &'ast Node<'ast>), Option<(usize,Tok,usize)>> +) -> Result<&'ast Node<'ast>, Option<(usize,Tok,usize)>> { let mut __tokens = __tokens.into_iter(); let __lookahead = __tokens.next(); match try!(__parse__Expr::__state0(arena, None, __lookahead, &mut __tokens)) { - (_, __lookahead, __parse__Expr::__Nonterminal::____Expr(__nt)) => Ok((__lookahead, __nt)), + (_, __lookahead, __parse__Expr::__Nonterminal::____Expr(__nt)) => { + if __lookahead.is_some() { + Err(__lookahead) + } else { + Ok(__nt) + } + } _ => unreachable!(), } } @@ -27,14 +33,14 @@ mod __parse__Expr { use util::tok::Tok; pub enum __Nonterminal<'ast, > { - ____Expr(&'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>), + _28_3cExpr_3e_20_22_2c_22_29(&'ast Node<'ast>), _28_3cExpr_3e_20_22_2c_22_29_2a(::std::vec::Vec<&'ast Node<'ast>>), + ____Expr(&'ast Node<'ast>), Term(&'ast Node<'ast>), - Factor(&'ast Node<'ast>), Expr_3f(::std::option::Option<&'ast Node<'ast>>), + Factor(&'ast Node<'ast>), + Comma_3cExpr_3e(Vec<&'ast Node<'ast>>), } // State 0 @@ -79,13 +85,13 @@ mod __parse__Expr { // Term = (*) "Num" ["/"] // __Expr = (*) Expr [EOF] // - // "(" -> Shift(S1) - // "*" -> Shift(S5) - // "Num" -> Shift(S6) + // "Num" -> Shift(S5) + // "(" -> Shift(S4) + // "*" -> Shift(S6) // + // Factor -> S3 // Term -> S2 - // Factor -> S4 - // Expr -> S3 + // Expr -> S1 pub fn __state0< 'ast, __TOKENS: Iterator, @@ -98,22 +104,22 @@ mod __parse__Expr { { let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { + Some((_, Tok::Num(__tok0), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym0 = &mut Some((__tok0)); + let __lookahead = __tokens.next(); + __result = try!(__state5(arena, __lookbehind, __lookahead, __tokens, __sym0)); + } Some((_, __tok @ Tok::LParen(..), __loc)) => { let mut __lookbehind = Some(__loc); let mut __sym0 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state1(arena, __lookbehind, __lookahead, __tokens, __sym0)); + __result = try!(__state4(arena, __lookbehind, __lookahead, __tokens, __sym0)); } Some((_, __tok @ Tok::Times(..), __loc)) => { let mut __lookbehind = Some(__loc); let mut __sym0 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state5(arena, __lookbehind, __lookahead, __tokens, __sym0)); - } - Some((_, Tok::Num(__tok0), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym0 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); __result = try!(__state6(arena, __lookbehind, __lookahead, __tokens, __sym0)); } _ => { @@ -123,17 +129,17 @@ mod __parse__Expr { loop { let (__lookbehind, __lookahead, __nt) = __result; match __nt { + __Nonterminal::Factor(__nt) => { + let __sym0 = &mut Some(__nt); + __result = try!(__state3(arena, __lookbehind, __lookahead, __tokens, __sym0)); + } __Nonterminal::Term(__nt) => { let __sym0 = &mut Some(__nt); __result = try!(__state2(arena, __lookbehind, __lookahead, __tokens, __sym0)); } - __Nonterminal::Factor(__nt) => { - let __sym0 = &mut Some(__nt); - __result = try!(__state4(arena, __lookbehind, __lookahead, __tokens, __sym0)); - } __Nonterminal::Expr(__nt) => { let __sym0 = &mut Some(__nt); - __result = try!(__state3(arena, __lookbehind, __lookahead, __tokens, __sym0)); + __result = try!(__state1(arena, __lookbehind, __lookahead, __tokens, __sym0)); } _ => { return Ok((__lookbehind, __lookahead, __nt)); @@ -143,6 +149,181 @@ mod __parse__Expr { } // State 1 + // Expr = Expr (*) "+" Factor [EOF] + // Expr = Expr (*) "+" Factor ["+"] + // Expr = Expr (*) "+" Factor ["-"] + // Expr = Expr (*) "-" Factor [EOF] + // Expr = Expr (*) "-" Factor ["+"] + // Expr = Expr (*) "-" Factor ["-"] + // __Expr = Expr (*) [EOF] + // + // EOF -> Reduce(__Expr = Expr => Call(ActionFn(0));) + // "+" -> Shift(S8) + // "-" -> Shift(S7) + // + pub fn __state1< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, __tok @ Tok::Plus(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state8(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + } + Some((_, __tok @ Tok::Minus(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state7(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + } + None => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action0(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::____Expr(__nt))); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + + // State 2 + // Factor = Term (*) [EOF] + // Factor = Term (*) ["*"] + // Factor = Term (*) ["+"] + // Factor = Term (*) ["-"] + // Factor = Term (*) ["/"] + // + // "*" -> Reduce(Factor = Term => Call(ActionFn(7));) + // "+" -> Reduce(Factor = Term => Call(ActionFn(7));) + // EOF -> Reduce(Factor = Term => Call(ActionFn(7));) + // "/" -> Reduce(Factor = Term => Call(ActionFn(7));) + // "-" -> Reduce(Factor = Term => Call(ActionFn(7));) + // + pub fn __state2< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, Tok::Times(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action7(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action7(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + None => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action7(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Div(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action7(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action7(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 3 + // Expr = Factor (*) [EOF] + // Expr = Factor (*) ["+"] + // Expr = Factor (*) ["-"] + // Factor = Factor (*) "*" Term [EOF] + // Factor = Factor (*) "*" Term ["*"] + // Factor = Factor (*) "*" Term ["+"] + // Factor = Factor (*) "*" Term ["-"] + // Factor = Factor (*) "*" Term ["/"] + // Factor = Factor (*) "/" Term [EOF] + // Factor = Factor (*) "/" Term ["*"] + // Factor = Factor (*) "/" Term ["+"] + // Factor = Factor (*) "/" Term ["-"] + // Factor = Factor (*) "/" Term ["/"] + // + // "+" -> Reduce(Expr = Factor => Call(ActionFn(3));) + // EOF -> Reduce(Expr = Factor => Call(ActionFn(3));) + // "/" -> Shift(S10) + // "*" -> Shift(S9) + // "-" -> Reduce(Expr = Factor => Call(ActionFn(3));) + // + pub fn __state3< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, __tok @ Tok::Div(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state10(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + } + Some((_, __tok @ Tok::Times(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state9(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action3(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + None => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action3(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action3(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + + // State 4 // Expr = (*) Expr "+" Factor [")"] // Expr = (*) Expr "+" Factor ["+"] // Expr = (*) Expr "+" Factor ["-"] @@ -188,14 +369,14 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "(" -> Shift(S8) - // "Num" -> Shift(S9) - // "*" -> Shift(S10) + // "(" -> Shift(S12) + // "*" -> Shift(S15) + // "Num" -> Shift(S16) // - // Expr -> S11 - // Factor -> S7 - // Term -> S12 - pub fn __state1< + // Expr -> S13 + // Term -> S14 + // Factor -> S11 + pub fn __state4< 'ast, __TOKENS: Iterator, >( @@ -212,19 +393,19 @@ mod __parse__Expr { let mut __lookbehind = Some(__loc); let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state8(arena, __lookbehind, __lookahead, __tokens, __sym1)); - } - Some((_, Tok::Num(__tok0), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym1 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state9(arena, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state12(arena, __lookbehind, __lookahead, __tokens, __sym1)); } Some((_, __tok @ Tok::Times(..), __loc)) => { let mut __lookbehind = Some(__loc); let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state10(arena, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state15(arena, __lookbehind, __lookahead, __tokens, __sym1)); + } + Some((_, Tok::Num(__tok0), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym1 = &mut Some((__tok0)); + let __lookahead = __tokens.next(); + __result = try!(__state16(arena, __lookbehind, __lookahead, __tokens, __sym1)); } _ => { return Err(__lookahead); @@ -235,15 +416,15 @@ mod __parse__Expr { match __nt { __Nonterminal::Expr(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state11(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); - } - __Nonterminal::Factor(__nt) => { - let __sym1 = &mut Some(__nt); - __result = try!(__state7(arena, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state13(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); } __Nonterminal::Term(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state12(arena, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state14(arena, __lookbehind, __lookahead, __tokens, __sym1)); + } + __Nonterminal::Factor(__nt) => { + let __sym1 = &mut Some(__nt); + __result = try!(__state11(arena, __lookbehind, __lookahead, __tokens, __sym1)); } _ => { return Ok((__lookbehind, __lookahead, __nt)); @@ -253,20 +434,20 @@ mod __parse__Expr { return Ok(__result); } - // State 2 - // Factor = Term (*) [EOF] - // Factor = Term (*) ["*"] - // Factor = Term (*) ["+"] - // Factor = Term (*) ["-"] - // Factor = Term (*) ["/"] + // State 5 + // Term = "Num" (*) [EOF] + // Term = "Num" (*) ["*"] + // Term = "Num" (*) ["+"] + // Term = "Num" (*) ["-"] + // Term = "Num" (*) ["/"] // - // EOF -> Reduce(Factor = Term => Call(ActionFn(7));) - // "+" -> Reduce(Factor = Term => Call(ActionFn(7));) - // "*" -> Reduce(Factor = Term => Call(ActionFn(7));) - // "-" -> Reduce(Factor = Term => Call(ActionFn(7));) - // "/" -> Reduce(Factor = Term => Call(ActionFn(7));) + // "-" -> Reduce(Term = "Num" => Call(ActionFn(8));) + // "/" -> Reduce(Term = "Num" => Call(ActionFn(8));) + // EOF -> Reduce(Term = "Num" => Call(ActionFn(8));) + // "+" -> Reduce(Term = "Num" => Call(ActionFn(8));) + // "*" -> Reduce(Term = "Num" => Call(ActionFn(8));) // - pub fn __state2< + pub fn __state5< 'ast, __TOKENS: Iterator, >( @@ -274,161 +455,43 @@ mod __parse__Expr { __lookbehind: Option, __lookahead: Option<(usize,Tok,usize)>, __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, + __sym0: &mut Option, ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> { let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - None => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action7(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action7(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Times(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action7(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } Some((_, Tok::Minus(..), _)) => { let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action7(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + let __nt = super::__action8(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); } Some((_, Tok::Div(..), _)) => { let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action7(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 3 - // Expr = Expr (*) "+" Factor [EOF] - // Expr = Expr (*) "+" Factor ["+"] - // Expr = Expr (*) "+" Factor ["-"] - // Expr = Expr (*) "-" Factor [EOF] - // Expr = Expr (*) "-" Factor ["+"] - // Expr = Expr (*) "-" Factor ["-"] - // __Expr = Expr (*) [EOF] - // - // EOF -> Reduce(__Expr = Expr => Call(ActionFn(0));) - // "-" -> Shift(S13) - // "+" -> Shift(S14) - // - pub fn __state3< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize,Tok,usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> - { - let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, __tok @ Tok::Minus(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym1 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state13(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); - } - Some((_, __tok @ Tok::Plus(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym1 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state14(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + let __nt = super::__action8(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); } None => { let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action0(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::____Expr(__nt))); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 4 - // Expr = Factor (*) [EOF] - // Expr = Factor (*) ["+"] - // Expr = Factor (*) ["-"] - // Factor = Factor (*) "*" Term [EOF] - // Factor = Factor (*) "*" Term ["*"] - // Factor = Factor (*) "*" Term ["+"] - // Factor = Factor (*) "*" Term ["-"] - // Factor = Factor (*) "*" Term ["/"] - // Factor = Factor (*) "/" Term [EOF] - // Factor = Factor (*) "/" Term ["*"] - // Factor = Factor (*) "/" Term ["+"] - // Factor = Factor (*) "/" Term ["-"] - // Factor = Factor (*) "/" Term ["/"] - // - // EOF -> Reduce(Expr = Factor => Call(ActionFn(3));) - // "+" -> Reduce(Expr = Factor => Call(ActionFn(3));) - // "-" -> Reduce(Expr = Factor => Call(ActionFn(3));) - // "/" -> Shift(S16) - // "*" -> Shift(S15) - // - pub fn __state4< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize,Tok,usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> - { - let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, __tok @ Tok::Div(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym1 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state16(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); - } - Some((_, __tok @ Tok::Times(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym1 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state15(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); - } - None => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action3(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + let __nt = super::__action8(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); } Some((_, Tok::Plus(..), _)) => { let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action3(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + let __nt = super::__action8(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); } - Some((_, Tok::Minus(..), _)) => { + Some((_, Tok::Times(..), _)) => { let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action3(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + let __nt = super::__action8(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); } _ => { return Err(__lookahead); } } - return Ok(__result); } - // State 5 + // State 6 // Factor = "*" (*) "(" Comma ")" [EOF] // Factor = "*" (*) "(" Comma ")" ["*"] // Factor = "*" (*) "(" Comma ")" ["+"] @@ -437,7 +500,7 @@ mod __parse__Expr { // // "(" -> Shift(S17) // - pub fn __state5< + pub fn __state6< 'ast, __TOKENS: Iterator, >( @@ -463,20 +526,48 @@ mod __parse__Expr { return Ok(__result); } - // State 6 - // Term = "Num" (*) [EOF] - // Term = "Num" (*) ["*"] - // Term = "Num" (*) ["+"] - // Term = "Num" (*) ["-"] - // Term = "Num" (*) ["/"] + // State 7 + // Expr = Expr "-" (*) Factor [EOF] + // Expr = Expr "-" (*) Factor ["+"] + // Expr = Expr "-" (*) Factor ["-"] + // Factor = (*) Factor "*" Term [EOF] + // Factor = (*) Factor "*" Term ["*"] + // Factor = (*) Factor "*" Term ["+"] + // Factor = (*) Factor "*" Term ["-"] + // Factor = (*) Factor "*" Term ["/"] + // Factor = (*) Factor "/" Term [EOF] + // Factor = (*) Factor "/" Term ["*"] + // Factor = (*) Factor "/" Term ["+"] + // Factor = (*) Factor "/" Term ["-"] + // Factor = (*) Factor "/" Term ["/"] + // Factor = (*) Term [EOF] + // Factor = (*) Term ["*"] + // Factor = (*) Term ["+"] + // Factor = (*) Term ["-"] + // Factor = (*) Term ["/"] + // Factor = (*) "*" "(" Comma ")" [EOF] + // Factor = (*) "*" "(" Comma ")" ["*"] + // Factor = (*) "*" "(" Comma ")" ["+"] + // Factor = (*) "*" "(" Comma ")" ["-"] + // Factor = (*) "*" "(" Comma ")" ["/"] + // Term = (*) "(" Expr ")" [EOF] + // Term = (*) "(" Expr ")" ["*"] + // Term = (*) "(" Expr ")" ["+"] + // Term = (*) "(" Expr ")" ["-"] + // Term = (*) "(" Expr ")" ["/"] + // Term = (*) "Num" [EOF] + // Term = (*) "Num" ["*"] + // Term = (*) "Num" ["+"] + // Term = (*) "Num" ["-"] + // Term = (*) "Num" ["/"] // - // "*" -> Reduce(Term = "Num" => Call(ActionFn(8));) - // "/" -> Reduce(Term = "Num" => Call(ActionFn(8));) - // EOF -> Reduce(Term = "Num" => Call(ActionFn(8));) - // "+" -> Reduce(Term = "Num" => Call(ActionFn(8));) - // "-" -> Reduce(Term = "Num" => Call(ActionFn(8));) + // "*" -> Shift(S6) + // "Num" -> Shift(S5) + // "(" -> Shift(S4) // - pub fn __state6< + // Factor -> S18 + // Term -> S2 + pub fn __state7< 'ast, __TOKENS: Iterator, >( @@ -484,43 +575,282 @@ mod __parse__Expr { __lookbehind: Option, __lookahead: Option<(usize,Tok,usize)>, __tokens: &mut __TOKENS, - __sym0: &mut Option, + __sym0: &mut Option<&'ast Node<'ast>>, + __sym1: &mut Option, ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> { let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some((_, Tok::Times(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action8(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + Some((_, __tok @ Tok::Times(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state6(arena, __lookbehind, __lookahead, __tokens, __sym2)); } - Some((_, Tok::Div(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action8(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + Some((_, Tok::Num(__tok0), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok0)); + let __lookahead = __tokens.next(); + __result = try!(__state5(arena, __lookbehind, __lookahead, __tokens, __sym2)); } - None => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action8(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - Some((_, Tok::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action8(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action8(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + Some((_, __tok @ Tok::LParen(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state4(arena, __lookbehind, __lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); } } + while __sym1.is_some() { + let (__lookbehind, __lookahead, __nt) = __result; + match __nt { + __Nonterminal::Factor(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state18(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state2(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + _ => { + return Ok((__lookbehind, __lookahead, __nt)); + } + } + } + return Ok(__result); } - // State 7 + // 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(S6) + // "(" -> Shift(S4) + // "Num" -> Shift(S5) + // + // Term -> S2 + // Factor -> S19 + pub fn __state8< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + __sym1: &mut Option, + ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, __tok @ Tok::Times(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state6(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + Some((_, __tok @ Tok::LParen(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state4(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + Some((_, Tok::Num(__tok0), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok0)); + let __lookahead = __tokens.next(); + __result = try!(__state5(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + _ => { + return Err(__lookahead); + } + } + while __sym1.is_some() { + let (__lookbehind, __lookahead, __nt) = __result; + match __nt { + __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state2(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + __Nonterminal::Factor(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state19(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + _ => { + return Ok((__lookbehind, __lookahead, __nt)); + } + } + } + return Ok(__result); + } + + // State 9 + // Factor = Factor "*" (*) Term [EOF] + // Factor = Factor "*" (*) Term ["*"] + // Factor = Factor "*" (*) Term ["+"] + // Factor = Factor "*" (*) Term ["-"] + // Factor = Factor "*" (*) Term ["/"] + // Term = (*) "(" Expr ")" [EOF] + // Term = (*) "(" Expr ")" ["*"] + // Term = (*) "(" Expr ")" ["+"] + // Term = (*) "(" Expr ")" ["-"] + // Term = (*) "(" Expr ")" ["/"] + // Term = (*) "Num" [EOF] + // Term = (*) "Num" ["*"] + // Term = (*) "Num" ["+"] + // Term = (*) "Num" ["-"] + // Term = (*) "Num" ["/"] + // + // "Num" -> Shift(S5) + // "(" -> Shift(S4) + // + // Term -> S20 + pub fn __state9< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + __sym1: &mut Option, + ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, Tok::Num(__tok0), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok0)); + let __lookahead = __tokens.next(); + __result = try!(__state5(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + Some((_, __tok @ Tok::LParen(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state4(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + _ => { + return Err(__lookahead); + } + } + while __sym1.is_some() { + let (__lookbehind, __lookahead, __nt) = __result; + match __nt { + __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state20(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + _ => { + return Ok((__lookbehind, __lookahead, __nt)); + } + } + } + return Ok(__result); + } + + // State 10 + // Factor = Factor "/" (*) Term [EOF] + // Factor = Factor "/" (*) Term ["*"] + // Factor = Factor "/" (*) Term ["+"] + // Factor = Factor "/" (*) Term ["-"] + // Factor = Factor "/" (*) Term ["/"] + // Term = (*) "(" Expr ")" [EOF] + // Term = (*) "(" Expr ")" ["*"] + // Term = (*) "(" Expr ")" ["+"] + // Term = (*) "(" Expr ")" ["-"] + // Term = (*) "(" Expr ")" ["/"] + // Term = (*) "Num" [EOF] + // Term = (*) "Num" ["*"] + // Term = (*) "Num" ["+"] + // Term = (*) "Num" ["-"] + // Term = (*) "Num" ["/"] + // + // "Num" -> Shift(S5) + // "(" -> Shift(S4) + // + // Term -> S21 + pub fn __state10< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + __sym1: &mut Option, + ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, Tok::Num(__tok0), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok0)); + let __lookahead = __tokens.next(); + __result = try!(__state5(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + Some((_, __tok @ Tok::LParen(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state4(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + _ => { + return Err(__lookahead); + } + } + while __sym1.is_some() { + let (__lookbehind, __lookahead, __nt) = __result; + match __nt { + __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state21(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + _ => { + return Ok((__lookbehind, __lookahead, __nt)); + } + } + } + return Ok(__result); + } + + // State 11 // Expr = Factor (*) [")"] // Expr = Factor (*) ["+"] // Expr = Factor (*) ["-"] @@ -535,13 +865,13 @@ mod __parse__Expr { // Factor = Factor (*) "/" Term ["-"] // Factor = Factor (*) "/" Term ["/"] // - // "/" -> Shift(S18) // "-" -> Reduce(Expr = Factor => Call(ActionFn(3));) - // ")" -> Reduce(Expr = Factor => Call(ActionFn(3));) // "+" -> Reduce(Expr = Factor => Call(ActionFn(3));) - // "*" -> Shift(S19) + // "/" -> Shift(S23) + // "*" -> Shift(S22) + // ")" -> Reduce(Expr = Factor => Call(ActionFn(3));) // - pub fn __state7< + pub fn __state11< 'ast, __TOKENS: Iterator, >( @@ -558,25 +888,25 @@ mod __parse__Expr { let mut __lookbehind = Some(__loc); let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state18(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + __result = try!(__state23(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); } Some((_, __tok @ Tok::Times(..), __loc)) => { let mut __lookbehind = Some(__loc); let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state19(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + __result = try!(__state22(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); } Some((_, Tok::Minus(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __nt = super::__action3(arena, __sym0); return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); } - Some((_, Tok::RParen(..), _)) => { + Some((_, Tok::Plus(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __nt = super::__action3(arena, __sym0); return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); } - Some((_, Tok::Plus(..), _)) => { + Some((_, Tok::RParen(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __nt = super::__action3(arena, __sym0); return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); @@ -588,7 +918,7 @@ mod __parse__Expr { return Ok(__result); } - // State 8 + // State 12 // Expr = (*) Expr "+" Factor [")"] // Expr = (*) Expr "+" Factor ["+"] // Expr = (*) Expr "+" Factor ["-"] @@ -634,14 +964,14 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "Num" -> Shift(S9) - // "*" -> Shift(S10) - // "(" -> Shift(S8) + // "*" -> Shift(S15) + // "Num" -> Shift(S16) + // "(" -> Shift(S12) // - // Expr -> S20 - // Factor -> S7 - // Term -> S12 - pub fn __state8< + // Expr -> S24 + // Term -> S14 + // Factor -> S11 + pub fn __state12< 'ast, __TOKENS: Iterator, >( @@ -654,23 +984,23 @@ mod __parse__Expr { { let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some((_, Tok::Num(__tok0), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym1 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state9(arena, __lookbehind, __lookahead, __tokens, __sym1)); - } Some((_, __tok @ Tok::Times(..), __loc)) => { let mut __lookbehind = Some(__loc); let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state10(arena, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state15(arena, __lookbehind, __lookahead, __tokens, __sym1)); + } + Some((_, Tok::Num(__tok0), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym1 = &mut Some((__tok0)); + let __lookahead = __tokens.next(); + __result = try!(__state16(arena, __lookbehind, __lookahead, __tokens, __sym1)); } Some((_, __tok @ Tok::LParen(..), __loc)) => { let mut __lookbehind = Some(__loc); let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state8(arena, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state12(arena, __lookbehind, __lookahead, __tokens, __sym1)); } _ => { return Err(__lookahead); @@ -681,15 +1011,15 @@ mod __parse__Expr { match __nt { __Nonterminal::Expr(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state20(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); - } - __Nonterminal::Factor(__nt) => { - let __sym1 = &mut Some(__nt); - __result = try!(__state7(arena, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state24(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); } __Nonterminal::Term(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state12(arena, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state14(arena, __lookbehind, __lookahead, __tokens, __sym1)); + } + __Nonterminal::Factor(__nt) => { + let __sym1 = &mut Some(__nt); + __result = try!(__state11(arena, __lookbehind, __lookahead, __tokens, __sym1)); } _ => { return Ok((__lookbehind, __lookahead, __nt)); @@ -699,99 +1029,7 @@ mod __parse__Expr { return Ok(__result); } - // State 9 - // Term = "Num" (*) [")"] - // Term = "Num" (*) ["*"] - // Term = "Num" (*) ["+"] - // Term = "Num" (*) ["-"] - // Term = "Num" (*) ["/"] - // - // "*" -> Reduce(Term = "Num" => Call(ActionFn(8));) - // ")" -> Reduce(Term = "Num" => Call(ActionFn(8));) - // "/" -> Reduce(Term = "Num" => Call(ActionFn(8));) - // "-" -> Reduce(Term = "Num" => Call(ActionFn(8));) - // "+" -> Reduce(Term = "Num" => Call(ActionFn(8));) - // - pub fn __state9< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize,Tok,usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> - { - let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, Tok::Times(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action8(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - Some((_, Tok::RParen(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action8(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - Some((_, Tok::Div(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action8(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action8(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - Some((_, Tok::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action8(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 10 - // Factor = "*" (*) "(" Comma ")" [")"] - // Factor = "*" (*) "(" Comma ")" ["*"] - // Factor = "*" (*) "(" Comma ")" ["+"] - // Factor = "*" (*) "(" Comma ")" ["-"] - // Factor = "*" (*) "(" Comma ")" ["/"] - // - // "(" -> Shift(S21) - // - pub fn __state10< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize,Tok,usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> - { - let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, __tok @ Tok::LParen(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym1 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state21(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 11 + // State 13 // Expr = Expr (*) "+" Factor [")"] // Expr = Expr (*) "+" Factor ["+"] // Expr = Expr (*) "+" Factor ["-"] @@ -804,11 +1042,11 @@ mod __parse__Expr { // Term = "(" Expr (*) ")" ["-"] // Term = "(" Expr (*) ")" ["/"] // - // ")" -> Shift(S22) - // "+" -> Shift(S24) - // "-" -> Shift(S23) + // "-" -> Shift(S26) + // ")" -> Shift(S25) + // "+" -> Shift(S27) // - pub fn __state11< + pub fn __state13< 'ast, __TOKENS: Iterator, >( @@ -822,23 +1060,23 @@ mod __parse__Expr { { let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { + Some((_, __tok @ Tok::Minus(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state26(arena, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); + } Some((_, __tok @ Tok::RParen(..), __loc)) => { let mut __lookbehind = Some(__loc); let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state22(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + __result = try!(__state25(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); } Some((_, __tok @ Tok::Plus(..), __loc)) => { let mut __lookbehind = Some(__loc); let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state24(arena, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); - } - Some((_, __tok @ Tok::Minus(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state23(arena, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); + __result = try!(__state27(arena, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); } _ => { return Err(__lookahead); @@ -847,200 +1085,19 @@ mod __parse__Expr { return Ok(__result); } - // State 12 - // Factor = Term (*) [")"] - // Factor = Term (*) ["*"] - // Factor = Term (*) ["+"] - // Factor = Term (*) ["-"] - // Factor = Term (*) ["/"] - // - // ")" -> Reduce(Factor = Term => Call(ActionFn(7));) - // "*" -> Reduce(Factor = Term => Call(ActionFn(7));) - // "/" -> Reduce(Factor = Term => Call(ActionFn(7));) - // "-" -> Reduce(Factor = Term => Call(ActionFn(7));) - // "+" -> Reduce(Factor = Term => Call(ActionFn(7));) - // - pub fn __state12< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize,Tok,usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> - { - let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, Tok::RParen(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action7(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Times(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action7(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Div(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action7(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action7(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action7(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 13 - // Expr = Expr "-" (*) Factor [EOF] - // Expr = Expr "-" (*) Factor ["+"] - // Expr = Expr "-" (*) Factor ["-"] - // Factor = (*) Factor "*" Term [EOF] - // Factor = (*) Factor "*" Term ["*"] - // Factor = (*) Factor "*" Term ["+"] - // Factor = (*) Factor "*" Term ["-"] - // Factor = (*) Factor "*" Term ["/"] - // Factor = (*) Factor "/" Term [EOF] - // Factor = (*) Factor "/" Term ["*"] - // Factor = (*) Factor "/" Term ["+"] - // Factor = (*) Factor "/" Term ["-"] - // Factor = (*) Factor "/" Term ["/"] - // Factor = (*) Term [EOF] - // Factor = (*) Term ["*"] - // Factor = (*) Term ["+"] - // Factor = (*) Term ["-"] - // Factor = (*) Term ["/"] - // Factor = (*) "*" "(" Comma ")" [EOF] - // Factor = (*) "*" "(" Comma ")" ["*"] - // Factor = (*) "*" "(" Comma ")" ["+"] - // Factor = (*) "*" "(" Comma ")" ["-"] - // Factor = (*) "*" "(" Comma ")" ["/"] - // Term = (*) "(" Expr ")" [EOF] - // Term = (*) "(" Expr ")" ["*"] - // Term = (*) "(" Expr ")" ["+"] - // Term = (*) "(" Expr ")" ["-"] - // Term = (*) "(" Expr ")" ["/"] - // Term = (*) "Num" [EOF] - // Term = (*) "Num" ["*"] - // Term = (*) "Num" ["+"] - // Term = (*) "Num" ["-"] - // Term = (*) "Num" ["/"] - // - // "(" -> Shift(S1) - // "Num" -> Shift(S6) - // "*" -> Shift(S5) - // - // Factor -> S25 - // Term -> S2 - pub fn __state13< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize,Tok,usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, - ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> - { - let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, __tok @ Tok::LParen(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state1(arena, __lookbehind, __lookahead, __tokens, __sym2)); - } - Some((_, Tok::Num(__tok0), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state6(arena, __lookbehind, __lookahead, __tokens, __sym2)); - } - Some((_, __tok @ Tok::Times(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state5(arena, __lookbehind, __lookahead, __tokens, __sym2)); - } - _ => { - return Err(__lookahead); - } - } - while __sym1.is_some() { - let (__lookbehind, __lookahead, __nt) = __result; - match __nt { - __Nonterminal::Factor(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state25(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - __Nonterminal::Term(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state2(arena, __lookbehind, __lookahead, __tokens, __sym2)); - } - _ => { - return Ok((__lookbehind, __lookahead, __nt)); - } - } - } - return Ok(__result); - } - // State 14 - // Expr = Expr "+" (*) Factor [EOF] - // Expr = Expr "+" (*) Factor ["+"] - // Expr = Expr "+" (*) Factor ["-"] - // Factor = (*) Factor "*" Term [EOF] - // Factor = (*) Factor "*" Term ["*"] - // Factor = (*) Factor "*" Term ["+"] - // Factor = (*) Factor "*" Term ["-"] - // Factor = (*) Factor "*" Term ["/"] - // Factor = (*) Factor "/" Term [EOF] - // Factor = (*) Factor "/" Term ["*"] - // Factor = (*) Factor "/" Term ["+"] - // Factor = (*) Factor "/" Term ["-"] - // Factor = (*) Factor "/" Term ["/"] - // Factor = (*) Term [EOF] - // Factor = (*) Term ["*"] - // Factor = (*) Term ["+"] - // Factor = (*) Term ["-"] - // Factor = (*) Term ["/"] - // 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" ["/"] + // Factor = Term (*) [")"] + // Factor = Term (*) ["*"] + // Factor = Term (*) ["+"] + // Factor = Term (*) ["-"] + // Factor = Term (*) ["/"] // - // "(" -> Shift(S1) - // "*" -> Shift(S5) - // "Num" -> Shift(S6) + // "*" -> Reduce(Factor = Term => Call(ActionFn(7));) + // "+" -> Reduce(Factor = Term => Call(ActionFn(7));) + // ")" -> Reduce(Factor = Term => Call(ActionFn(7));) + // "-" -> Reduce(Factor = Term => Call(ActionFn(7));) + // "/" -> Reduce(Factor = Term => Call(ActionFn(7));) // - // Term -> S2 - // Factor -> S26 pub fn __state14< 'ast, __TOKENS: Iterator, @@ -1050,73 +1107,50 @@ mod __parse__Expr { __lookahead: Option<(usize,Tok,usize)>, __tokens: &mut __TOKENS, __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> { let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some((_, __tok @ Tok::LParen(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state1(arena, __lookbehind, __lookahead, __tokens, __sym2)); + Some((_, Tok::Times(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action7(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } - Some((_, __tok @ Tok::Times(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state5(arena, __lookbehind, __lookahead, __tokens, __sym2)); + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action7(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } - Some((_, Tok::Num(__tok0), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state6(arena, __lookbehind, __lookahead, __tokens, __sym2)); + Some((_, Tok::RParen(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action7(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action7(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Div(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action7(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } _ => { return Err(__lookahead); } } - while __sym1.is_some() { - let (__lookbehind, __lookahead, __nt) = __result; - match __nt { - __Nonterminal::Term(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state2(arena, __lookbehind, __lookahead, __tokens, __sym2)); - } - __Nonterminal::Factor(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state26(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - _ => { - return Ok((__lookbehind, __lookahead, __nt)); - } - } - } - return Ok(__result); } // State 15 - // Factor = Factor "*" (*) Term [EOF] - // Factor = Factor "*" (*) Term ["*"] - // Factor = Factor "*" (*) Term ["+"] - // Factor = Factor "*" (*) Term ["-"] - // Factor = Factor "*" (*) Term ["/"] - // Term = (*) "(" Expr ")" [EOF] - // Term = (*) "(" Expr ")" ["*"] - // Term = (*) "(" Expr ")" ["+"] - // Term = (*) "(" Expr ")" ["-"] - // Term = (*) "(" Expr ")" ["/"] - // Term = (*) "Num" [EOF] - // Term = (*) "Num" ["*"] - // Term = (*) "Num" ["+"] - // Term = (*) "Num" ["-"] - // Term = (*) "Num" ["/"] + // Factor = "*" (*) "(" Comma ")" [")"] + // Factor = "*" (*) "(" Comma ")" ["*"] + // Factor = "*" (*) "(" Comma ")" ["+"] + // Factor = "*" (*) "(" Comma ")" ["-"] + // Factor = "*" (*) "(" Comma ")" ["/"] // - // "Num" -> Shift(S6) - // "(" -> Shift(S1) + // "(" -> Shift(S28) // - // Term -> S27 pub fn __state15< 'ast, __TOKENS: Iterator, @@ -1125,64 +1159,37 @@ mod __parse__Expr { __lookbehind: Option, __lookahead: Option<(usize,Tok,usize)>, __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, + __sym0: &mut Option, ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> { let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some((_, Tok::Num(__tok0), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state6(arena, __lookbehind, __lookahead, __tokens, __sym2)); - } Some((_, __tok @ Tok::LParen(..), __loc)) => { let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok)); + let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state1(arena, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state28(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); } _ => { return Err(__lookahead); } } - while __sym1.is_some() { - let (__lookbehind, __lookahead, __nt) = __result; - match __nt { - __Nonterminal::Term(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state27(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - _ => { - return Ok((__lookbehind, __lookahead, __nt)); - } - } - } return Ok(__result); } // State 16 - // 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" ["/"] + // Term = "Num" (*) [")"] + // Term = "Num" (*) ["*"] + // Term = "Num" (*) ["+"] + // Term = "Num" (*) ["-"] + // Term = "Num" (*) ["/"] // - // "Num" -> Shift(S6) - // "(" -> Shift(S1) + // ")" -> Reduce(Term = "Num" => Call(ActionFn(8));) + // "+" -> Reduce(Term = "Num" => Call(ActionFn(8));) + // "*" -> Reduce(Term = "Num" => Call(ActionFn(8));) + // "-" -> Reduce(Term = "Num" => Call(ActionFn(8));) + // "/" -> Reduce(Term = "Num" => Call(ActionFn(8));) // - // Term -> S28 pub fn __state16< 'ast, __TOKENS: Iterator, @@ -1191,41 +1198,40 @@ mod __parse__Expr { __lookbehind: Option, __lookahead: Option<(usize,Tok,usize)>, __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, + __sym0: &mut Option, ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> { let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some((_, Tok::Num(__tok0), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state6(arena, __lookbehind, __lookahead, __tokens, __sym2)); + Some((_, Tok::RParen(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action8(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); } - Some((_, __tok @ Tok::LParen(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state1(arena, __lookbehind, __lookahead, __tokens, __sym2)); + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action8(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + Some((_, Tok::Times(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action8(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action8(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + Some((_, Tok::Div(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action8(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); } _ => { return Err(__lookahead); } } - while __sym1.is_some() { - let (__lookbehind, __lookahead, __nt) = __result; - match __nt { - __Nonterminal::Term(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state28(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - _ => { - return Ok((__lookbehind, __lookahead, __nt)); - } - } - } - return Ok(__result); } // State 17 @@ -1246,11 +1252,11 @@ mod __parse__Expr { // // ")" -> Reduce(( ",")* = => Call(ActionFn(13));) // "Num" -> Reduce(( ",")* = => Call(ActionFn(13));) - // "(" -> Reduce(( ",")* = => Call(ActionFn(13));) // "*" -> Reduce(( ",")* = => Call(ActionFn(13));) + // "(" -> Reduce(( ",")* = => Call(ActionFn(13));) // - // ( ",")* -> S30 - // Comma -> S29 + // Comma -> S30 + // ( ",")* -> S29 pub fn __state17< 'ast, __TOKENS: Iterator, @@ -1273,11 +1279,11 @@ mod __parse__Expr { let __nt = super::__action13(arena, ); __result = (__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); } - Some((_, Tok::LParen(..), _)) => { + Some((_, Tok::Times(..), _)) => { let __nt = super::__action13(arena, ); __result = (__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); } - Some((_, Tok::Times(..), _)) => { + Some((_, Tok::LParen(..), _)) => { let __nt = super::__action13(arena, ); __result = (__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); } @@ -1288,13 +1294,13 @@ mod __parse__Expr { while __sym1.is_some() { let (__lookbehind, __lookahead, __nt) = __result; match __nt { - __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state30(arena, __lookbehind, __lookahead, __tokens, __sym2)); - } __Nonterminal::Comma_3cExpr_3e(__nt) => { let __sym2 = &mut Some(__nt); - __result = try!(__state29(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + __result = try!(__state30(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state29(arena, __lookbehind, __lookahead, __tokens, __sym2)); } _ => { return Ok((__lookbehind, __lookahead, __nt)); @@ -1305,11 +1311,301 @@ mod __parse__Expr { } // State 18 - // 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 ["/"] + // + // "*" -> Shift(S9) + // "/" -> Shift(S10) + // "+" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // "-" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // EOF -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // + pub fn __state18< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + __sym1: &mut Option, + __sym2: &mut Option<&'ast Node<'ast>>, + ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, __tok @ Tok::Times(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym3 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state9(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); + } + Some((_, __tok @ Tok::Div(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym3 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state10(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action1(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action1(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + None => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action1(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + _ => { + 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 ["/"] + // + // "/" -> Shift(S10) + // "+" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) + // "-" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) + // "*" -> Shift(S9) + // EOF -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) + // + pub fn __state19< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + __sym1: &mut Option, + __sym2: &mut Option<&'ast Node<'ast>>, + ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, __tok @ Tok::Div(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym3 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state10(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); + } + Some((_, __tok @ Tok::Times(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym3 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state9(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action2(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action2(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + None => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action2(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + + // State 20 + // Factor = Factor "*" Term (*) [EOF] + // Factor = Factor "*" Term (*) ["*"] + // Factor = Factor "*" Term (*) ["+"] + // Factor = Factor "*" Term (*) ["-"] + // Factor = Factor "*" Term (*) ["/"] + // + // "*" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // "/" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // "-" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // EOF -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // "+" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // + pub fn __state20< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + __sym1: &mut Option, + __sym2: &mut Option<&'ast Node<'ast>>, + ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, Tok::Times(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action4(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Div(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action4(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action4(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + None => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action4(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action4(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 21 + // Factor = Factor "/" Term (*) [EOF] + // Factor = Factor "/" Term (*) ["*"] + // Factor = Factor "/" Term (*) ["+"] + // Factor = Factor "/" Term (*) ["-"] + // Factor = Factor "/" Term (*) ["/"] + // + // EOF -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // "+" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // "/" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // "*" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // "-" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // + pub fn __state21< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + __sym1: &mut Option, + __sym2: &mut Option<&'ast Node<'ast>>, + ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + None => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action5(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action5(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Div(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action5(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Times(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action5(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action5(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 22 + // Factor = Factor "*" (*) Term [")"] + // Factor = Factor "*" (*) Term ["*"] + // Factor = Factor "*" (*) Term ["+"] + // Factor = Factor "*" (*) Term ["-"] + // Factor = Factor "*" (*) Term ["/"] // Term = (*) "(" Expr ")" [")"] // Term = (*) "(" Expr ")" ["*"] // Term = (*) "(" Expr ")" ["+"] @@ -1321,11 +1617,11 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "Num" -> Shift(S9) - // "(" -> Shift(S8) + // "Num" -> Shift(S16) + // "(" -> Shift(S12) // // Term -> S31 - pub fn __state18< + pub fn __state22< 'ast, __TOKENS: Iterator, >( @@ -1343,13 +1639,13 @@ mod __parse__Expr { let mut __lookbehind = Some(__loc); let mut __sym2 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state9(arena, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state16(arena, __lookbehind, __lookahead, __tokens, __sym2)); } Some((_, __tok @ Tok::LParen(..), __loc)) => { let mut __lookbehind = Some(__loc); let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state8(arena, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state12(arena, __lookbehind, __lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); @@ -1370,12 +1666,12 @@ mod __parse__Expr { return Ok(__result); } - // State 19 - // Factor = Factor "*" (*) Term [")"] - // Factor = Factor "*" (*) Term ["*"] - // Factor = Factor "*" (*) Term ["+"] - // Factor = Factor "*" (*) Term ["-"] - // Factor = Factor "*" (*) Term ["/"] + // State 23 + // Factor = Factor "/" (*) Term [")"] + // Factor = Factor "/" (*) Term ["*"] + // Factor = Factor "/" (*) Term ["+"] + // Factor = Factor "/" (*) Term ["-"] + // Factor = Factor "/" (*) Term ["/"] // Term = (*) "(" Expr ")" [")"] // Term = (*) "(" Expr ")" ["*"] // Term = (*) "(" Expr ")" ["+"] @@ -1387,11 +1683,11 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "Num" -> Shift(S9) - // "(" -> Shift(S8) + // "Num" -> Shift(S16) + // "(" -> Shift(S12) // // Term -> S32 - pub fn __state19< + pub fn __state23< 'ast, __TOKENS: Iterator, >( @@ -1409,13 +1705,13 @@ mod __parse__Expr { let mut __lookbehind = Some(__loc); let mut __sym2 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state9(arena, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state16(arena, __lookbehind, __lookahead, __tokens, __sym2)); } Some((_, __tok @ Tok::LParen(..), __loc)) => { let mut __lookbehind = Some(__loc); let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state8(arena, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state12(arena, __lookbehind, __lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); @@ -1436,7 +1732,7 @@ mod __parse__Expr { return Ok(__result); } - // State 20 + // State 24 // Expr = Expr (*) "+" Factor [")"] // Expr = Expr (*) "+" Factor ["+"] // Expr = Expr (*) "+" Factor ["-"] @@ -1449,11 +1745,11 @@ mod __parse__Expr { // Term = "(" Expr (*) ")" ["-"] // Term = "(" Expr (*) ")" ["/"] // + // "+" -> Shift(S27) // ")" -> Shift(S33) - // "-" -> Shift(S23) - // "+" -> Shift(S24) + // "-" -> Shift(S26) // - pub fn __state20< + pub fn __state24< 'ast, __TOKENS: Iterator, >( @@ -1467,6 +1763,12 @@ mod __parse__Expr { { let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { + Some((_, __tok @ Tok::Plus(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state27(arena, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); + } Some((_, __tok @ Tok::RParen(..), __loc)) => { let mut __lookbehind = Some(__loc); let mut __sym2 = &mut Some((__tok)); @@ -1477,13 +1779,7 @@ mod __parse__Expr { let mut __lookbehind = Some(__loc); let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state23(arena, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); - } - Some((_, __tok @ Tok::Plus(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state24(arena, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); + __result = try!(__state26(arena, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); } _ => { return Err(__lookahead); @@ -1492,96 +1788,20 @@ mod __parse__Expr { return Ok(__result); } - // State 21 - // ( ",")* = (*) ["("] - // ( ",")* = (*) [")"] - // ( ",")* = (*) ["*"] - // ( ",")* = (*) ["Num"] - // ( ",")* = (*) ( ",")* ( ",") ["("] - // ( ",")* = (*) ( ",")* ( ",") [")"] - // ( ",")* = (*) ( ",")* ( ",") ["*"] - // ( ",")* = (*) ( ",")* ( ",") ["Num"] - // Comma = (*) ( ",")* Expr? [")"] - // Factor = "*" "(" (*) Comma ")" [")"] - // Factor = "*" "(" (*) Comma ")" ["*"] - // Factor = "*" "(" (*) Comma ")" ["+"] - // Factor = "*" "(" (*) Comma ")" ["-"] - // Factor = "*" "(" (*) Comma ")" ["/"] - // - // ")" -> Reduce(( ",")* = => Call(ActionFn(13));) - // "Num" -> Reduce(( ",")* = => Call(ActionFn(13));) - // "(" -> Reduce(( ",")* = => Call(ActionFn(13));) - // "*" -> Reduce(( ",")* = => Call(ActionFn(13));) - // - // ( ",")* -> S30 - // Comma -> S34 - pub fn __state21< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize,Tok,usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option, - ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> - { - let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, Tok::RParen(..), _)) => { - let __nt = super::__action13(arena, ); - __result = (__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); - } - Some((_, Tok::Num(_), _)) => { - let __nt = super::__action13(arena, ); - __result = (__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); - } - Some((_, Tok::LParen(..), _)) => { - let __nt = super::__action13(arena, ); - __result = (__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); - } - Some((_, Tok::Times(..), _)) => { - let __nt = super::__action13(arena, ); - __result = (__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); - } - _ => { - return Err(__lookahead); - } - } - while __sym1.is_some() { - let (__lookbehind, __lookahead, __nt) = __result; - match __nt { - __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state30(arena, __lookbehind, __lookahead, __tokens, __sym2)); - } - __Nonterminal::Comma_3cExpr_3e(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state34(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - _ => { - return Ok((__lookbehind, __lookahead, __nt)); - } - } - } - return Ok(__result); - } - - // State 22 + // State 25 // Term = "(" Expr ")" (*) [EOF] // Term = "(" Expr ")" (*) ["*"] // Term = "(" Expr ")" (*) ["+"] // Term = "(" Expr ")" (*) ["-"] // Term = "(" Expr ")" (*) ["/"] // - // "*" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) - // "/" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) // "-" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) - // EOF -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) + // "*" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) // "+" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) + // EOF -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) + // "/" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) // - pub fn __state22< + pub fn __state25< 'ast, __TOKENS: Iterator, >( @@ -1596,20 +1816,6 @@ mod __parse__Expr { { let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some((_, Tok::Times(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action9(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - Some((_, Tok::Div(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action9(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } Some((_, Tok::Minus(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); @@ -1617,7 +1823,7 @@ mod __parse__Expr { let __nt = super::__action9(arena, __sym0, __sym1, __sym2); return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); } - None => { + Some((_, Tok::Times(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); @@ -1631,13 +1837,27 @@ mod __parse__Expr { let __nt = super::__action9(arena, __sym0, __sym1, __sym2); return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); } + None => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action9(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + Some((_, Tok::Div(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action9(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } _ => { return Err(__lookahead); } } } - // State 23 + // State 26 // Expr = Expr "-" (*) Factor [")"] // Expr = Expr "-" (*) Factor ["+"] // Expr = Expr "-" (*) Factor ["-"] @@ -1672,13 +1892,13 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "Num" -> Shift(S9) - // "*" -> Shift(S10) - // "(" -> Shift(S8) + // "*" -> Shift(S15) + // "Num" -> Shift(S16) + // "(" -> Shift(S12) // - // Term -> S12 - // Factor -> S35 - pub fn __state23< + // Term -> S14 + // Factor -> S34 + pub fn __state26< 'ast, __TOKENS: Iterator, >( @@ -1692,23 +1912,23 @@ mod __parse__Expr { { let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some((_, Tok::Num(__tok0), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state9(arena, __lookbehind, __lookahead, __tokens, __sym2)); - } Some((_, __tok @ Tok::Times(..), __loc)) => { let mut __lookbehind = Some(__loc); let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state10(arena, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state15(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + Some((_, Tok::Num(__tok0), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok0)); + let __lookahead = __tokens.next(); + __result = try!(__state16(arena, __lookbehind, __lookahead, __tokens, __sym2)); } Some((_, __tok @ Tok::LParen(..), __loc)) => { let mut __lookbehind = Some(__loc); let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state8(arena, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state12(arena, __lookbehind, __lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); @@ -1719,11 +1939,11 @@ mod __parse__Expr { match __nt { __Nonterminal::Term(__nt) => { let __sym2 = &mut Some(__nt); - __result = try!(__state12(arena, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state14(arena, __lookbehind, __lookahead, __tokens, __sym2)); } __Nonterminal::Factor(__nt) => { let __sym2 = &mut Some(__nt); - __result = try!(__state35(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + __result = try!(__state34(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); } _ => { return Ok((__lookbehind, __lookahead, __nt)); @@ -1733,7 +1953,7 @@ mod __parse__Expr { return Ok(__result); } - // State 24 + // State 27 // Expr = Expr "+" (*) Factor [")"] // Expr = Expr "+" (*) Factor ["+"] // Expr = Expr "+" (*) Factor ["-"] @@ -1768,13 +1988,13 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "*" -> Shift(S10) - // "(" -> Shift(S8) - // "Num" -> Shift(S9) + // "Num" -> Shift(S16) + // "(" -> Shift(S12) + // "*" -> Shift(S15) // - // Term -> S12 - // Factor -> S36 - pub fn __state24< + // Factor -> S35 + // Term -> S14 + pub fn __state27< 'ast, __TOKENS: Iterator, >( @@ -1788,23 +2008,23 @@ mod __parse__Expr { { let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some((_, __tok @ Tok::Times(..), __loc)) => { + Some((_, Tok::Num(__tok0), __loc)) => { let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok)); + let mut __sym2 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state10(arena, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state16(arena, __lookbehind, __lookahead, __tokens, __sym2)); } Some((_, __tok @ Tok::LParen(..), __loc)) => { let mut __lookbehind = Some(__loc); let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state8(arena, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state12(arena, __lookbehind, __lookahead, __tokens, __sym2)); } - Some((_, Tok::Num(__tok0), __loc)) => { + Some((_, __tok @ Tok::Times(..), __loc)) => { let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok0)); + let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state9(arena, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state15(arena, __lookbehind, __lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); @@ -1813,11 +2033,87 @@ mod __parse__Expr { while __sym1.is_some() { let (__lookbehind, __lookahead, __nt) = __result; match __nt { + __Nonterminal::Factor(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state35(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } __Nonterminal::Term(__nt) => { let __sym2 = &mut Some(__nt); - __result = try!(__state12(arena, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state14(arena, __lookbehind, __lookahead, __tokens, __sym2)); } - __Nonterminal::Factor(__nt) => { + _ => { + return Ok((__lookbehind, __lookahead, __nt)); + } + } + } + return Ok(__result); + } + + // State 28 + // ( ",")* = (*) ["("] + // ( ",")* = (*) [")"] + // ( ",")* = (*) ["*"] + // ( ",")* = (*) ["Num"] + // ( ",")* = (*) ( ",")* ( ",") ["("] + // ( ",")* = (*) ( ",")* ( ",") [")"] + // ( ",")* = (*) ( ",")* ( ",") ["*"] + // ( ",")* = (*) ( ",")* ( ",") ["Num"] + // Comma = (*) ( ",")* Expr? [")"] + // Factor = "*" "(" (*) Comma ")" [")"] + // Factor = "*" "(" (*) Comma ")" ["*"] + // Factor = "*" "(" (*) Comma ")" ["+"] + // Factor = "*" "(" (*) Comma ")" ["-"] + // Factor = "*" "(" (*) Comma ")" ["/"] + // + // "(" -> Reduce(( ",")* = => Call(ActionFn(13));) + // ")" -> Reduce(( ",")* = => Call(ActionFn(13));) + // "*" -> Reduce(( ",")* = => Call(ActionFn(13));) + // "Num" -> Reduce(( ",")* = => Call(ActionFn(13));) + // + // ( ",")* -> S29 + // Comma -> S36 + pub fn __state28< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + __sym1: &mut Option, + ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, Tok::LParen(..), _)) => { + let __nt = super::__action13(arena, ); + __result = (__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); + } + Some((_, Tok::RParen(..), _)) => { + let __nt = super::__action13(arena, ); + __result = (__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); + } + Some((_, Tok::Times(..), _)) => { + let __nt = super::__action13(arena, ); + __result = (__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); + } + Some((_, Tok::Num(_), _)) => { + let __nt = super::__action13(arena, ); + __result = (__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); + } + _ => { + return Err(__lookahead); + } + } + while __sym1.is_some() { + let (__lookbehind, __lookahead, __nt) = __result; + match __nt { + __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state29(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + __Nonterminal::Comma_3cExpr_3e(__nt) => { let __sym2 = &mut Some(__nt); __result = try!(__state36(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); } @@ -1829,334 +2125,7 @@ mod __parse__Expr { return Ok(__result); } - // State 25 - // 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 => Call(ActionFn(1));) - // "-" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) - // EOF -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) - // "/" -> Shift(S16) - // "*" -> Shift(S15) - // - pub fn __state25< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize,Tok,usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, - __sym2: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> - { - let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, __tok @ Tok::Div(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym3 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state16(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); - } - Some((_, __tok @ Tok::Times(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym3 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state15(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); - } - Some((_, Tok::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action1(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action1(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - None => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action1(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 26 - // 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 => Call(ActionFn(2));) - // EOF -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) - // "+" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) - // "*" -> Shift(S15) - // "/" -> Shift(S16) - // - pub fn __state26< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize,Tok,usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, - __sym2: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> - { - let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, __tok @ Tok::Times(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym3 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state15(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); - } - Some((_, __tok @ Tok::Div(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym3 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state16(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); - } - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action2(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - None => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action2(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - Some((_, Tok::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action2(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 27 - // Factor = Factor "*" Term (*) [EOF] - // Factor = Factor "*" Term (*) ["*"] - // Factor = Factor "*" Term (*) ["+"] - // Factor = Factor "*" Term (*) ["-"] - // Factor = Factor "*" Term (*) ["/"] - // - // "-" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) - // "/" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) - // EOF -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) - // "*" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) - // "+" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) - // - pub fn __state27< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize,Tok,usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, - __sym2: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> - { - let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Div(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - None => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Times(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 28 - // Factor = Factor "/" Term (*) [EOF] - // Factor = Factor "/" Term (*) ["*"] - // Factor = Factor "/" Term (*) ["+"] - // Factor = Factor "/" Term (*) ["-"] - // Factor = Factor "/" Term (*) ["/"] - // - // "-" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // "/" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // "+" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // EOF -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // "*" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // - pub fn __state28< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize,Tok,usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, - __sym2: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> - { - let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action5(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Div(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action5(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action5(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - None => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action5(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Times(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action5(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - // State 29 - // Factor = "*" "(" Comma (*) ")" [EOF] - // Factor = "*" "(" Comma (*) ")" ["*"] - // Factor = "*" "(" Comma (*) ")" ["+"] - // Factor = "*" "(" Comma (*) ")" ["-"] - // Factor = "*" "(" Comma (*) ")" ["/"] - // - // ")" -> Shift(S37) - // - pub fn __state29< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize,Tok,usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option, - __sym2: &mut Option>>, - ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> - { - let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, __tok @ Tok::RParen(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym3 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state37(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2, __sym3)); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 30 // ( ",") = (*) Expr "," ["("] // ( ",") = (*) Expr "," [")"] // ( ",") = (*) Expr "," ["*"] @@ -2217,17 +2186,17 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "(" -> Shift(S45) // ")" -> Reduce(Expr? = => Call(ActionFn(12));) - // "Num" -> Shift(S41) - // "*" -> Shift(S40) + // "Num" -> Shift(S38) + // "(" -> Shift(S37) + // "*" -> Shift(S39) // - // Expr? -> S39 - // ( ",") -> S42 - // Factor -> S44 - // Expr -> S38 + // ( ",") -> S41 + // Expr? -> S42 // Term -> S43 - pub fn __state30< + // Expr -> S40 + // Factor -> S44 + pub fn __state29< 'ast, __TOKENS: Iterator, >( @@ -2240,23 +2209,23 @@ mod __parse__Expr { { let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some((_, __tok @ Tok::LParen(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym1 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state45(arena, __lookbehind, __lookahead, __tokens, __sym1)); - } Some((_, Tok::Num(__tok0), __loc)) => { let mut __lookbehind = Some(__loc); let mut __sym1 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state41(arena, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state38(arena, __lookbehind, __lookahead, __tokens, __sym1)); + } + Some((_, __tok @ Tok::LParen(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state37(arena, __lookbehind, __lookahead, __tokens, __sym1)); } Some((_, __tok @ Tok::Times(..), __loc)) => { let mut __lookbehind = Some(__loc); let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state40(arena, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state39(arena, __lookbehind, __lookahead, __tokens, __sym1)); } Some((_, Tok::RParen(..), _)) => { let __nt = super::__action12(arena, ); @@ -2269,26 +2238,26 @@ mod __parse__Expr { while __sym0.is_some() { let (__lookbehind, __lookahead, __nt) = __result; match __nt { - __Nonterminal::Expr_3f(__nt) => { - let __sym1 = &mut Some(__nt); - __result = try!(__state39(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); - } __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29(__nt) => { + let __sym1 = &mut Some(__nt); + __result = try!(__state41(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + } + __Nonterminal::Expr_3f(__nt) => { let __sym1 = &mut Some(__nt); __result = try!(__state42(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); } - __Nonterminal::Factor(__nt) => { - let __sym1 = &mut Some(__nt); - __result = try!(__state44(arena, __lookbehind, __lookahead, __tokens, __sym1)); - } - __Nonterminal::Expr(__nt) => { - let __sym1 = &mut Some(__nt); - __result = try!(__state38(arena, __lookbehind, __lookahead, __tokens, __sym1)); - } __Nonterminal::Term(__nt) => { let __sym1 = &mut Some(__nt); __result = try!(__state43(arena, __lookbehind, __lookahead, __tokens, __sym1)); } + __Nonterminal::Expr(__nt) => { + let __sym1 = &mut Some(__nt); + __result = try!(__state40(arena, __lookbehind, __lookahead, __tokens, __sym1)); + } + __Nonterminal::Factor(__nt) => { + let __sym1 = &mut Some(__nt); + __result = try!(__state44(arena, __lookbehind, __lookahead, __tokens, __sym1)); + } _ => { return Ok((__lookbehind, __lookahead, __nt)); } @@ -2297,18 +2266,55 @@ mod __parse__Expr { return Ok(__result); } - // State 31 - // Factor = Factor "/" Term (*) [")"] - // Factor = Factor "/" Term (*) ["*"] - // Factor = Factor "/" Term (*) ["+"] - // Factor = Factor "/" Term (*) ["-"] - // Factor = Factor "/" Term (*) ["/"] + // State 30 + // Factor = "*" "(" Comma (*) ")" [EOF] + // Factor = "*" "(" Comma (*) ")" ["*"] + // Factor = "*" "(" Comma (*) ")" ["+"] + // Factor = "*" "(" Comma (*) ")" ["-"] + // Factor = "*" "(" Comma (*) ")" ["/"] // - // "+" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // "/" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // ")" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // "*" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // "-" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // ")" -> Shift(S45) + // + pub fn __state30< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + __sym1: &mut Option, + __sym2: &mut Option>>, + ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, __tok @ Tok::RParen(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym3 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state45(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2, __sym3)); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + + // State 31 + // Factor = Factor "*" Term (*) [")"] + // Factor = Factor "*" Term (*) ["*"] + // Factor = Factor "*" Term (*) ["+"] + // Factor = Factor "*" Term (*) ["-"] + // Factor = Factor "*" Term (*) ["/"] + // + // "*" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // "/" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // ")" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // "-" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // "+" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) // pub fn __state31< 'ast, @@ -2325,39 +2331,39 @@ mod __parse__Expr { { let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some((_, Tok::Plus(..), _)) => { + Some((_, Tok::Times(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action5(arena, __sym0, __sym1, __sym2); + let __nt = super::__action4(arena, __sym0, __sym1, __sym2); return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } Some((_, Tok::Div(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action5(arena, __sym0, __sym1, __sym2); + let __nt = super::__action4(arena, __sym0, __sym1, __sym2); return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } Some((_, Tok::RParen(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action5(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Times(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action5(arena, __sym0, __sym1, __sym2); + let __nt = super::__action4(arena, __sym0, __sym1, __sym2); return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } Some((_, Tok::Minus(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action5(arena, __sym0, __sym1, __sym2); + let __nt = super::__action4(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action4(arena, __sym0, __sym1, __sym2); return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } _ => { @@ -2367,17 +2373,17 @@ mod __parse__Expr { } // State 32 - // 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 => Call(ActionFn(4));) - // "*" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) - // "+" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) - // ")" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) - // "-" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // "/" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // ")" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // "*" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // "-" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // "+" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) // pub fn __state32< 'ast, @@ -2398,35 +2404,35 @@ mod __parse__Expr { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Times(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action4(arena, __sym0, __sym1, __sym2); + let __nt = super::__action5(arena, __sym0, __sym1, __sym2); return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } Some((_, Tok::RParen(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action4(arena, __sym0, __sym1, __sym2); + let __nt = super::__action5(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Times(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action5(arena, __sym0, __sym1, __sym2); return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } Some((_, Tok::Minus(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action4(arena, __sym0, __sym1, __sym2); + let __nt = super::__action5(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action5(arena, __sym0, __sym1, __sym2); return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } _ => { @@ -2442,11 +2448,11 @@ mod __parse__Expr { // Term = "(" Expr ")" (*) ["-"] // Term = "(" Expr ")" (*) ["/"] // - // "*" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) - // "-" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) - // ")" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) // "+" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) // "/" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) + // "-" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) + // "*" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) + // ")" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) // pub fn __state33< 'ast, @@ -2463,27 +2469,6 @@ mod __parse__Expr { { let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some((_, Tok::Times(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action9(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action9(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - Some((_, Tok::RParen(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action9(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } Some((_, Tok::Plus(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); @@ -2498,6 +2483,27 @@ mod __parse__Expr { let __nt = super::__action9(arena, __sym0, __sym1, __sym2); return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action9(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + Some((_, Tok::Times(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action9(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + Some((_, Tok::RParen(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action9(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } _ => { return Err(__lookahead); } @@ -2505,6 +2511,158 @@ mod __parse__Expr { } // State 34 + // Expr = Expr "-" Factor (*) [")"] + // Expr = Expr "-" Factor (*) ["+"] + // Expr = Expr "-" Factor (*) ["-"] + // Factor = Factor (*) "*" Term [")"] + // Factor = Factor (*) "*" Term ["*"] + // Factor = Factor (*) "*" Term ["+"] + // Factor = Factor (*) "*" Term ["-"] + // Factor = Factor (*) "*" Term ["/"] + // Factor = Factor (*) "/" Term [")"] + // Factor = Factor (*) "/" Term ["*"] + // Factor = Factor (*) "/" Term ["+"] + // Factor = Factor (*) "/" Term ["-"] + // Factor = Factor (*) "/" Term ["/"] + // + // "/" -> Shift(S23) + // "*" -> Shift(S22) + // "-" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // ")" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // "+" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // + pub fn __state34< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + __sym1: &mut Option, + __sym2: &mut Option<&'ast Node<'ast>>, + ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, __tok @ Tok::Div(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym3 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state23(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); + } + Some((_, __tok @ Tok::Times(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym3 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state22(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action1(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + Some((_, Tok::RParen(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action1(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action1(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + + // State 35 + // Expr = Expr "+" Factor (*) [")"] + // Expr = Expr "+" Factor (*) ["+"] + // Expr = Expr "+" Factor (*) ["-"] + // Factor = Factor (*) "*" Term [")"] + // Factor = Factor (*) "*" Term ["*"] + // Factor = Factor (*) "*" Term ["+"] + // Factor = Factor (*) "*" Term ["-"] + // Factor = Factor (*) "*" Term ["/"] + // Factor = Factor (*) "/" Term [")"] + // Factor = Factor (*) "/" Term ["*"] + // Factor = Factor (*) "/" Term ["+"] + // Factor = Factor (*) "/" Term ["-"] + // Factor = Factor (*) "/" Term ["/"] + // + // "/" -> Shift(S23) + // "+" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) + // ")" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) + // "*" -> Shift(S22) + // "-" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) + // + pub fn __state35< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + __sym1: &mut Option, + __sym2: &mut Option<&'ast Node<'ast>>, + ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, __tok @ Tok::Div(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym3 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state23(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); + } + Some((_, __tok @ Tok::Times(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym3 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state22(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action2(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + Some((_, Tok::RParen(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action2(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action2(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + + // State 36 // Factor = "*" "(" Comma (*) ")" [")"] // Factor = "*" "(" Comma (*) ")" ["*"] // Factor = "*" "(" Comma (*) ")" ["+"] @@ -2513,7 +2671,7 @@ mod __parse__Expr { // // ")" -> Shift(S46) // - pub fn __state34< + pub fn __state36< 'ast, __TOKENS: Iterator, >( @@ -2541,624 +2699,7 @@ mod __parse__Expr { return Ok(__result); } - // State 35 - // Expr = Expr "-" Factor (*) [")"] - // Expr = Expr "-" Factor (*) ["+"] - // Expr = Expr "-" Factor (*) ["-"] - // Factor = Factor (*) "*" Term [")"] - // Factor = Factor (*) "*" Term ["*"] - // Factor = Factor (*) "*" Term ["+"] - // Factor = Factor (*) "*" Term ["-"] - // Factor = Factor (*) "*" Term ["/"] - // Factor = Factor (*) "/" Term [")"] - // Factor = Factor (*) "/" Term ["*"] - // Factor = Factor (*) "/" Term ["+"] - // Factor = Factor (*) "/" Term ["-"] - // Factor = Factor (*) "/" Term ["/"] - // - // "/" -> Shift(S18) - // "-" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) - // ")" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) - // "+" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) - // "*" -> Shift(S19) - // - pub fn __state35< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize,Tok,usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, - __sym2: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> - { - let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, __tok @ Tok::Div(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym3 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state18(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); - } - Some((_, __tok @ Tok::Times(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym3 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state19(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); - } - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action1(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - Some((_, Tok::RParen(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action1(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - Some((_, Tok::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action1(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 36 - // Expr = Expr "+" Factor (*) [")"] - // Expr = Expr "+" Factor (*) ["+"] - // Expr = Expr "+" Factor (*) ["-"] - // Factor = Factor (*) "*" Term [")"] - // Factor = Factor (*) "*" Term ["*"] - // Factor = Factor (*) "*" Term ["+"] - // Factor = Factor (*) "*" Term ["-"] - // Factor = Factor (*) "*" Term ["/"] - // Factor = Factor (*) "/" Term [")"] - // Factor = Factor (*) "/" Term ["*"] - // Factor = Factor (*) "/" Term ["+"] - // Factor = Factor (*) "/" Term ["-"] - // Factor = Factor (*) "/" Term ["/"] - // - // "*" -> Shift(S19) - // "+" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) - // "/" -> Shift(S18) - // "-" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) - // ")" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) - // - pub fn __state36< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize,Tok,usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, - __sym2: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> - { - let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, __tok @ Tok::Times(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym3 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state19(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); - } - Some((_, __tok @ Tok::Div(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym3 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state18(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); - } - Some((_, Tok::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action2(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action2(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - Some((_, Tok::RParen(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action2(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - // State 37 - // Factor = "*" "(" Comma ")" (*) [EOF] - // Factor = "*" "(" Comma ")" (*) ["*"] - // Factor = "*" "(" Comma ")" (*) ["+"] - // Factor = "*" "(" Comma ")" (*) ["-"] - // Factor = "*" "(" Comma ")" (*) ["/"] - // - // "*" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) - // "/" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) - // "-" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) - // EOF -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) - // "+" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) - // - pub fn __state37< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize,Tok,usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option, - __sym2: &mut Option>>, - __sym3: &mut Option, - ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> - { - let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, Tok::Times(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __sym3 = __sym3.take().unwrap(); - let __nt = super::__action6(arena, __sym0, __sym1, __sym2, __sym3); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Div(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __sym3 = __sym3.take().unwrap(); - let __nt = super::__action6(arena, __sym0, __sym1, __sym2, __sym3); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __sym3 = __sym3.take().unwrap(); - let __nt = super::__action6(arena, __sym0, __sym1, __sym2, __sym3); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - None => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __sym3 = __sym3.take().unwrap(); - let __nt = super::__action6(arena, __sym0, __sym1, __sym2, __sym3); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __sym3 = __sym3.take().unwrap(); - let __nt = super::__action6(arena, __sym0, __sym1, __sym2, __sym3); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 38 - // ( ",") = 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(S47) - // ")" -> Reduce(Expr? = Expr => Call(ActionFn(11));) - // "," -> Shift(S49) - // "-" -> Shift(S48) - // - pub fn __state38< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize,Tok,usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> - { - let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, __tok @ Tok::Plus(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym1 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state47(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); - } - Some((_, __tok @ Tok::Comma(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym1 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state49(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); - } - Some((_, __tok @ Tok::Minus(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym1 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state48(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); - } - Some((_, Tok::RParen(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action11(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr_3f(__nt))); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 39 - // Comma = ( ",")* Expr? (*) [")"] - // - // ")" -> Reduce(Comma = ( ",")*, Expr? => Call(ActionFn(10));) - // - pub fn __state39< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize,Tok,usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option<::std::vec::Vec<&'ast Node<'ast>>>, - __sym1: &mut Option<::std::option::Option<&'ast Node<'ast>>>, - ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> - { - let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, Tok::RParen(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __nt = super::__action10(arena, __sym0, __sym1); - return Ok((__lookbehind, __lookahead, __Nonterminal::Comma_3cExpr_3e(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 40 - // Factor = "*" (*) "(" Comma ")" [")"] - // Factor = "*" (*) "(" Comma ")" ["*"] - // Factor = "*" (*) "(" Comma ")" ["+"] - // Factor = "*" (*) "(" Comma ")" [","] - // Factor = "*" (*) "(" Comma ")" ["-"] - // Factor = "*" (*) "(" Comma ")" ["/"] - // - // "(" -> Shift(S50) - // - pub fn __state40< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize,Tok,usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> - { - let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, __tok @ Tok::LParen(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym1 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state50(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 41 - // Term = "Num" (*) [")"] - // Term = "Num" (*) ["*"] - // Term = "Num" (*) ["+"] - // Term = "Num" (*) [","] - // Term = "Num" (*) ["-"] - // Term = "Num" (*) ["/"] - // - // "," -> Reduce(Term = "Num" => Call(ActionFn(8));) - // "+" -> Reduce(Term = "Num" => Call(ActionFn(8));) - // ")" -> Reduce(Term = "Num" => Call(ActionFn(8));) - // "-" -> Reduce(Term = "Num" => Call(ActionFn(8));) - // "*" -> Reduce(Term = "Num" => Call(ActionFn(8));) - // "/" -> Reduce(Term = "Num" => Call(ActionFn(8));) - // - pub fn __state41< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize,Tok,usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> - { - let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, Tok::Comma(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action8(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - Some((_, Tok::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action8(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - Some((_, Tok::RParen(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action8(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action8(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - Some((_, Tok::Times(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action8(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - Some((_, Tok::Div(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action8(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 42 - // ( ",")* = ( ",")* ( ",") (*) ["("] - // ( ",")* = ( ",")* ( ",") (*) [")"] - // ( ",")* = ( ",")* ( ",") (*) ["*"] - // ( ",")* = ( ",")* ( ",") (*) ["Num"] - // - // "Num" -> Reduce(( ",")* = ( ",")*, ( ",") => Call(ActionFn(14));) - // "(" -> Reduce(( ",")* = ( ",")*, ( ",") => Call(ActionFn(14));) - // ")" -> Reduce(( ",")* = ( ",")*, ( ",") => Call(ActionFn(14));) - // "*" -> Reduce(( ",")* = ( ",")*, ( ",") => Call(ActionFn(14));) - // - pub fn __state42< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize,Tok,usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option<::std::vec::Vec<&'ast Node<'ast>>>, - __sym1: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> - { - let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, Tok::Num(_), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __nt = super::__action14(arena, __sym0, __sym1); - return Ok((__lookbehind, __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::__action14(arena, __sym0, __sym1); - return Ok((__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt))); - } - Some((_, Tok::RParen(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __nt = super::__action14(arena, __sym0, __sym1); - return Ok((__lookbehind, __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::__action14(arena, __sym0, __sym1); - return Ok((__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 43 - // Factor = Term (*) [")"] - // Factor = Term (*) ["*"] - // Factor = Term (*) ["+"] - // Factor = Term (*) [","] - // Factor = Term (*) ["-"] - // Factor = Term (*) ["/"] - // - // "," -> Reduce(Factor = Term => Call(ActionFn(7));) - // ")" -> Reduce(Factor = Term => Call(ActionFn(7));) - // "+" -> Reduce(Factor = Term => Call(ActionFn(7));) - // "*" -> Reduce(Factor = Term => Call(ActionFn(7));) - // "-" -> Reduce(Factor = Term => Call(ActionFn(7));) - // "/" -> Reduce(Factor = Term => Call(ActionFn(7));) - // - pub fn __state43< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize,Tok,usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> - { - let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, Tok::Comma(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action7(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::RParen(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action7(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action7(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Times(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action7(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action7(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Div(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action7(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // 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 => Call(ActionFn(3));) - // "," -> Reduce(Expr = Factor => Call(ActionFn(3));) - // ")" -> Reduce(Expr = Factor => Call(ActionFn(3));) - // "/" -> Shift(S51) - // "-" -> Reduce(Expr = Factor => Call(ActionFn(3));) - // "*" -> Shift(S52) - // - pub fn __state44< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize,Tok,usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> - { - let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, __tok @ Tok::Div(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym1 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state51(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); - } - Some((_, __tok @ Tok::Times(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym1 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state52(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); - } - Some((_, Tok::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action3(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - Some((_, Tok::Comma(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action3(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - Some((_, Tok::RParen(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action3(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action3(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 45 // Expr = (*) Expr "+" Factor [")"] // Expr = (*) Expr "+" Factor ["+"] // Expr = (*) Expr "+" Factor ["-"] @@ -3205,14 +2746,14 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "*" -> Shift(S10) - // "(" -> Shift(S8) - // "Num" -> Shift(S9) + // "Num" -> Shift(S16) + // "(" -> Shift(S12) + // "*" -> Shift(S15) // - // Expr -> S53 - // Term -> S12 - // Factor -> S7 - pub fn __state45< + // Expr -> S47 + // Term -> S14 + // Factor -> S11 + pub fn __state37< 'ast, __TOKENS: Iterator, >( @@ -3225,23 +2766,23 @@ mod __parse__Expr { { let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some((_, __tok @ Tok::Times(..), __loc)) => { + Some((_, Tok::Num(__tok0), __loc)) => { let mut __lookbehind = Some(__loc); - let mut __sym1 = &mut Some((__tok)); + let mut __sym1 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state10(arena, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state16(arena, __lookbehind, __lookahead, __tokens, __sym1)); } Some((_, __tok @ Tok::LParen(..), __loc)) => { let mut __lookbehind = Some(__loc); let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state8(arena, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state12(arena, __lookbehind, __lookahead, __tokens, __sym1)); } - Some((_, Tok::Num(__tok0), __loc)) => { + Some((_, __tok @ Tok::Times(..), __loc)) => { let mut __lookbehind = Some(__loc); - let mut __sym1 = &mut Some((__tok0)); + let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state9(arena, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state15(arena, __lookbehind, __lookahead, __tokens, __sym1)); } _ => { return Err(__lookahead); @@ -3252,15 +2793,15 @@ mod __parse__Expr { match __nt { __Nonterminal::Expr(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state53(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + __result = try!(__state47(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); } __Nonterminal::Term(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state12(arena, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state14(arena, __lookbehind, __lookahead, __tokens, __sym1)); } __Nonterminal::Factor(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state7(arena, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state11(arena, __lookbehind, __lookahead, __tokens, __sym1)); } _ => { return Ok((__lookbehind, __lookahead, __nt)); @@ -3270,6 +2811,471 @@ mod __parse__Expr { return Ok(__result); } + // State 38 + // Term = "Num" (*) [")"] + // Term = "Num" (*) ["*"] + // Term = "Num" (*) ["+"] + // Term = "Num" (*) [","] + // Term = "Num" (*) ["-"] + // Term = "Num" (*) ["/"] + // + // "*" -> Reduce(Term = "Num" => Call(ActionFn(8));) + // ")" -> Reduce(Term = "Num" => Call(ActionFn(8));) + // "/" -> Reduce(Term = "Num" => Call(ActionFn(8));) + // "," -> Reduce(Term = "Num" => Call(ActionFn(8));) + // "-" -> Reduce(Term = "Num" => Call(ActionFn(8));) + // "+" -> Reduce(Term = "Num" => Call(ActionFn(8));) + // + pub fn __state38< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, Tok::Times(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action8(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + Some((_, Tok::RParen(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action8(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + Some((_, Tok::Div(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action8(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + Some((_, Tok::Comma(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action8(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action8(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action8(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 39 + // Factor = "*" (*) "(" Comma ")" [")"] + // Factor = "*" (*) "(" Comma ")" ["*"] + // Factor = "*" (*) "(" Comma ")" ["+"] + // Factor = "*" (*) "(" Comma ")" [","] + // Factor = "*" (*) "(" Comma ")" ["-"] + // Factor = "*" (*) "(" Comma ")" ["/"] + // + // "(" -> Shift(S48) + // + pub fn __state39< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, __tok @ Tok::LParen(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state48(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + + // State 40 + // ( ",") = 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 => Call(ActionFn(11));) + // "," -> Shift(S49) + // "+" -> Shift(S50) + // + pub fn __state40< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, __tok @ Tok::Minus(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state51(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + } + Some((_, __tok @ Tok::Comma(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state49(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + } + Some((_, __tok @ Tok::Plus(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state50(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + } + Some((_, Tok::RParen(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action11(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr_3f(__nt))); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + + // State 41 + // ( ",")* = ( ",")* ( ",") (*) ["("] + // ( ",")* = ( ",")* ( ",") (*) [")"] + // ( ",")* = ( ",")* ( ",") (*) ["*"] + // ( ",")* = ( ",")* ( ",") (*) ["Num"] + // + // "*" -> Reduce(( ",")* = ( ",")*, ( ",") => Call(ActionFn(14));) + // "(" -> Reduce(( ",")* = ( ",")*, ( ",") => Call(ActionFn(14));) + // "Num" -> Reduce(( ",")* = ( ",")*, ( ",") => Call(ActionFn(14));) + // ")" -> Reduce(( ",")* = ( ",")*, ( ",") => Call(ActionFn(14));) + // + pub fn __state41< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<::std::vec::Vec<&'ast Node<'ast>>>, + __sym1: &mut Option<&'ast Node<'ast>>, + ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, Tok::Times(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __nt = super::__action14(arena, __sym0, __sym1); + return Ok((__lookbehind, __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::__action14(arena, __sym0, __sym1); + return Ok((__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt))); + } + Some((_, Tok::Num(_), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __nt = super::__action14(arena, __sym0, __sym1); + return Ok((__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt))); + } + Some((_, Tok::RParen(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __nt = super::__action14(arena, __sym0, __sym1); + return Ok((__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 42 + // Comma = ( ",")* Expr? (*) [")"] + // + // ")" -> Reduce(Comma = ( ",")*, Expr? => Call(ActionFn(10));) + // + pub fn __state42< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<::std::vec::Vec<&'ast Node<'ast>>>, + __sym1: &mut Option<::std::option::Option<&'ast Node<'ast>>>, + ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, Tok::RParen(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __nt = super::__action10(arena, __sym0, __sym1); + return Ok((__lookbehind, __lookahead, __Nonterminal::Comma_3cExpr_3e(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 43 + // Factor = Term (*) [")"] + // Factor = Term (*) ["*"] + // Factor = Term (*) ["+"] + // Factor = Term (*) [","] + // Factor = Term (*) ["-"] + // Factor = Term (*) ["/"] + // + // "*" -> Reduce(Factor = Term => Call(ActionFn(7));) + // "," -> Reduce(Factor = Term => Call(ActionFn(7));) + // ")" -> Reduce(Factor = Term => Call(ActionFn(7));) + // "+" -> Reduce(Factor = Term => Call(ActionFn(7));) + // "/" -> Reduce(Factor = Term => Call(ActionFn(7));) + // "-" -> Reduce(Factor = Term => Call(ActionFn(7));) + // + pub fn __state43< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, Tok::Times(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action7(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Comma(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action7(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::RParen(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action7(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action7(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Div(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action7(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action7(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + + // 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 ["/"] + // + // "/" -> Shift(S52) + // "+" -> Reduce(Expr = Factor => Call(ActionFn(3));) + // "*" -> Shift(S53) + // ")" -> Reduce(Expr = Factor => Call(ActionFn(3));) + // "-" -> Reduce(Expr = Factor => Call(ActionFn(3));) + // "," -> Reduce(Expr = Factor => Call(ActionFn(3));) + // + pub fn __state44< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, __tok @ Tok::Div(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state52(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + } + Some((_, __tok @ Tok::Times(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state53(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action3(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + Some((_, Tok::RParen(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action3(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action3(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + Some((_, Tok::Comma(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action3(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + + // State 45 + // Factor = "*" "(" Comma ")" (*) [EOF] + // Factor = "*" "(" Comma ")" (*) ["*"] + // Factor = "*" "(" Comma ")" (*) ["+"] + // Factor = "*" "(" Comma ")" (*) ["-"] + // Factor = "*" "(" Comma ")" (*) ["/"] + // + // "-" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) + // "*" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) + // EOF -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) + // "/" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) + // "+" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) + // + pub fn __state45< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + __sym1: &mut Option, + __sym2: &mut Option>>, + __sym3: &mut Option, + ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __sym3 = __sym3.take().unwrap(); + let __nt = super::__action6(arena, __sym0, __sym1, __sym2, __sym3); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Times(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __sym3 = __sym3.take().unwrap(); + let __nt = super::__action6(arena, __sym0, __sym1, __sym2, __sym3); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + None => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __sym3 = __sym3.take().unwrap(); + let __nt = super::__action6(arena, __sym0, __sym1, __sym2, __sym3); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Div(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __sym3 = __sym3.take().unwrap(); + let __nt = super::__action6(arena, __sym0, __sym1, __sym2, __sym3); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __sym3 = __sym3.take().unwrap(); + let __nt = super::__action6(arena, __sym0, __sym1, __sym2, __sym3); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + // State 46 // Factor = "*" "(" Comma ")" (*) [")"] // Factor = "*" "(" Comma ")" (*) ["*"] @@ -3278,10 +3284,10 @@ mod __parse__Expr { // Factor = "*" "(" Comma ")" (*) ["/"] // // "+" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) - // "/" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) - // "-" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) - // ")" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) // "*" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) + // "-" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) + // "/" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) + // ")" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) // pub fn __state46< 'ast, @@ -3307,7 +3313,7 @@ mod __parse__Expr { let __nt = super::__action6(arena, __sym0, __sym1, __sym2, __sym3); return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } - Some((_, Tok::Div(..), _)) => { + Some((_, Tok::Times(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); @@ -3323,7 +3329,7 @@ mod __parse__Expr { let __nt = super::__action6(arena, __sym0, __sym1, __sym2, __sym3); return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } - Some((_, Tok::RParen(..), _)) => { + Some((_, Tok::Div(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); @@ -3331,7 +3337,7 @@ mod __parse__Expr { let __nt = super::__action6(arena, __sym0, __sym1, __sym2, __sym3); return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } - Some((_, Tok::Times(..), _)) => { + Some((_, Tok::RParen(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); @@ -3346,6 +3352,195 @@ mod __parse__Expr { } // State 47 + // Expr = Expr (*) "+" Factor [")"] + // Expr = Expr (*) "+" Factor ["+"] + // Expr = Expr (*) "+" Factor ["-"] + // Expr = Expr (*) "-" Factor [")"] + // Expr = Expr (*) "-" Factor ["+"] + // Expr = Expr (*) "-" Factor ["-"] + // Term = "(" Expr (*) ")" [")"] + // Term = "(" Expr (*) ")" ["*"] + // Term = "(" Expr (*) ")" ["+"] + // Term = "(" Expr (*) ")" [","] + // Term = "(" Expr (*) ")" ["-"] + // Term = "(" Expr (*) ")" ["/"] + // + // "+" -> Shift(S27) + // ")" -> Shift(S54) + // "-" -> Shift(S26) + // + pub fn __state47< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + __sym1: &mut Option<&'ast Node<'ast>>, + ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, __tok @ Tok::Plus(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state27(arena, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); + } + Some((_, __tok @ Tok::RParen(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state54(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + Some((_, __tok @ Tok::Minus(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state26(arena, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + + // State 48 + // ( ",")* = (*) ["("] + // ( ",")* = (*) [")"] + // ( ",")* = (*) ["*"] + // ( ",")* = (*) ["Num"] + // ( ",")* = (*) ( ",")* ( ",") ["("] + // ( ",")* = (*) ( ",")* ( ",") [")"] + // ( ",")* = (*) ( ",")* ( ",") ["*"] + // ( ",")* = (*) ( ",")* ( ",") ["Num"] + // Comma = (*) ( ",")* Expr? [")"] + // Factor = "*" "(" (*) Comma ")" [")"] + // Factor = "*" "(" (*) Comma ")" ["*"] + // Factor = "*" "(" (*) Comma ")" ["+"] + // Factor = "*" "(" (*) Comma ")" [","] + // Factor = "*" "(" (*) Comma ")" ["-"] + // Factor = "*" "(" (*) Comma ")" ["/"] + // + // ")" -> Reduce(( ",")* = => Call(ActionFn(13));) + // "(" -> Reduce(( ",")* = => Call(ActionFn(13));) + // "*" -> Reduce(( ",")* = => Call(ActionFn(13));) + // "Num" -> Reduce(( ",")* = => Call(ActionFn(13));) + // + // ( ",")* -> S29 + // Comma -> S55 + pub fn __state48< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + __sym1: &mut Option, + ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, Tok::RParen(..), _)) => { + let __nt = super::__action13(arena, ); + __result = (__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); + } + Some((_, Tok::LParen(..), _)) => { + let __nt = super::__action13(arena, ); + __result = (__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); + } + Some((_, Tok::Times(..), _)) => { + let __nt = super::__action13(arena, ); + __result = (__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); + } + Some((_, Tok::Num(_), _)) => { + let __nt = super::__action13(arena, ); + __result = (__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); + } + _ => { + return Err(__lookahead); + } + } + while __sym1.is_some() { + let (__lookbehind, __lookahead, __nt) = __result; + match __nt { + __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state29(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + __Nonterminal::Comma_3cExpr_3e(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state55(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + _ => { + return Ok((__lookbehind, __lookahead, __nt)); + } + } + } + return Ok(__result); + } + + // State 49 + // ( ",") = Expr "," (*) ["("] + // ( ",") = Expr "," (*) [")"] + // ( ",") = Expr "," (*) ["*"] + // ( ",") = Expr "," (*) ["Num"] + // + // "(" -> Reduce(( ",") = Expr, "," => Call(ActionFn(15));) + // "*" -> Reduce(( ",") = Expr, "," => Call(ActionFn(15));) + // "Num" -> Reduce(( ",") = Expr, "," => Call(ActionFn(15));) + // ")" -> Reduce(( ",") = Expr, "," => Call(ActionFn(15));) + // + pub fn __state49< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + __sym1: &mut Option, + ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, Tok::LParen(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __nt = super::__action15(arena, __sym0, __sym1); + return Ok((__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29(__nt))); + } + Some((_, Tok::Times(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __nt = super::__action15(arena, __sym0, __sym1); + return Ok((__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29(__nt))); + } + Some((_, Tok::Num(_), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __nt = super::__action15(arena, __sym0, __sym1); + return Ok((__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29(__nt))); + } + Some((_, Tok::RParen(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __nt = super::__action15(arena, __sym0, __sym1); + return Ok((__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 50 // Expr = Expr "+" (*) Factor [")"] // Expr = Expr "+" (*) Factor ["+"] // Expr = Expr "+" (*) Factor [","] @@ -3387,13 +3582,13 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "(" -> Shift(S45) - // "*" -> Shift(S40) - // "Num" -> Shift(S41) + // "Num" -> Shift(S38) + // "*" -> Shift(S39) + // "(" -> Shift(S37) // // Term -> S43 - // Factor -> S54 - pub fn __state47< + // Factor -> S56 + pub fn __state50< 'ast, __TOKENS: Iterator, >( @@ -3407,23 +3602,23 @@ mod __parse__Expr { { let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some((_, __tok @ Tok::LParen(..), __loc)) => { + Some((_, Tok::Num(__tok0), __loc)) => { let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok)); + let mut __sym2 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state45(arena, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state38(arena, __lookbehind, __lookahead, __tokens, __sym2)); } Some((_, __tok @ Tok::Times(..), __loc)) => { let mut __lookbehind = Some(__loc); let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state40(arena, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state39(arena, __lookbehind, __lookahead, __tokens, __sym2)); } - Some((_, Tok::Num(__tok0), __loc)) => { + Some((_, __tok @ Tok::LParen(..), __loc)) => { let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok0)); + let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state41(arena, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state37(arena, __lookbehind, __lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); @@ -3438,7 +3633,7 @@ mod __parse__Expr { } __Nonterminal::Factor(__nt) => { let __sym2 = &mut Some(__nt); - __result = try!(__state54(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + __result = try!(__state56(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); } _ => { return Ok((__lookbehind, __lookahead, __nt)); @@ -3448,7 +3643,7 @@ mod __parse__Expr { return Ok(__result); } - // State 48 + // State 51 // Expr = Expr "-" (*) Factor [")"] // Expr = Expr "-" (*) Factor ["+"] // Expr = Expr "-" (*) Factor [","] @@ -3490,13 +3685,13 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "*" -> Shift(S40) - // "Num" -> Shift(S41) - // "(" -> Shift(S45) + // "Num" -> Shift(S38) + // "(" -> Shift(S37) + // "*" -> Shift(S39) // + // Factor -> S57 // Term -> S43 - // Factor -> S55 - pub fn __state48< + pub fn __state51< 'ast, __TOKENS: Iterator, >( @@ -3510,23 +3705,23 @@ mod __parse__Expr { { let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some((_, __tok @ Tok::Times(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state40(arena, __lookbehind, __lookahead, __tokens, __sym2)); - } Some((_, Tok::Num(__tok0), __loc)) => { let mut __lookbehind = Some(__loc); let mut __sym2 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state41(arena, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state38(arena, __lookbehind, __lookahead, __tokens, __sym2)); } Some((_, __tok @ Tok::LParen(..), __loc)) => { let mut __lookbehind = Some(__loc); let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state45(arena, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state37(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + Some((_, __tok @ Tok::Times(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state39(arena, __lookbehind, __lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); @@ -3535,14 +3730,14 @@ mod __parse__Expr { while __sym1.is_some() { let (__lookbehind, __lookahead, __nt) = __result; match __nt { + __Nonterminal::Factor(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state57(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } __Nonterminal::Term(__nt) => { let __sym2 = &mut Some(__nt); __result = try!(__state43(arena, __lookbehind, __lookahead, __tokens, __sym2)); } - __Nonterminal::Factor(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state55(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } _ => { return Ok((__lookbehind, __lookahead, __nt)); } @@ -3551,139 +3746,7 @@ mod __parse__Expr { return Ok(__result); } - // State 49 - // ( ",") = Expr "," (*) ["("] - // ( ",") = Expr "," (*) [")"] - // ( ",") = Expr "," (*) ["*"] - // ( ",") = Expr "," (*) ["Num"] - // - // ")" -> Reduce(( ",") = Expr, "," => Call(ActionFn(15));) - // "*" -> Reduce(( ",") = Expr, "," => Call(ActionFn(15));) - // "Num" -> Reduce(( ",") = Expr, "," => Call(ActionFn(15));) - // "(" -> Reduce(( ",") = Expr, "," => Call(ActionFn(15));) - // - pub fn __state49< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize,Tok,usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, - ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> - { - let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, Tok::RParen(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __nt = super::__action15(arena, __sym0, __sym1); - return Ok((__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29(__nt))); - } - Some((_, Tok::Times(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __nt = super::__action15(arena, __sym0, __sym1); - return Ok((__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29(__nt))); - } - Some((_, Tok::Num(_), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __nt = super::__action15(arena, __sym0, __sym1); - return Ok((__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29(__nt))); - } - Some((_, Tok::LParen(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __nt = super::__action15(arena, __sym0, __sym1); - return Ok((__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 50 - // ( ",")* = (*) ["("] - // ( ",")* = (*) [")"] - // ( ",")* = (*) ["*"] - // ( ",")* = (*) ["Num"] - // ( ",")* = (*) ( ",")* ( ",") ["("] - // ( ",")* = (*) ( ",")* ( ",") [")"] - // ( ",")* = (*) ( ",")* ( ",") ["*"] - // ( ",")* = (*) ( ",")* ( ",") ["Num"] - // Comma = (*) ( ",")* Expr? [")"] - // Factor = "*" "(" (*) Comma ")" [")"] - // Factor = "*" "(" (*) Comma ")" ["*"] - // Factor = "*" "(" (*) Comma ")" ["+"] - // Factor = "*" "(" (*) Comma ")" [","] - // Factor = "*" "(" (*) Comma ")" ["-"] - // Factor = "*" "(" (*) Comma ")" ["/"] - // - // "(" -> Reduce(( ",")* = => Call(ActionFn(13));) - // "*" -> Reduce(( ",")* = => Call(ActionFn(13));) - // "Num" -> Reduce(( ",")* = => Call(ActionFn(13));) - // ")" -> Reduce(( ",")* = => Call(ActionFn(13));) - // - // ( ",")* -> S30 - // Comma -> S56 - pub fn __state50< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize,Tok,usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option, - ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> - { - let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, Tok::LParen(..), _)) => { - let __nt = super::__action13(arena, ); - __result = (__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); - } - Some((_, Tok::Times(..), _)) => { - let __nt = super::__action13(arena, ); - __result = (__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); - } - Some((_, Tok::Num(_), _)) => { - let __nt = super::__action13(arena, ); - __result = (__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); - } - Some((_, Tok::RParen(..), _)) => { - let __nt = super::__action13(arena, ); - __result = (__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); - } - _ => { - return Err(__lookahead); - } - } - while __sym1.is_some() { - let (__lookbehind, __lookahead, __nt) = __result; - match __nt { - __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state30(arena, __lookbehind, __lookahead, __tokens, __sym2)); - } - __Nonterminal::Comma_3cExpr_3e(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state56(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - _ => { - return Ok((__lookbehind, __lookahead, __nt)); - } - } - } - return Ok(__result); - } - - // State 51 + // State 52 // Factor = Factor "/" (*) Term [")"] // Factor = Factor "/" (*) Term ["*"] // Factor = Factor "/" (*) Term ["+"] @@ -3703,77 +3766,8 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "(" -> Shift(S45) - // "Num" -> Shift(S41) - // - // Term -> S57 - pub fn __state51< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize,Tok,usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, - ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> - { - let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, __tok @ Tok::LParen(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state45(arena, __lookbehind, __lookahead, __tokens, __sym2)); - } - Some((_, Tok::Num(__tok0), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state41(arena, __lookbehind, __lookahead, __tokens, __sym2)); - } - _ => { - return Err(__lookahead); - } - } - while __sym1.is_some() { - let (__lookbehind, __lookahead, __nt) = __result; - match __nt { - __Nonterminal::Term(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state57(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - _ => { - return Ok((__lookbehind, __lookahead, __nt)); - } - } - } - return Ok(__result); - } - - // State 52 - // Factor = Factor "*" (*) Term [")"] - // Factor = Factor "*" (*) Term ["*"] - // Factor = Factor "*" (*) Term ["+"] - // Factor = Factor "*" (*) Term [","] - // Factor = Factor "*" (*) Term ["-"] - // Factor = Factor "*" (*) Term ["/"] - // Term = (*) "(" Expr ")" [")"] - // Term = (*) "(" Expr ")" ["*"] - // Term = (*) "(" Expr ")" ["+"] - // Term = (*) "(" Expr ")" [","] - // Term = (*) "(" Expr ")" ["-"] - // Term = (*) "(" Expr ")" ["/"] - // Term = (*) "Num" [")"] - // Term = (*) "Num" ["*"] - // Term = (*) "Num" ["+"] - // Term = (*) "Num" [","] - // Term = (*) "Num" ["-"] - // Term = (*) "Num" ["/"] - // - // "(" -> Shift(S45) - // "Num" -> Shift(S41) + // "(" -> Shift(S37) + // "Num" -> Shift(S38) // // Term -> S58 pub fn __state52< @@ -3794,13 +3788,13 @@ mod __parse__Expr { let mut __lookbehind = Some(__loc); let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state45(arena, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state37(arena, __lookbehind, __lookahead, __tokens, __sym2)); } Some((_, Tok::Num(__tok0), __loc)) => { let mut __lookbehind = Some(__loc); let mut __sym2 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state41(arena, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state38(arena, __lookbehind, __lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); @@ -3822,23 +3816,29 @@ mod __parse__Expr { } // State 53 - // Expr = Expr (*) "+" Factor [")"] - // Expr = Expr (*) "+" Factor ["+"] - // Expr = Expr (*) "+" Factor ["-"] - // Expr = Expr (*) "-" Factor [")"] - // Expr = Expr (*) "-" Factor ["+"] - // Expr = Expr (*) "-" Factor ["-"] - // Term = "(" Expr (*) ")" [")"] - // Term = "(" Expr (*) ")" ["*"] - // Term = "(" Expr (*) ")" ["+"] - // Term = "(" Expr (*) ")" [","] - // Term = "(" Expr (*) ")" ["-"] - // Term = "(" Expr (*) ")" ["/"] + // 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(S23) - // "+" -> Shift(S24) - // ")" -> Shift(S59) + // "(" -> Shift(S37) + // "Num" -> Shift(S38) // + // Term -> S59 pub fn __state53< 'ast, __TOKENS: Iterator, @@ -3847,406 +3847,44 @@ mod __parse__Expr { __lookbehind: Option, __lookahead: Option<(usize,Tok,usize)>, __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option<&'ast Node<'ast>>, + __sym0: &mut Option<&'ast Node<'ast>>, + __sym1: &mut Option, ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> { let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some((_, __tok @ Tok::Minus(..), __loc)) => { + Some((_, __tok @ Tok::LParen(..), __loc)) => { let mut __lookbehind = Some(__loc); let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state23(arena, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); + __result = try!(__state37(arena, __lookbehind, __lookahead, __tokens, __sym2)); } - Some((_, __tok @ Tok::Plus(..), __loc)) => { + Some((_, Tok::Num(__tok0), __loc)) => { let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok)); + let mut __sym2 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state24(arena, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); - } - Some((_, __tok @ Tok::RParen(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state59(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + __result = try!(__state38(arena, __lookbehind, __lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); } } + while __sym1.is_some() { + let (__lookbehind, __lookahead, __nt) = __result; + match __nt { + __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state59(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + _ => { + return Ok((__lookbehind, __lookahead, __nt)); + } + } + } return Ok(__result); } // State 54 - // Expr = Expr "+" Factor (*) [")"] - // Expr = Expr "+" Factor (*) ["+"] - // Expr = Expr "+" Factor (*) [","] - // Expr = Expr "+" Factor (*) ["-"] - // Factor = Factor (*) "*" Term [")"] - // Factor = Factor (*) "*" Term ["*"] - // Factor = Factor (*) "*" Term ["+"] - // Factor = Factor (*) "*" Term [","] - // Factor = Factor (*) "*" Term ["-"] - // Factor = Factor (*) "*" Term ["/"] - // Factor = Factor (*) "/" Term [")"] - // Factor = Factor (*) "/" Term ["*"] - // Factor = Factor (*) "/" Term ["+"] - // Factor = Factor (*) "/" Term [","] - // Factor = Factor (*) "/" Term ["-"] - // Factor = Factor (*) "/" Term ["/"] - // - // "-" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) - // "," -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) - // "*" -> Shift(S52) - // ")" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) - // "+" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) - // "/" -> Shift(S51) - // - pub fn __state54< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize,Tok,usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, - __sym2: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> - { - let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, __tok @ Tok::Times(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym3 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state52(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); - } - Some((_, __tok @ Tok::Div(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym3 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state51(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); - } - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action2(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - Some((_, Tok::Comma(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action2(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - Some((_, Tok::RParen(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action2(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - Some((_, Tok::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action2(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 55 - // Expr = Expr "-" Factor (*) [")"] - // Expr = Expr "-" Factor (*) ["+"] - // Expr = Expr "-" Factor (*) [","] - // Expr = Expr "-" Factor (*) ["-"] - // Factor = Factor (*) "*" Term [")"] - // Factor = Factor (*) "*" Term ["*"] - // Factor = Factor (*) "*" Term ["+"] - // Factor = Factor (*) "*" Term [","] - // Factor = Factor (*) "*" Term ["-"] - // Factor = Factor (*) "*" Term ["/"] - // Factor = Factor (*) "/" Term [")"] - // Factor = Factor (*) "/" Term ["*"] - // Factor = Factor (*) "/" Term ["+"] - // Factor = Factor (*) "/" Term [","] - // Factor = Factor (*) "/" Term ["-"] - // Factor = Factor (*) "/" Term ["/"] - // - // "*" -> Shift(S52) - // "/" -> Shift(S51) - // "-" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) - // "," -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) - // ")" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) - // "+" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) - // - pub fn __state55< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize,Tok,usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, - __sym2: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> - { - let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, __tok @ Tok::Times(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym3 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state52(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); - } - Some((_, __tok @ Tok::Div(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym3 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state51(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); - } - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action1(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - Some((_, Tok::Comma(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action1(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - Some((_, Tok::RParen(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action1(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - Some((_, Tok::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action1(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 56 - // Factor = "*" "(" Comma (*) ")" [")"] - // Factor = "*" "(" Comma (*) ")" ["*"] - // Factor = "*" "(" Comma (*) ")" ["+"] - // Factor = "*" "(" Comma (*) ")" [","] - // Factor = "*" "(" Comma (*) ")" ["-"] - // Factor = "*" "(" Comma (*) ")" ["/"] - // - // ")" -> Shift(S60) - // - pub fn __state56< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize,Tok,usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option, - __sym2: &mut Option>>, - ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> - { - let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, __tok @ Tok::RParen(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym3 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state60(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2, __sym3)); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 57 - // Factor = Factor "/" Term (*) [")"] - // Factor = Factor "/" Term (*) ["*"] - // Factor = Factor "/" Term (*) ["+"] - // Factor = Factor "/" Term (*) [","] - // Factor = Factor "/" Term (*) ["-"] - // Factor = Factor "/" Term (*) ["/"] - // - // "*" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // "-" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // "," -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // "/" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // ")" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // "+" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // - pub fn __state57< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize,Tok,usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, - __sym2: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> - { - let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, Tok::Times(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action5(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action5(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Comma(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action5(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Div(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action5(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::RParen(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action5(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action5(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 58 - // Factor = Factor "*" Term (*) [")"] - // Factor = Factor "*" Term (*) ["*"] - // Factor = Factor "*" Term (*) ["+"] - // Factor = Factor "*" Term (*) [","] - // Factor = Factor "*" Term (*) ["-"] - // Factor = Factor "*" Term (*) ["/"] - // - // "," -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) - // "/" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) - // ")" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) - // "*" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) - // "-" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) - // "+" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) - // - pub fn __state58< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize,Tok,usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, - __sym2: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> - { - let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, Tok::Comma(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Div(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::RParen(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Times(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 59 // Term = "(" Expr ")" (*) [")"] // Term = "(" Expr ")" (*) ["*"] // Term = "(" Expr ")" (*) ["+"] @@ -4261,7 +3899,7 @@ mod __parse__Expr { // "," -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) // "/" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) // - pub fn __state59< + pub fn __state54< 'ast, __TOKENS: Iterator, >( @@ -4324,6 +3962,374 @@ mod __parse__Expr { } } + // State 55 + // Factor = "*" "(" Comma (*) ")" [")"] + // Factor = "*" "(" Comma (*) ")" ["*"] + // Factor = "*" "(" Comma (*) ")" ["+"] + // Factor = "*" "(" Comma (*) ")" [","] + // Factor = "*" "(" Comma (*) ")" ["-"] + // Factor = "*" "(" Comma (*) ")" ["/"] + // + // ")" -> Shift(S60) + // + pub fn __state55< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + __sym1: &mut Option, + __sym2: &mut Option>>, + ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, __tok @ Tok::RParen(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym3 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state60(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2, __sym3)); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + + // State 56 + // Expr = Expr "+" Factor (*) [")"] + // Expr = Expr "+" Factor (*) ["+"] + // Expr = Expr "+" Factor (*) [","] + // Expr = Expr "+" Factor (*) ["-"] + // Factor = Factor (*) "*" Term [")"] + // Factor = Factor (*) "*" Term ["*"] + // Factor = Factor (*) "*" Term ["+"] + // Factor = Factor (*) "*" Term [","] + // Factor = Factor (*) "*" Term ["-"] + // Factor = Factor (*) "*" Term ["/"] + // Factor = Factor (*) "/" Term [")"] + // Factor = Factor (*) "/" Term ["*"] + // Factor = Factor (*) "/" Term ["+"] + // Factor = Factor (*) "/" Term [","] + // Factor = Factor (*) "/" Term ["-"] + // Factor = Factor (*) "/" Term ["/"] + // + // "*" -> Shift(S53) + // ")" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) + // "+" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) + // "/" -> Shift(S52) + // "," -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) + // "-" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) + // + pub fn __state56< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + __sym1: &mut Option, + __sym2: &mut Option<&'ast Node<'ast>>, + ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, __tok @ Tok::Times(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym3 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state53(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); + } + Some((_, __tok @ Tok::Div(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym3 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state52(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); + } + Some((_, Tok::RParen(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action2(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action2(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + Some((_, Tok::Comma(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action2(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action2(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + _ => { + 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 ["/"] + // + // "," -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // "+" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // ")" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // "/" -> Shift(S52) + // "*" -> Shift(S53) + // "-" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // + pub fn __state57< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + __sym1: &mut Option, + __sym2: &mut Option<&'ast Node<'ast>>, + ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, __tok @ Tok::Div(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym3 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state52(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); + } + Some((_, __tok @ Tok::Times(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym3 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state53(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); + } + Some((_, Tok::Comma(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action1(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action1(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + Some((_, Tok::RParen(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action1(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action1(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + _ => { + return Err(__lookahead); + } + } + 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 => Call(ActionFn(5));) + // "," -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // "/" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // "-" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // "*" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // ")" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // + pub fn __state58< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + __sym1: &mut Option, + __sym2: &mut Option<&'ast Node<'ast>>, + ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action5(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Comma(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action5(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Div(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action5(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action5(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Times(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action5(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::RParen(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action5(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 59 + // Factor = Factor "*" Term (*) [")"] + // Factor = Factor "*" Term (*) ["*"] + // Factor = Factor "*" Term (*) ["+"] + // Factor = Factor "*" Term (*) [","] + // Factor = Factor "*" Term (*) ["-"] + // Factor = Factor "*" Term (*) ["/"] + // + // ")" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // "," -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // "+" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // "-" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // "/" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // "*" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // + pub fn __state59< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + __sym1: &mut Option, + __sym2: &mut Option<&'ast Node<'ast>>, + ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, Tok::RParen(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action4(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Comma(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action4(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action4(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action4(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Div(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action4(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Times(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action4(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + // State 60 // Factor = "*" "(" Comma ")" (*) [")"] // Factor = "*" "(" Comma ")" (*) ["*"] @@ -4332,12 +4338,12 @@ mod __parse__Expr { // Factor = "*" "(" Comma ")" (*) ["-"] // Factor = "*" "(" Comma ")" (*) ["/"] // + // "," -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) + // "/" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) + // "+" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) // "*" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) // "-" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) - // "+" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) // ")" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) - // "/" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) - // "," -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) // pub fn __state60< 'ast, @@ -4355,6 +4361,30 @@ mod __parse__Expr { { let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { + Some((_, Tok::Comma(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __sym3 = __sym3.take().unwrap(); + let __nt = super::__action6(arena, __sym0, __sym1, __sym2, __sym3); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Div(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __sym3 = __sym3.take().unwrap(); + let __nt = super::__action6(arena, __sym0, __sym1, __sym2, __sym3); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __sym3 = __sym3.take().unwrap(); + let __nt = super::__action6(arena, __sym0, __sym1, __sym2, __sym3); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } Some((_, Tok::Times(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); @@ -4371,14 +4401,6 @@ mod __parse__Expr { let __nt = super::__action6(arena, __sym0, __sym1, __sym2, __sym3); return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } - Some((_, Tok::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __sym3 = __sym3.take().unwrap(); - let __nt = super::__action6(arena, __sym0, __sym1, __sym2, __sym3); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } Some((_, Tok::RParen(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); @@ -4387,22 +4409,6 @@ mod __parse__Expr { let __nt = super::__action6(arena, __sym0, __sym1, __sym2, __sym3); return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } - Some((_, Tok::Div(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __sym3 = __sym3.take().unwrap(); - let __nt = super::__action6(arena, __sym0, __sym1, __sym2, __sym3); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Comma(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __sym3 = __sym3.take().unwrap(); - let __nt = super::__action6(arena, __sym0, __sym1, __sym2, __sym3); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } _ => { return Err(__lookahead); } diff --git a/lalrpop-test/src/loc.rs b/lalrpop-test/src/loc.rs index c8a03ac..35d5ab2 100644 --- a/lalrpop-test/src/loc.rs +++ b/lalrpop-test/src/loc.rs @@ -6,12 +6,18 @@ pub fn parse_Items< __TOKENS: IntoIterator, >( __tokens: __TOKENS, -) -> Result<(Option<(usize,Tok,usize)>, Vec<(usize, usize)>), Option<(usize,Tok,usize)>> +) -> Result, Option<(usize,Tok,usize)>> { let mut __tokens = __tokens.into_iter(); let __lookahead = __tokens.next(); match try!(__parse__Items::__state0(None, __lookahead, &mut __tokens)) { - (_, __lookahead, __parse__Items::__Nonterminal::____Items(__nt)) => Ok((__lookahead, __nt)), + (_, __lookahead, __parse__Items::__Nonterminal::____Items(__nt)) => { + if __lookahead.is_some() { + Err(__lookahead) + } else { + Ok(__nt) + } + } _ => unreachable!(), } } @@ -22,11 +28,11 @@ mod __parse__Items { use util::tok::Tok; pub enum __Nonterminal<> { - _40_3e(usize), - ____Items(Vec<(usize, usize)>), Items(Vec<(usize, usize)>), + ____Items(Vec<(usize, usize)>), Spanned_3c_22_2b_22_3e((usize, usize)), _40_3c(usize), + _40_3e(usize), } // State 0 @@ -45,11 +51,11 @@ mod __parse__Items { // __Items = (*) Items [EOF] // // EOF -> Reduce(@< = => Lookahead;) - // "-" -> Reduce(@< = => Lookahead;) // "+" -> Reduce(@< = => Lookahead;) + // "-" -> Reduce(@< = => Lookahead;) // - // Items -> S2 - // @< -> S1 + // @< -> S2 + // Items -> S1 pub fn __state0< __TOKENS: Iterator, >( @@ -64,11 +70,11 @@ mod __parse__Items { let __nt = __lookahead.as_ref().map(|o| ::std::clone::Clone::clone(&o.0)).or_else(|| ::std::clone::Clone::clone(&__lookbehind)).unwrap_or_default(); __result = (__lookbehind, __lookahead, __Nonterminal::_40_3c(__nt)); } - Some((_, Tok::Minus(..), _)) => { + Some((_, Tok::Plus(..), _)) => { let __nt = __lookahead.as_ref().map(|o| ::std::clone::Clone::clone(&o.0)).or_else(|| ::std::clone::Clone::clone(&__lookbehind)).unwrap_or_default(); __result = (__lookbehind, __lookahead, __Nonterminal::_40_3c(__nt)); } - Some((_, Tok::Plus(..), _)) => { + Some((_, Tok::Minus(..), _)) => { let __nt = __lookahead.as_ref().map(|o| ::std::clone::Clone::clone(&o.0)).or_else(|| ::std::clone::Clone::clone(&__lookbehind)).unwrap_or_default(); __result = (__lookbehind, __lookahead, __Nonterminal::_40_3c(__nt)); } @@ -79,11 +85,11 @@ mod __parse__Items { loop { let (__lookbehind, __lookahead, __nt) = __result; match __nt { - __Nonterminal::Items(__nt) => { + __Nonterminal::_40_3c(__nt) => { let __sym0 = &mut Some(__nt); __result = try!(__state2(__lookbehind, __lookahead, __tokens, __sym0)); } - __Nonterminal::_40_3c(__nt) => { + __Nonterminal::Items(__nt) => { let __sym0 = &mut Some(__nt); __result = try!(__state1(__lookbehind, __lookahead, __tokens, __sym0)); } @@ -95,6 +101,74 @@ mod __parse__Items { } // State 1 + // @< = (*) ["+"] + // Items = Items (*) Spanned<"+"> [EOF] + // Items = Items (*) Spanned<"+"> ["+"] + // Items = Items (*) Spanned<"+"> ["-"] + // Items = Items (*) "-" [EOF] + // Items = Items (*) "-" ["+"] + // Items = Items (*) "-" ["-"] + // Spanned<"+"> = (*) @< "+" @> [EOF] + // Spanned<"+"> = (*) @< "+" @> ["+"] + // Spanned<"+"> = (*) @< "+" @> ["-"] + // __Items = Items (*) [EOF] + // + // "+" -> Reduce(@< = => Lookahead;) + // EOF -> Reduce(__Items = Items => Call(ActionFn(0));) + // "-" -> Shift(S3) + // + // Spanned<"+"> -> S5 + // @< -> S4 + pub fn __state1< + __TOKENS: Iterator, + >( + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option>, + ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<>), Option<(usize,Tok,usize)>> + { + let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<>); + match __lookahead { + Some((_, __tok @ Tok::Minus(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state3(__lookbehind, __lookahead, __tokens, __sym0, __sym1)); + } + Some((_, Tok::Plus(..), _)) => { + let __nt = __lookahead.as_ref().map(|o| ::std::clone::Clone::clone(&o.0)).or_else(|| ::std::clone::Clone::clone(&__lookbehind)).unwrap_or_default(); + __result = (__lookbehind, __lookahead, __Nonterminal::_40_3c(__nt)); + } + None => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action0(__sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::____Items(__nt))); + } + _ => { + return Err(__lookahead); + } + } + while __sym0.is_some() { + let (__lookbehind, __lookahead, __nt) = __result; + match __nt { + __Nonterminal::Spanned_3c_22_2b_22_3e(__nt) => { + let __sym1 = &mut Some(__nt); + __result = try!(__state5(__lookbehind, __lookahead, __tokens, __sym0, __sym1)); + } + __Nonterminal::_40_3c(__nt) => { + let __sym1 = &mut Some(__nt); + __result = try!(__state4(__lookbehind, __lookahead, __tokens, __sym1)); + } + _ => { + return Ok((__lookbehind, __lookahead, __nt)); + } + } + } + return Ok(__result); + } + + // State 2 // @> = (*) [EOF] // @> = (*) ["+"] // @> = (*) ["-"] @@ -106,8 +180,8 @@ mod __parse__Items { // "+" -> Reduce(@> = => Lookbehind;) // "-" -> Reduce(@> = => Lookbehind;) // - // @> -> S3 - pub fn __state1< + // @> -> S6 + pub fn __state2< __TOKENS: Iterator, >( __lookbehind: Option, @@ -139,75 +213,7 @@ mod __parse__Items { match __nt { __Nonterminal::_40_3e(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state3(__lookbehind, __lookahead, __tokens, __sym0, __sym1)); - } - _ => { - return Ok((__lookbehind, __lookahead, __nt)); - } - } - } - return Ok(__result); - } - - // State 2 - // @< = (*) ["+"] - // Items = Items (*) Spanned<"+"> [EOF] - // Items = Items (*) Spanned<"+"> ["+"] - // Items = Items (*) Spanned<"+"> ["-"] - // Items = Items (*) "-" [EOF] - // Items = Items (*) "-" ["+"] - // Items = Items (*) "-" ["-"] - // Spanned<"+"> = (*) @< "+" @> [EOF] - // Spanned<"+"> = (*) @< "+" @> ["+"] - // Spanned<"+"> = (*) @< "+" @> ["-"] - // __Items = Items (*) [EOF] - // - // "-" -> Shift(S5) - // EOF -> Reduce(__Items = Items => Call(ActionFn(0));) - // "+" -> Reduce(@< = => Lookahead;) - // - // @< -> S6 - // Spanned<"+"> -> S4 - pub fn __state2< - __TOKENS: Iterator, - >( - __lookbehind: Option, - __lookahead: Option<(usize,Tok,usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option>, - ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<>), Option<(usize,Tok,usize)>> - { - let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<>); - match __lookahead { - Some((_, __tok @ Tok::Minus(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym1 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state5(__lookbehind, __lookahead, __tokens, __sym0, __sym1)); - } - None => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action0(__sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::____Items(__nt))); - } - Some((_, Tok::Plus(..), _)) => { - let __nt = __lookahead.as_ref().map(|o| ::std::clone::Clone::clone(&o.0)).or_else(|| ::std::clone::Clone::clone(&__lookbehind)).unwrap_or_default(); - __result = (__lookbehind, __lookahead, __Nonterminal::_40_3c(__nt)); - } - _ => { - return Err(__lookahead); - } - } - while __sym0.is_some() { - let (__lookbehind, __lookahead, __nt) = __result; - match __nt { - __Nonterminal::_40_3c(__nt) => { - let __sym1 = &mut Some(__nt); - __result = try!(__state6(__lookbehind, __lookahead, __tokens, __sym1)); - } - __Nonterminal::Spanned_3c_22_2b_22_3e(__nt) => { - let __sym1 = &mut Some(__nt); - __result = try!(__state4(__lookbehind, __lookahead, __tokens, __sym0, __sym1)); + __result = try!(__state6(__lookbehind, __lookahead, __tokens, __sym0, __sym1)); } _ => { return Ok((__lookbehind, __lookahead, __nt)); @@ -218,105 +224,15 @@ mod __parse__Items { } // State 3 - // Items = @< @> (*) [EOF] - // Items = @< @> (*) ["+"] - // Items = @< @> (*) ["-"] - // - // "+" -> Reduce(Items = @<, @> => Call(ActionFn(1));) - // "-" -> Reduce(Items = @<, @> => Call(ActionFn(1));) - // EOF -> Reduce(Items = @<, @> => Call(ActionFn(1));) - // - pub fn __state3< - __TOKENS: Iterator, - >( - __lookbehind: Option, - __lookahead: Option<(usize,Tok,usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option, - ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<>), Option<(usize,Tok,usize)>> - { - let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<>); - match __lookahead { - Some((_, Tok::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __nt = super::__action1(__sym0, __sym1); - return Ok((__lookbehind, __lookahead, __Nonterminal::Items(__nt))); - } - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __nt = super::__action1(__sym0, __sym1); - return Ok((__lookbehind, __lookahead, __Nonterminal::Items(__nt))); - } - None => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __nt = super::__action1(__sym0, __sym1); - return Ok((__lookbehind, __lookahead, __Nonterminal::Items(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 4 - // Items = Items Spanned<"+"> (*) [EOF] - // Items = Items Spanned<"+"> (*) ["+"] - // Items = Items Spanned<"+"> (*) ["-"] - // - // "-" -> Reduce(Items = Items, Spanned<"+"> => Call(ActionFn(2));) - // EOF -> Reduce(Items = Items, Spanned<"+"> => Call(ActionFn(2));) - // "+" -> Reduce(Items = Items, Spanned<"+"> => Call(ActionFn(2));) - // - pub fn __state4< - __TOKENS: Iterator, - >( - __lookbehind: Option, - __lookahead: Option<(usize,Tok,usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option>, - __sym1: &mut Option<(usize, usize)>, - ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<>), Option<(usize,Tok,usize)>> - { - let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<>); - match __lookahead { - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __nt = super::__action2(__sym0, __sym1); - return Ok((__lookbehind, __lookahead, __Nonterminal::Items(__nt))); - } - None => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __nt = super::__action2(__sym0, __sym1); - return Ok((__lookbehind, __lookahead, __Nonterminal::Items(__nt))); - } - Some((_, Tok::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __nt = super::__action2(__sym0, __sym1); - return Ok((__lookbehind, __lookahead, __Nonterminal::Items(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 5 // Items = Items "-" (*) [EOF] // Items = Items "-" (*) ["+"] // Items = Items "-" (*) ["-"] // - // EOF -> Reduce(Items = Items, "-" => Call(ActionFn(3));) // "-" -> Reduce(Items = Items, "-" => Call(ActionFn(3));) + // EOF -> Reduce(Items = Items, "-" => Call(ActionFn(3));) // "+" -> Reduce(Items = Items, "-" => Call(ActionFn(3));) // - pub fn __state5< + pub fn __state3< __TOKENS: Iterator, >( __lookbehind: Option, @@ -328,13 +244,13 @@ mod __parse__Items { { let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<>); match __lookahead { - None => { + Some((_, Tok::Minus(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __nt = super::__action3(__sym0, __sym1); return Ok((__lookbehind, __lookahead, __Nonterminal::Items(__nt))); } - Some((_, Tok::Minus(..), _)) => { + None => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __nt = super::__action3(__sym0, __sym1); @@ -352,14 +268,14 @@ mod __parse__Items { } } - // State 6 + // State 4 // Spanned<"+"> = @< (*) "+" @> [EOF] // Spanned<"+"> = @< (*) "+" @> ["+"] // Spanned<"+"> = @< (*) "+" @> ["-"] // // "+" -> Shift(S7) // - pub fn __state6< + pub fn __state4< __TOKENS: Iterator, >( __lookbehind: Option, @@ -383,6 +299,96 @@ mod __parse__Items { return Ok(__result); } + // State 5 + // Items = Items Spanned<"+"> (*) [EOF] + // Items = Items Spanned<"+"> (*) ["+"] + // Items = Items Spanned<"+"> (*) ["-"] + // + // "+" -> Reduce(Items = Items, Spanned<"+"> => Call(ActionFn(2));) + // "-" -> Reduce(Items = Items, Spanned<"+"> => Call(ActionFn(2));) + // EOF -> Reduce(Items = Items, Spanned<"+"> => Call(ActionFn(2));) + // + pub fn __state5< + __TOKENS: Iterator, + >( + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option>, + __sym1: &mut Option<(usize, usize)>, + ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<>), Option<(usize,Tok,usize)>> + { + let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<>); + match __lookahead { + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __nt = super::__action2(__sym0, __sym1); + return Ok((__lookbehind, __lookahead, __Nonterminal::Items(__nt))); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __nt = super::__action2(__sym0, __sym1); + return Ok((__lookbehind, __lookahead, __Nonterminal::Items(__nt))); + } + None => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __nt = super::__action2(__sym0, __sym1); + return Ok((__lookbehind, __lookahead, __Nonterminal::Items(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 6 + // Items = @< @> (*) [EOF] + // Items = @< @> (*) ["+"] + // Items = @< @> (*) ["-"] + // + // "-" -> Reduce(Items = @<, @> => Call(ActionFn(1));) + // EOF -> Reduce(Items = @<, @> => Call(ActionFn(1));) + // "+" -> Reduce(Items = @<, @> => Call(ActionFn(1));) + // + pub fn __state6< + __TOKENS: Iterator, + >( + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + __sym1: &mut Option, + ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<>), Option<(usize,Tok,usize)>> + { + let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<>); + match __lookahead { + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __nt = super::__action1(__sym0, __sym1); + return Ok((__lookbehind, __lookahead, __Nonterminal::Items(__nt))); + } + None => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __nt = super::__action1(__sym0, __sym1); + return Ok((__lookbehind, __lookahead, __Nonterminal::Items(__nt))); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __nt = super::__action1(__sym0, __sym1); + return Ok((__lookbehind, __lookahead, __Nonterminal::Items(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + // State 7 // @> = (*) [EOF] // @> = (*) ["+"] @@ -391,8 +397,8 @@ mod __parse__Items { // Spanned<"+"> = @< "+" (*) @> ["+"] // Spanned<"+"> = @< "+" (*) @> ["-"] // - // EOF -> Reduce(@> = => Lookbehind;) // "-" -> Reduce(@> = => Lookbehind;) + // EOF -> Reduce(@> = => Lookbehind;) // "+" -> Reduce(@> = => Lookbehind;) // // @> -> S8 @@ -408,11 +414,11 @@ mod __parse__Items { { let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<>); match __lookahead { - None => { + Some((_, Tok::Minus(..), _)) => { let __nt = ::std::clone::Clone::clone(&__lookbehind).unwrap_or_default(); __result = (__lookbehind, __lookahead, __Nonterminal::_40_3e(__nt)); } - Some((_, Tok::Minus(..), _)) => { + None => { let __nt = ::std::clone::Clone::clone(&__lookbehind).unwrap_or_default(); __result = (__lookbehind, __lookahead, __Nonterminal::_40_3e(__nt)); } @@ -445,8 +451,8 @@ mod __parse__Items { // Spanned<"+"> = @< "+" @> (*) ["-"] // // "+" -> Reduce(Spanned<"+"> = @<, "+", @> => Call(ActionFn(4));) - // EOF -> Reduce(Spanned<"+"> = @<, "+", @> => Call(ActionFn(4));) // "-" -> Reduce(Spanned<"+"> = @<, "+", @> => Call(ActionFn(4));) + // EOF -> Reduce(Spanned<"+"> = @<, "+", @> => Call(ActionFn(4));) // pub fn __state8< __TOKENS: Iterator, @@ -468,14 +474,14 @@ mod __parse__Items { let __nt = super::__action4(__sym0, __sym1, __sym2); return Ok((__lookbehind, __lookahead, __Nonterminal::Spanned_3c_22_2b_22_3e(__nt))); } - None => { + Some((_, Tok::Minus(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); let __nt = super::__action4(__sym0, __sym1, __sym2); return Ok((__lookbehind, __lookahead, __Nonterminal::Spanned_3c_22_2b_22_3e(__nt))); } - Some((_, Tok::Minus(..), _)) => { + None => { 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 340b497..b26519a 100644 --- a/lalrpop-test/src/sub.rs +++ b/lalrpop-test/src/sub.rs @@ -6,12 +6,18 @@ pub fn parse_S< __TOKENS: IntoIterator, >( __tokens: __TOKENS, -) -> Result<(Option, i32), Option> +) -> Result> { let mut __tokens = __tokens.into_iter(); let __lookahead = __tokens.next(); match try!(__parse__S::__state0(None, __lookahead, &mut __tokens)) { - (_, __lookahead, __parse__S::__Nonterminal::____S(__nt)) => Ok((__lookahead, __nt)), + (_, __lookahead, __parse__S::__Nonterminal::____S(__nt)) => { + if __lookahead.is_some() { + Err(__lookahead) + } else { + Ok(__nt) + } + } _ => unreachable!(), } } @@ -22,10 +28,10 @@ mod __parse__S { use util::tok::Tok; pub enum __Nonterminal<> { - ____S(i32), - T(i32), E(i32), S(i32), + ____S(i32), + T(i32), } // State 0 @@ -40,12 +46,12 @@ mod __parse__S { // T = (*) "Num" ["-"] // __S = (*) S [EOF] // - // "(" -> Shift(S2) - // "Num" -> Shift(S3) + // "Num" -> Shift(S5) + // "(" -> Shift(S3) // // S -> S1 + // T -> S2 // E -> S4 - // T -> S5 pub fn __state0< __TOKENS: Iterator, >( @@ -56,16 +62,16 @@ mod __parse__S { { let mut __result: (Option<()>, Option, __Nonterminal<>); match __lookahead { - Some(__tok @ Tok::LParen(..)) => { - let mut __lookbehind = None; - let mut __sym0 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state2(__lookbehind, __lookahead, __tokens, __sym0)); - } Some(Tok::Num(__tok0)) => { let mut __lookbehind = None; let mut __sym0 = &mut Some((__tok0)); let __lookahead = __tokens.next(); + __result = try!(__state5(__lookbehind, __lookahead, __tokens, __sym0)); + } + Some(__tok @ Tok::LParen(..)) => { + let mut __lookbehind = None; + let mut __sym0 = &mut Some((__tok)); + let __lookahead = __tokens.next(); __result = try!(__state3(__lookbehind, __lookahead, __tokens, __sym0)); } _ => { @@ -79,14 +85,14 @@ mod __parse__S { let __sym0 = &mut Some(__nt); __result = try!(__state1(__lookbehind, __lookahead, __tokens, __sym0)); } + __Nonterminal::T(__nt) => { + let __sym0 = &mut Some(__nt); + __result = try!(__state2(__lookbehind, __lookahead, __tokens, __sym0)); + } __Nonterminal::E(__nt) => { let __sym0 = &mut Some(__nt); __result = try!(__state4(__lookbehind, __lookahead, __tokens, __sym0)); } - __Nonterminal::T(__nt) => { - let __sym0 = &mut Some(__nt); - __result = try!(__state5(__lookbehind, __lookahead, __tokens, __sym0)); - } _ => { return Ok((__lookbehind, __lookahead, __nt)); } @@ -122,77 +128,14 @@ mod __parse__S { } // State 2 - // E = (*) E "-" T [")"] - // E = (*) E "-" T ["-"] - // E = (*) T [")"] - // E = (*) T ["-"] - // T = (*) "(" E ")" [")"] - // T = (*) "(" E ")" ["-"] - // T = "(" (*) E ")" [EOF] - // T = "(" (*) E ")" ["-"] - // T = (*) "Num" [")"] - // T = (*) "Num" ["-"] + // E = T (*) [EOF] + // E = T (*) ["-"] // - // "Num" -> Shift(S9) - // "(" -> Shift(S8) + // "-" -> Reduce(E = T => Call(ActionFn(3));) + // EOF -> Reduce(E = T => Call(ActionFn(3));) // - // E -> S7 - // T -> S6 pub fn __state2< __TOKENS: Iterator, - >( - __lookbehind: Option<()>, - __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - ) -> Result<(Option<()>, Option, __Nonterminal<>), Option> - { - let mut __result: (Option<()>, Option, __Nonterminal<>); - match __lookahead { - Some(Tok::Num(__tok0)) => { - let mut __lookbehind = None; - let mut __sym1 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state9(__lookbehind, __lookahead, __tokens, __sym1)); - } - Some(__tok @ Tok::LParen(..)) => { - let mut __lookbehind = None; - let mut __sym1 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state8(__lookbehind, __lookahead, __tokens, __sym1)); - } - _ => { - return Err(__lookahead); - } - } - while __sym0.is_some() { - let (__lookbehind, __lookahead, __nt) = __result; - match __nt { - __Nonterminal::E(__nt) => { - let __sym1 = &mut Some(__nt); - __result = try!(__state7(__lookbehind, __lookahead, __tokens, __sym0, __sym1)); - } - __Nonterminal::T(__nt) => { - let __sym1 = &mut Some(__nt); - __result = try!(__state6(__lookbehind, __lookahead, __tokens, __sym1)); - } - _ => { - return Ok((__lookbehind, __lookahead, __nt)); - } - } - } - return Ok(__result); - } - - // State 3 - // T = "Num" (*) [EOF] - // T = "Num" (*) ["-"] - // - // "-" -> Reduce(T = "Num" => Call(ActionFn(4));) - // EOF -> Reduce(T = "Num" => Call(ActionFn(4));) - // - pub fn __state3< - __TOKENS: Iterator, >( __lookbehind: Option<()>, __lookahead: Option, @@ -204,13 +147,13 @@ mod __parse__S { match __lookahead { Some(Tok::Minus(..)) => { let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action4(__sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::T(__nt))); + let __nt = super::__action3(__sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::E(__nt))); } None => { let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action4(__sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::T(__nt))); + let __nt = super::__action3(__sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::E(__nt))); } _ => { return Err(__lookahead); @@ -218,6 +161,69 @@ mod __parse__S { } } + // State 3 + // E = (*) E "-" T [")"] + // E = (*) E "-" T ["-"] + // E = (*) T [")"] + // E = (*) T ["-"] + // T = (*) "(" E ")" [")"] + // T = (*) "(" E ")" ["-"] + // T = "(" (*) E ")" [EOF] + // T = "(" (*) E ")" ["-"] + // T = (*) "Num" [")"] + // T = (*) "Num" ["-"] + // + // "(" -> Shift(S7) + // "Num" -> Shift(S9) + // + // T -> S6 + // E -> S8 + pub fn __state3< + __TOKENS: Iterator, + >( + __lookbehind: Option<()>, + __lookahead: Option, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + ) -> Result<(Option<()>, Option, __Nonterminal<>), Option> + { + let mut __result: (Option<()>, Option, __Nonterminal<>); + match __lookahead { + Some(__tok @ Tok::LParen(..)) => { + let mut __lookbehind = None; + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state7(__lookbehind, __lookahead, __tokens, __sym1)); + } + Some(Tok::Num(__tok0)) => { + let mut __lookbehind = None; + let mut __sym1 = &mut Some((__tok0)); + let __lookahead = __tokens.next(); + __result = try!(__state9(__lookbehind, __lookahead, __tokens, __sym1)); + } + _ => { + return Err(__lookahead); + } + } + while __sym0.is_some() { + let (__lookbehind, __lookahead, __nt) = __result; + match __nt { + __Nonterminal::T(__nt) => { + let __sym1 = &mut Some(__nt); + __result = try!(__state6(__lookbehind, __lookahead, __tokens, __sym1)); + } + __Nonterminal::E(__nt) => { + let __sym1 = &mut Some(__nt); + __result = try!(__state8(__lookbehind, __lookahead, __tokens, __sym0, __sym1)); + } + _ => { + return Ok((__lookbehind, __lookahead, __nt)); + } + } + } + return Ok(__result); + } + // State 4 // E = E (*) "-" T [EOF] // E = E (*) "-" T ["-"] @@ -256,11 +262,11 @@ mod __parse__S { } // State 5 - // E = T (*) [EOF] - // E = T (*) ["-"] + // T = "Num" (*) [EOF] + // T = "Num" (*) ["-"] // - // "-" -> Reduce(E = T => Call(ActionFn(3));) - // EOF -> Reduce(E = T => Call(ActionFn(3));) + // "-" -> Reduce(T = "Num" => Call(ActionFn(4));) + // EOF -> Reduce(T = "Num" => Call(ActionFn(4));) // pub fn __state5< __TOKENS: Iterator, @@ -275,13 +281,13 @@ mod __parse__S { match __lookahead { Some(Tok::Minus(..)) => { let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action3(__sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::E(__nt))); + let __nt = super::__action4(__sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::T(__nt))); } None => { let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action3(__sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::E(__nt))); + let __nt = super::__action4(__sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::T(__nt))); } _ => { return Err(__lookahead); @@ -324,46 +330,6 @@ mod __parse__S { } // State 7 - // E = E (*) "-" T [")"] - // E = E (*) "-" T ["-"] - // T = "(" E (*) ")" [EOF] - // T = "(" E (*) ")" ["-"] - // - // "-" -> Shift(S11) - // ")" -> Shift(S12) - // - pub fn __state7< - __TOKENS: Iterator, - >( - __lookbehind: Option<()>, - __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option, - ) -> Result<(Option<()>, Option, __Nonterminal<>), Option> - { - let mut __result: (Option<()>, Option, __Nonterminal<>); - match __lookahead { - Some(__tok @ Tok::Minus(..)) => { - let mut __lookbehind = None; - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state11(__lookbehind, __lookahead, __tokens, __sym1, __sym2)); - } - Some(__tok @ Tok::RParen(..)) => { - let mut __lookbehind = None; - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state12(__lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 8 // E = (*) E "-" T [")"] // E = (*) E "-" T ["-"] // E = (*) T [")"] @@ -376,11 +342,11 @@ mod __parse__S { // T = (*) "Num" ["-"] // // "Num" -> Shift(S9) - // "(" -> Shift(S8) + // "(" -> Shift(S7) // - // E -> S13 // T -> S6 - pub fn __state8< + // E -> S11 + pub fn __state7< __TOKENS: Iterator, >( __lookbehind: Option<()>, @@ -401,7 +367,7 @@ mod __parse__S { let mut __lookbehind = None; let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state8(__lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state7(__lookbehind, __lookahead, __tokens, __sym1)); } _ => { return Err(__lookahead); @@ -410,14 +376,14 @@ mod __parse__S { while __sym0.is_some() { let (__lookbehind, __lookahead, __nt) = __result; match __nt { - __Nonterminal::E(__nt) => { - let __sym1 = &mut Some(__nt); - __result = try!(__state13(__lookbehind, __lookahead, __tokens, __sym0, __sym1)); - } __Nonterminal::T(__nt) => { let __sym1 = &mut Some(__nt); __result = try!(__state6(__lookbehind, __lookahead, __tokens, __sym1)); } + __Nonterminal::E(__nt) => { + let __sym1 = &mut Some(__nt); + __result = try!(__state11(__lookbehind, __lookahead, __tokens, __sym0, __sym1)); + } _ => { return Ok((__lookbehind, __lookahead, __nt)); } @@ -426,6 +392,46 @@ mod __parse__S { return Ok(__result); } + // State 8 + // E = E (*) "-" T [")"] + // E = E (*) "-" T ["-"] + // T = "(" E (*) ")" [EOF] + // T = "(" E (*) ")" ["-"] + // + // "-" -> Shift(S12) + // ")" -> Shift(S13) + // + pub fn __state8< + __TOKENS: Iterator, + >( + __lookbehind: Option<()>, + __lookahead: Option, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + __sym1: &mut Option, + ) -> Result<(Option<()>, Option, __Nonterminal<>), Option> + { + let mut __result: (Option<()>, Option, __Nonterminal<>); + match __lookahead { + Some(__tok @ Tok::Minus(..)) => { + let mut __lookbehind = None; + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state12(__lookbehind, __lookahead, __tokens, __sym1, __sym2)); + } + Some(__tok @ Tok::RParen(..)) => { + let mut __lookbehind = None; + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state13(__lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + // State 9 // T = "Num" (*) [")"] // T = "Num" (*) ["-"] @@ -468,8 +474,8 @@ mod __parse__S { // T = (*) "Num" [EOF] // T = (*) "Num" ["-"] // - // "Num" -> Shift(S3) - // "(" -> Shift(S2) + // "(" -> Shift(S3) + // "Num" -> Shift(S5) // // T -> S14 pub fn __state10< @@ -484,17 +490,17 @@ mod __parse__S { { let mut __result: (Option<()>, Option, __Nonterminal<>); match __lookahead { - Some(Tok::Num(__tok0)) => { - let mut __lookbehind = None; - let mut __sym2 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state3(__lookbehind, __lookahead, __tokens, __sym2)); - } Some(__tok @ Tok::LParen(..)) => { let mut __lookbehind = None; let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state2(__lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state3(__lookbehind, __lookahead, __tokens, __sym2)); + } + Some(Tok::Num(__tok0)) => { + let mut __lookbehind = None; + let mut __sym2 = &mut Some((__tok0)); + let __lookahead = __tokens.next(); + __result = try!(__state5(__lookbehind, __lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); @@ -516,110 +522,15 @@ mod __parse__S { } // State 11 - // E = E "-" (*) T [")"] - // E = E "-" (*) T ["-"] - // T = (*) "(" E ")" [")"] - // T = (*) "(" E ")" ["-"] - // T = (*) "Num" [")"] - // T = (*) "Num" ["-"] - // - // "(" -> Shift(S8) - // "Num" -> Shift(S9) - // - // T -> S15 - pub fn __state11< - __TOKENS: Iterator, - >( - __lookbehind: Option<()>, - __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option, - ) -> Result<(Option<()>, Option, __Nonterminal<>), Option> - { - let mut __result: (Option<()>, Option, __Nonterminal<>); - match __lookahead { - Some(__tok @ Tok::LParen(..)) => { - let mut __lookbehind = None; - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state8(__lookbehind, __lookahead, __tokens, __sym2)); - } - Some(Tok::Num(__tok0)) => { - let mut __lookbehind = None; - let mut __sym2 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state9(__lookbehind, __lookahead, __tokens, __sym2)); - } - _ => { - return Err(__lookahead); - } - } - while __sym1.is_some() { - let (__lookbehind, __lookahead, __nt) = __result; - match __nt { - __Nonterminal::T(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state15(__lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - _ => { - return Ok((__lookbehind, __lookahead, __nt)); - } - } - } - return Ok(__result); - } - - // State 12 - // T = "(" E ")" (*) [EOF] - // T = "(" E ")" (*) ["-"] - // - // "-" -> Reduce(T = "(", E, ")" => Call(ActionFn(5));) - // EOF -> Reduce(T = "(", E, ")" => Call(ActionFn(5));) - // - pub fn __state12< - __TOKENS: Iterator, - >( - __lookbehind: Option<()>, - __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option, - __sym2: &mut Option, - ) -> Result<(Option<()>, Option, __Nonterminal<>), Option> - { - let mut __result: (Option<()>, 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::__action5(__sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::T(__nt))); - } - None => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action5(__sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::T(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 13 // E = E (*) "-" T [")"] // E = E (*) "-" T ["-"] // T = "(" E (*) ")" [")"] // T = "(" E (*) ")" ["-"] // - // ")" -> Shift(S16) - // "-" -> Shift(S11) + // ")" -> Shift(S15) + // "-" -> Shift(S12) // - pub fn __state13< + pub fn __state11< __TOKENS: Iterator, >( __lookbehind: Option<()>, @@ -635,13 +546,13 @@ mod __parse__S { let mut __lookbehind = None; let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state16(__lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + __result = try!(__state15(__lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); } Some(__tok @ Tok::Minus(..)) => { let mut __lookbehind = None; let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state11(__lookbehind, __lookahead, __tokens, __sym1, __sym2)); + __result = try!(__state12(__lookbehind, __lookahead, __tokens, __sym1, __sym2)); } _ => { return Err(__lookahead); @@ -650,12 +561,107 @@ mod __parse__S { return Ok(__result); } + // State 12 + // E = E "-" (*) T [")"] + // E = E "-" (*) T ["-"] + // T = (*) "(" E ")" [")"] + // T = (*) "(" E ")" ["-"] + // T = (*) "Num" [")"] + // T = (*) "Num" ["-"] + // + // "Num" -> Shift(S9) + // "(" -> Shift(S7) + // + // T -> S16 + pub fn __state12< + __TOKENS: Iterator, + >( + __lookbehind: Option<()>, + __lookahead: Option, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + __sym1: &mut Option, + ) -> Result<(Option<()>, Option, __Nonterminal<>), Option> + { + let mut __result: (Option<()>, Option, __Nonterminal<>); + match __lookahead { + Some(Tok::Num(__tok0)) => { + let mut __lookbehind = None; + let mut __sym2 = &mut Some((__tok0)); + let __lookahead = __tokens.next(); + __result = try!(__state9(__lookbehind, __lookahead, __tokens, __sym2)); + } + Some(__tok @ Tok::LParen(..)) => { + let mut __lookbehind = None; + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state7(__lookbehind, __lookahead, __tokens, __sym2)); + } + _ => { + return Err(__lookahead); + } + } + while __sym1.is_some() { + let (__lookbehind, __lookahead, __nt) = __result; + match __nt { + __Nonterminal::T(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state16(__lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + _ => { + return Ok((__lookbehind, __lookahead, __nt)); + } + } + } + return Ok(__result); + } + + // State 13 + // T = "(" E ")" (*) [EOF] + // T = "(" E ")" (*) ["-"] + // + // EOF -> Reduce(T = "(", E, ")" => Call(ActionFn(5));) + // "-" -> Reduce(T = "(", E, ")" => Call(ActionFn(5));) + // + pub fn __state13< + __TOKENS: Iterator, + >( + __lookbehind: Option<()>, + __lookahead: Option, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + __sym1: &mut Option, + __sym2: &mut Option, + ) -> Result<(Option<()>, Option, __Nonterminal<>), Option> + { + let mut __result: (Option<()>, Option, __Nonterminal<>); + match __lookahead { + None => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action5(__sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::T(__nt))); + } + Some(Tok::Minus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action5(__sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::T(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + // State 14 // E = E "-" T (*) [EOF] // E = E "-" T (*) ["-"] // - // "-" -> Reduce(E = E, "-", T => Call(ActionFn(2));) // EOF -> Reduce(E = E, "-", T => Call(ActionFn(2));) + // "-" -> Reduce(E = E, "-", T => Call(ActionFn(2));) // pub fn __state14< __TOKENS: Iterator, @@ -670,14 +676,14 @@ mod __parse__S { { let mut __result: (Option<()>, Option, __Nonterminal<>); match __lookahead { - Some(Tok::Minus(..)) => { + None => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); let __nt = super::__action2(__sym0, __sym1, __sym2); return Ok((__lookbehind, __lookahead, __Nonterminal::E(__nt))); } - None => { + Some(Tok::Minus(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); @@ -691,13 +697,53 @@ mod __parse__S { } // State 15 + // T = "(" E ")" (*) [")"] + // T = "(" E ")" (*) ["-"] + // + // "-" -> Reduce(T = "(", E, ")" => Call(ActionFn(5));) + // ")" -> Reduce(T = "(", E, ")" => Call(ActionFn(5));) + // + pub fn __state15< + __TOKENS: Iterator, + >( + __lookbehind: Option<()>, + __lookahead: Option, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + __sym1: &mut Option, + __sym2: &mut Option, + ) -> Result<(Option<()>, Option, __Nonterminal<>), Option> + { + let mut __result: (Option<()>, 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::__action5(__sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::T(__nt))); + } + Some(Tok::RParen(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action5(__sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::T(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 16 // E = E "-" T (*) [")"] // E = E "-" T (*) ["-"] // // ")" -> Reduce(E = E, "-", T => Call(ActionFn(2));) // "-" -> Reduce(E = E, "-", T => Call(ActionFn(2));) // - pub fn __state15< + pub fn __state16< __TOKENS: Iterator, >( __lookbehind: Option<()>, @@ -729,46 +775,6 @@ mod __parse__S { } } } - - // State 16 - // T = "(" E ")" (*) [")"] - // T = "(" E ")" (*) ["-"] - // - // ")" -> Reduce(T = "(", E, ")" => Call(ActionFn(5));) - // "-" -> Reduce(T = "(", E, ")" => Call(ActionFn(5));) - // - pub fn __state16< - __TOKENS: Iterator, - >( - __lookbehind: Option<()>, - __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option, - __sym2: &mut Option, - ) -> Result<(Option<()>, Option, __Nonterminal<>), Option> - { - let mut __result: (Option<()>, Option, __Nonterminal<>); - match __lookahead { - Some(Tok::RParen(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action5(__sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::T(__nt))); - } - Some(Tok::Minus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action5(__sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::T(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } } pub fn __action0< diff --git a/lalrpop-test/src/util/mod.rs b/lalrpop-test/src/util/mod.rs index 3c4380e..179ec56 100644 --- a/lalrpop-test/src/util/mod.rs +++ b/lalrpop-test/src/util/mod.rs @@ -9,7 +9,7 @@ pub mod tok; pub fn test(parse_fn: F, input: &str, expected: R) - where F: FnOnce(Vec) -> Result<(Option,R),Option> + where F: FnOnce(Vec) -> Result> { // create tokens let tokens = tok::tokenize(input); @@ -17,11 +17,8 @@ pub fn test(parse_fn: F, // filter to tokens let tokens = tokens.into_iter().map(|(_, tok, _)| tok).collect(); - // parse - let (lookahead, r) = parse_fn(tokens).unwrap(); - - // expect input to be completely consumed - assert!(lookahead.is_none(), "input not completely consumed"); + // parse, expecting input to be totally consumed + let r = parse_fn(tokens).unwrap(); // expect output to be correct assert!(r == expected, "parsing {:?}, got {:#?}, expected {:#?}", input, r, expected); @@ -30,17 +27,13 @@ pub fn test(parse_fn: F, pub fn test_loc(parse_fn: F, input: &str, expected: R) - where F: FnOnce(Vec<(usize, Tok, usize)>) -> Result<(Option<(usize, Tok, usize)>,R), - Option<(usize, Tok, usize)>> + where F: FnOnce(Vec<(usize, Tok, usize)>) -> Result> { // create tokens let tokens = tok::tokenize(input); - // parse - let (lookahead, r) = parse_fn(tokens).unwrap(); - - // expect input to be completely consumed - assert!(lookahead.is_none(), "input not completely consumed"); + // parse, expecting input to be totally consumed + let r = parse_fn(tokens).unwrap(); // expect output to be correct assert!(r == expected, "parsing {:?}, got {:#?}, expected {:#?}", input, r, expected); diff --git a/lalrpop/src/lr1/ascent.rs b/lalrpop/src/lr1/ascent.rs index 9f86056..3b13f6a 100644 --- a/lalrpop/src/lr1/ascent.rs +++ b/lalrpop/src/lr1/ascent.rs @@ -103,6 +103,9 @@ impl<'ascent,'grammar,W:Write> RecursiveAscent<'ascent,'grammar,W> { Ok(()) } + // Generates a function `parse_Foo` that will parse an entire + // input as `Foo`. An error is reported if the entire input is not + // consumed. fn write_start_fn(&mut self) -> io::Result<()> { let item_type = self.iterator_item_type(); rust!(self.out, "#[allow(non_snake_case)]"); @@ -111,8 +114,8 @@ impl<'ascent,'grammar,W:Write> RecursiveAscent<'ascent,'grammar,W> { format!("parse_{}", self.user_start_symbol), vec![format!("{}TOKENS: IntoIterator", self.prefix, item_type)], vec![format!("{}tokens: {}TOKENS", self.prefix, self.prefix)], - format!("Result<(Option<{}>, {}), Option<{}>>", - item_type, self.types.nonterminal_type(self.start_symbol), item_type), + format!("Result<{}, Option<{}>>", + self.types.nonterminal_type(self.start_symbol), item_type), vec![])); rust!(self.out, "{{"); rust!(self.out, "let mut {}tokens = {}tokens.into_iter();", self.prefix, self.prefix); @@ -120,10 +123,15 @@ impl<'ascent,'grammar,W:Write> RecursiveAscent<'ascent,'grammar,W> { rust!(self.out, "match try!({}parse{}::{}state0({}None, {}lookahead, &mut {}tokens)) {{", self.prefix, self.start_symbol, self.prefix, self.grammar.user_parameter_refs(), self.prefix, self.prefix); - rust!(self.out, "(_, {}lookahead, {}parse{}::{}Nonterminal::{}({}nt)) => \ - Ok(({}lookahead, {}nt)),", + rust!(self.out, "(_, {}lookahead, {}parse{}::{}Nonterminal::{}({}nt)) => {{", self.prefix, self.prefix, self.start_symbol, self.prefix, Escape(self.start_symbol), - self.prefix, self.prefix, self.prefix); + self.prefix); + rust!(self.out, "if {}lookahead.is_some() {{", self.prefix); + rust!(self.out, "Err({}lookahead)", self.prefix); // extra tokens + rust!(self.out, "}} else {{"); + rust!(self.out, "Ok({}nt)", self.prefix); + rust!(self.out, "}}"); + rust!(self.out, "}}"); rust!(self.out, "_ => unreachable!(),"); rust!(self.out, "}}"); rust!(self.out, "}}");