From 2383a021c905b32fa953e1e8834f632b3a511df8 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Mon, 20 Jul 2015 05:36:52 -0400 Subject: [PATCH] change the behavior of `@<` and friends so that instead of supplying `None`, they use `Default::default`. You can always give an option yourself if that's what you want, after all, but most of the time it's kind of annoying! --- lalrpop-test/src/expr.rs | 1734 +++++------ lalrpop-test/src/expr_arena.rs | 4004 +++++++++++++------------- lalrpop-test/src/loc.lalrpop | 6 +- lalrpop-test/src/loc.rs | 372 ++- lalrpop-test/src/main.rs | 16 +- lalrpop-test/src/sub.rs | 492 ++-- lalrpop/src/lr1/ascent.rs | 17 +- lalrpop/src/normalize/tyinfer/mod.rs | 6 +- 8 files changed, 3385 insertions(+), 3262 deletions(-) diff --git a/lalrpop-test/src/expr.rs b/lalrpop-test/src/expr.rs index 31961b4..11d87ed 100644 --- a/lalrpop-test/src/expr.rs +++ b/lalrpop-test/src/expr.rs @@ -24,10 +24,10 @@ mod __parse__Expr { use util::tok::Tok; pub enum __Nonterminal<> { - Expr(i32), + Term(i32), Factor(i32), ____Expr(i32), - Term(i32), + Expr(i32), } // State 0 @@ -67,12 +67,12 @@ mod __parse__Expr { // Term = (*) "Num" ["/"] // __Expr = (*) Expr [EOF] // - // "(" -> Shift(S1) - // "Num" -> Shift(S5) + // "(" -> Shift(S3) + // "Num" -> Shift(S2) // - // Term -> S2 - // Expr -> S4 - // Factor -> S3 + // Term -> S1 + // Expr -> S5 + // Factor -> S4 pub fn __state0< __TOKENS: Iterator, >( @@ -88,13 +88,13 @@ mod __parse__Expr { let mut __lookbehind = None; let mut __sym0 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state1(scale, __lookbehind, __lookahead, __tokens, __sym0)); + __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!(__state5(scale, __lookbehind, __lookahead, __tokens, __sym0)); + __result = try!(__state2(scale, __lookbehind, __lookahead, __tokens, __sym0)); } _ => { return Err(__lookahead); @@ -105,15 +105,15 @@ mod __parse__Expr { match __nt { __Nonterminal::Term(__nt) => { let __sym0 = &mut Some(__nt); - __result = try!(__state2(scale, __lookbehind, __lookahead, __tokens, __sym0)); + __result = try!(__state1(scale, __lookbehind, __lookahead, __tokens, __sym0)); } __Nonterminal::Expr(__nt) => { let __sym0 = &mut Some(__nt); - __result = try!(__state4(scale, __lookbehind, __lookahead, __tokens, __sym0)); + __result = try!(__state5(scale, __lookbehind, __lookahead, __tokens, __sym0)); } __Nonterminal::Factor(__nt) => { let __sym0 = &mut Some(__nt); - __result = try!(__state3(scale, __lookbehind, __lookahead, __tokens, __sym0)); + __result = try!(__state4(scale, __lookbehind, __lookahead, __tokens, __sym0)); } _ => { return Ok((__lookbehind, __lookahead, __nt)); @@ -123,6 +123,118 @@ mod __parse__Expr { } // State 1 + // Factor = Term (*) [EOF] + // Factor = Term (*) ["*"] + // Factor = Term (*) ["+"] + // Factor = Term (*) ["-"] + // 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));) + // + pub fn __state1< + __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::Times(..)) => { + 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))); + } + None => { + 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::Div(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action6(scale, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 2 + // Term = "Num" (*) [EOF] + // Term = "Num" (*) ["*"] + // Term = "Num" (*) ["+"] + // Term = "Num" (*) ["-"] + // Term = "Num" (*) ["/"] + // + // "*" -> Reduce(Term = "Num" => Call(ActionFn(7));) + // "/" -> Reduce(Term = "Num" => Call(ActionFn(7));) + // EOF -> Reduce(Term = "Num" => Call(ActionFn(7));) + // "-" -> Reduce(Term = "Num" => Call(ActionFn(7));) + // "+" -> Reduce(Term = "Num" => Call(ActionFn(7));) + // + pub fn __state2< + __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::Times(..)) => { + 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))); + } + 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))); + } + Some(Tok::Plus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action7(scale, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 3 // Expr = (*) Expr "+" Factor [")"] // Expr = (*) Expr "+" Factor ["+"] // Expr = (*) Expr "+" Factor ["-"] @@ -163,13 +275,13 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "(" -> Shift(S6) - // "Num" -> Shift(S9) + // "(" -> Shift(S8) + // "Num" -> Shift(S6) // - // Expr -> S7 - // Term -> S10 - // Factor -> S8 - pub fn __state1< + // Expr -> S10 + // Factor -> S9 + // Term -> S7 + pub fn __state3< __TOKENS: Iterator, >( scale: i32, @@ -185,13 +297,13 @@ mod __parse__Expr { let mut __lookbehind = None; let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state6(scale, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state8(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!(__state9(scale, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state6(scale, __lookbehind, __lookahead, __tokens, __sym1)); } _ => { return Err(__lookahead); @@ -202,15 +314,15 @@ mod __parse__Expr { match __nt { __Nonterminal::Expr(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state7(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); - } - __Nonterminal::Term(__nt) => { - let __sym1 = &mut Some(__nt); - __result = try!(__state10(scale, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state10(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); } __Nonterminal::Factor(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state8(scale, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state9(scale, __lookbehind, __lookahead, __tokens, __sym1)); + } + __Nonterminal::Term(__nt) => { + let __sym1 = &mut Some(__nt); + __result = try!(__state7(scale, __lookbehind, __lookahead, __tokens, __sym1)); } _ => { return Ok((__lookbehind, __lookahead, __nt)); @@ -220,63 +332,7 @@ mod __parse__Expr { return Ok(__result); } - // State 2 - // Factor = Term (*) [EOF] - // Factor = Term (*) ["*"] - // Factor = Term (*) ["+"] - // Factor = Term (*) ["-"] - // Factor = Term (*) ["/"] - // - // 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, - >( - 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 { - None => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action6(scale, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Div(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action6(scale, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Minus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action6(scale, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Times(..)) => { - 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))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 3 + // State 4 // Expr = Factor (*) [EOF] // Expr = Factor (*) ["+"] // Expr = Factor (*) ["-"] @@ -291,13 +347,13 @@ mod __parse__Expr { // Factor = Factor (*) "/" Term ["-"] // Factor = Factor (*) "/" Term ["/"] // - // "-" -> Reduce(Expr = Factor => Call(ActionFn(3));) + // "/" -> Shift(S12) // EOF -> Reduce(Expr = Factor => Call(ActionFn(3));) - // "/" -> Shift(S11) - // "*" -> Shift(S12) // "+" -> Reduce(Expr = Factor => Call(ActionFn(3));) + // "*" -> Shift(S11) + // "-" -> Reduce(Expr = Factor => Call(ActionFn(3));) // - pub fn __state3< + pub fn __state4< __TOKENS: Iterator, >( scale: i32, @@ -313,18 +369,13 @@ mod __parse__Expr { let mut __lookbehind = None; let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state11(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + __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!(__state12(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))); + __result = try!(__state11(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); } None => { let __sym0 = __sym0.take().unwrap(); @@ -336,6 +387,11 @@ mod __parse__Expr { 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); } @@ -343,7 +399,7 @@ mod __parse__Expr { return Ok(__result); } - // State 4 + // State 5 // Expr = Expr (*) "+" Factor [EOF] // Expr = Expr (*) "+" Factor ["+"] // Expr = Expr (*) "+" Factor ["-"] @@ -352,11 +408,11 @@ mod __parse__Expr { // Expr = Expr (*) "-" Factor ["-"] // __Expr = Expr (*) [EOF] // - // "+" -> Shift(S13) - // "-" -> Shift(S14) + // "-" -> Shift(S13) + // "+" -> Shift(S14) // EOF -> Reduce(__Expr = Expr => Call(ActionFn(0));) // - pub fn __state4< + pub fn __state5< __TOKENS: Iterator, >( scale: i32, @@ -368,13 +424,13 @@ mod __parse__Expr { { let mut __result: (Option<()>, Option, __Nonterminal<>); match __lookahead { - Some(__tok @ Tok::Plus(..)) => { + 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::Minus(..)) => { + Some(__tok @ Tok::Plus(..)) => { let mut __lookbehind = None; let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); @@ -392,20 +448,20 @@ mod __parse__Expr { return Ok(__result); } - // State 5 - // Term = "Num" (*) [EOF] + // State 6 + // 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));) - // 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< + pub fn __state6< __TOKENS: Iterator, >( scale: i32, @@ -417,11 +473,6 @@ mod __parse__Expr { { let mut __result: (Option<()>, Option, __Nonterminal<>); match __lookahead { - Some(Tok::Times(..)) => { - 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); @@ -432,7 +483,7 @@ mod __parse__Expr { let __nt = super::__action7(scale, __sym0); return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); } - None => { + Some(Tok::Times(..)) => { let __sym0 = __sym0.take().unwrap(); let __nt = super::__action7(scale, __sym0); return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); @@ -442,13 +493,74 @@ mod __parse__Expr { 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 6 + // State 7 + // Factor = Term (*) [")"] + // Factor = Term (*) ["*"] + // Factor = Term (*) ["+"] + // Factor = Term (*) ["-"] + // Factor = Term (*) ["/"] + // + // "/" -> Reduce(Factor = Term => Call(ActionFn(6));) + // "-" -> Reduce(Factor = Term => Call(ActionFn(6));) + // "*" -> Reduce(Factor = Term => Call(ActionFn(6));) + // ")" -> Reduce(Factor = Term => Call(ActionFn(6));) + // "+" -> Reduce(Factor = Term => Call(ActionFn(6));) + // + pub fn __state7< + __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::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(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action6(scale, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some(Tok::RParen(..)) => { + 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))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 8 // Expr = (*) Expr "+" Factor [")"] // Expr = (*) Expr "+" Factor ["+"] // Expr = (*) Expr "+" Factor ["-"] @@ -489,13 +601,13 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "Num" -> Shift(S9) - // "(" -> Shift(S6) + // "(" -> Shift(S8) + // "Num" -> Shift(S6) // - // Factor -> S8 - // Term -> S10 + // Term -> S7 // Expr -> S15 - pub fn __state6< + // Factor -> S9 + pub fn __state8< __TOKENS: Iterator, >( scale: i32, @@ -507,16 +619,16 @@ mod __parse__Expr { { 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(scale, __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(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)); } _ => { @@ -526,18 +638,18 @@ mod __parse__Expr { while __sym0.is_some() { let (__lookbehind, __lookahead, __nt) = __result; match __nt { - __Nonterminal::Factor(__nt) => { - let __sym1 = &mut Some(__nt); - __result = try!(__state8(scale, __lookbehind, __lookahead, __tokens, __sym1)); - } __Nonterminal::Term(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state10(scale, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state7(scale, __lookbehind, __lookahead, __tokens, __sym1)); } __Nonterminal::Expr(__nt) => { let __sym1 = &mut Some(__nt); __result = try!(__state15(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); } + __Nonterminal::Factor(__nt) => { + let __sym1 = &mut Some(__nt); + __result = try!(__state9(scale, __lookbehind, __lookahead, __tokens, __sym1)); + } _ => { return Ok((__lookbehind, __lookahead, __nt)); } @@ -546,62 +658,7 @@ mod __parse__Expr { return Ok(__result); } - // State 7 - // 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(S18) - // "-" -> Shift(S17) - // ")" -> Shift(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::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 @ Tok::Minus(..)) => { - let mut __lookbehind = None; - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state17(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!(__state16(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 8 + // State 9 // Expr = Factor (*) [")"] // Expr = Factor (*) ["+"] // Expr = Factor (*) ["-"] @@ -616,70 +673,11 @@ mod __parse__Expr { // Factor = Factor (*) "/" Term ["-"] // Factor = Factor (*) "/" Term ["/"] // - // "+" -> Reduce(Expr = Factor => Call(ActionFn(3));) - // "/" -> Shift(S19) - // ")" -> Reduce(Expr = Factor => Call(ActionFn(3));) // "-" -> Reduce(Expr = Factor => Call(ActionFn(3));) - // "*" -> Shift(S20) - // - pub fn __state8< - __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!(__state19(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!(__state20(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); - } - Some(Tok::Plus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action3(scale, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - Some(Tok::RParen(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action3(scale, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - Some(Tok::Minus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action3(scale, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 9 - // Term = "Num" (*) [")"] - // Term = "Num" (*) ["*"] - // Term = "Num" (*) ["+"] - // Term = "Num" (*) ["-"] - // Term = "Num" (*) ["/"] - // - // ")" -> Reduce(Term = "Num" => Call(ActionFn(7));) - // "+" -> Reduce(Term = "Num" => Call(ActionFn(7));) - // "-" -> Reduce(Term = "Num" => Call(ActionFn(7));) - // "*" -> Reduce(Term = "Num" => Call(ActionFn(7));) - // "/" -> Reduce(Term = "Num" => Call(ActionFn(7));) + // ")" -> Reduce(Expr = Factor => Call(ActionFn(3));) + // "*" -> Shift(S16) + // "/" -> Shift(S17) + // "+" -> Reduce(Expr = Factor => Call(ActionFn(3));) // pub fn __state9< __TOKENS: Iterator, @@ -693,49 +691,56 @@ mod __parse__Expr { { let mut __result: (Option<()>, Option, __Nonterminal<>); match __lookahead { - Some(Tok::RParen(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action7(scale, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + 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::Plus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action7(scale, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + 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)); } Some(Tok::Minus(..)) => { let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action7(scale, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + let __nt = super::__action3(scale, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); } - Some(Tok::Times(..)) => { + Some(Tok::RParen(..)) => { let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action7(scale, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__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::__action7(scale, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + let __nt = super::__action3(scale, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); } _ => { return Err(__lookahead); } } + return Ok(__result); } // State 10 - // Factor = Term (*) [")"] - // Factor = Term (*) ["*"] - // Factor = Term (*) ["+"] - // Factor = Term (*) ["-"] - // Factor = Term (*) ["/"] + // 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 (*) ")" ["/"] // - // ")" -> 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));) + // "-" -> Shift(S19) + // ")" -> Shift(S20) + // "+" -> Shift(S18) // pub fn __state10< __TOKENS: Iterator, @@ -744,48 +749,43 @@ mod __parse__Expr { __lookbehind: Option<()>, __lookahead: Option, __tokens: &mut __TOKENS, - __sym0: &mut Option, + __sym0: &mut Option, + __sym1: &mut Option, ) -> Result<(Option<()>, Option, __Nonterminal<>), Option> { let mut __result: (Option<()>, Option, __Nonterminal<>); match __lookahead { - Some(Tok::RParen(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action6(scale, __sym0); - 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::Minus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action6(scale, __sym0); - 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!(__state20(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); } - Some(Tok::Plus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action6(scale, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Times(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action6(scale, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Div(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action6(scale, __sym0); - 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!(__state18(scale, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); } _ => { return Err(__lookahead); } } + return Ok(__result); } // State 11 - // 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 ["/"] // Term = (*) "(" Expr ")" [EOF] // Term = (*) "(" Expr ")" ["*"] // Term = (*) "(" Expr ")" ["+"] @@ -797,8 +797,8 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "Num" -> Shift(S5) - // "(" -> Shift(S1) + // "(" -> Shift(S3) + // "Num" -> Shift(S2) // // Term -> S21 pub fn __state11< @@ -814,17 +814,17 @@ mod __parse__Expr { { 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!(__state1(scale, __lookbehind, __lookahead, __tokens, __sym2)); + __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); @@ -846,11 +846,11 @@ mod __parse__Expr { } // State 12 - // 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 ["/"] // Term = (*) "(" Expr ")" [EOF] // Term = (*) "(" Expr ")" ["*"] // Term = (*) "(" Expr ")" ["+"] @@ -862,8 +862,8 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "Num" -> Shift(S5) - // "(" -> Shift(S1) + // "(" -> Shift(S3) + // "Num" -> Shift(S2) // // Term -> S22 pub fn __state12< @@ -879,17 +879,17 @@ mod __parse__Expr { { 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!(__state1(scale, __lookbehind, __lookahead, __tokens, __sym2)); + __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); @@ -911,89 +911,6 @@ mod __parse__Expr { } // State 13 - // Expr = Expr "+" (*) Factor [EOF] - // Expr = Expr "+" (*) Factor ["+"] - // Expr = Expr "+" (*) Factor ["-"] - // Factor = (*) Factor "*" Term [EOF] - // Factor = (*) Factor "*" Term ["*"] - // Factor = (*) Factor "*" Term ["+"] - // Factor = (*) Factor "*" Term ["-"] - // Factor = (*) Factor "*" Term ["/"] - // Factor = (*) Factor "/" Term [EOF] - // Factor = (*) Factor "/" Term ["*"] - // Factor = (*) Factor "/" Term ["+"] - // Factor = (*) Factor "/" Term ["-"] - // Factor = (*) Factor "/" Term ["/"] - // Factor = (*) Term [EOF] - // Factor = (*) Term ["*"] - // Factor = (*) Term ["+"] - // Factor = (*) Term ["-"] - // Factor = (*) Term ["/"] - // Term = (*) "(" Expr ")" [EOF] - // Term = (*) "(" Expr ")" ["*"] - // Term = (*) "(" Expr ")" ["+"] - // Term = (*) "(" Expr ")" ["-"] - // Term = (*) "(" Expr ")" ["/"] - // Term = (*) "Num" [EOF] - // Term = (*) "Num" ["*"] - // Term = (*) "Num" ["+"] - // Term = (*) "Num" ["-"] - // Term = (*) "Num" ["/"] - // - // "Num" -> Shift(S5) - // "(" -> Shift(S1) - // - // Factor -> S23 - // Term -> S2 - 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::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!(__state1(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!(__state2(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 ["-"] @@ -1023,11 +940,94 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "Num" -> Shift(S5) - // "(" -> Shift(S1) + // "(" -> 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 - // Term -> S2 pub fn __state14< __TOKENS: Iterator, >( @@ -1045,13 +1045,13 @@ mod __parse__Expr { let mut __lookbehind = None; let mut __sym2 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state5(scale, __lookbehind, __lookahead, __tokens, __sym2)); + __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!(__state1(scale, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state3(scale, __lookbehind, __lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); @@ -1060,14 +1060,14 @@ mod __parse__Expr { 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)); } - __Nonterminal::Term(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state2(scale, __lookbehind, __lookahead, __tokens, __sym2)); - } _ => { return Ok((__lookbehind, __lookahead, __nt)); } @@ -1089,9 +1089,9 @@ mod __parse__Expr { // Term = "(" Expr (*) ")" ["-"] // Term = "(" Expr (*) ")" ["/"] // - // ")" -> Shift(S25) - // "-" -> Shift(S17) // "+" -> Shift(S18) + // ")" -> Shift(S25) + // "-" -> Shift(S19) // pub fn __state15< __TOKENS: Iterator, @@ -1106,6 +1106,12 @@ mod __parse__Expr { { 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 @ Tok::RParen(..)) => { let mut __lookbehind = None; let mut __sym2 = &mut Some((__tok)); @@ -1116,13 +1122,7 @@ mod __parse__Expr { let mut __lookbehind = None; let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state17(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!(__state18(scale, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); + __result = try!(__state19(scale, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); } _ => { return Err(__lookahead); @@ -1132,92 +1132,11 @@ mod __parse__Expr { } // State 16 - // Term = "(" Expr ")" (*) [EOF] - // Term = "(" Expr ")" (*) ["*"] - // Term = "(" Expr ")" (*) ["+"] - // Term = "(" Expr ")" (*) ["-"] - // Term = "(" Expr ")" (*) ["/"] - // - // "-" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) - // "+" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) - // "*" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) - // "/" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) - // EOF -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) - // - pub fn __state16< - __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::Minus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action8(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - Some(Tok::Plus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action8(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - Some(Tok::Times(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action8(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - 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))); - } - None => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action8(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 17 - // Expr = Expr "-" (*) Factor [")"] - // Expr = Expr "-" (*) Factor ["+"] - // Expr = Expr "-" (*) Factor ["-"] - // Factor = (*) Factor "*" Term [")"] - // Factor = (*) Factor "*" Term ["*"] - // Factor = (*) Factor "*" Term ["+"] - // Factor = (*) Factor "*" Term ["-"] - // Factor = (*) Factor "*" Term ["/"] - // Factor = (*) Factor "/" Term [")"] - // Factor = (*) Factor "/" Term ["*"] - // Factor = (*) Factor "/" Term ["+"] - // Factor = (*) Factor "/" Term ["-"] - // Factor = (*) Factor "/" Term ["/"] - // Factor = (*) Term [")"] - // Factor = (*) Term ["*"] - // Factor = (*) Term ["+"] - // Factor = (*) Term ["-"] - // Factor = (*) Term ["/"] + // Factor = Factor "*" (*) Term [")"] + // Factor = Factor "*" (*) Term ["*"] + // Factor = Factor "*" (*) Term ["+"] + // Factor = Factor "*" (*) Term ["-"] + // Factor = Factor "*" (*) Term ["/"] // Term = (*) "(" Expr ")" [")"] // Term = (*) "(" Expr ")" ["*"] // Term = (*) "(" Expr ")" ["+"] @@ -1229,12 +1148,11 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "Num" -> Shift(S9) - // "(" -> Shift(S6) + // "Num" -> Shift(S6) + // "(" -> Shift(S8) // - // Term -> S10 - // Factor -> S26 - pub fn __state17< + // Term -> S26 + pub fn __state16< __TOKENS: Iterator, >( scale: i32, @@ -1251,12 +1169,77 @@ mod __parse__Expr { let mut __lookbehind = None; let mut __sym2 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state9(scale, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state6(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)); + } + _ => { + 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" ["/"] + // + // "(" -> Shift(S8) + // "Num" -> Shift(S6) + // + // Term -> S27 + pub fn __state17< + __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!(__state8(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!(__state6(scale, __lookbehind, __lookahead, __tokens, __sym2)); } _ => { @@ -1268,11 +1251,7 @@ mod __parse__Expr { 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!(__state26(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + __result = try!(__state27(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); } _ => { return Ok((__lookbehind, __lookahead, __nt)); @@ -1312,11 +1291,11 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "Num" -> Shift(S9) - // "(" -> Shift(S6) + // "Num" -> Shift(S6) + // "(" -> Shift(S8) // - // Term -> S10 - // Factor -> S27 + // Factor -> S28 + // Term -> S7 pub fn __state18< __TOKENS: Iterator, >( @@ -1334,13 +1313,13 @@ mod __parse__Expr { let mut __lookbehind = None; let mut __sym2 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state9(scale, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state6(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!(__state6(scale, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state8(scale, __lookbehind, __lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); @@ -1349,13 +1328,13 @@ mod __parse__Expr { 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!(__state27(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + __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)); @@ -1366,11 +1345,24 @@ mod __parse__Expr { } // State 19 - // 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 ["/"] + // Factor = (*) Term [")"] + // Factor = (*) Term ["*"] + // Factor = (*) Term ["+"] + // Factor = (*) Term ["-"] + // Factor = (*) Term ["/"] // Term = (*) "(" Expr ")" [")"] // Term = (*) "(" Expr ")" ["*"] // Term = (*) "(" Expr ")" ["+"] @@ -1382,10 +1374,11 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "(" -> Shift(S6) - // "Num" -> Shift(S9) + // "Num" -> Shift(S6) + // "(" -> Shift(S8) // - // Term -> S28 + // Factor -> S29 + // Term -> S7 pub fn __state19< __TOKENS: Iterator, >( @@ -1399,17 +1392,17 @@ mod __parse__Expr { { 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!(__state6(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!(__state9(scale, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state6(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)); } _ => { return Err(__lookahead); @@ -1418,9 +1411,13 @@ mod __parse__Expr { while __sym1.is_some() { let (__lookbehind, __lookahead, __nt) = __result; match __nt { + __Nonterminal::Factor(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state29(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } __Nonterminal::Term(__nt) => { let __sym2 = &mut Some(__nt); - __result = try!(__state28(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + __result = try!(__state7(scale, __lookbehind, __lookahead, __tokens, __sym2)); } _ => { return Ok((__lookbehind, __lookahead, __nt)); @@ -1431,26 +1428,18 @@ mod __parse__Expr { } // State 20 - // 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" ["/"] + // Term = "(" Expr ")" (*) [EOF] + // Term = "(" Expr ")" (*) ["*"] + // Term = "(" Expr ")" (*) ["+"] + // Term = "(" Expr ")" (*) ["-"] + // Term = "(" Expr ")" (*) ["/"] // - // "(" -> Shift(S6) - // "Num" -> Shift(S9) + // "/" -> 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));) // - // Term -> S29 pub fn __state20< __TOKENS: Iterator, >( @@ -1458,55 +1447,66 @@ 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::LParen(..)) => { - let mut __lookbehind = None; - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state6(scale, __lookbehind, __lookahead, __tokens, __sym2)); + Some(Tok::Div(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action8(scale, __sym0, __sym1, __sym2); + 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!(__state9(scale, __lookbehind, __lookahead, __tokens, __sym2)); + Some(Tok::Minus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action8(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + Some(Tok::Plus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action8(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + Some(Tok::Times(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action8(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + None => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action8(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); } _ => { 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 21 - // Factor = Factor "/" Term (*) [EOF] - // Factor = Factor "/" Term (*) ["*"] - // Factor = Factor "/" Term (*) ["+"] - // Factor = Factor "/" Term (*) ["-"] - // Factor = Factor "/" Term (*) ["/"] + // Factor = Factor "*" Term (*) [EOF] + // Factor = Factor "*" Term (*) ["*"] + // Factor = Factor "*" Term (*) ["+"] + // Factor = Factor "*" Term (*) ["-"] + // Factor = Factor "*" Term (*) ["/"] // - // EOF -> Reduce(Factor = Factor, "/", Term => 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(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, @@ -1522,39 +1522,39 @@ mod __parse__Expr { { 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::Div(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action5(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Times(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action5(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } Some(Tok::Plus(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action5(scale, __sym0, __sym1, __sym2); + 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::__action5(scale, __sym0, __sym1, __sym2); + 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))); } _ => { @@ -1564,17 +1564,17 @@ mod __parse__Expr { } // State 22 - // Factor = Factor "*" Term (*) [EOF] - // Factor = Factor "*" Term (*) ["*"] - // Factor = Factor "*" Term (*) ["+"] - // Factor = Factor "*" Term (*) ["-"] - // Factor = Factor "*" Term (*) ["/"] + // Factor = Factor "/" Term (*) [EOF] + // Factor = Factor "/" Term (*) ["*"] + // Factor = Factor "/" Term (*) ["+"] + // Factor = Factor "/" Term (*) ["-"] + // Factor = Factor "/" Term (*) ["/"] // - // "*" -> Reduce(Factor = Factor, "*", Term => 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));) + // 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 __state22< __TOKENS: Iterator, @@ -1590,39 +1590,39 @@ mod __parse__Expr { { 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::Times(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action4(scale, __sym0, __sym1, __sym2); + 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::__action4(scale, __sym0, __sym1, __sym2); + 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::__action4(scale, __sym0, __sym1, __sym2); + 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::__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); + let __nt = super::__action5(scale, __sym0, __sym1, __sym2); return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } _ => { @@ -1632,9 +1632,9 @@ mod __parse__Expr { } // State 23 - // Expr = Expr "+" Factor (*) [EOF] - // Expr = Expr "+" Factor (*) ["+"] - // Expr = Expr "+" Factor (*) ["-"] + // Expr = Expr "-" Factor (*) [EOF] + // Expr = Expr "-" Factor (*) ["+"] + // Expr = Expr "-" Factor (*) ["-"] // Factor = Factor (*) "*" Term [EOF] // Factor = Factor (*) "*" Term ["*"] // Factor = Factor (*) "*" Term ["+"] @@ -1646,11 +1646,11 @@ mod __parse__Expr { // 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(S12) - // "/" -> Shift(S11) + // "*" -> 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));) // pub fn __state23< __TOKENS: Iterator, @@ -1670,33 +1670,33 @@ mod __parse__Expr { let mut __lookbehind = None; let mut __sym3 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state12(scale, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); + __result = try!(__state11(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!(__state11(scale, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); - } - Some(Tok::Minus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action2(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + __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::__action2(scale, __sym0, __sym1, __sym2); + 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::__action2(scale, __sym0, __sym1, __sym2); + let __nt = super::__action1(scale, __sym0, __sym1, __sym2); return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); } _ => { @@ -1707,9 +1707,9 @@ mod __parse__Expr { } // State 24 - // Expr = Expr "-" Factor (*) [EOF] - // Expr = Expr "-" Factor (*) ["+"] - // Expr = Expr "-" Factor (*) ["-"] + // Expr = Expr "+" Factor (*) [EOF] + // Expr = Expr "+" Factor (*) ["+"] + // Expr = Expr "+" Factor (*) ["-"] // Factor = Factor (*) "*" Term [EOF] // Factor = Factor (*) "*" Term ["*"] // Factor = Factor (*) "*" Term ["+"] @@ -1721,11 +1721,11 @@ mod __parse__Expr { // Factor = Factor (*) "/" Term ["-"] // Factor = Factor (*) "/" Term ["/"] // - // "+" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) - // "*" -> Shift(S12) - // "/" -> Shift(S11) - // EOF -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) - // "-" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // "/" -> 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) // pub fn __state24< __TOKENS: Iterator, @@ -1741,37 +1741,37 @@ mod __parse__Expr { { let mut __result: (Option<()>, Option, __Nonterminal<>); match __lookahead { - Some(__tok @ Tok::Times(..)) => { + 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::Div(..)) => { + 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)); } + Some(Tok::Minus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action2(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } Some(Tok::Plus(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action1(scale, __sym0, __sym1, __sym2); + 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::__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); + let __nt = super::__action2(scale, __sym0, __sym1, __sym2); return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); } _ => { @@ -1788,11 +1788,11 @@ mod __parse__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));) - // "+" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) + // ")" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) // pub fn __state25< __TOKENS: Iterator, @@ -1808,6 +1808,13 @@ mod __parse__Expr { { 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(); @@ -1822,13 +1829,6 @@ mod __parse__Expr { 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))); - } Some(Tok::Div(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); @@ -1836,7 +1836,7 @@ mod __parse__Expr { let __nt = super::__action8(scale, __sym0, __sym1, __sym2); return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); } - Some(Tok::Plus(..)) => { + Some(Tok::RParen(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); @@ -1850,25 +1850,17 @@ mod __parse__Expr { } // State 26 - // Expr = Expr "-" Factor (*) [")"] - // Expr = Expr "-" Factor (*) ["+"] - // Expr = Expr "-" Factor (*) ["-"] - // Factor = Factor (*) "*" Term [")"] - // Factor = Factor (*) "*" Term ["*"] - // Factor = Factor (*) "*" Term ["+"] - // Factor = Factor (*) "*" Term ["-"] - // Factor = Factor (*) "*" Term ["/"] - // Factor = Factor (*) "/" Term [")"] - // Factor = Factor (*) "/" Term ["*"] - // Factor = Factor (*) "/" Term ["+"] - // Factor = Factor (*) "/" Term ["-"] - // Factor = Factor (*) "/" Term ["/"] + // Factor = Factor "*" Term (*) [")"] + // Factor = Factor "*" Term (*) ["*"] + // Factor = Factor "*" Term (*) ["+"] + // Factor = Factor "*" Term (*) ["-"] + // Factor = Factor "*" Term (*) ["/"] // - // "/" -> Shift(S19) - // ")" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) - // "+" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) - // "*" -> Shift(S20) - // "-" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // "/" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // ")" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // "-" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // "*" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // "+" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) // pub fn __state26< __TOKENS: Iterator, @@ -1884,66 +1876,59 @@ 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!(__state19(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!(__state20(scale, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); + Some(Tok::Div(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__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::__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))); + 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::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); } // State 27 - // Expr = Expr "+" Factor (*) [")"] - // Expr = Expr "+" Factor (*) ["+"] - // Expr = Expr "+" Factor (*) ["-"] - // Factor = Factor (*) "*" Term [")"] - // Factor = Factor (*) "*" Term ["*"] - // Factor = Factor (*) "*" Term ["+"] - // Factor = Factor (*) "*" Term ["-"] - // Factor = Factor (*) "*" Term ["/"] - // Factor = Factor (*) "/" Term [")"] - // Factor = Factor (*) "/" Term ["*"] - // Factor = Factor (*) "/" Term ["+"] - // Factor = Factor (*) "/" Term ["-"] - // Factor = Factor (*) "/" Term ["/"] + // Factor = Factor "/" Term (*) [")"] + // Factor = Factor "/" Term (*) ["*"] + // Factor = Factor "/" Term (*) ["+"] + // Factor = Factor "/" Term (*) ["-"] + // Factor = Factor "/" Term (*) ["/"] // - // "/" -> Shift(S19) - // "*" -> Shift(S20) - // "-" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) - // "+" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) - // ")" -> 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 __state27< __TOKENS: Iterator, @@ -1959,26 +1944,102 @@ 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!(__state19(scale, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); + Some(Tok::Times(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action5(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } + Some(Tok::Div(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action5(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some(Tok::Plus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action5(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + 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::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))); + } + _ => { + return Err(__lookahead); + } + } + } + + // 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 ["/"] + // + // "+" -> 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));) + // + pub fn __state28< + __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 @ Tok::Times(..)) => { let mut __lookbehind = None; let mut __sym3 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state20(scale, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); + __result = try!(__state16(scale, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); } - Some(Tok::Minus(..)) => { + 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))); } - Some(Tok::Plus(..)) => { + Some(Tok::Minus(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); @@ -1999,86 +2060,26 @@ mod __parse__Expr { return Ok(__result); } - // State 28 - // Factor = Factor "/" Term (*) [")"] - // Factor = Factor "/" Term (*) ["*"] - // Factor = Factor "/" Term (*) ["+"] - // Factor = Factor "/" Term (*) ["-"] - // Factor = Factor "/" Term (*) ["/"] - // - // "-" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // ")" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // "/" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // "*" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // "+" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // - pub fn __state28< - __TOKENS: Iterator, - >( - scale: i32, - __lookbehind: Option<()>, - __lookahead: Option, - __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(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::RParen(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action5(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Div(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action5(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Times(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action5(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Plus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action5(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - // State 29 - // Factor = Factor "*" Term (*) [")"] - // Factor = Factor "*" Term (*) ["*"] - // Factor = Factor "*" Term (*) ["+"] - // Factor = Factor "*" Term (*) ["-"] - // Factor = Factor "*" Term (*) ["/"] + // 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(1));) + // "/" -> Shift(S17) + // ")" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // "-" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // "*" -> Shift(S16) // pub fn __state29< __TOKENS: Iterator, @@ -2094,45 +2095,44 @@ mod __parse__Expr { { let mut __result: (Option<()>, Option, __Nonterminal<>); match __lookahead { - Some(Tok::Times(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__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!(__state17(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::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::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!(__state16(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::__action4(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + let __nt = super::__action1(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + Some(Tok::RParen(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action1(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + Some(Tok::Minus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action1(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); } _ => { return Err(__lookahead); } } + return Ok(__result); } } diff --git a/lalrpop-test/src/expr_arena.rs b/lalrpop-test/src/expr_arena.rs index 4514026..15ed082 100644 --- a/lalrpop-test/src/expr_arena.rs +++ b/lalrpop-test/src/expr_arena.rs @@ -27,14 +27,14 @@ mod __parse__Expr { use util::tok::Tok; pub enum __Nonterminal<'ast, > { - _28_3cExpr_3e_20_22_2c_22_29(&'ast Node<'ast>), + ____Expr(&'ast Node<'ast>), Comma_3cExpr_3e(Vec<&'ast Node<'ast>>), + _28_3cExpr_3e_20_22_2c_22_29(&'ast Node<'ast>), + Expr(&'ast Node<'ast>), + _28_3cExpr_3e_20_22_2c_22_29_2a(::std::vec::Vec<&'ast Node<'ast>>), Term(&'ast Node<'ast>), Factor(&'ast Node<'ast>), - _28_3cExpr_3e_20_22_2c_22_29_2a(::std::vec::Vec<&'ast Node<'ast>>), - Expr(&'ast Node<'ast>), Expr_3f(::std::option::Option<&'ast Node<'ast>>), - ____Expr(&'ast Node<'ast>), } // State 0 @@ -79,13 +79,13 @@ mod __parse__Expr { // Term = (*) "Num" ["/"] // __Expr = (*) Expr [EOF] // - // "(" -> Shift(S3) - // "*" -> Shift(S6) - // "Num" -> Shift(S1) + // "(" -> Shift(S1) + // "*" -> Shift(S5) + // "Num" -> Shift(S6) // - // Expr -> S4 - // Term -> S5 - // Factor -> S2 + // Term -> S2 + // Factor -> S4 + // Expr -> S3 pub fn __state0< 'ast, __TOKENS: Iterator, @@ -102,19 +102,19 @@ mod __parse__Expr { let mut __lookbehind = Some(__loc); let mut __sym0 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state3(arena, __lookbehind, __lookahead, __tokens, __sym0)); + __result = try!(__state1(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!(__state6(arena, __lookbehind, __lookahead, __tokens, __sym0)); + __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!(__state1(arena, __lookbehind, __lookahead, __tokens, __sym0)); + __result = try!(__state6(arena, __lookbehind, __lookahead, __tokens, __sym0)); } _ => { return Err(__lookahead); @@ -123,17 +123,17 @@ mod __parse__Expr { loop { let (__lookbehind, __lookahead, __nt) = __result; match __nt { - __Nonterminal::Expr(__nt) => { - let __sym0 = &mut Some(__nt); - __result = try!(__state4(arena, __lookbehind, __lookahead, __tokens, __sym0)); - } __Nonterminal::Term(__nt) => { let __sym0 = &mut Some(__nt); - __result = try!(__state5(arena, __lookbehind, __lookahead, __tokens, __sym0)); + __result = try!(__state2(arena, __lookbehind, __lookahead, __tokens, __sym0)); } __Nonterminal::Factor(__nt) => { let __sym0 = &mut Some(__nt); - __result = try!(__state2(arena, __lookbehind, __lookahead, __tokens, __sym0)); + __result = try!(__state4(arena, __lookbehind, __lookahead, __tokens, __sym0)); + } + __Nonterminal::Expr(__nt) => { + let __sym0 = &mut Some(__nt); + __result = try!(__state3(arena, __lookbehind, __lookahead, __tokens, __sym0)); } _ => { return Ok((__lookbehind, __lookahead, __nt)); @@ -143,131 +143,6 @@ mod __parse__Expr { } // State 1 - // Term = "Num" (*) [EOF] - // Term = "Num" (*) ["*"] - // Term = "Num" (*) ["+"] - // Term = "Num" (*) ["-"] - // Term = "Num" (*) ["/"] - // - // "+" -> Reduce(Term = "Num" => Call(ActionFn(8));) - // EOF -> Reduce(Term = "Num" => Call(ActionFn(8));) - // "-" -> Reduce(Term = "Num" => Call(ActionFn(8));) - // "*" -> Reduce(Term = "Num" => Call(ActionFn(8));) - // "/" -> Reduce(Term = "Num" => Call(ActionFn(8));) - // - pub fn __state1< - '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::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action8(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - None => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action8(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action8(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - Some((_, Tok::Times(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action8(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - Some((_, Tok::Div(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action8(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 2 - // 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(S8) - // "*" -> Shift(S7) - // "-" -> Reduce(Expr = Factor => Call(ActionFn(3));) - // EOF -> Reduce(Expr = Factor => Call(ActionFn(3));) - // "+" -> Reduce(Expr = Factor => Call(ActionFn(3));) - // - 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 @ Tok::Div(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym1 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state8(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); - } - Some((_, __tok @ Tok::Times(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym1 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state7(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); - } - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action3(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - None => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action3(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - Some((_, Tok::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action3(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 3 // Expr = (*) Expr "+" Factor [")"] // Expr = (*) Expr "+" Factor ["+"] // Expr = (*) Expr "+" Factor ["-"] @@ -313,14 +188,14 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "(" -> Shift(S14) - // "*" -> Shift(S11) + // "(" -> Shift(S8) // "Num" -> Shift(S9) + // "*" -> Shift(S10) // - // Expr -> S10 + // Expr -> S11 + // Factor -> S7 // Term -> S12 - // Factor -> S13 - pub fn __state3< + pub fn __state1< 'ast, __TOKENS: Iterator, >( @@ -337,13 +212,7 @@ mod __parse__Expr { let mut __lookbehind = Some(__loc); let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state14(arena, __lookbehind, __lookahead, __tokens, __sym1)); - } - Some((_, __tok @ Tok::Times(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym1 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state11(arena, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state8(arena, __lookbehind, __lookahead, __tokens, __sym1)); } Some((_, Tok::Num(__tok0), __loc)) => { let mut __lookbehind = Some(__loc); @@ -351,6 +220,12 @@ mod __parse__Expr { 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)); + } _ => { return Err(__lookahead); } @@ -360,16 +235,16 @@ mod __parse__Expr { match __nt { __Nonterminal::Expr(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state10(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + __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)); } __Nonterminal::Term(__nt) => { let __sym1 = &mut Some(__nt); __result = try!(__state12(arena, __lookbehind, __lookahead, __tokens, __sym1)); } - __Nonterminal::Factor(__nt) => { - let __sym1 = &mut Some(__nt); - __result = try!(__state13(arena, __lookbehind, __lookahead, __tokens, __sym1)); - } _ => { return Ok((__lookbehind, __lookahead, __nt)); } @@ -378,7 +253,64 @@ mod __parse__Expr { return Ok(__result); } - // State 4 + // State 2 + // Factor = Term (*) [EOF] + // Factor = Term (*) ["*"] + // Factor = Term (*) ["+"] + // Factor = Term (*) ["-"] + // Factor = Term (*) ["/"] + // + // EOF -> Reduce(Factor = Term => Call(ActionFn(7));) + // "+" -> Reduce(Factor = Term => Call(ActionFn(7));) + // "*" -> Reduce(Factor = Term => Call(ActionFn(7));) + // "-" -> Reduce(Factor = Term => Call(ActionFn(7));) + // "/" -> Reduce(Factor = Term => Call(ActionFn(7));) + // + pub fn __state2< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + None => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action7(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action7(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::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 3 // Expr = Expr (*) "+" Factor [EOF] // Expr = Expr (*) "+" Factor ["+"] // Expr = Expr (*) "+" Factor ["-"] @@ -387,11 +319,11 @@ mod __parse__Expr { // Expr = Expr (*) "-" Factor ["-"] // __Expr = Expr (*) [EOF] // - // "-" -> Shift(S15) - // "+" -> Shift(S16) // EOF -> Reduce(__Expr = Expr => Call(ActionFn(0));) + // "-" -> Shift(S13) + // "+" -> Shift(S14) // - pub fn __state4< + pub fn __state3< 'ast, __TOKENS: Iterator, >( @@ -408,13 +340,13 @@ mod __parse__Expr { let mut __lookbehind = Some(__loc); let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state15(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + __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!(__state16(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + __result = try!(__state14(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); } None => { let __sym0 = __sym0.take().unwrap(); @@ -428,20 +360,28 @@ mod __parse__Expr { return Ok(__result); } - // State 5 - // Factor = Term (*) [EOF] - // Factor = Term (*) ["*"] - // Factor = Term (*) ["+"] - // Factor = Term (*) ["-"] - // Factor = Term (*) ["/"] + // State 4 + // Expr = Factor (*) [EOF] + // Expr = Factor (*) ["+"] + // Expr = Factor (*) ["-"] + // Factor = Factor (*) "*" Term [EOF] + // Factor = Factor (*) "*" Term ["*"] + // Factor = Factor (*) "*" Term ["+"] + // Factor = Factor (*) "*" Term ["-"] + // Factor = Factor (*) "*" Term ["/"] + // Factor = Factor (*) "/" Term [EOF] + // Factor = Factor (*) "/" Term ["*"] + // Factor = Factor (*) "/" Term ["+"] + // Factor = Factor (*) "/" Term ["-"] + // Factor = Factor (*) "/" Term ["/"] // - // "*" -> Reduce(Factor = Term => Call(ActionFn(7));) - // "-" -> Reduce(Factor = Term => Call(ActionFn(7));) - // "/" -> Reduce(Factor = Term => Call(ActionFn(7));) - // "+" -> Reduce(Factor = Term => Call(ActionFn(7));) - // EOF -> Reduce(Factor = Term => Call(ActionFn(7));) + // 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 __state5< + pub fn __state4< 'ast, __TOKENS: Iterator, >( @@ -454,38 +394,41 @@ mod __parse__Expr { { let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some((_, Tok::Times(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action7(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + Some((_, __tok @ 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::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))); - } - Some((_, Tok::Plus(..), _)) => { - 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 __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::__action7(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + let __nt = super::__action3(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__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 6 + // State 5 // Factor = "*" (*) "(" Comma ")" [EOF] // Factor = "*" (*) "(" Comma ")" ["*"] // Factor = "*" (*) "(" Comma ")" ["+"] @@ -494,7 +437,7 @@ mod __parse__Expr { // // "(" -> Shift(S17) // - pub fn __state6< + pub fn __state5< 'ast, __TOKENS: Iterator, >( @@ -520,152 +463,20 @@ mod __parse__Expr { 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(S3) - // "Num" -> Shift(S1) - // - // Term -> S18 - pub fn __state7< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize,Tok,usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, - ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> - { - let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, __tok @ Tok::LParen(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state3(arena, __lookbehind, __lookahead, __tokens, __sym2)); - } - Some((_, Tok::Num(__tok0), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state1(arena, __lookbehind, __lookahead, __tokens, __sym2)); - } - _ => { - return Err(__lookahead); - } - } - while __sym1.is_some() { - let (__lookbehind, __lookahead, __nt) = __result; - match __nt { - __Nonterminal::Term(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state18(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - _ => { - return Ok((__lookbehind, __lookahead, __nt)); - } - } - } - return Ok(__result); - } - - // State 8 - // Factor = Factor "/" (*) Term [EOF] - // Factor = Factor "/" (*) Term ["*"] - // Factor = Factor "/" (*) Term ["+"] - // Factor = Factor "/" (*) Term ["-"] - // Factor = Factor "/" (*) Term ["/"] - // Term = (*) "(" Expr ")" [EOF] - // Term = (*) "(" Expr ")" ["*"] - // Term = (*) "(" Expr ")" ["+"] - // Term = (*) "(" Expr ")" ["-"] - // Term = (*) "(" Expr ")" ["/"] - // Term = (*) "Num" [EOF] - // Term = (*) "Num" ["*"] - // Term = (*) "Num" ["+"] - // Term = (*) "Num" ["-"] - // Term = (*) "Num" ["/"] - // - // "(" -> Shift(S3) - // "Num" -> Shift(S1) - // - // Term -> S19 - pub fn __state8< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize,Tok,usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, - ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> - { - let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, __tok @ Tok::LParen(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state3(arena, __lookbehind, __lookahead, __tokens, __sym2)); - } - Some((_, Tok::Num(__tok0), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state1(arena, __lookbehind, __lookahead, __tokens, __sym2)); - } - _ => { - return Err(__lookahead); - } - } - while __sym1.is_some() { - let (__lookbehind, __lookahead, __nt) = __result; - match __nt { - __Nonterminal::Term(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state19(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - _ => { - return Ok((__lookbehind, __lookahead, __nt)); - } - } - } - return Ok(__result); - } - - // State 9 - // Term = "Num" (*) [")"] + // State 6 + // Term = "Num" (*) [EOF] // 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));) + // EOF -> Reduce(Term = "Num" => Call(ActionFn(8));) + // "+" -> Reduce(Term = "Num" => Call(ActionFn(8));) + // "-" -> Reduce(Term = "Num" => Call(ActionFn(8));) // - pub fn __state9< + pub fn __state6< 'ast, __TOKENS: Iterator, >( @@ -678,7 +489,7 @@ 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 __nt = super::__action8(arena, __sym0); return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); @@ -688,168 +499,20 @@ mod __parse__Expr { let __nt = super::__action8(arena, __sym0); return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); } - Some((_, Tok::Minus(..), _)) => { + None => { let __sym0 = __sym0.take().unwrap(); let __nt = super::__action8(arena, __sym0); return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); } - Some((_, Tok::Times(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action8(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - Some((_, Tok::RParen(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action8(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 10 - // Expr = Expr (*) "+" Factor [")"] - // Expr = Expr (*) "+" Factor ["+"] - // Expr = Expr (*) "+" Factor ["-"] - // Expr = Expr (*) "-" Factor [")"] - // Expr = Expr (*) "-" Factor ["+"] - // Expr = Expr (*) "-" Factor ["-"] - // Term = "(" Expr (*) ")" [EOF] - // Term = "(" Expr (*) ")" ["*"] - // Term = "(" Expr (*) ")" ["+"] - // Term = "(" Expr (*) ")" ["-"] - // Term = "(" Expr (*) ")" ["/"] - // - // "+" -> Shift(S22) - // ")" -> Shift(S21) - // "-" -> Shift(S20) - // - pub fn __state10< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize,Tok,usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> - { - let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, __tok @ Tok::Plus(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state22(arena, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); - } - Some((_, __tok @ Tok::RParen(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state21(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - Some((_, __tok @ Tok::Minus(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state20(arena, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 11 - // Factor = "*" (*) "(" Comma ")" [")"] - // Factor = "*" (*) "(" Comma ")" ["*"] - // Factor = "*" (*) "(" Comma ")" ["+"] - // Factor = "*" (*) "(" Comma ")" ["-"] - // Factor = "*" (*) "(" Comma ")" ["/"] - // - // "(" -> Shift(S23) - // - pub fn __state11< - '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!(__state23(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); - } - _ => { - return Err(__lookahead); - } - } - 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::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))); + let __nt = super::__action8(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); } - Some((_, Tok::RParen(..), _)) => { + 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))); } _ => { return Err(__lookahead); @@ -857,7 +520,7 @@ mod __parse__Expr { } } - // State 13 + // State 7 // Expr = Factor (*) [")"] // Expr = Factor (*) ["+"] // Expr = Factor (*) ["-"] @@ -872,13 +535,13 @@ mod __parse__Expr { // Factor = Factor (*) "/" Term ["-"] // Factor = Factor (*) "/" Term ["/"] // - // "*" -> Shift(S25) + // "/" -> Shift(S18) + // "-" -> Reduce(Expr = Factor => Call(ActionFn(3));) // ")" -> Reduce(Expr = Factor => Call(ActionFn(3));) // "+" -> Reduce(Expr = Factor => Call(ActionFn(3));) - // "-" -> Reduce(Expr = Factor => Call(ActionFn(3));) - // "/" -> Shift(S24) + // "*" -> Shift(S19) // - pub fn __state13< + pub fn __state7< 'ast, __TOKENS: Iterator, >( @@ -891,17 +554,22 @@ mod __parse__Expr { { let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some((_, __tok @ Tok::Times(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym1 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state25(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); - } Some((_, __tok @ Tok::Div(..), __loc)) => { let mut __lookbehind = Some(__loc); let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state24(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + __result = try!(__state18(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)); + } + Some((_, Tok::Minus(..), _)) => { + 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(); @@ -913,11 +581,6 @@ mod __parse__Expr { 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); } @@ -925,7 +588,7 @@ mod __parse__Expr { return Ok(__result); } - // State 14 + // State 8 // Expr = (*) Expr "+" Factor [")"] // Expr = (*) Expr "+" Factor ["+"] // Expr = (*) Expr "+" Factor ["-"] @@ -971,14 +634,14 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "*" -> Shift(S11) // "Num" -> Shift(S9) - // "(" -> Shift(S14) + // "*" -> Shift(S10) + // "(" -> Shift(S8) // - // Expr -> S26 + // Expr -> S20 + // Factor -> S7 // Term -> S12 - // Factor -> S13 - pub fn __state14< + pub fn __state8< 'ast, __TOKENS: Iterator, >( @@ -991,23 +654,23 @@ mod __parse__Expr { { let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some((_, __tok @ Tok::Times(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym1 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state11(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)); } + 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)); + } Some((_, __tok @ Tok::LParen(..), __loc)) => { let mut __lookbehind = Some(__loc); let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state14(arena, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state8(arena, __lookbehind, __lookahead, __tokens, __sym1)); } _ => { return Err(__lookahead); @@ -1018,16 +681,16 @@ mod __parse__Expr { match __nt { __Nonterminal::Expr(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state26(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + __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)); } __Nonterminal::Term(__nt) => { let __sym1 = &mut Some(__nt); __result = try!(__state12(arena, __lookbehind, __lookahead, __tokens, __sym1)); } - __Nonterminal::Factor(__nt) => { - let __sym1 = &mut Some(__nt); - __result = try!(__state13(arena, __lookbehind, __lookahead, __tokens, __sym1)); - } _ => { return Ok((__lookbehind, __lookahead, __nt)); } @@ -1036,7 +699,212 @@ mod __parse__Expr { return Ok(__result); } - // State 15 + // 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 + // 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(S22) + // "+" -> Shift(S24) + // "-" -> Shift(S23) + // + pub fn __state11< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + __sym1: &mut Option<&'ast Node<'ast>>, + ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, __tok @ Tok::RParen(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state22(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)); + } + _ => { + return Err(__lookahead); + } + } + 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 ["-"] @@ -1071,13 +939,13 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "(" -> Shift(S3) - // "Num" -> Shift(S1) - // "*" -> Shift(S6) + // "(" -> Shift(S1) + // "Num" -> Shift(S6) + // "*" -> Shift(S5) // - // Term -> S5 - // Factor -> S27 - pub fn __state15< + // Factor -> S25 + // Term -> S2 + pub fn __state13< 'ast, __TOKENS: Iterator, >( @@ -1095,19 +963,19 @@ mod __parse__Expr { let mut __lookbehind = Some(__loc); let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state3(arena, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__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!(__state1(arena, __lookbehind, __lookahead, __tokens, __sym2)); + __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!(__state6(arena, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state5(arena, __lookbehind, __lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); @@ -1116,13 +984,13 @@ mod __parse__Expr { while __sym1.is_some() { let (__lookbehind, __lookahead, __nt) = __result; match __nt { - __Nonterminal::Term(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state5(arena, __lookbehind, __lookahead, __tokens, __sym2)); - } __Nonterminal::Factor(__nt) => { let __sym2 = &mut Some(__nt); - __result = try!(__state27(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + __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)); @@ -1132,7 +1000,7 @@ mod __parse__Expr { return Ok(__result); } - // State 16 + // State 14 // Expr = Expr "+" (*) Factor [EOF] // Expr = Expr "+" (*) Factor ["+"] // Expr = Expr "+" (*) Factor ["-"] @@ -1167,13 +1035,13 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "(" -> Shift(S3) - // "Num" -> Shift(S1) - // "*" -> Shift(S6) + // "(" -> Shift(S1) + // "*" -> Shift(S5) + // "Num" -> Shift(S6) // - // Factor -> S28 - // Term -> S5 - pub fn __state16< + // Term -> S2 + // Factor -> S26 + pub fn __state14< 'ast, __TOKENS: Iterator, >( @@ -1191,18 +1059,18 @@ mod __parse__Expr { let mut __lookbehind = Some(__loc); let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state3(arena, __lookbehind, __lookahead, __tokens, __sym2)); - } - Some((_, Tok::Num(__tok0), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); __result = try!(__state1(arena, __lookbehind, __lookahead, __tokens, __sym2)); } Some((_, __tok @ Tok::Times(..), __loc)) => { let mut __lookbehind = Some(__loc); let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); + __result = try!(__state5(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)); } _ => { @@ -1212,13 +1080,145 @@ mod __parse__Expr { while __sym1.is_some() { let (__lookbehind, __lookahead, __nt) = __result; match __nt { - __Nonterminal::Factor(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state28(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } __Nonterminal::Term(__nt) => { let __sym2 = &mut Some(__nt); - __result = try!(__state5(arena, __lookbehind, __lookahead, __tokens, __sym2)); + __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" ["/"] + // + // "Num" -> Shift(S6) + // "(" -> Shift(S1) + // + // Term -> S27 + pub fn __state15< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + __sym1: &mut Option, + ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, Tok::Num(__tok0), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok0)); + let __lookahead = __tokens.next(); + __result = try!(__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!(__state1(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + _ => { + return Err(__lookahead); + } + } + while __sym1.is_some() { + let (__lookbehind, __lookahead, __nt) = __result; + match __nt { + __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__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" ["/"] + // + // "Num" -> Shift(S6) + // "(" -> Shift(S1) + // + // Term -> S28 + pub fn __state16< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + __sym1: &mut Option, + ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, Tok::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 __lookahead = __tokens.next(); + __result = try!(__state1(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + _ => { + return Err(__lookahead); + } + } + while __sym1.is_some() { + let (__lookbehind, __lookahead, __nt) = __result; + match __nt { + __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state28(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); } _ => { return Ok((__lookbehind, __lookahead, __nt)); @@ -1244,9 +1244,9 @@ mod __parse__Expr { // Factor = "*" "(" (*) Comma ")" ["-"] // Factor = "*" "(" (*) Comma ")" ["/"] // + // ")" -> Reduce(( ",")* = => Call(ActionFn(13));) // "Num" -> Reduce(( ",")* = => Call(ActionFn(13));) // "(" -> Reduce(( ",")* = => Call(ActionFn(13));) - // ")" -> Reduce(( ",")* = => Call(ActionFn(13));) // "*" -> Reduce(( ",")* = => Call(ActionFn(13));) // // ( ",")* -> S30 @@ -1265,6 +1265,10 @@ mod __parse__Expr { { 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)); @@ -1273,10 +1277,6 @@ mod __parse__Expr { 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)); @@ -1305,18 +1305,26 @@ mod __parse__Expr { } // State 18 - // 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" ["/"] // - // EOF -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) - // "-" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) - // "/" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) - // "+" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) - // "*" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // "Num" -> Shift(S9) + // "(" -> Shift(S8) // + // Term -> S31 pub fn __state18< 'ast, __TOKENS: Iterator, @@ -1327,65 +1335,62 @@ mod __parse__Expr { __tokens: &mut __TOKENS, __sym0: &mut Option<&'ast Node<'ast>>, __sym1: &mut Option, - __sym2: &mut Option<&'ast Node<'ast>>, ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> { let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - None => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + Some((_, Tok::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::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Div(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Times(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + Some((_, __tok @ Tok::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)); } _ => { return Err(__lookahead); } } + while __sym1.is_some() { + let (__lookbehind, __lookahead, __nt) = __result; + match __nt { + __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state31(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + _ => { + return Ok((__lookbehind, __lookahead, __nt)); + } + } + } + return Ok(__result); } // State 19 - // Factor = Factor "/" Term (*) [EOF] - // Factor = Factor "/" Term (*) ["*"] - // Factor = Factor "/" Term (*) ["+"] - // Factor = Factor "/" Term (*) ["-"] - // Factor = Factor "/" Term (*) ["/"] + // Factor = Factor "*" (*) Term [")"] + // Factor = Factor "*" (*) Term ["*"] + // Factor = Factor "*" (*) Term ["+"] + // Factor = Factor "*" (*) Term ["-"] + // Factor = Factor "*" (*) Term ["/"] + // Term = (*) "(" Expr ")" [")"] + // Term = (*) "(" Expr ")" ["*"] + // Term = (*) "(" Expr ")" ["+"] + // Term = (*) "(" Expr ")" ["-"] + // Term = (*) "(" Expr ")" ["/"] + // Term = (*) "Num" [")"] + // Term = (*) "Num" ["*"] + // Term = (*) "Num" ["+"] + // Term = (*) "Num" ["-"] + // Term = (*) "Num" ["/"] // - // "*" -> Reduce(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));) + // "Num" -> Shift(S9) + // "(" -> Shift(S8) // + // Term -> S32 pub fn __state19< 'ast, __TOKENS: Iterator, @@ -1396,7 +1401,197 @@ mod __parse__Expr { __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::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::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)); + } + _ => { + return Err(__lookahead); + } + } + while __sym1.is_some() { + let (__lookbehind, __lookahead, __nt) = __result; + match __nt { + __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state32(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + _ => { + return Ok((__lookbehind, __lookahead, __nt)); + } + } + } + return Ok(__result); + } + + // State 20 + // Expr = Expr (*) "+" Factor [")"] + // Expr = Expr (*) "+" Factor ["+"] + // Expr = Expr (*) "+" Factor ["-"] + // Expr = Expr (*) "-" Factor [")"] + // Expr = Expr (*) "-" Factor ["+"] + // Expr = Expr (*) "-" Factor ["-"] + // Term = "(" Expr (*) ")" [")"] + // Term = "(" Expr (*) ")" ["*"] + // Term = "(" Expr (*) ")" ["+"] + // Term = "(" Expr (*) ")" ["-"] + // Term = "(" Expr (*) ")" ["/"] + // + // ")" -> Shift(S33) + // "-" -> Shift(S23) + // "+" -> Shift(S24) + // + pub fn __state20< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + __sym1: &mut Option<&'ast Node<'ast>>, + ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, __tok @ Tok::RParen(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state33(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!(__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)); + } + _ => { + return Err(__lookahead); + } + } + 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 + // 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));) + // + pub fn __state22< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + __sym1: &mut Option<&'ast Node<'ast>>, + __sym2: &mut Option, ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> { let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); @@ -1405,36 +1600,36 @@ mod __parse__Expr { 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))); + 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::__action5(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + 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::__action5(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + 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::__action5(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + let __nt = super::__action9(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action9(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); } _ => { return Err(__lookahead); @@ -1442,7 +1637,7 @@ mod __parse__Expr { } } - // State 20 + // State 23 // Expr = Expr "-" (*) Factor [")"] // Expr = Expr "-" (*) Factor ["+"] // Expr = Expr "-" (*) Factor ["-"] @@ -1477,13 +1672,13 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "(" -> Shift(S14) // "Num" -> Shift(S9) - // "*" -> Shift(S11) + // "*" -> Shift(S10) + // "(" -> Shift(S8) // - // Factor -> S31 // Term -> S12 - pub fn __state20< + // Factor -> S35 + pub fn __state23< 'ast, __TOKENS: Iterator, >( @@ -1497,12 +1692,6 @@ 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 __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state14(arena, __lookbehind, __lookahead, __tokens, __sym2)); - } Some((_, Tok::Num(__tok0), __loc)) => { let mut __lookbehind = Some(__loc); let mut __sym2 = &mut Some((__tok0)); @@ -1513,7 +1702,13 @@ mod __parse__Expr { let mut __lookbehind = Some(__loc); let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state11(arena, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state10(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)); } _ => { return Err(__lookahead); @@ -1522,14 +1717,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!(__state31(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } __Nonterminal::Term(__nt) => { let __sym2 = &mut Some(__nt); __result = try!(__state12(arena, __lookbehind, __lookahead, __tokens, __sym2)); } + __Nonterminal::Factor(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state35(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } _ => { return Ok((__lookbehind, __lookahead, __nt)); } @@ -1538,76 +1733,7 @@ mod __parse__Expr { return Ok(__result); } - // State 21 - // Term = "(" Expr ")" (*) [EOF] - // Term = "(" Expr ")" (*) ["*"] - // Term = "(" Expr ")" (*) ["+"] - // Term = "(" Expr ")" (*) ["-"] - // Term = "(" Expr ")" (*) ["/"] - // - // EOF -> 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 __state21< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize,Tok,usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option<&'ast Node<'ast>>, - __sym2: &mut Option, - ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> - { - let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); - match __lookahead { - 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))); - } - 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::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action9(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action9(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 22 + // State 24 // Expr = Expr "+" (*) Factor [")"] // Expr = Expr "+" (*) Factor ["+"] // Expr = Expr "+" (*) Factor ["-"] @@ -1642,13 +1768,13 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "*" -> Shift(S11) + // "*" -> Shift(S10) + // "(" -> Shift(S8) // "Num" -> Shift(S9) - // "(" -> Shift(S14) // - // Factor -> S32 // Term -> S12 - pub fn __state22< + // Factor -> S36 + pub fn __state24< 'ast, __TOKENS: Iterator, >( @@ -1666,7 +1792,13 @@ mod __parse__Expr { let mut __lookbehind = Some(__loc); let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state11(arena, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state10(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)); } Some((_, Tok::Num(__tok0), __loc)) => { let mut __lookbehind = Some(__loc); @@ -1674,12 +1806,6 @@ mod __parse__Expr { let __lookahead = __tokens.next(); __result = try!(__state9(arena, __lookbehind, __lookahead, __tokens, __sym2)); } - Some((_, __tok @ Tok::LParen(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state14(arena, __lookbehind, __lookahead, __tokens, __sym2)); - } _ => { return Err(__lookahead); } @@ -1687,155 +1813,13 @@ mod __parse__Expr { while __sym1.is_some() { let (__lookbehind, __lookahead, __nt) = __result; match __nt { - __Nonterminal::Factor(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state32(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } __Nonterminal::Term(__nt) => { let __sym2 = &mut Some(__nt); __result = try!(__state12(arena, __lookbehind, __lookahead, __tokens, __sym2)); } - _ => { - return Ok((__lookbehind, __lookahead, __nt)); - } - } - } - return Ok(__result); - } - - // State 23 - // ( ",")* = (*) ["("] - // ( ",")* = (*) [")"] - // ( ",")* = (*) ["*"] - // ( ",")* = (*) ["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));) - // - // Comma -> S33 - // ( ",")* -> S30 - pub fn __state23< - '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::Comma_3cExpr_3e(__nt) => { + __Nonterminal::Factor(__nt) => { let __sym2 = &mut Some(__nt); - __result = try!(__state33(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!(__state30(arena, __lookbehind, __lookahead, __tokens, __sym2)); - } - _ => { - return Ok((__lookbehind, __lookahead, __nt)); - } - } - } - return Ok(__result); - } - - // State 24 - // Factor = Factor "/" (*) Term [")"] - // Factor = Factor "/" (*) Term ["*"] - // Factor = Factor "/" (*) Term ["+"] - // Factor = Factor "/" (*) Term ["-"] - // Factor = Factor "/" (*) Term ["/"] - // Term = (*) "(" Expr ")" [")"] - // Term = (*) "(" Expr ")" ["*"] - // Term = (*) "(" Expr ")" ["+"] - // Term = (*) "(" Expr ")" ["-"] - // Term = (*) "(" Expr ")" ["/"] - // Term = (*) "Num" [")"] - // Term = (*) "Num" ["*"] - // Term = (*) "Num" ["+"] - // Term = (*) "Num" ["-"] - // Term = (*) "Num" ["/"] - // - // "(" -> Shift(S14) - // "Num" -> Shift(S9) - // - // Term -> S34 - pub fn __state24< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize,Tok,usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, - ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> - { - let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, __tok @ Tok::LParen(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state14(arena, __lookbehind, __lookahead, __tokens, __sym2)); - } - Some((_, Tok::Num(__tok0), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state9(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!(__state34(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + __result = try!(__state36(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); } _ => { return Ok((__lookbehind, __lookahead, __nt)); @@ -1846,128 +1830,6 @@ mod __parse__Expr { } // State 25 - // Factor = Factor "*" (*) Term [")"] - // Factor = Factor "*" (*) Term ["*"] - // Factor = Factor "*" (*) Term ["+"] - // Factor = Factor "*" (*) Term ["-"] - // Factor = Factor "*" (*) Term ["/"] - // Term = (*) "(" Expr ")" [")"] - // Term = (*) "(" Expr ")" ["*"] - // Term = (*) "(" Expr ")" ["+"] - // Term = (*) "(" Expr ")" ["-"] - // Term = (*) "(" Expr ")" ["/"] - // Term = (*) "Num" [")"] - // Term = (*) "Num" ["*"] - // Term = (*) "Num" ["+"] - // Term = (*) "Num" ["-"] - // Term = (*) "Num" ["/"] - // - // "(" -> Shift(S14) - // "Num" -> Shift(S9) - // - // Term -> S35 - 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, - ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> - { - let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, __tok @ Tok::LParen(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state14(arena, __lookbehind, __lookahead, __tokens, __sym2)); - } - Some((_, Tok::Num(__tok0), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state9(arena, __lookbehind, __lookahead, __tokens, __sym2)); - } - _ => { - return Err(__lookahead); - } - } - while __sym1.is_some() { - let (__lookbehind, __lookahead, __nt) = __result; - match __nt { - __Nonterminal::Term(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state35(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - _ => { - return Ok((__lookbehind, __lookahead, __nt)); - } - } - } - return Ok(__result); - } - - // State 26 - // Expr = Expr (*) "+" Factor [")"] - // Expr = Expr (*) "+" Factor ["+"] - // Expr = Expr (*) "+" Factor ["-"] - // Expr = Expr (*) "-" Factor [")"] - // Expr = Expr (*) "-" Factor ["+"] - // Expr = Expr (*) "-" Factor ["-"] - // Term = "(" Expr (*) ")" [")"] - // Term = "(" Expr (*) ")" ["*"] - // Term = "(" Expr (*) ")" ["+"] - // Term = "(" Expr (*) ")" ["-"] - // Term = "(" Expr (*) ")" ["/"] - // - // "+" -> Shift(S22) - // ")" -> Shift(S36) - // "-" -> Shift(S20) - // - pub fn __state26< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize,Tok,usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option<&'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!(__state22(arena, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); - } - Some((_, __tok @ Tok::RParen(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state36(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!(__state20(arena, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 27 // Expr = Expr "-" Factor (*) [EOF] // Expr = Expr "-" Factor (*) ["+"] // Expr = Expr "-" Factor (*) ["-"] @@ -1983,10 +1845,154 @@ mod __parse__Expr { // Factor = Factor (*) "/" Term ["/"] // // "+" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) - // "/" -> Shift(S8) // "-" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) // EOF -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) - // "*" -> Shift(S7) + // "/" -> 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, @@ -2003,66 +2009,59 @@ mod __parse__Expr { { let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some((_, __tok @ Tok::Div(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym3 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state8(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); - } - Some((_, __tok @ Tok::Times(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym3 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state7(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); - } - Some((_, Tok::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))); + 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::__action1(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + 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); } } - return Ok(__result); } // State 28 - // Expr = Expr "+" Factor (*) [EOF] - // Expr = Expr "+" Factor (*) ["+"] - // Expr = Expr "+" Factor (*) ["-"] - // Factor = Factor (*) "*" Term [EOF] - // Factor = Factor (*) "*" Term ["*"] - // Factor = Factor (*) "*" Term ["+"] - // Factor = Factor (*) "*" Term ["-"] - // Factor = Factor (*) "*" Term ["/"] - // Factor = Factor (*) "/" Term [EOF] - // Factor = Factor (*) "/" Term ["*"] - // Factor = Factor (*) "/" Term ["+"] - // Factor = Factor (*) "/" Term ["-"] - // Factor = Factor (*) "/" Term ["/"] + // Factor = Factor "/" Term (*) [EOF] + // Factor = Factor "/" Term (*) ["*"] + // Factor = Factor "/" Term (*) ["+"] + // Factor = Factor "/" Term (*) ["-"] + // Factor = Factor "/" Term (*) ["/"] // - // "/" -> Shift(S8) - // "+" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) - // "-" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) - // "*" -> Shift(S7) - // EOF -> 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));) + // EOF -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // "*" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) // pub fn __state28< 'ast, @@ -2079,44 +2078,45 @@ mod __parse__Expr { { let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some((_, __tok @ Tok::Div(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym3 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state8(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); + Some((_, Tok::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 @ Tok::Times(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym3 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state7(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); + Some((_, Tok::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::__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))); + 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::__action2(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + let __nt = super::__action5(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Times(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action5(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } _ => { return Err(__lookahead); } } - return Ok(__result); } // State 29 @@ -2219,14 +2219,14 @@ mod __parse__Expr { // // "(" -> Shift(S45) // ")" -> Reduce(Expr? = => Call(ActionFn(12));) - // "Num" -> Shift(S42) + // "Num" -> Shift(S41) // "*" -> Shift(S40) // - // Factor -> S38 - // Expr -> S41 // Expr? -> S39 + // ( ",") -> S42 + // Factor -> S44 + // Expr -> S38 // Term -> S43 - // ( ",") -> S44 pub fn __state30< 'ast, __TOKENS: Iterator, @@ -2250,7 +2250,7 @@ mod __parse__Expr { let mut __lookbehind = Some(__loc); let mut __sym1 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state42(arena, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state41(arena, __lookbehind, __lookahead, __tokens, __sym1)); } Some((_, __tok @ Tok::Times(..), __loc)) => { let mut __lookbehind = Some(__loc); @@ -2269,26 +2269,26 @@ mod __parse__Expr { while __sym0.is_some() { let (__lookbehind, __lookahead, __nt) = __result; match __nt { - __Nonterminal::Factor(__nt) => { - let __sym1 = &mut Some(__nt); - __result = try!(__state38(arena, __lookbehind, __lookahead, __tokens, __sym1)); - } - __Nonterminal::Expr(__nt) => { - let __sym1 = &mut Some(__nt); - __result = try!(__state41(arena, __lookbehind, __lookahead, __tokens, __sym1)); - } __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!(__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::_28_3cExpr_3e_20_22_2c_22_29(__nt) => { - let __sym1 = &mut Some(__nt); - __result = try!(__state44(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); - } _ => { return Ok((__lookbehind, __lookahead, __nt)); } @@ -2298,25 +2298,17 @@ mod __parse__Expr { } // State 31 - // 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 (*) ["/"] // - // "/" -> Shift(S24) - // ")" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) - // "-" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) - // "+" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) - // "*" -> Shift(S25) + // "+" -> 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 __state31< 'ast, @@ -2333,66 +2325,59 @@ mod __parse__Expr { { 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!(__state24(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action5(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } - Some((_, __tok @ Tok::Times(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym3 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state25(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); + Some((_, Tok::Div(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__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::__action1(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + 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::__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))); + let __nt = super::__action5(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } _ => { return Err(__lookahead); } } - return Ok(__result); } // State 32 - // 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(S24) - // "+" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) - // ")" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) - // "*" -> Shift(S25) + // "/" -> 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 __state32< 'ast, @@ -2409,47 +2394,117 @@ mod __parse__Expr { { 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!(__state24(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!(__state25(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); - } - Some((_, Tok::Minus(..), _)) => { + Some((_, Tok::Div(..), _)) => { 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))); + 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::__action2(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + 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::__action2(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + let __nt = super::__action4(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action4(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } _ => { return Err(__lookahead); } } - return Ok(__result); } // State 33 + // Term = "(" Expr ")" (*) [")"] + // Term = "(" Expr ")" (*) ["*"] + // Term = "(" Expr ")" (*) ["+"] + // Term = "(" Expr ")" (*) ["-"] + // Term = "(" Expr ")" (*) ["/"] + // + // "*" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) + // "-" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) + // ")" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) + // "+" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) + // "/" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) + // + pub fn __state33< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + __sym1: &mut Option<&'ast Node<'ast>>, + __sym2: &mut Option, + ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, Tok::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(); + 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 34 // Factor = "*" "(" Comma (*) ")" [")"] // Factor = "*" "(" Comma (*) ")" ["*"] // Factor = "*" "(" Comma (*) ")" ["+"] @@ -2458,7 +2513,7 @@ mod __parse__Expr { // // ")" -> Shift(S46) // - pub fn __state33< + pub fn __state34< 'ast, __TOKENS: Iterator, >( @@ -2486,87 +2541,26 @@ mod __parse__Expr { return Ok(__result); } - // State 34 - // Factor = Factor "/" Term (*) [")"] - // Factor = Factor "/" Term (*) ["*"] - // Factor = Factor "/" Term (*) ["+"] - // Factor = Factor "/" Term (*) ["-"] - // Factor = Factor "/" Term (*) ["/"] - // - // "+" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // "*" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // "/" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // ")" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // "-" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // - pub fn __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::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::Times(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action5(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Div(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action5(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - 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::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 35 - // 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));) + // "/" -> 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, @@ -2583,59 +2577,66 @@ mod __parse__Expr { { let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some((_, Tok::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + Some((_, __tok @ 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::Times(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + Some((_, __tok @ Tok::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::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + 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::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + let __nt = super::__action1(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); } - Some((_, Tok::Div(..), _)) => { + Some((_, Tok::Plus(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + let __nt = super::__action1(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); } _ => { return Err(__lookahead); } } + return Ok(__result); } // State 36 - // Term = "(" Expr ")" (*) [")"] - // Term = "(" Expr ")" (*) ["*"] - // Term = "(" Expr ")" (*) ["+"] - // Term = "(" Expr ")" (*) ["-"] - // Term = "(" Expr ")" (*) ["/"] + // 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(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));) + // "*" -> 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, @@ -2645,52 +2646,51 @@ mod __parse__Expr { __lookbehind: Option, __lookahead: Option<(usize,Tok,usize)>, __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option<&'ast Node<'ast>>, - __sym2: &mut Option, + __sym0: &mut Option<&'ast Node<'ast>>, + __sym1: &mut Option, + __sym2: &mut Option<&'ast Node<'ast>>, ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> { let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some((_, Tok::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 @ 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::__action9(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + let __nt = super::__action2(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); } Some((_, Tok::Minus(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); - let __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))); + 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::__action9(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + let __nt = super::__action2(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); } _ => { return Err(__lookahead); } } + return Ok(__result); } // State 37 @@ -2700,11 +2700,11 @@ 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));) // EOF -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) + // "+" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) // pub fn __state37< 'ast, @@ -2722,22 +2722,6 @@ mod __parse__Expr { { 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 __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))); - } Some((_, Tok::Times(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); @@ -2754,6 +2738,14 @@ mod __parse__Expr { 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(); @@ -2762,6 +2754,14 @@ 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))); + } _ => { return Err(__lookahead); } @@ -2769,29 +2769,24 @@ mod __parse__Expr { } // State 38 - // Expr = Factor (*) [")"] - // Expr = Factor (*) ["+"] - // Expr = Factor (*) [","] - // Expr = Factor (*) ["-"] - // Factor = Factor (*) "*" Term [")"] - // Factor = Factor (*) "*" Term ["*"] - // Factor = Factor (*) "*" Term ["+"] - // Factor = Factor (*) "*" Term [","] - // Factor = Factor (*) "*" Term ["-"] - // Factor = Factor (*) "*" Term ["/"] - // Factor = Factor (*) "/" Term [")"] - // Factor = Factor (*) "/" Term ["*"] - // Factor = Factor (*) "/" Term ["+"] - // Factor = Factor (*) "/" Term [","] - // Factor = Factor (*) "/" Term ["-"] - // Factor = Factor (*) "/" Term ["/"] + // ( ",") = 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 (*) [")"] // - // "," -> Reduce(Expr = Factor => Call(ActionFn(3));) - // "-" -> Reduce(Expr = Factor => Call(ActionFn(3));) - // "*" -> Shift(S47) - // "/" -> Shift(S48) - // ")" -> Reduce(Expr = Factor => Call(ActionFn(3));) - // "+" -> Reduce(Expr = Factor => Call(ActionFn(3));) + // "+" -> Shift(S47) + // ")" -> Reduce(Expr? = Expr => Call(ActionFn(11));) + // "," -> Shift(S49) + // "-" -> Shift(S48) // pub fn __state38< 'ast, @@ -2806,37 +2801,28 @@ mod __parse__Expr { { let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some((_, __tok @ Tok::Times(..), __loc)) => { + 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::Div(..), __loc)) => { + 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::Comma(..), _)) => { - 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::RParen(..), _)) => { let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action3(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - Some((_, Tok::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action3(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + let __nt = super::__action11(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr_3f(__nt))); } _ => { return Err(__lookahead); @@ -2884,7 +2870,7 @@ mod __parse__Expr { // Factor = "*" (*) "(" Comma ")" ["-"] // Factor = "*" (*) "(" Comma ")" ["/"] // - // "(" -> Shift(S49) + // "(" -> Shift(S50) // pub fn __state40< 'ast, @@ -2903,7 +2889,7 @@ mod __parse__Expr { let mut __lookbehind = Some(__loc); let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state49(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + __result = try!(__state50(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); } _ => { return Err(__lookahead); @@ -2913,69 +2899,6 @@ mod __parse__Expr { } // State 41 - // ( ",") = 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(S50) - // ")" -> Reduce(Expr? = Expr => Call(ActionFn(11));) - // "," -> Shift(S51) - // "-" -> Shift(S52) - // - pub fn __state41< - '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!(__state50(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!(__state51(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!(__state52(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 42 // Term = "Num" (*) [")"] // Term = "Num" (*) ["*"] // Term = "Num" (*) ["+"] @@ -2983,14 +2906,14 @@ mod __parse__Expr { // Term = "Num" (*) ["-"] // Term = "Num" (*) ["/"] // - // "/" -> Reduce(Term = "Num" => Call(ActionFn(8));) // "," -> Reduce(Term = "Num" => Call(ActionFn(8));) // "+" -> Reduce(Term = "Num" => Call(ActionFn(8));) // ")" -> Reduce(Term = "Num" => Call(ActionFn(8));) - // "*" -> Reduce(Term = "Num" => Call(ActionFn(8));) // "-" -> Reduce(Term = "Num" => Call(ActionFn(8));) + // "*" -> Reduce(Term = "Num" => Call(ActionFn(8));) + // "/" -> Reduce(Term = "Num" => Call(ActionFn(8));) // - pub fn __state42< + pub fn __state41< 'ast, __TOKENS: Iterator, >( @@ -3003,11 +2926,6 @@ mod __parse__Expr { { let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some((_, Tok::Div(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action8(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } Some((_, Tok::Comma(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __nt = super::__action8(arena, __sym0); @@ -3023,12 +2941,17 @@ mod __parse__Expr { 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::Minus(..), _)) => { + Some((_, Tok::Div(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __nt = super::__action8(arena, __sym0); return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); @@ -3039,6 +2962,61 @@ mod __parse__Expr { } } + // 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 (*) ["*"] @@ -3047,12 +3025,12 @@ mod __parse__Expr { // 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));) // "*" -> Reduce(Factor = Term => Call(ActionFn(7));) + // "-" -> Reduce(Factor = Term => Call(ActionFn(7));) + // "/" -> Reduce(Factor = Term => Call(ActionFn(7));) // pub fn __state43< 'ast, @@ -3067,6 +3045,11 @@ mod __parse__Expr { { 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); @@ -3077,12 +3060,7 @@ mod __parse__Expr { let __nt = super::__action7(arena, __sym0); return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } - Some((_, Tok::Div(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action7(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Comma(..), _)) => { + Some((_, Tok::Times(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __nt = super::__action7(arena, __sym0); return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); @@ -3092,7 +3070,7 @@ mod __parse__Expr { let __nt = super::__action7(arena, __sym0); return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } - Some((_, Tok::Times(..), _)) => { + Some((_, Tok::Div(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __nt = super::__action7(arena, __sym0); return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); @@ -3104,15 +3082,29 @@ mod __parse__Expr { } // State 44 - // ( ",")* = ( ",")* ( ",") (*) ["("] - // ( ",")* = ( ",")* ( ",") (*) [")"] - // ( ",")* = ( ",")* ( ",") (*) ["*"] - // ( ",")* = ( ",")* ( ",") (*) ["Num"] + // 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(( ",")* = ( ",")*, ( ",") => Call(ActionFn(14));) - // ")" -> Reduce(( ",")* = ( ",")*, ( ",") => Call(ActionFn(14));) - // "(" -> Reduce(( ",")* = ( ",")*, ( ",") => Call(ActionFn(14));) - // "Num" -> Reduce(( ",")* = ( ",")*, ( ",") => Call(ActionFn(14));) + // "+" -> 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, @@ -3122,40 +3114,48 @@ mod __parse__Expr { __lookbehind: Option, __lookahead: Option<(usize,Tok,usize)>, __tokens: &mut __TOKENS, - __sym0: &mut Option<::std::vec::Vec<&'ast Node<'ast>>>, - __sym1: &mut Option<&'ast Node<'ast>>, + __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(..), _)) => { + 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 __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))); + 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 __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))); + let __nt = super::__action3(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); } - Some((_, Tok::LParen(..), _)) => { + Some((_, Tok::Minus(..), _)) => { 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))); + let __nt = super::__action3(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); } _ => { return Err(__lookahead); } } + return Ok(__result); } // State 45 @@ -3205,13 +3205,13 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // + // "*" -> Shift(S10) + // "(" -> Shift(S8) // "Num" -> Shift(S9) - // "(" -> Shift(S14) - // "*" -> Shift(S11) // - // Factor -> S13 // Expr -> S53 // Term -> S12 + // Factor -> S7 pub fn __state45< 'ast, __TOKENS: Iterator, @@ -3225,23 +3225,23 @@ mod __parse__Expr { { let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - 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!(__state10(arena, __lookbehind, __lookahead, __tokens, __sym1)); } Some((_, __tok @ Tok::LParen(..), __loc)) => { let mut __lookbehind = Some(__loc); let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state14(arena, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state8(arena, __lookbehind, __lookahead, __tokens, __sym1)); } - 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!(__state11(arena, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state9(arena, __lookbehind, __lookahead, __tokens, __sym1)); } _ => { return Err(__lookahead); @@ -3250,10 +3250,6 @@ mod __parse__Expr { while __sym0.is_some() { let (__lookbehind, __lookahead, __nt) = __result; match __nt { - __Nonterminal::Factor(__nt) => { - let __sym1 = &mut Some(__nt); - __result = try!(__state13(arena, __lookbehind, __lookahead, __tokens, __sym1)); - } __Nonterminal::Expr(__nt) => { let __sym1 = &mut Some(__nt); __result = try!(__state53(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); @@ -3262,6 +3258,10 @@ mod __parse__Expr { let __sym1 = &mut Some(__nt); __result = try!(__state12(arena, __lookbehind, __lookahead, __tokens, __sym1)); } + __Nonterminal::Factor(__nt) => { + let __sym1 = &mut Some(__nt); + __result = try!(__state7(arena, __lookbehind, __lookahead, __tokens, __sym1)); + } _ => { return Ok((__lookbehind, __lookahead, __nt)); } @@ -3277,10 +3277,10 @@ 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));) // pub fn __state46< @@ -3299,22 +3299,6 @@ mod __parse__Expr { { let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __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(); - 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(); @@ -3331,6 +3315,22 @@ mod __parse__Expr { 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))); + } + Some((_, Tok::RParen(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __sym3 = __sym3.take().unwrap(); + let __nt = super::__action6(arena, __sym0, __sym1, __sym2, __sym3); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } Some((_, Tok::Times(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); @@ -3346,221 +3346,6 @@ mod __parse__Expr { } // State 47 - // Factor = Factor "*" (*) Term [")"] - // Factor = Factor "*" (*) Term ["*"] - // Factor = Factor "*" (*) Term ["+"] - // Factor = Factor "*" (*) Term [","] - // Factor = Factor "*" (*) Term ["-"] - // Factor = Factor "*" (*) Term ["/"] - // Term = (*) "(" Expr ")" [")"] - // Term = (*) "(" Expr ")" ["*"] - // Term = (*) "(" Expr ")" ["+"] - // Term = (*) "(" Expr ")" [","] - // Term = (*) "(" Expr ")" ["-"] - // Term = (*) "(" Expr ")" ["/"] - // Term = (*) "Num" [")"] - // Term = (*) "Num" ["*"] - // Term = (*) "Num" ["+"] - // Term = (*) "Num" [","] - // Term = (*) "Num" ["-"] - // Term = (*) "Num" ["/"] - // - // "Num" -> Shift(S42) - // "(" -> Shift(S45) - // - // Term -> S54 - pub fn __state47< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize,Tok,usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, - ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> - { - let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, Tok::Num(__tok0), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state42(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)); - } - _ => { - return Err(__lookahead); - } - } - while __sym1.is_some() { - let (__lookbehind, __lookahead, __nt) = __result; - match __nt { - __Nonterminal::Term(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state54(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - _ => { - return Ok((__lookbehind, __lookahead, __nt)); - } - } - } - return Ok(__result); - } - - // State 48 - // Factor = Factor "/" (*) Term [")"] - // Factor = Factor "/" (*) Term ["*"] - // Factor = Factor "/" (*) Term ["+"] - // Factor = Factor "/" (*) Term [","] - // Factor = Factor "/" (*) Term ["-"] - // Factor = Factor "/" (*) Term ["/"] - // Term = (*) "(" Expr ")" [")"] - // Term = (*) "(" Expr ")" ["*"] - // Term = (*) "(" Expr ")" ["+"] - // Term = (*) "(" Expr ")" [","] - // Term = (*) "(" Expr ")" ["-"] - // Term = (*) "(" Expr ")" ["/"] - // Term = (*) "Num" [")"] - // Term = (*) "Num" ["*"] - // Term = (*) "Num" ["+"] - // Term = (*) "Num" [","] - // Term = (*) "Num" ["-"] - // Term = (*) "Num" ["/"] - // - // "Num" -> Shift(S42) - // "(" -> Shift(S45) - // - // Term -> S55 - pub fn __state48< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize,Tok,usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, - ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> - { - let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, Tok::Num(__tok0), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state42(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)); - } - _ => { - return Err(__lookahead); - } - } - while __sym1.is_some() { - let (__lookbehind, __lookahead, __nt) = __result; - match __nt { - __Nonterminal::Term(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state55(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - _ => { - return Ok((__lookbehind, __lookahead, __nt)); - } - } - } - return Ok(__result); - } - - // State 49 - // ( ",")* = (*) ["("] - // ( ",")* = (*) [")"] - // ( ",")* = (*) ["*"] - // ( ",")* = (*) ["Num"] - // ( ",")* = (*) ( ",")* ( ",") ["("] - // ( ",")* = (*) ( ",")* ( ",") [")"] - // ( ",")* = (*) ( ",")* ( ",") ["*"] - // ( ",")* = (*) ( ",")* ( ",") ["Num"] - // Comma = (*) ( ",")* Expr? [")"] - // Factor = "*" "(" (*) Comma ")" [")"] - // 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 -> S56 - pub fn __state49< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize,Tok,usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option, - ) -> 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::Times(..), _)) => { - 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)); - } - _ => { - 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 50 // Expr = Expr "+" (*) Factor [")"] // Expr = Expr "+" (*) Factor ["+"] // Expr = Expr "+" (*) Factor [","] @@ -3604,11 +3389,11 @@ mod __parse__Expr { // // "(" -> Shift(S45) // "*" -> Shift(S40) - // "Num" -> Shift(S42) + // "Num" -> Shift(S41) // - // Factor -> S57 // Term -> S43 - pub fn __state50< + // Factor -> S54 + pub fn __state47< 'ast, __TOKENS: Iterator, >( @@ -3638,7 +3423,7 @@ mod __parse__Expr { let mut __lookbehind = Some(__loc); let mut __sym2 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state42(arena, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state41(arena, __lookbehind, __lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); @@ -3647,14 +3432,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!(__state54(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } _ => { return Ok((__lookbehind, __lookahead, __nt)); } @@ -3663,62 +3448,7 @@ mod __parse__Expr { return Ok(__result); } - // State 51 - // ( ",") = Expr "," (*) ["("] - // ( ",") = Expr "," (*) [")"] - // ( ",") = Expr "," (*) ["*"] - // ( ",") = Expr "," (*) ["Num"] - // - // "(" -> Reduce(( ",") = Expr, "," => Call(ActionFn(15));) - // "Num" -> Reduce(( ",") = Expr, "," => Call(ActionFn(15));) - // ")" -> Reduce(( ",") = Expr, "," => Call(ActionFn(15));) - // "*" -> Reduce(( ",") = Expr, "," => Call(ActionFn(15));) - // - 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::LParen(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __nt = super::__action15(arena, __sym0, __sym1); - return Ok((__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29(__nt))); - } - Some((_, Tok::Num(_), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __nt = super::__action15(arena, __sym0, __sym1); - return Ok((__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29(__nt))); - } - Some((_, Tok::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))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 52 + // State 48 // Expr = Expr "-" (*) Factor [")"] // Expr = Expr "-" (*) Factor ["+"] // Expr = Expr "-" (*) Factor [","] @@ -3760,12 +3490,292 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "(" -> Shift(S45) // "*" -> Shift(S40) - // "Num" -> Shift(S42) + // "Num" -> Shift(S41) + // "(" -> Shift(S45) // // Term -> S43 - // Factor -> S58 + // Factor -> S55 + pub fn __state48< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + __sym1: &mut Option, + ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, __tok @ Tok::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)); + } + 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)); + } + _ => { + return Err(__lookahead); + } + } + while __sym1.is_some() { + let (__lookbehind, __lookahead, __nt) = __result; + match __nt { + __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state43(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + __Nonterminal::Factor(__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::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 + // 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) + // + // 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) + // + // Term -> S58 pub fn __state52< 'ast, __TOKENS: Iterator, @@ -3786,17 +3796,11 @@ mod __parse__Expr { let __lookahead = __tokens.next(); __result = try!(__state45(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)); - } Some((_, Tok::Num(__tok0), __loc)) => { let mut __lookbehind = Some(__loc); let mut __sym2 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state42(arena, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state41(arena, __lookbehind, __lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); @@ -3806,10 +3810,6 @@ mod __parse__Expr { let (__lookbehind, __lookahead, __nt) = __result; match __nt { __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!(__state58(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); } @@ -3835,8 +3835,8 @@ mod __parse__Expr { // Term = "(" Expr (*) ")" ["-"] // Term = "(" Expr (*) ")" ["/"] // - // "-" -> Shift(S20) - // "+" -> Shift(S22) + // "-" -> Shift(S23) + // "+" -> Shift(S24) // ")" -> Shift(S59) // pub fn __state53< @@ -3857,13 +3857,13 @@ mod __parse__Expr { let mut __lookbehind = Some(__loc); let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state20(arena, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); + __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!(__state22(arena, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); + __result = try!(__state24(arena, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); } Some((_, __tok @ Tok::RParen(..), __loc)) => { let mut __lookbehind = Some(__loc); @@ -3879,19 +3879,29 @@ mod __parse__Expr { } // State 54 - // Factor = Factor "*" Term (*) [")"] - // Factor = Factor "*" Term (*) ["*"] - // Factor = Factor "*" Term (*) ["+"] - // Factor = Factor "*" Term (*) [","] - // Factor = Factor "*" Term (*) ["-"] - // Factor = Factor "*" Term (*) ["/"] + // 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(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));) + // "-" -> 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, @@ -3908,68 +3918,77 @@ mod __parse__Expr { { let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some((_, Tok::Div(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + Some((_, __tok @ 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::Times(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + Some((_, __tok @ Tok::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::__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::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))); + 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::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + 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 - // Factor = Factor "/" Term (*) [")"] - // Factor = Factor "/" Term (*) ["*"] - // Factor = Factor "/" Term (*) ["+"] - // Factor = Factor "/" Term (*) [","] - // Factor = Factor "/" Term (*) ["-"] - // Factor = Factor "/" Term (*) ["/"] + // 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(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));) + // "*" -> 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, @@ -3986,52 +4005,51 @@ mod __parse__Expr { { 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 @ 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::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); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + 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::__action5(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + 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::__action5(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + let __nt = super::__action1(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); } - Some((_, Tok::Div(..), _)) => { + Some((_, Tok::RParen(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action5(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + 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 @@ -4073,29 +4091,19 @@ mod __parse__Expr { } // 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 ["/"] + // 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(S47) - // "-" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) - // "/" -> Shift(S48) - // ")" -> 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));) + // "+" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) // pub fn __state57< 'ast, @@ -4112,77 +4120,68 @@ 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 __sym3 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state47(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!(__state48(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); - } - Some((_, Tok::Comma(..), _)) => { + Some((_, Tok::Times(..), _)) => { 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))); + 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::__action2(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + 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::__action2(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + 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); } } - return Ok(__result); } // State 58 - // Expr = Expr "-" Factor (*) [")"] - // Expr = Expr "-" Factor (*) ["+"] - // Expr = Expr "-" Factor (*) [","] - // Expr = Expr "-" Factor (*) ["-"] - // Factor = Factor (*) "*" Term [")"] - // Factor = Factor (*) "*" Term ["*"] - // Factor = Factor (*) "*" Term ["+"] - // Factor = Factor (*) "*" Term [","] - // Factor = Factor (*) "*" Term ["-"] - // Factor = Factor (*) "*" Term ["/"] - // Factor = Factor (*) "/" Term [")"] - // Factor = Factor (*) "/" Term ["*"] - // Factor = Factor (*) "/" Term ["+"] - // Factor = Factor (*) "/" Term [","] - // Factor = Factor (*) "/" Term ["-"] - // Factor = Factor (*) "/" Term ["/"] + // 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(S47) - // "+" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) - // "," -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) - // "-" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) - // "/" -> Shift(S48) + // "," -> 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, @@ -4199,51 +4198,52 @@ 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 __sym3 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state47(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); + Some((_, Tok::Comma(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action4(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } - Some((_, __tok @ Tok::Div(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym3 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state48(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); + Some((_, Tok::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::__action1(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + let __nt = super::__action4(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } - Some((_, Tok::Plus(..), _)) => { + Some((_, Tok::Times(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); - let __nt = super::__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))); + 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::__action1(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + let __nt = super::__action4(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action4(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } _ => { return Err(__lookahead); } } - return Ok(__result); } // State 59 @@ -4254,12 +4254,12 @@ 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));) + // "/" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) // pub fn __state59< 'ast, @@ -4276,7 +4276,7 @@ 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(); @@ -4297,14 +4297,7 @@ mod __parse__Expr { let __nt = super::__action9(arena, __sym0, __sym1, __sym2); return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); } - Some((_, Tok::Div(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__action9(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - Some((_, Tok::Times(..), _)) => { + Some((_, Tok::Plus(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); @@ -4318,6 +4311,13 @@ mod __parse__Expr { let __nt = super::__action9(arena, __sym0, __sym1, __sym2); return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); } + Some((_, Tok::Div(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action9(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } _ => { return Err(__lookahead); } @@ -4332,12 +4332,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));) + // "," -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) // pub fn __state60< 'ast, @@ -4355,7 +4355,15 @@ mod __parse__Expr { { let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some((_, Tok::Div(..), _)) => { + 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::Minus(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); @@ -4371,22 +4379,6 @@ mod __parse__Expr { 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))); - } - 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::RParen(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); @@ -4395,7 +4387,15 @@ mod __parse__Expr { let __nt = super::__action6(arena, __sym0, __sym1, __sym2, __sym3); return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } - Some((_, Tok::Minus(..), _)) => { + Some((_, Tok::Div(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + 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(); diff --git a/lalrpop-test/src/loc.lalrpop b/lalrpop-test/src/loc.lalrpop index 983c842..3841721 100644 --- a/lalrpop-test/src/loc.lalrpop +++ b/lalrpop-test/src/loc.lalrpop @@ -11,8 +11,8 @@ extern token { } } -pub Items: Vec<(Option, Option)> = { - => vec![]; +pub Items: Vec<(usize, usize)> = { + <@<> <@>> => vec![(<>)]; > => { let mut v = v; @@ -23,6 +23,6 @@ pub Items: Vec<(Option, Option)> = { "-" => v; }; -Spanned: (Option, Option) = { +Spanned: (usize, usize) = { <@<> T <@>> => (<>); }; diff --git a/lalrpop-test/src/loc.rs b/lalrpop-test/src/loc.rs index 5de0b30..c8a03ac 100644 --- a/lalrpop-test/src/loc.rs +++ b/lalrpop-test/src/loc.rs @@ -6,7 +6,7 @@ pub fn parse_Items< __TOKENS: IntoIterator, >( __tokens: __TOKENS, -) -> Result<(Option<(usize,Tok,usize)>, Vec<(Option, Option)>), Option<(usize,Tok,usize)>> +) -> Result<(Option<(usize,Tok,usize)>, Vec<(usize, usize)>), Option<(usize,Tok,usize)>> { let mut __tokens = __tokens.into_iter(); let __lookahead = __tokens.next(); @@ -22,17 +22,20 @@ mod __parse__Items { use util::tok::Tok; pub enum __Nonterminal<> { - Items(Vec<(Option, Option)>), - _40_3e(::std::option::Option), - _40_3c(::std::option::Option), - ____Items(Vec<(Option, Option)>), - Spanned_3c_22_2b_22_3e((Option, Option)), + _40_3e(usize), + ____Items(Vec<(usize, usize)>), + Items(Vec<(usize, usize)>), + Spanned_3c_22_2b_22_3e((usize, usize)), + _40_3c(usize), } // State 0 - // Items = (*) [EOF] - // Items = (*) ["+"] - // Items = (*) ["-"] + // @< = (*) [EOF] + // @< = (*) ["+"] + // @< = (*) ["-"] + // Items = (*) @< @> [EOF] + // Items = (*) @< @> ["+"] + // Items = (*) @< @> ["-"] // Items = (*) Items Spanned<"+"> [EOF] // Items = (*) Items Spanned<"+"> ["+"] // Items = (*) Items Spanned<"+"> ["-"] @@ -41,11 +44,12 @@ mod __parse__Items { // Items = (*) Items "-" ["-"] // __Items = (*) Items [EOF] // - // "-" -> Reduce(Items = => Call(ActionFn(1));) - // "+" -> Reduce(Items = => Call(ActionFn(1));) - // EOF -> Reduce(Items = => Call(ActionFn(1));) + // EOF -> Reduce(@< = => Lookahead;) + // "-" -> Reduce(@< = => Lookahead;) + // "+" -> Reduce(@< = => Lookahead;) // - // Items -> S1 + // Items -> S2 + // @< -> S1 pub fn __state0< __TOKENS: Iterator, >( @@ -56,17 +60,17 @@ mod __parse__Items { { let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<>); match __lookahead { + None => { + 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(..), _)) => { - let __nt = super::__action1(); - __result = (__lookbehind, __lookahead, __Nonterminal::Items(__nt)); + 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(..), _)) => { - let __nt = super::__action1(); - __result = (__lookbehind, __lookahead, __Nonterminal::Items(__nt)); - } - None => { - let __nt = super::__action1(); - __result = (__lookbehind, __lookahead, __Nonterminal::Items(__nt)); + 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); @@ -76,6 +80,10 @@ mod __parse__Items { let (__lookbehind, __lookahead, __nt) = __result; match __nt { __Nonterminal::Items(__nt) => { + let __sym0 = &mut Some(__nt); + __result = try!(__state2(__lookbehind, __lookahead, __tokens, __sym0)); + } + __Nonterminal::_40_3c(__nt) => { let __sym0 = &mut Some(__nt); __result = try!(__state1(__lookbehind, __lookahead, __tokens, __sym0)); } @@ -87,6 +95,61 @@ mod __parse__Items { } // State 1 + // @> = (*) [EOF] + // @> = (*) ["+"] + // @> = (*) ["-"] + // Items = @< (*) @> [EOF] + // Items = @< (*) @> ["+"] + // Items = @< (*) @> ["-"] + // + // EOF -> Reduce(@> = => Lookbehind;) + // "+" -> Reduce(@> = => Lookbehind;) + // "-" -> Reduce(@> = => Lookbehind;) + // + // @> -> S3 + pub fn __state1< + __TOKENS: Iterator, + >( + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<>), Option<(usize,Tok,usize)>> + { + let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<>); + match __lookahead { + None => { + let __nt = ::std::clone::Clone::clone(&__lookbehind).unwrap_or_default(); + __result = (__lookbehind, __lookahead, __Nonterminal::_40_3e(__nt)); + } + Some((_, Tok::Plus(..), _)) => { + let __nt = ::std::clone::Clone::clone(&__lookbehind).unwrap_or_default(); + __result = (__lookbehind, __lookahead, __Nonterminal::_40_3e(__nt)); + } + Some((_, Tok::Minus(..), _)) => { + let __nt = ::std::clone::Clone::clone(&__lookbehind).unwrap_or_default(); + __result = (__lookbehind, __lookahead, __Nonterminal::_40_3e(__nt)); + } + _ => { + return Err(__lookahead); + } + } + while __sym0.is_some() { + let (__lookbehind, __lookahead, __nt) = __result; + match __nt { + __Nonterminal::_40_3e(__nt) => { + let __sym1 = &mut Some(__nt); + __result = try!(__state3(__lookbehind, __lookahead, __tokens, __sym0, __sym1)); + } + _ => { + return Ok((__lookbehind, __lookahead, __nt)); + } + } + } + return Ok(__result); + } + + // State 2 // @< = (*) ["+"] // Items = Items (*) Spanned<"+"> [EOF] // Items = Items (*) Spanned<"+"> ["+"] @@ -99,19 +162,19 @@ mod __parse__Items { // Spanned<"+"> = (*) @< "+" @> ["-"] // __Items = Items (*) [EOF] // - // "+" -> Reduce(@< = => Lookahead;) + // "-" -> Shift(S5) // EOF -> Reduce(__Items = Items => Call(ActionFn(0));) - // "-" -> Shift(S2) + // "+" -> Reduce(@< = => Lookahead;) // + // @< -> S6 // Spanned<"+"> -> S4 - // @< -> S3 - pub fn __state1< + pub fn __state2< __TOKENS: Iterator, >( __lookbehind: Option, __lookahead: Option<(usize,Tok,usize)>, __tokens: &mut __TOKENS, - __sym0: &mut Option, Option)>>, + __sym0: &mut Option>, ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<>), Option<(usize,Tok,usize)>> { let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<>); @@ -120,17 +183,17 @@ mod __parse__Items { let mut __lookbehind = Some(__loc); let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state2(__lookbehind, __lookahead, __tokens, __sym0, __sym1)); - } - Some((_, Tok::Plus(..), _)) => { - let __nt = __lookahead.as_ref().map(|o| ::std::clone::Clone::clone(&o.0)); - __result = (__lookbehind, __lookahead, __Nonterminal::_40_3c(__nt)); + __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); } @@ -138,14 +201,14 @@ mod __parse__Items { 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)); } - __Nonterminal::_40_3c(__nt) => { - let __sym1 = &mut Some(__nt); - __result = try!(__state3(__lookbehind, __lookahead, __tokens, __sym1)); - } _ => { return Ok((__lookbehind, __lookahead, __nt)); } @@ -154,57 +217,14 @@ mod __parse__Items { return Ok(__result); } - // State 2 - // Items = Items "-" (*) [EOF] - // Items = Items "-" (*) ["+"] - // Items = Items "-" (*) ["-"] - // - // "-" -> Reduce(Items = Items, "-" => Call(ActionFn(3));) - // "+" -> Reduce(Items = Items, "-" => Call(ActionFn(3));) - // EOF -> Reduce(Items = Items, "-" => Call(ActionFn(3));) - // - pub fn __state2< - __TOKENS: Iterator, - >( - __lookbehind: Option, - __lookahead: Option<(usize,Tok,usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option, 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::__action3(__sym0, __sym1); - return Ok((__lookbehind, __lookahead, __Nonterminal::Items(__nt))); - } - Some((_, Tok::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __nt = super::__action3(__sym0, __sym1); - return Ok((__lookbehind, __lookahead, __Nonterminal::Items(__nt))); - } - None => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __nt = super::__action3(__sym0, __sym1); - return Ok((__lookbehind, __lookahead, __Nonterminal::Items(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - // State 3 - // Spanned<"+"> = @< (*) "+" @> [EOF] - // Spanned<"+"> = @< (*) "+" @> ["+"] - // Spanned<"+"> = @< (*) "+" @> ["-"] + // Items = @< @> (*) [EOF] + // Items = @< @> (*) ["+"] + // Items = @< @> (*) ["-"] // - // "+" -> Shift(S5) + // "+" -> Reduce(Items = @<, @> => Call(ActionFn(1));) + // "-" -> Reduce(Items = @<, @> => Call(ActionFn(1));) + // EOF -> Reduce(Items = @<, @> => Call(ActionFn(1));) // pub fn __state3< __TOKENS: Iterator, @@ -212,22 +232,34 @@ mod __parse__Items { __lookbehind: Option, __lookahead: Option<(usize,Tok,usize)>, __tokens: &mut __TOKENS, - __sym0: &mut Option<::std::option::Option>, + __sym0: &mut Option, + __sym1: &mut Option, ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<>), Option<(usize,Tok,usize)>> { let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<>); match __lookahead { - Some((_, __tok @ Tok::Plus(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym1 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state5(__lookbehind, __lookahead, __tokens, __sym0, __sym1)); + 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); } } - return Ok(__result); } // State 4 @@ -235,8 +267,8 @@ mod __parse__Items { // Items = Items Spanned<"+"> (*) ["+"] // Items = Items Spanned<"+"> (*) ["-"] // - // EOF -> Reduce(Items = Items, Spanned<"+"> => Call(ActionFn(2));) // "-" -> 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< @@ -245,19 +277,19 @@ mod __parse__Items { __lookbehind: Option, __lookahead: Option<(usize,Tok,usize)>, __tokens: &mut __TOKENS, - __sym0: &mut Option, Option)>>, - __sym1: &mut Option<(Option, Option)>, + __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 { - None => { + 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))); } - Some((_, Tok::Minus(..), _)) => { + None => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __nt = super::__action2(__sym0, __sym1); @@ -276,6 +308,82 @@ mod __parse__Items { } // State 5 + // Items = Items "-" (*) [EOF] + // Items = Items "-" (*) ["+"] + // Items = Items "-" (*) ["-"] + // + // EOF -> Reduce(Items = Items, "-" => Call(ActionFn(3));) + // "-" -> Reduce(Items = Items, "-" => Call(ActionFn(3));) + // "+" -> Reduce(Items = Items, "-" => Call(ActionFn(3));) + // + pub fn __state5< + __TOKENS: Iterator, + >( + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option>, + __sym1: &mut Option, + ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<>), Option<(usize,Tok,usize)>> + { + let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<>); + match __lookahead { + None => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __nt = super::__action3(__sym0, __sym1); + return Ok((__lookbehind, __lookahead, __Nonterminal::Items(__nt))); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __nt = super::__action3(__sym0, __sym1); + return Ok((__lookbehind, __lookahead, __Nonterminal::Items(__nt))); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __nt = super::__action3(__sym0, __sym1); + return Ok((__lookbehind, __lookahead, __Nonterminal::Items(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 6 + // Spanned<"+"> = @< (*) "+" @> [EOF] + // Spanned<"+"> = @< (*) "+" @> ["+"] + // Spanned<"+"> = @< (*) "+" @> ["-"] + // + // "+" -> Shift(S7) + // + pub fn __state6< + __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::Plus(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state7(__lookbehind, __lookahead, __tokens, __sym0, __sym1)); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + + // State 7 // @> = (*) [EOF] // @> = (*) ["+"] // @> = (*) ["-"] @@ -284,32 +392,32 @@ mod __parse__Items { // Spanned<"+"> = @< "+" (*) @> ["-"] // // EOF -> Reduce(@> = => Lookbehind;) - // "+" -> Reduce(@> = => Lookbehind;) // "-" -> Reduce(@> = => Lookbehind;) + // "+" -> Reduce(@> = => Lookbehind;) // - // @> -> S6 - pub fn __state5< + // @> -> S8 + pub fn __state7< __TOKENS: Iterator, >( __lookbehind: Option, __lookahead: Option<(usize,Tok,usize)>, __tokens: &mut __TOKENS, - __sym0: &mut Option<::std::option::Option>, + __sym0: &mut Option, __sym1: &mut Option, ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<>), Option<(usize,Tok,usize)>> { let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<>); match __lookahead { None => { - let __nt = ::std::clone::Clone::clone(&__lookbehind); - __result = (__lookbehind, __lookahead, __Nonterminal::_40_3e(__nt)); - } - Some((_, Tok::Plus(..), _)) => { - let __nt = ::std::clone::Clone::clone(&__lookbehind); + let __nt = ::std::clone::Clone::clone(&__lookbehind).unwrap_or_default(); __result = (__lookbehind, __lookahead, __Nonterminal::_40_3e(__nt)); } Some((_, Tok::Minus(..), _)) => { - let __nt = ::std::clone::Clone::clone(&__lookbehind); + let __nt = ::std::clone::Clone::clone(&__lookbehind).unwrap_or_default(); + __result = (__lookbehind, __lookahead, __Nonterminal::_40_3e(__nt)); + } + Some((_, Tok::Plus(..), _)) => { + let __nt = ::std::clone::Clone::clone(&__lookbehind).unwrap_or_default(); __result = (__lookbehind, __lookahead, __Nonterminal::_40_3e(__nt)); } _ => { @@ -321,7 +429,7 @@ mod __parse__Items { match __nt { __Nonterminal::_40_3e(__nt) => { let __sym2 = &mut Some(__nt); - __result = try!(__state6(__lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + __result = try!(__state8(__lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); } _ => { return Ok((__lookbehind, __lookahead, __nt)); @@ -331,35 +439,28 @@ mod __parse__Items { return Ok(__result); } - // State 6 + // State 8 // Spanned<"+"> = @< "+" @> (*) [EOF] // Spanned<"+"> = @< "+" @> (*) ["+"] // Spanned<"+"> = @< "+" @> (*) ["-"] // - // "-" -> Reduce(Spanned<"+"> = @<, "+", @> => Call(ActionFn(4));) // "+" -> Reduce(Spanned<"+"> = @<, "+", @> => Call(ActionFn(4));) // EOF -> Reduce(Spanned<"+"> = @<, "+", @> => Call(ActionFn(4));) + // "-" -> Reduce(Spanned<"+"> = @<, "+", @> => Call(ActionFn(4));) // - pub fn __state6< + pub fn __state8< __TOKENS: Iterator, >( __lookbehind: Option, __lookahead: Option<(usize,Tok,usize)>, __tokens: &mut __TOKENS, - __sym0: &mut Option<::std::option::Option>, + __sym0: &mut Option, __sym1: &mut Option, - __sym2: &mut Option<::std::option::Option>, + __sym2: &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 __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::Plus(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); @@ -374,6 +475,13 @@ mod __parse__Items { let __nt = super::__action4(__sym0, __sym1, __sym2); return Ok((__lookbehind, __lookahead, __Nonterminal::Spanned_3c_22_2b_22_3e(__nt))); } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__action4(__sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Spanned_3c_22_2b_22_3e(__nt))); + } _ => { return Err(__lookahead); } @@ -383,24 +491,26 @@ mod __parse__Items { pub fn __action0< >( - __0: Vec<(Option, Option)>, -) -> Vec<(Option, Option)> + __0: Vec<(usize, usize)>, +) -> Vec<(usize, usize)> { (__0) } pub fn __action1< >( -) -> Vec<(Option, Option)> + __0: usize, + __1: usize, +) -> Vec<(usize, usize)> { - vec![] + vec![(__0, __1)] } pub fn __action2< >( - v: Vec<(Option, Option)>, - e: (Option, Option), -) -> Vec<(Option, Option)> + v: Vec<(usize, usize)>, + e: (usize, usize), +) -> Vec<(usize, usize)> { { let mut v = v; @@ -411,19 +521,19 @@ pub fn __action2< pub fn __action3< >( - v: Vec<(Option, Option)>, + v: Vec<(usize, usize)>, _: Tok, -) -> Vec<(Option, Option)> +) -> Vec<(usize, usize)> { v } pub fn __action4< >( - __0: ::std::option::Option, + __0: usize, _: Tok, - __1: ::std::option::Option, -) -> (Option, Option) + __1: usize, +) -> (usize, usize) { (__0, __1) } diff --git a/lalrpop-test/src/main.rs b/lalrpop-test/src/main.rs index 9c12ec3..14101e7 100644 --- a/lalrpop-test/src/main.rs +++ b/lalrpop-test/src/main.rs @@ -77,9 +77,10 @@ fn expr_arena_test2() { #[test] fn loc_test1() { - let expected = vec![(Some(4), Some(5)), - (Some(8), Some(9)), - (Some(16), Some(17))]; + let expected = vec![(0, 0), + (4, 5), + (8, 9), + (16, 17)]; util::test_loc(|v| loc::parse_Items(v), "--+-+---+", expected); // 000001111 // 024680246 @@ -87,6 +88,13 @@ fn loc_test1() { #[test] fn loc_test2() { - util::test_loc(|v| loc::parse_Items(v), "+", vec![(Some(0), Some(1))]); + util::test_loc(|v| loc::parse_Items(v), "+", vec![(0, 0), + (0, 1)]); +} + +#[test] +fn loc_empty() { + // test what happens when `@<` and `@>` are invoked on an empty input + util::test_loc(|v| loc::parse_Items(v), "", vec![(0, 0)]); } diff --git a/lalrpop-test/src/sub.rs b/lalrpop-test/src/sub.rs index 81d4604..340b497 100644 --- a/lalrpop-test/src/sub.rs +++ b/lalrpop-test/src/sub.rs @@ -23,9 +23,9 @@ mod __parse__S { pub enum __Nonterminal<> { ____S(i32), - S(i32), T(i32), E(i32), + S(i32), } // State 0 @@ -40,12 +40,12 @@ mod __parse__S { // T = (*) "Num" ["-"] // __S = (*) S [EOF] // - // "Num" -> Shift(S5) - // "(" -> Shift(S4) + // "(" -> Shift(S2) + // "Num" -> Shift(S3) // - // S -> S2 - // T -> S1 - // E -> S3 + // S -> S1 + // E -> S4 + // T -> S5 pub fn __state0< __TOKENS: Iterator, >( @@ -56,17 +56,17 @@ mod __parse__S { { let mut __result: (Option<()>, Option, __Nonterminal<>); match __lookahead { - 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!(__state4(__lookbehind, __lookahead, __tokens, __sym0)); + __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!(__state3(__lookbehind, __lookahead, __tokens, __sym0)); } _ => { return Err(__lookahead); @@ -76,16 +76,16 @@ mod __parse__S { let (__lookbehind, __lookahead, __nt) = __result; match __nt { __Nonterminal::S(__nt) => { - let __sym0 = &mut Some(__nt); - __result = try!(__state2(__lookbehind, __lookahead, __tokens, __sym0)); - } - __Nonterminal::T(__nt) => { let __sym0 = &mut Some(__nt); __result = try!(__state1(__lookbehind, __lookahead, __tokens, __sym0)); } __Nonterminal::E(__nt) => { let __sym0 = &mut Some(__nt); - __result = try!(__state3(__lookbehind, __lookahead, __tokens, __sym0)); + __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)); @@ -95,45 +95,11 @@ mod __parse__S { } // State 1 - // E = T (*) [EOF] - // E = T (*) ["-"] - // - // "-" -> Reduce(E = T => Call(ActionFn(3));) - // EOF -> Reduce(E = T => Call(ActionFn(3));) - // - pub fn __state1< - __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::Minus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action3(__sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::E(__nt))); - } - None => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action3(__sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::E(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 2 // __S = S (*) [EOF] // // EOF -> Reduce(__S = S => Call(ActionFn(0));) // - pub fn __state2< + pub fn __state1< __TOKENS: Iterator, >( __lookbehind: Option<()>, @@ -155,44 +121,7 @@ mod __parse__S { } } - // State 3 - // E = E (*) "-" T [EOF] - // E = E (*) "-" T ["-"] - // S = E (*) [EOF] - // - // EOF -> Reduce(S = E => Call(ActionFn(1));) - // "-" -> Shift(S6) - // - 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::Minus(..)) => { - let mut __lookbehind = None; - let mut __sym1 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state6(__lookbehind, __lookahead, __tokens, __sym0, __sym1)); - } - None => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action1(__sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::S(__nt))); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 4 + // State 2 // E = (*) E "-" T [")"] // E = (*) E "-" T ["-"] // E = (*) T [")"] @@ -204,12 +133,12 @@ mod __parse__S { // T = (*) "Num" [")"] // T = (*) "Num" ["-"] // - // "Num" -> Shift(S10) - // "(" -> Shift(S9) + // "Num" -> Shift(S9) + // "(" -> Shift(S8) // - // E -> S8 - // T -> S7 - pub fn __state4< + // E -> S7 + // T -> S6 + pub fn __state2< __TOKENS: Iterator, >( __lookbehind: Option<()>, @@ -224,13 +153,13 @@ mod __parse__S { let mut __lookbehind = None; let mut __sym1 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state10(__lookbehind, __lookahead, __tokens, __sym1)); + __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!(__state9(__lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state8(__lookbehind, __lookahead, __tokens, __sym1)); } _ => { return Err(__lookahead); @@ -241,11 +170,11 @@ mod __parse__S { match __nt { __Nonterminal::E(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state8(__lookbehind, __lookahead, __tokens, __sym0, __sym1)); + __result = try!(__state7(__lookbehind, __lookahead, __tokens, __sym0, __sym1)); } __Nonterminal::T(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state7(__lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state6(__lookbehind, __lookahead, __tokens, __sym1)); } _ => { return Ok((__lookbehind, __lookahead, __nt)); @@ -255,12 +184,83 @@ mod __parse__S { return Ok(__result); } - // State 5 + // State 3 // T = "Num" (*) [EOF] // T = "Num" (*) ["-"] // - // EOF -> Reduce(T = "Num" => Call(ActionFn(4));) // "-" -> Reduce(T = "Num" => Call(ActionFn(4));) + // EOF -> Reduce(T = "Num" => Call(ActionFn(4));) + // + 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::Minus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action4(__sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::T(__nt))); + } + None => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action4(__sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::T(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 4 + // E = E (*) "-" T [EOF] + // E = E (*) "-" T ["-"] + // S = E (*) [EOF] + // + // EOF -> Reduce(S = E => Call(ActionFn(1));) + // "-" -> Shift(S10) + // + pub fn __state4< + __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::Minus(..)) => { + let mut __lookbehind = None; + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state10(__lookbehind, __lookahead, __tokens, __sym0, __sym1)); + } + None => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action1(__sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::S(__nt))); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + + // State 5 + // E = T (*) [EOF] + // E = T (*) ["-"] + // + // "-" -> Reduce(E = T => Call(ActionFn(3));) + // EOF -> Reduce(E = T => Call(ActionFn(3));) // pub fn __state5< __TOKENS: Iterator, @@ -273,15 +273,15 @@ mod __parse__S { { let mut __result: (Option<()>, Option, __Nonterminal<>); match __lookahead { - None => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action4(__sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::T(__nt))); - } Some(Tok::Minus(..)) => { let __sym0 = __sym0.take().unwrap(); - let __nt = super::__action4(__sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::T(__nt))); + let __nt = super::__action3(__sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::E(__nt))); + } + None => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__action3(__sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::E(__nt))); } _ => { return Err(__lookahead); @@ -290,68 +290,13 @@ mod __parse__S { } // State 6 - // E = E "-" (*) T [EOF] - // E = E "-" (*) T ["-"] - // T = (*) "(" E ")" [EOF] - // T = (*) "(" E ")" ["-"] - // T = (*) "Num" [EOF] - // T = (*) "Num" ["-"] - // - // "(" -> Shift(S4) - // "Num" -> Shift(S5) - // - // T -> S11 - pub fn __state6< - __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!(__state4(__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); - } - } - while __sym1.is_some() { - let (__lookbehind, __lookahead, __nt) = __result; - match __nt { - __Nonterminal::T(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state11(__lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - _ => { - return Ok((__lookbehind, __lookahead, __nt)); - } - } - } - return Ok(__result); - } - - // State 7 // E = T (*) [")"] // E = T (*) ["-"] // // "-" -> Reduce(E = T => Call(ActionFn(3));) // ")" -> Reduce(E = T => Call(ActionFn(3));) // - pub fn __state7< + pub fn __state6< __TOKENS: Iterator, >( __lookbehind: Option<()>, @@ -378,16 +323,16 @@ mod __parse__S { } } - // State 8 + // State 7 // E = E (*) "-" T [")"] // E = E (*) "-" T ["-"] // T = "(" E (*) ")" [EOF] // T = "(" E (*) ")" ["-"] // - // "-" -> Shift(S12) - // ")" -> Shift(S13) + // "-" -> Shift(S11) + // ")" -> Shift(S12) // - pub fn __state8< + pub fn __state7< __TOKENS: Iterator, >( __lookbehind: Option<()>, @@ -403,13 +348,13 @@ mod __parse__S { let mut __lookbehind = None; let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state12(__lookbehind, __lookahead, __tokens, __sym1, __sym2)); + __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!(__state13(__lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + __result = try!(__state12(__lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); } _ => { return Err(__lookahead); @@ -418,7 +363,7 @@ mod __parse__S { return Ok(__result); } - // State 9 + // State 8 // E = (*) E "-" T [")"] // E = (*) E "-" T ["-"] // E = (*) T [")"] @@ -430,12 +375,12 @@ mod __parse__S { // T = (*) "Num" [")"] // T = (*) "Num" ["-"] // - // "(" -> Shift(S9) - // "Num" -> Shift(S10) + // "Num" -> Shift(S9) + // "(" -> Shift(S8) // - // E -> S14 - // T -> S7 - pub fn __state9< + // E -> S13 + // T -> S6 + pub fn __state8< __TOKENS: Iterator, >( __lookbehind: Option<()>, @@ -446,17 +391,17 @@ mod __parse__S { { 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!(__state9(__lookbehind, __lookahead, __tokens, __sym1)); - } Some(Tok::Num(__tok0)) => { let mut __lookbehind = None; let mut __sym1 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state10(__lookbehind, __lookahead, __tokens, __sym1)); + __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); @@ -467,11 +412,11 @@ mod __parse__S { match __nt { __Nonterminal::E(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state14(__lookbehind, __lookahead, __tokens, __sym0, __sym1)); + __result = try!(__state13(__lookbehind, __lookahead, __tokens, __sym0, __sym1)); } __Nonterminal::T(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state7(__lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state6(__lookbehind, __lookahead, __tokens, __sym1)); } _ => { return Ok((__lookbehind, __lookahead, __nt)); @@ -481,14 +426,14 @@ mod __parse__S { return Ok(__result); } - // State 10 + // State 9 // T = "Num" (*) [")"] // T = "Num" (*) ["-"] // // "-" -> Reduce(T = "Num" => Call(ActionFn(4));) // ")" -> Reduce(T = "Num" => Call(ActionFn(4));) // - pub fn __state10< + pub fn __state9< __TOKENS: Iterator, >( __lookbehind: Option<()>, @@ -515,59 +460,19 @@ mod __parse__S { } } - // State 11 - // E = E "-" T (*) [EOF] - // E = E "-" T (*) ["-"] - // - // "-" -> Reduce(E = E, "-", T => Call(ActionFn(2));) - // EOF -> Reduce(E = E, "-", T => Call(ActionFn(2));) - // - pub fn __state11< - __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::__action2(__sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::E(__nt))); - } - 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))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 12 - // E = E "-" (*) T [")"] + // State 10 + // E = E "-" (*) T [EOF] // E = E "-" (*) T ["-"] - // T = (*) "(" E ")" [")"] + // T = (*) "(" E ")" [EOF] // T = (*) "(" E ")" ["-"] - // T = (*) "Num" [")"] + // T = (*) "Num" [EOF] // T = (*) "Num" ["-"] // - // "Num" -> Shift(S10) - // "(" -> Shift(S9) + // "Num" -> Shift(S3) + // "(" -> Shift(S2) // - // T -> S15 - pub fn __state12< + // T -> S14 + pub fn __state10< __TOKENS: Iterator, >( __lookbehind: Option<()>, @@ -583,12 +488,67 @@ mod __parse__S { let mut __lookbehind = None; let mut __sym2 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state10(__lookbehind, __lookahead, __tokens, __sym2)); + __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)); + } + _ => { + return Err(__lookahead); + } + } + while __sym1.is_some() { + let (__lookbehind, __lookahead, __nt) = __result; + match __nt { + __Nonterminal::T(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state14(__lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + _ => { + return Ok((__lookbehind, __lookahead, __nt)); + } + } + } + return Ok(__result); + } + + // 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)); } _ => { @@ -610,14 +570,14 @@ mod __parse__S { return Ok(__result); } - // State 13 + // State 12 // T = "(" E ")" (*) [EOF] // T = "(" E ")" (*) ["-"] // // "-" -> Reduce(T = "(", E, ")" => Call(ActionFn(5));) // EOF -> Reduce(T = "(", E, ")" => Call(ActionFn(5));) // - pub fn __state13< + pub fn __state12< __TOKENS: Iterator, >( __lookbehind: Option<()>, @@ -650,16 +610,16 @@ mod __parse__S { } } - // State 14 + // State 13 // E = E (*) "-" T [")"] // E = E (*) "-" T ["-"] // T = "(" E (*) ")" [")"] // T = "(" E (*) ")" ["-"] // // ")" -> Shift(S16) - // "-" -> Shift(S12) + // "-" -> Shift(S11) // - pub fn __state14< + pub fn __state13< __TOKENS: Iterator, >( __lookbehind: Option<()>, @@ -681,7 +641,7 @@ mod __parse__S { let mut __lookbehind = None; let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state12(__lookbehind, __lookahead, __tokens, __sym1, __sym2)); + __result = try!(__state11(__lookbehind, __lookahead, __tokens, __sym1, __sym2)); } _ => { return Err(__lookahead); @@ -690,6 +650,46 @@ mod __parse__S { return Ok(__result); } + // State 14 + // E = E "-" T (*) [EOF] + // E = E "-" T (*) ["-"] + // + // "-" -> Reduce(E = E, "-", T => Call(ActionFn(2));) + // EOF -> Reduce(E = E, "-", T => Call(ActionFn(2));) + // + pub fn __state14< + __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::__action2(__sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::E(__nt))); + } + 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))); + } + _ => { + return Err(__lookahead); + } + } + } + // State 15 // E = E "-" T (*) [")"] // E = E "-" T (*) ["-"] @@ -734,8 +734,8 @@ mod __parse__S { // T = "(" E ")" (*) [")"] // T = "(" E ")" (*) ["-"] // - // "-" -> Reduce(T = "(", E, ")" => Call(ActionFn(5));) // ")" -> Reduce(T = "(", E, ")" => Call(ActionFn(5));) + // "-" -> Reduce(T = "(", E, ")" => Call(ActionFn(5));) // pub fn __state16< __TOKENS: Iterator, @@ -750,14 +750,14 @@ mod __parse__S { { let mut __result: (Option<()>, Option, __Nonterminal<>); match __lookahead { - Some(Tok::Minus(..)) => { + Some(Tok::RParen(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); let __nt = super::__action5(__sym0, __sym1, __sym2); return Ok((__lookbehind, __lookahead, __Nonterminal::T(__nt))); } - Some(Tok::RParen(..)) => { + Some(Tok::Minus(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); diff --git a/lalrpop/src/lr1/ascent.rs b/lalrpop/src/lr1/ascent.rs index 8c71d63..9f86056 100644 --- a/lalrpop/src/lr1/ascent.rs +++ b/lalrpop/src/lr1/ascent.rs @@ -248,17 +248,26 @@ impl<'ascent,'grammar,W:Write> RecursiveAscent<'ascent,'grammar,W> { } ActionKind::Lookahead => { + // take the lookahead, if any; otherwise, we are + // at EOF, so taker the lookbehind (end of last + // pushed token); if that is missing too, then + // supply default. debug_assert!(self.types.opt_terminal_loc_type().is_some()); rust!(self.out, - "let {}nt = {}lookahead.as_ref().map(\ - |o| ::std::clone::Clone::clone(&o.0));", - self.prefix, self.prefix); + "let {}nt = \ + {}lookahead.as_ref()\ + .map(|o| ::std::clone::Clone::clone(&o.0))\ + .or_else(|| ::std::clone::Clone::clone(&{}lookbehind))\ + .unwrap_or_default();", + self.prefix, self.prefix, self.prefix); } ActionKind::Lookbehind => { + // take lookbehind or supply default. debug_assert!(self.types.opt_terminal_loc_type().is_some()); rust!(self.out, - "let {}nt = ::std::clone::Clone::clone(&{}lookbehind);", + "let {}nt = ::std::clone::Clone::clone(&{}lookbehind)\ + .unwrap_or_default();", self.prefix, self.prefix); } } diff --git a/lalrpop/src/normalize/tyinfer/mod.rs b/lalrpop/src/normalize/tyinfer/mod.rs index 13dc233..06f45ec 100644 --- a/lalrpop/src/normalize/tyinfer/mod.rs +++ b/lalrpop/src/normalize/tyinfer/mod.rs @@ -230,11 +230,7 @@ impl<'grammar> TypeInferencer<'grammar> { AlternativeAction::User(&ActionKind::Lookahead) | AlternativeAction::User(&ActionKind::Lookbehind) => { - let loc_type = self.types.opt_terminal_loc_type().unwrap().clone(); - Ok(TypeRepr::Nominal(NominalTypeRepr { - path: Path::option(), - types: vec![loc_type] - })) + Ok(self.types.opt_terminal_loc_type().unwrap().clone()) } AlternativeAction::Default(Symbols::Named(ref syms)) => {