From a40f774ecce179ee4a9c4a81f518b232fd60c25f Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Sun, 19 Jul 2015 07:44:13 -0400 Subject: [PATCH] initial take on a tokenizer for LALRPOP --- lalrpop-test/src/expr.rs | 1934 +++++----- lalrpop-test/src/expr_arena.rs | 4910 +++++++++++++------------- lalrpop-test/src/loc.rs | 220 +- lalrpop-test/src/sub.rs | 258 +- lalrpop-test/src/util/lalrpop_tok.rs | 455 +++ lalrpop-test/src/util/mod.rs | 1 + 6 files changed, 4117 insertions(+), 3661 deletions(-) create mode 100644 lalrpop-test/src/util/lalrpop_tok.rs diff --git a/lalrpop-test/src/expr.rs b/lalrpop-test/src/expr.rs index 4641e94..36a3c5a 100644 --- a/lalrpop-test/src/expr.rs +++ b/lalrpop-test/src/expr.rs @@ -23,8 +23,8 @@ mod __parse__Expr { use util::tok::Tok; pub enum __Nonterminal<> { - Factor(i32), Term(i32), + Factor(i32), ____Expr(i32), Expr(i32), } @@ -66,12 +66,12 @@ mod __parse__Expr { // Term = (*) "Num" ["/"] // __Expr = (*) Expr [EOF] // - // "(" -> Shift(S4) - // "Num" -> Shift(S1) + // "(" -> Shift(S2) + // "Num" -> Shift(S5) // - // Term -> S5 - // Factor -> S2 - // Expr -> S3 + // Expr -> S4 + // Factor -> S1 + // Term -> S3 pub fn __state0< __TOKENS: Iterator, >( @@ -87,13 +87,13 @@ mod __parse__Expr { let mut __lookbehind = None; let mut __sym0 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state4(scale, __lookbehind, __lookahead, __tokens, __sym0)); + __result = try!(__state2(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!(__state1(scale, __lookbehind, __lookahead, __tokens, __sym0)); + __result = try!(__state5(scale, __lookbehind, __lookahead, __tokens, __sym0)); } _ => { return Err(__lookahead); @@ -102,15 +102,15 @@ mod __parse__Expr { loop { let (__lookbehind, __lookahead, __nt) = __result; match __nt { - __Nonterminal::Term(__nt) => { + __Nonterminal::Expr(__nt) => { let __sym0 = &mut Some(__nt); - __result = try!(__state5(scale, __lookbehind, __lookahead, __tokens, __sym0)); + __result = try!(__state4(scale, __lookbehind, __lookahead, __tokens, __sym0)); } __Nonterminal::Factor(__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) => { + __Nonterminal::Term(__nt) => { let __sym0 = &mut Some(__nt); __result = try!(__state3(scale, __lookbehind, __lookahead, __tokens, __sym0)); } @@ -122,62 +122,6 @@ mod __parse__Expr { } // State 1 - // Term = "Num" (*) [EOF] - // Term = "Num" (*) ["*"] - // Term = "Num" (*) ["+"] - // Term = "Num" (*) ["-"] - // Term = "Num" (*) ["/"] - // - // "/" -> Reduce(Term = "Num" => Call(ActionFn(7));) - // "+" -> Reduce(Term = "Num" => Call(ActionFn(7));) - // "*" -> Reduce(Term = "Num" => Call(ActionFn(7));) - // EOF -> Reduce(Term = "Num" => Call(ActionFn(7));) - // "-" -> Reduce(Term = "Num" => Call(ActionFn(7));) - // - 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::Div(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(scale, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - Some(Tok::Plus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(scale, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - Some(Tok::Times(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(scale, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - None => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(scale, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - Some(Tok::Minus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(scale, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 2 // Expr = Factor (*) [EOF] // Expr = Factor (*) ["+"] // Expr = Factor (*) ["-"] @@ -192,13 +136,13 @@ mod __parse__Expr { // Factor = Factor (*) "/" Term ["-"] // Factor = Factor (*) "/" Term ["/"] // - // "/" -> Shift(S6) - // "+" -> Reduce(Expr = Factor => Call(ActionFn(3));) - // "*" -> Shift(S7) // "-" -> Reduce(Expr = Factor => Call(ActionFn(3));) + // "*" -> Shift(S6) // EOF -> Reduce(Expr = Factor => Call(ActionFn(3));) + // "/" -> Shift(S7) + // "+" -> Reduce(Expr = Factor => Call(ActionFn(3));) // - pub fn __state2< + pub fn __state1< __TOKENS: Iterator, >( scale: i32, @@ -210,23 +154,18 @@ mod __parse__Expr { { let mut __result: (Option<()>, Option, __Nonterminal<>); match __lookahead { - Some(__tok @ Tok::Div(..)) => { + Some(__tok @ Tok::Times(..)) => { let mut __lookbehind = None; let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); __result = try!(__state6(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); } - Some(__tok @ Tok::Times(..)) => { + Some(__tok @ Tok::Div(..)) => { let mut __lookbehind = None; let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); __result = try!(__state7(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); } - Some(Tok::Plus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action3(scale, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } Some(Tok::Minus(..)) => { let __sym0 = __sym0.take().unwrap(); let __nt = super::__actions::__action3(scale, __sym0); @@ -237,54 +176,10 @@ mod __parse__Expr { let __nt = super::__actions::__action3(scale, __sym0); return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 3 - // Expr = Expr (*) "+" Factor [EOF] - // Expr = Expr (*) "+" Factor ["+"] - // Expr = Expr (*) "+" Factor ["-"] - // Expr = Expr (*) "-" Factor [EOF] - // Expr = Expr (*) "-" Factor ["+"] - // Expr = Expr (*) "-" Factor ["-"] - // __Expr = Expr (*) [EOF] - // - // EOF -> Reduce(__Expr = Expr => Call(ActionFn(0));) - // "-" -> Shift(S8) - // "+" -> Shift(S9) - // - pub fn __state3< - __TOKENS: Iterator, - >( - scale: i32, - __lookbehind: Option<()>, - __lookahead: Option, - __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!(__state8(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); - } - Some(__tok @ Tok::Plus(..)) => { - let mut __lookbehind = None; - let mut __sym1 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state9(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); - } - None => { + Some(Tok::Plus(..)) => { let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action0(scale, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::____Expr(__nt))); + let __nt = super::__actions::__action3(scale, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); } _ => { return Err(__lookahead); @@ -293,7 +188,7 @@ mod __parse__Expr { return Ok(__result); } - // State 4 + // State 2 // Expr = (*) Expr "+" Factor [")"] // Expr = (*) Expr "+" Factor ["+"] // Expr = (*) Expr "+" Factor ["-"] @@ -334,13 +229,13 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "Num" -> Shift(S12) - // "(" -> Shift(S14) + // "(" -> Shift(S11) + // "Num" -> Shift(S9) // - // Term -> S13 - // Factor -> S11 - // Expr -> S10 - pub fn __state4< + // Expr -> S12 + // Term -> S10 + // Factor -> S8 + pub fn __state2< __TOKENS: Iterator, >( scale: i32, @@ -352,17 +247,17 @@ 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!(__state12(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!(__state14(scale, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state11(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)); } _ => { return Err(__lookahead); @@ -371,17 +266,17 @@ mod __parse__Expr { while __sym0.is_some() { let (__lookbehind, __lookahead, __nt) = __result; match __nt { + __Nonterminal::Expr(__nt) => { + let __sym1 = &mut Some(__nt); + __result = try!(__state12(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + } __Nonterminal::Term(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state13(scale, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state10(scale, __lookbehind, __lookahead, __tokens, __sym1)); } __Nonterminal::Factor(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state11(scale, __lookbehind, __lookahead, __tokens, __sym1)); - } - __Nonterminal::Expr(__nt) => { - let __sym1 = &mut Some(__nt); - __result = try!(__state10(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + __result = try!(__state8(scale, __lookbehind, __lookahead, __tokens, __sym1)); } _ => { return Ok((__lookbehind, __lookahead, __nt)); @@ -391,18 +286,123 @@ mod __parse__Expr { return Ok(__result); } - // State 5 + // State 3 // 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));) + // "+" -> 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 __state3< + __TOKENS: Iterator, + >( + scale: i32, + __lookbehind: Option<()>, + __lookahead: Option, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + ) -> Result<(Option<()>, Option, __Nonterminal<>), Option> + { + let mut __result: (Option<()>, Option, __Nonterminal<>); + match __lookahead { + Some(Tok::Minus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action6(scale, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some(Tok::Plus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action6(scale, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + None => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action6(scale, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some(Tok::Times(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action6(scale, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some(Tok::Div(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action6(scale, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 4 + // Expr = Expr (*) "+" Factor [EOF] + // Expr = Expr (*) "+" Factor ["+"] + // Expr = Expr (*) "+" Factor ["-"] + // Expr = Expr (*) "-" Factor [EOF] + // Expr = Expr (*) "-" Factor ["+"] + // Expr = Expr (*) "-" Factor ["-"] + // __Expr = Expr (*) [EOF] + // + // "-" -> Shift(S13) + // "+" -> Shift(S14) + // EOF -> Reduce(__Expr = Expr => Call(ActionFn(0));) + // + pub fn __state4< + __TOKENS: Iterator, + >( + scale: i32, + __lookbehind: Option<()>, + __lookahead: Option, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + ) -> Result<(Option<()>, Option, __Nonterminal<>), Option> + { + let mut __result: (Option<()>, Option, __Nonterminal<>); + match __lookahead { + Some(__tok @ Tok::Minus(..)) => { + let mut __lookbehind = None; + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state13(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + } + Some(__tok @ Tok::Plus(..)) => { + let mut __lookbehind = None; + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state14(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + } + None => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action0(scale, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::____Expr(__nt))); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + + // State 5 + // Term = "Num" (*) [EOF] + // Term = "Num" (*) ["*"] + // Term = "Num" (*) ["+"] + // Term = "Num" (*) ["-"] + // Term = "Num" (*) ["/"] + // + // 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));) + // "/" -> Reduce(Term = "Num" => Call(ActionFn(7));) // pub fn __state5< __TOKENS: Iterator, @@ -416,30 +416,30 @@ mod __parse__Expr { { let mut __result: (Option<()>, Option, __Nonterminal<>); match __lookahead { - Some(Tok::Plus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action6(scale, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Times(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action6(scale, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } None => { let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action6(scale, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Div(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action6(scale, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + let __nt = super::__actions::__action7(scale, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); } Some(Tok::Minus(..)) => { let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action6(scale, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + let __nt = super::__actions::__action7(scale, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + Some(Tok::Times(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action7(scale, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + Some(Tok::Plus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action7(scale, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + Some(Tok::Div(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action7(scale, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); } _ => { return Err(__lookahead); @@ -448,11 +448,11 @@ mod __parse__Expr { } // State 6 - // 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 ")" ["+"] @@ -464,8 +464,8 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "Num" -> Shift(S1) - // "(" -> Shift(S4) + // "Num" -> Shift(S5) + // "(" -> Shift(S2) // // Term -> S15 pub fn __state6< @@ -485,13 +485,13 @@ mod __parse__Expr { let mut __lookbehind = None; let mut __sym2 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state1(scale, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state5(scale, __lookbehind, __lookahead, __tokens, __sym2)); } Some(__tok @ Tok::LParen(..)) => { let mut __lookbehind = None; let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state4(scale, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state2(scale, __lookbehind, __lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); @@ -513,11 +513,11 @@ mod __parse__Expr { } // State 7 - // 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 ")" ["+"] @@ -529,8 +529,8 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "(" -> Shift(S4) - // "Num" -> Shift(S1) + // "Num" -> Shift(S5) + // "(" -> Shift(S2) // // Term -> S16 pub fn __state7< @@ -546,17 +546,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!(__state4(scale, __lookbehind, __lookahead, __tokens, __sym2)); - } Some(Tok::Num(__tok0)) => { let mut __lookbehind = None; let mut __sym2 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state1(scale, __lookbehind, __lookahead, __tokens, __sym2)); + __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!(__state2(scale, __lookbehind, __lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); @@ -578,227 +578,6 @@ mod __parse__Expr { } // State 8 - // Expr = Expr "-" (*) Factor [EOF] - // Expr = Expr "-" (*) Factor ["+"] - // Expr = Expr "-" (*) Factor ["-"] - // Factor = (*) Factor "*" Term [EOF] - // Factor = (*) Factor "*" Term ["*"] - // Factor = (*) Factor "*" Term ["+"] - // Factor = (*) Factor "*" Term ["-"] - // Factor = (*) Factor "*" Term ["/"] - // Factor = (*) Factor "/" Term [EOF] - // Factor = (*) Factor "/" Term ["*"] - // Factor = (*) Factor "/" Term ["+"] - // Factor = (*) Factor "/" Term ["-"] - // Factor = (*) Factor "/" Term ["/"] - // Factor = (*) Term [EOF] - // Factor = (*) Term ["*"] - // Factor = (*) Term ["+"] - // Factor = (*) Term ["-"] - // Factor = (*) Term ["/"] - // Term = (*) "(" Expr ")" [EOF] - // Term = (*) "(" Expr ")" ["*"] - // Term = (*) "(" Expr ")" ["+"] - // Term = (*) "(" Expr ")" ["-"] - // Term = (*) "(" Expr ")" ["/"] - // Term = (*) "Num" [EOF] - // Term = (*) "Num" ["*"] - // Term = (*) "Num" ["+"] - // Term = (*) "Num" ["-"] - // Term = (*) "Num" ["/"] - // - // "Num" -> Shift(S1) - // "(" -> Shift(S4) - // - // Term -> S5 - // Factor -> S17 - pub fn __state8< - __TOKENS: Iterator, - >( - scale: i32, - __lookbehind: Option<()>, - __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option, - ) -> Result<(Option<()>, Option, __Nonterminal<>), Option> - { - let mut __result: (Option<()>, Option, __Nonterminal<>); - match __lookahead { - Some(Tok::Num(__tok0)) => { - let mut __lookbehind = None; - let mut __sym2 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state1(scale, __lookbehind, __lookahead, __tokens, __sym2)); - } - Some(__tok @ Tok::LParen(..)) => { - let mut __lookbehind = None; - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state4(scale, __lookbehind, __lookahead, __tokens, __sym2)); - } - _ => { - return Err(__lookahead); - } - } - while __sym1.is_some() { - let (__lookbehind, __lookahead, __nt) = __result; - match __nt { - __Nonterminal::Term(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state5(scale, __lookbehind, __lookahead, __tokens, __sym2)); - } - __Nonterminal::Factor(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state17(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - _ => { - return Ok((__lookbehind, __lookahead, __nt)); - } - } - } - return Ok(__result); - } - - // State 9 - // Expr = Expr "+" (*) Factor [EOF] - // Expr = Expr "+" (*) Factor ["+"] - // Expr = Expr "+" (*) Factor ["-"] - // Factor = (*) Factor "*" Term [EOF] - // Factor = (*) Factor "*" Term ["*"] - // Factor = (*) Factor "*" Term ["+"] - // Factor = (*) Factor "*" Term ["-"] - // Factor = (*) Factor "*" Term ["/"] - // Factor = (*) Factor "/" Term [EOF] - // Factor = (*) Factor "/" Term ["*"] - // Factor = (*) Factor "/" Term ["+"] - // Factor = (*) Factor "/" Term ["-"] - // Factor = (*) Factor "/" Term ["/"] - // Factor = (*) Term [EOF] - // Factor = (*) Term ["*"] - // Factor = (*) Term ["+"] - // Factor = (*) Term ["-"] - // Factor = (*) Term ["/"] - // Term = (*) "(" Expr ")" [EOF] - // Term = (*) "(" Expr ")" ["*"] - // Term = (*) "(" Expr ")" ["+"] - // Term = (*) "(" Expr ")" ["-"] - // Term = (*) "(" Expr ")" ["/"] - // Term = (*) "Num" [EOF] - // Term = (*) "Num" ["*"] - // Term = (*) "Num" ["+"] - // Term = (*) "Num" ["-"] - // Term = (*) "Num" ["/"] - // - // "(" -> Shift(S4) - // "Num" -> Shift(S1) - // - // Factor -> S18 - // Term -> S5 - pub fn __state9< - __TOKENS: Iterator, - >( - scale: i32, - __lookbehind: Option<()>, - __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option, - ) -> Result<(Option<()>, Option, __Nonterminal<>), Option> - { - let mut __result: (Option<()>, Option, __Nonterminal<>); - match __lookahead { - Some(__tok @ Tok::LParen(..)) => { - let mut __lookbehind = None; - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state4(scale, __lookbehind, __lookahead, __tokens, __sym2)); - } - Some(Tok::Num(__tok0)) => { - let mut __lookbehind = None; - let mut __sym2 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__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!(__state18(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - __Nonterminal::Term(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state5(scale, __lookbehind, __lookahead, __tokens, __sym2)); - } - _ => { - return Ok((__lookbehind, __lookahead, __nt)); - } - } - } - return Ok(__result); - } - - // State 10 - // Expr = Expr (*) "+" Factor [")"] - // Expr = Expr (*) "+" Factor ["+"] - // Expr = Expr (*) "+" Factor ["-"] - // Expr = Expr (*) "-" Factor [")"] - // Expr = Expr (*) "-" Factor ["+"] - // Expr = Expr (*) "-" Factor ["-"] - // Term = "(" Expr (*) ")" [EOF] - // Term = "(" Expr (*) ")" ["*"] - // Term = "(" Expr (*) ")" ["+"] - // Term = "(" Expr (*) ")" ["-"] - // Term = "(" Expr (*) ")" ["/"] - // - // ")" -> Shift(S19) - // "+" -> Shift(S21) - // "-" -> Shift(S20) - // - pub fn __state10< - __TOKENS: Iterator, - >( - scale: i32, - __lookbehind: Option<()>, - __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option, - ) -> Result<(Option<()>, Option, __Nonterminal<>), Option> - { - let mut __result: (Option<()>, Option, __Nonterminal<>); - match __lookahead { - Some(__tok @ Tok::RParen(..)) => { - let mut __lookbehind = None; - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state19(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - Some(__tok @ Tok::Plus(..)) => { - let mut __lookbehind = None; - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state21(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!(__state20(scale, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 11 // Expr = Factor (*) [")"] // Expr = Factor (*) ["+"] // Expr = Factor (*) ["-"] @@ -813,13 +592,13 @@ mod __parse__Expr { // Factor = Factor (*) "/" Term ["-"] // Factor = Factor (*) "/" Term ["/"] // - // "-" -> Reduce(Expr = Factor => Call(ActionFn(3));) - // "/" -> Shift(S22) // ")" -> Reduce(Expr = Factor => Call(ActionFn(3));) + // "/" -> Shift(S18) // "+" -> Reduce(Expr = Factor => Call(ActionFn(3));) - // "*" -> Shift(S23) + // "*" -> Shift(S17) + // "-" -> Reduce(Expr = Factor => Call(ActionFn(3));) // - pub fn __state11< + pub fn __state8< __TOKENS: Iterator, >( scale: i32, @@ -835,18 +614,13 @@ mod __parse__Expr { let mut __lookbehind = None; let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state22(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + __result = try!(__state18(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!(__state23(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); - } - Some(Tok::Minus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action3(scale, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + __result = try!(__state17(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); } Some(Tok::RParen(..)) => { let __sym0 = __sym0.take().unwrap(); @@ -858,6 +632,11 @@ mod __parse__Expr { let __nt = super::__actions::__action3(scale, __sym0); return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); } + Some(Tok::Minus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action3(scale, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } _ => { return Err(__lookahead); } @@ -865,20 +644,20 @@ mod __parse__Expr { return Ok(__result); } - // State 12 + // 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(Term = "Num" => Call(ActionFn(7));) + // ")" -> Reduce(Term = "Num" => Call(ActionFn(7));) + // "+" -> Reduce(Term = "Num" => Call(ActionFn(7));) // - pub fn __state12< + pub fn __state9< __TOKENS: Iterator, >( scale: i32, @@ -890,7 +669,12 @@ mod __parse__Expr { { let mut __result: (Option<()>, Option, __Nonterminal<>); match __lookahead { - Some(Tok::RParen(..)) => { + Some(Tok::Div(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action7(scale, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + Some(Tok::Minus(..)) => { let __sym0 = __sym0.take().unwrap(); let __nt = super::__actions::__action7(scale, __sym0); return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); @@ -900,7 +684,7 @@ mod __parse__Expr { let __nt = super::__actions::__action7(scale, __sym0); return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); } - Some(Tok::Div(..)) => { + Some(Tok::RParen(..)) => { let __sym0 = __sym0.take().unwrap(); let __nt = super::__actions::__action7(scale, __sym0); return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); @@ -910,18 +694,13 @@ mod __parse__Expr { let __nt = super::__actions::__action7(scale, __sym0); return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); } - Some(Tok::Minus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(scale, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } _ => { return Err(__lookahead); } } } - // State 13 + // State 10 // Factor = Term (*) [")"] // Factor = Term (*) ["*"] // Factor = Term (*) ["+"] @@ -929,12 +708,12 @@ mod __parse__Expr { // Factor = Term (*) ["/"] // // "+" -> Reduce(Factor = Term => Call(ActionFn(6));) - // "/" -> Reduce(Factor = Term => Call(ActionFn(6));) // "*" -> Reduce(Factor = Term => Call(ActionFn(6));) - // ")" -> Reduce(Factor = Term => Call(ActionFn(6));) // "-" -> Reduce(Factor = Term => Call(ActionFn(6));) + // "/" -> Reduce(Factor = Term => Call(ActionFn(6));) + // ")" -> Reduce(Factor = Term => Call(ActionFn(6));) // - pub fn __state13< + pub fn __state10< __TOKENS: Iterator, >( scale: i32, @@ -951,22 +730,22 @@ mod __parse__Expr { let __nt = super::__actions::__action6(scale, __sym0); return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } - Some(Tok::Div(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action6(scale, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } Some(Tok::Times(..)) => { let __sym0 = __sym0.take().unwrap(); let __nt = super::__actions::__action6(scale, __sym0); return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } - Some(Tok::RParen(..)) => { + Some(Tok::Minus(..)) => { let __sym0 = __sym0.take().unwrap(); let __nt = super::__actions::__action6(scale, __sym0); return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } - Some(Tok::Minus(..)) => { + Some(Tok::Div(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action6(scale, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some(Tok::RParen(..)) => { let __sym0 = __sym0.take().unwrap(); let __nt = super::__actions::__action6(scale, __sym0); return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); @@ -977,7 +756,7 @@ mod __parse__Expr { } } - // State 14 + // State 11 // Expr = (*) Expr "+" Factor [")"] // Expr = (*) Expr "+" Factor ["+"] // Expr = (*) Expr "+" Factor ["-"] @@ -1018,13 +797,13 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "(" -> Shift(S14) - // "Num" -> Shift(S12) + // "(" -> Shift(S11) + // "Num" -> Shift(S9) // - // Expr -> S24 - // Term -> S13 - // Factor -> S11 - pub fn __state14< + // Expr -> S19 + // Term -> S10 + // Factor -> S8 + pub fn __state11< __TOKENS: Iterator, >( scale: i32, @@ -1040,13 +819,13 @@ mod __parse__Expr { let mut __lookbehind = None; let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state14(scale, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state11(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!(__state12(scale, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state9(scale, __lookbehind, __lookahead, __tokens, __sym1)); } _ => { return Err(__lookahead); @@ -1057,15 +836,236 @@ mod __parse__Expr { match __nt { __Nonterminal::Expr(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state24(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + __result = try!(__state19(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); } __Nonterminal::Term(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state13(scale, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state10(scale, __lookbehind, __lookahead, __tokens, __sym1)); } __Nonterminal::Factor(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state11(scale, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state8(scale, __lookbehind, __lookahead, __tokens, __sym1)); + } + _ => { + return Ok((__lookbehind, __lookahead, __nt)); + } + } + } + return Ok(__result); + } + + // State 12 + // 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(S20) + // "+" -> Shift(S21) + // + pub fn __state12< + __TOKENS: Iterator, + >( + scale: i32, + __lookbehind: Option<()>, + __lookahead: Option, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + __sym1: &mut Option, + ) -> Result<(Option<()>, Option, __Nonterminal<>), Option> + { + let mut __result: (Option<()>, Option, __Nonterminal<>); + match __lookahead { + Some(__tok @ Tok::RParen(..)) => { + let mut __lookbehind = None; + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state22(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + Some(__tok @ Tok::Minus(..)) => { + let mut __lookbehind = None; + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state20(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!(__state21(scale, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + + // State 13 + // Expr = Expr "-" (*) Factor [EOF] + // Expr = Expr "-" (*) Factor ["+"] + // Expr = Expr "-" (*) Factor ["-"] + // Factor = (*) Factor "*" Term [EOF] + // Factor = (*) Factor "*" Term ["*"] + // Factor = (*) Factor "*" Term ["+"] + // Factor = (*) Factor "*" Term ["-"] + // Factor = (*) Factor "*" Term ["/"] + // Factor = (*) Factor "/" Term [EOF] + // Factor = (*) Factor "/" Term ["*"] + // Factor = (*) Factor "/" Term ["+"] + // Factor = (*) Factor "/" Term ["-"] + // Factor = (*) Factor "/" Term ["/"] + // Factor = (*) Term [EOF] + // Factor = (*) Term ["*"] + // Factor = (*) Term ["+"] + // Factor = (*) Term ["-"] + // Factor = (*) Term ["/"] + // Term = (*) "(" Expr ")" [EOF] + // Term = (*) "(" Expr ")" ["*"] + // Term = (*) "(" Expr ")" ["+"] + // Term = (*) "(" Expr ")" ["-"] + // Term = (*) "(" Expr ")" ["/"] + // Term = (*) "Num" [EOF] + // Term = (*) "Num" ["*"] + // Term = (*) "Num" ["+"] + // Term = (*) "Num" ["-"] + // Term = (*) "Num" ["/"] + // + // "Num" -> Shift(S5) + // "(" -> Shift(S2) + // + // Factor -> S23 + // Term -> S3 + 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!(__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!(__state3(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" ["/"] + // + // "(" -> Shift(S2) + // "Num" -> Shift(S5) + // + // Factor -> S24 + // Term -> S3 + pub fn __state14< + __TOKENS: Iterator, + >( + scale: i32, + __lookbehind: Option<()>, + __lookahead: Option, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + __sym1: &mut Option, + ) -> Result<(Option<()>, Option, __Nonterminal<>), Option> + { + let mut __result: (Option<()>, Option, __Nonterminal<>); + match __lookahead { + Some(__tok @ Tok::LParen(..)) => { + let mut __lookbehind = None; + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state2(scale, __lookbehind, __lookahead, __tokens, __sym2)); + } + Some(Tok::Num(__tok0)) => { + let mut __lookbehind = None; + let mut __sym2 = &mut Some((__tok0)); + let __lookahead = __tokens.next(); + __result = try!(__state5(scale, __lookbehind, __lookahead, __tokens, __sym2)); + } + _ => { + return Err(__lookahead); + } + } + while __sym1.is_some() { + let (__lookbehind, __lookahead, __nt) = __result; + match __nt { + __Nonterminal::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!(__state3(scale, __lookbehind, __lookahead, __tokens, __sym2)); } _ => { return Ok((__lookbehind, __lookahead, __nt)); @@ -1076,17 +1076,17 @@ mod __parse__Expr { } // State 15 - // 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(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));) + // "*" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // "-" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // "+" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // "/" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // EOF -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) // pub fn __state15< __TOKENS: Iterator, @@ -1106,35 +1106,35 @@ mod __parse__Expr { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action5(scale, __sym0, __sym1, __sym2); - return Ok((__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::__actions::__action5(scale, __sym0, __sym1, __sym2); + let __nt = super::__actions::__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::__actions::__action5(scale, __sym0, __sym1, __sym2); + let __nt = super::__actions::__action4(scale, __sym0, __sym1, __sym2); return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } - None => { + Some(Tok::Plus(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action5(scale, __sym0, __sym1, __sym2); + let __nt = super::__actions::__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::__actions::__action5(scale, __sym0, __sym1, __sym2); + let __nt = super::__actions::__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::__actions::__action4(scale, __sym0, __sym1, __sym2); return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } _ => { @@ -1144,17 +1144,17 @@ mod __parse__Expr { } // State 16 - // 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));) - // 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(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 __state16< __TOKENS: Iterator, @@ -1170,39 +1170,39 @@ 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::__actions::__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::__actions::__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::__actions::__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::__actions::__action4(scale, __sym0, __sym1, __sym2); + let __nt = super::__actions::__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::__actions::__action4(scale, __sym0, __sym1, __sym2); + let __nt = super::__actions::__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::__actions::__action5(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + None => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__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::__actions::__action5(scale, __sym0, __sym1, __sym2); return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } _ => { @@ -1212,26 +1212,26 @@ mod __parse__Expr { } // State 17 - // Expr = Expr "-" Factor (*) [EOF] - // Expr = Expr "-" Factor (*) ["+"] - // Expr = Expr "-" Factor (*) ["-"] - // Factor = Factor (*) "*" Term [EOF] - // Factor = Factor (*) "*" Term ["*"] - // Factor = Factor (*) "*" Term ["+"] - // Factor = Factor (*) "*" Term ["-"] - // Factor = Factor (*) "*" Term ["/"] - // Factor = Factor (*) "/" Term [EOF] - // Factor = Factor (*) "/" Term ["*"] - // Factor = Factor (*) "/" Term ["+"] - // Factor = Factor (*) "/" Term ["-"] - // Factor = Factor (*) "/" Term ["/"] + // Factor = Factor "*" (*) Term [")"] + // Factor = Factor "*" (*) Term ["*"] + // Factor = Factor "*" (*) Term ["+"] + // Factor = Factor "*" (*) Term ["-"] + // Factor = Factor "*" (*) Term ["/"] + // Term = (*) "(" Expr ")" [")"] + // Term = (*) "(" Expr ")" ["*"] + // Term = (*) "(" Expr ")" ["+"] + // Term = (*) "(" Expr ")" ["-"] + // Term = (*) "(" Expr ")" ["/"] + // Term = (*) "Num" [")"] + // Term = (*) "Num" ["*"] + // Term = (*) "Num" ["+"] + // Term = (*) "Num" ["-"] + // Term = (*) "Num" ["/"] // - // "+" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) - // "-" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) - // "*" -> Shift(S7) - // EOF -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) - // "/" -> Shift(S6) + // "Num" -> Shift(S9) + // "(" -> Shift(S11) // + // Term -> S25 pub fn __state17< __TOKENS: Iterator, >( @@ -1241,72 +1241,62 @@ mod __parse__Expr { __tokens: &mut __TOKENS, __sym0: &mut Option, __sym1: &mut Option, - __sym2: &mut Option, ) -> Result<(Option<()>, Option, __Nonterminal<>), Option> { let mut __result: (Option<()>, Option, __Nonterminal<>); match __lookahead { - Some(__tok @ Tok::Times(..)) => { + Some(Tok::Num(__tok0)) => { let mut __lookbehind = None; - let mut __sym3 = &mut Some((__tok)); + let mut __sym2 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state7(scale, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); + __result = try!(__state9(scale, __lookbehind, __lookahead, __tokens, __sym2)); } - Some(__tok @ Tok::Div(..)) => { + Some(__tok @ Tok::LParen(..)) => { let mut __lookbehind = None; - let mut __sym3 = &mut Some((__tok)); + let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state6(scale, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); - } - Some(Tok::Plus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__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::__actions::__action1(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::__actions::__action1(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + __result = try!(__state11(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!(__state25(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + _ => { + return Ok((__lookbehind, __lookahead, __nt)); + } + } + } return Ok(__result); } // State 18 - // Expr = Expr "+" Factor (*) [EOF] - // Expr = Expr "+" Factor (*) ["+"] - // Expr = Expr "+" Factor (*) ["-"] - // Factor = Factor (*) "*" Term [EOF] - // Factor = Factor (*) "*" Term ["*"] - // Factor = Factor (*) "*" Term ["+"] - // Factor = Factor (*) "*" Term ["-"] - // Factor = Factor (*) "*" Term ["/"] - // Factor = Factor (*) "/" Term [EOF] - // Factor = Factor (*) "/" Term ["*"] - // Factor = Factor (*) "/" Term ["+"] - // Factor = Factor (*) "/" Term ["-"] - // Factor = Factor (*) "/" Term ["/"] + // Factor = Factor "/" (*) Term [")"] + // 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(S6) - // EOF -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) - // "+" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) - // "*" -> Shift(S7) - // "-" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) + // "(" -> Shift(S11) + // "Num" -> Shift(S9) // + // Term -> S26 pub fn __state18< __TOKENS: Iterator, >( @@ -1316,63 +1306,57 @@ mod __parse__Expr { __tokens: &mut __TOKENS, __sym0: &mut Option, __sym1: &mut Option, - __sym2: &mut Option, ) -> Result<(Option<()>, Option, __Nonterminal<>), Option> { let mut __result: (Option<()>, Option, __Nonterminal<>); match __lookahead { - Some(__tok @ Tok::Div(..)) => { + Some(__tok @ Tok::LParen(..)) => { let mut __lookbehind = None; - let mut __sym3 = &mut Some((__tok)); + let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state6(scale, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); + __result = try!(__state11(scale, __lookbehind, __lookahead, __tokens, __sym2)); } - Some(__tok @ Tok::Times(..)) => { + Some(Tok::Num(__tok0)) => { let mut __lookbehind = None; - let mut __sym3 = &mut Some((__tok)); + let mut __sym2 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state7(scale, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); - } - None => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__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::__actions::__action2(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - Some(Tok::Minus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action2(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + __result = try!(__state9(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 19 - // Term = "(" Expr ")" (*) [EOF] - // Term = "(" Expr ")" (*) ["*"] - // Term = "(" Expr ")" (*) ["+"] - // Term = "(" Expr ")" (*) ["-"] - // Term = "(" Expr ")" (*) ["/"] + // Expr = Expr (*) "+" Factor [")"] + // Expr = Expr (*) "+" Factor ["+"] + // Expr = Expr (*) "+" Factor ["-"] + // Expr = Expr (*) "-" Factor [")"] + // Expr = Expr (*) "-" Factor ["+"] + // Expr = Expr (*) "-" Factor ["-"] + // Term = "(" Expr (*) ")" [")"] + // Term = "(" Expr (*) ")" ["*"] + // Term = "(" Expr (*) ")" ["+"] + // Term = "(" Expr (*) ")" ["-"] + // Term = "(" Expr (*) ")" ["/"] // - // EOF -> Reduce(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));) + // ")" -> Shift(S27) + // "+" -> Shift(S21) + // "-" -> Shift(S20) // pub fn __state19< __TOKENS: Iterator, @@ -1383,50 +1367,33 @@ mod __parse__Expr { __tokens: &mut __TOKENS, __sym0: &mut Option, __sym1: &mut Option, - __sym2: &mut Option, ) -> Result<(Option<()>, Option, __Nonterminal<>), Option> { let mut __result: (Option<()>, Option, __Nonterminal<>); match __lookahead { - None => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action8(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + Some(__tok @ Tok::RParen(..)) => { + let mut __lookbehind = None; + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state27(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); } - Some(Tok::Times(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action8(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + Some(__tok @ Tok::Plus(..)) => { + let mut __lookbehind = None; + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state21(scale, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); } - Some(Tok::Plus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action8(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - Some(Tok::Minus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__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::__actions::__action8(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + Some(__tok @ Tok::Minus(..)) => { + let mut __lookbehind = None; + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state20(scale, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); } _ => { return Err(__lookahead); } } + return Ok(__result); } // State 20 @@ -1459,11 +1426,11 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "(" -> Shift(S14) - // "Num" -> Shift(S12) + // "(" -> Shift(S11) + // "Num" -> Shift(S9) // - // Factor -> S25 - // Term -> S13 + // Term -> S10 + // Factor -> S28 pub fn __state20< __TOKENS: Iterator, >( @@ -1481,13 +1448,13 @@ mod __parse__Expr { let mut __lookbehind = None; let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state14(scale, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state11(scale, __lookbehind, __lookahead, __tokens, __sym2)); } Some(Tok::Num(__tok0)) => { let mut __lookbehind = None; let mut __sym2 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state12(scale, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state9(scale, __lookbehind, __lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); @@ -1496,13 +1463,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!(__state25(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } __Nonterminal::Term(__nt) => { let __sym2 = &mut Some(__nt); - __result = try!(__state13(scale, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state10(scale, __lookbehind, __lookahead, __tokens, __sym2)); + } + __Nonterminal::Factor(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state28(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); } _ => { return Ok((__lookbehind, __lookahead, __nt)); @@ -1542,11 +1509,11 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "(" -> Shift(S14) - // "Num" -> Shift(S12) + // "(" -> Shift(S11) + // "Num" -> Shift(S9) // - // Factor -> S26 - // Term -> S13 + // Factor -> S29 + // Term -> S10 pub fn __state21< __TOKENS: Iterator, >( @@ -1564,13 +1531,13 @@ mod __parse__Expr { let mut __lookbehind = None; let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state14(scale, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state11(scale, __lookbehind, __lookahead, __tokens, __sym2)); } Some(Tok::Num(__tok0)) => { let mut __lookbehind = None; let mut __sym2 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state12(scale, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state9(scale, __lookbehind, __lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); @@ -1581,11 +1548,11 @@ mod __parse__Expr { match __nt { __Nonterminal::Factor(__nt) => { let __sym2 = &mut Some(__nt); - __result = try!(__state26(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + __result = try!(__state29(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); } __Nonterminal::Term(__nt) => { let __sym2 = &mut Some(__nt); - __result = try!(__state13(scale, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state10(scale, __lookbehind, __lookahead, __tokens, __sym2)); } _ => { return Ok((__lookbehind, __lookahead, __nt)); @@ -1596,26 +1563,18 @@ mod __parse__Expr { } // State 22 - // 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(S14) - // "Num" -> Shift(S12) + // EOF -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) + // "/" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) + // "-" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) + // "+" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) + // "*" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) // - // Term -> S27 pub fn __state22< __TOKENS: Iterator, >( @@ -1623,64 +1582,75 @@ 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!(__state14(scale, __lookbehind, __lookahead, __tokens, __sym2)); + None => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action8(scale, __sym0, __sym1, __sym2); + return Ok((__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!(__state12(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::__actions::__action8(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + Some(Tok::Minus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__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::__actions::__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::__actions::__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!(__state27(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - _ => { - return Ok((__lookbehind, __lookahead, __nt)); - } - } - } - return Ok(__result); } // State 23 - // Factor = Factor "*" (*) Term [")"] - // Factor = Factor "*" (*) Term ["*"] - // Factor = Factor "*" (*) Term ["+"] - // Factor = Factor "*" (*) Term ["-"] - // Factor = Factor "*" (*) Term ["/"] - // Term = (*) "(" Expr ")" [")"] - // Term = (*) "(" Expr ")" ["*"] - // Term = (*) "(" Expr ")" ["+"] - // Term = (*) "(" Expr ")" ["-"] - // Term = (*) "(" Expr ")" ["/"] - // Term = (*) "Num" [")"] - // Term = (*) "Num" ["*"] - // Term = (*) "Num" ["+"] - // Term = (*) "Num" ["-"] - // Term = (*) "Num" ["/"] + // Expr = Expr "-" Factor (*) [EOF] + // Expr = Expr "-" Factor (*) ["+"] + // Expr = Expr "-" Factor (*) ["-"] + // Factor = Factor (*) "*" Term [EOF] + // Factor = Factor (*) "*" Term ["*"] + // Factor = Factor (*) "*" Term ["+"] + // Factor = Factor (*) "*" Term ["-"] + // Factor = Factor (*) "*" Term ["/"] + // Factor = Factor (*) "/" Term [EOF] + // Factor = Factor (*) "/" Term ["*"] + // Factor = Factor (*) "/" Term ["+"] + // Factor = Factor (*) "/" Term ["-"] + // Factor = Factor (*) "/" Term ["/"] // - // "(" -> Shift(S14) - // "Num" -> Shift(S12) + // "+" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // "*" -> Shift(S6) + // "-" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // "/" -> Shift(S7) + // EOF -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) // - // Term -> S28 pub fn __state23< __TOKENS: Iterator, >( @@ -1690,57 +1660,71 @@ mod __parse__Expr { __tokens: &mut __TOKENS, __sym0: &mut Option, __sym1: &mut Option, + __sym2: &mut Option, ) -> Result<(Option<()>, Option, __Nonterminal<>), Option> { let mut __result: (Option<()>, Option, __Nonterminal<>); match __lookahead { - Some(__tok @ Tok::LParen(..)) => { + Some(__tok @ Tok::Times(..)) => { let mut __lookbehind = None; - let mut __sym2 = &mut Some((__tok)); + let mut __sym3 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state14(scale, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state6(scale, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); } - Some(Tok::Num(__tok0)) => { + Some(__tok @ Tok::Div(..)) => { let mut __lookbehind = None; - let mut __sym2 = &mut Some((__tok0)); + let mut __sym3 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state12(scale, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state7(scale, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); + } + Some(Tok::Plus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__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::__actions::__action1(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::__actions::__action1(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); } _ => { return Err(__lookahead); } } - while __sym1.is_some() { - let (__lookbehind, __lookahead, __nt) = __result; - match __nt { - __Nonterminal::Term(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state28(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - _ => { - return Ok((__lookbehind, __lookahead, __nt)); - } - } - } return Ok(__result); } // State 24 - // 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 (*) ")" ["/"] + // Expr = Expr "+" Factor (*) [EOF] + // Expr = Expr "+" Factor (*) ["+"] + // Expr = Expr "+" Factor (*) ["-"] + // Factor = Factor (*) "*" Term [EOF] + // Factor = Factor (*) "*" Term ["*"] + // Factor = Factor (*) "*" Term ["+"] + // Factor = Factor (*) "*" Term ["-"] + // Factor = Factor (*) "*" Term ["/"] + // Factor = Factor (*) "/" Term [EOF] + // Factor = Factor (*) "/" Term ["*"] + // Factor = Factor (*) "/" Term ["+"] + // Factor = Factor (*) "/" Term ["-"] + // Factor = Factor (*) "/" Term ["/"] // - // "-" -> Shift(S20) - // "+" -> Shift(S21) - // ")" -> Shift(S29) + // "-" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) + // "/" -> Shift(S7) + // EOF -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) + // "*" -> Shift(S6) + // "+" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) // pub fn __state24< __TOKENS: Iterator, @@ -1749,29 +1733,45 @@ 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::Minus(..)) => { + Some(__tok @ Tok::Div(..)) => { let mut __lookbehind = None; - let mut __sym2 = &mut Some((__tok)); + let mut __sym3 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state20(scale, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); + __result = try!(__state7(scale, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); } - Some(__tok @ Tok::Plus(..)) => { + Some(__tok @ Tok::Times(..)) => { let mut __lookbehind = None; - let mut __sym2 = &mut Some((__tok)); + let mut __sym3 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state21(scale, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); + __result = try!(__state6(scale, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); } - Some(__tok @ Tok::RParen(..)) => { - let mut __lookbehind = None; - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state29(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + Some(Tok::Minus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__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::__actions::__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::__actions::__action2(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); } _ => { return Err(__lookahead); @@ -1781,25 +1781,17 @@ mod __parse__Expr { } // State 25 - // Expr = Expr "-" Factor (*) [")"] - // Expr = Expr "-" Factor (*) ["+"] - // Expr = Expr "-" Factor (*) ["-"] - // Factor = Factor (*) "*" Term [")"] - // Factor = Factor (*) "*" Term ["*"] - // Factor = Factor (*) "*" Term ["+"] - // Factor = Factor (*) "*" Term ["-"] - // Factor = Factor (*) "*" Term ["/"] - // Factor = Factor (*) "/" Term [")"] - // Factor = Factor (*) "/" Term ["*"] - // Factor = Factor (*) "/" Term ["+"] - // Factor = Factor (*) "/" Term ["-"] - // Factor = Factor (*) "/" Term ["/"] + // Factor = Factor "*" Term (*) [")"] + // Factor = Factor "*" Term (*) ["*"] + // Factor = Factor "*" Term (*) ["+"] + // Factor = Factor "*" Term (*) ["-"] + // Factor = Factor "*" Term (*) ["/"] // - // "/" -> Shift(S22) - // ")" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) - // "*" -> Shift(S23) - // "-" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) - // "+" -> 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 __state25< __TOKENS: Iterator, @@ -1815,66 +1807,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!(__state22(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!(__state23(scale, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); + Some(Tok::Minus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__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::__actions::__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::__actions::__action1(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + let __nt = super::__actions::__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::__actions::__action1(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + let __nt = super::__actions::__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::__actions::__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::__actions::__action4(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } _ => { return Err(__lookahead); } } - return Ok(__result); } // 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 (*) ["/"] // - // "+" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) - // ")" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) - // "-" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) - // "*" -> Shift(S23) - // "/" -> Shift(S22) + // "-" -> 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 __state26< __TOKENS: Iterator, @@ -1890,73 +1875,13 @@ mod __parse__Expr { { let mut __result: (Option<()>, Option, __Nonterminal<>); match __lookahead { - Some(__tok @ Tok::Times(..)) => { - let mut __lookbehind = None; - let mut __sym3 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state23(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!(__state22(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::__actions::__action2(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - Some(Tok::RParen(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action2(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } Some(Tok::Minus(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action2(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + let __nt = super::__actions::__action5(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 27 - // 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 __state27< - __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::Div(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); @@ -1985,12 +1910,73 @@ mod __parse__Expr { let __nt = super::__actions::__action5(scale, __sym0, __sym1, __sym2); return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } + _ => { + return Err(__lookahead); + } + } + } + + // State 27 + // Term = "(" Expr ")" (*) [")"] + // Term = "(" Expr ")" (*) ["*"] + // Term = "(" Expr ")" (*) ["+"] + // Term = "(" Expr ")" (*) ["-"] + // Term = "(" Expr ")" (*) ["/"] + // + // "+" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) + // "-" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) + // "/" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) + // ")" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) + // "*" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) + // + pub fn __state27< + __TOKENS: Iterator, + >( + scale: i32, + __lookbehind: Option<()>, + __lookahead: Option, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + __sym1: &mut Option, + __sym2: &mut Option, + ) -> Result<(Option<()>, Option, __Nonterminal<>), Option> + { + let mut __result: (Option<()>, Option, __Nonterminal<>); + match __lookahead { + Some(Tok::Plus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action8(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } Some(Tok::Minus(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action5(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + let __nt = super::__actions::__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::__actions::__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::__actions::__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::__actions::__action8(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); } _ => { return Err(__lookahead); @@ -1999,17 +1985,25 @@ mod __parse__Expr { } // State 28 - // 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(S17) + // ")" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // "+" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // "/" -> Shift(S18) + // "-" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) // pub fn __state28< __TOKENS: Iterator, @@ -2025,59 +2019,66 @@ mod __parse__Expr { { let mut __result: (Option<()>, Option, __Nonterminal<>); match __lookahead { - Some(Tok::Div(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__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!(__state17(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::__actions::__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::__actions::__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!(__state18(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::__actions::__action4(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + let __nt = super::__actions::__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::__actions::__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::__actions::__action4(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + let __nt = super::__actions::__action1(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); } _ => { return Err(__lookahead); } } + return Ok(__result); } // State 29 - // Term = "(" Expr ")" (*) [")"] - // Term = "(" Expr ")" (*) ["*"] - // Term = "(" Expr ")" (*) ["+"] - // 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(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));) + // "*" -> Shift(S17) + // ")" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) + // "-" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) + // "+" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) + // "/" -> Shift(S18) // pub fn __state29< __TOKENS: Iterator, @@ -2086,52 +2087,51 @@ mod __parse__Expr { __lookbehind: Option<()>, __lookahead: Option, __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option, - __sym2: &mut Option, + __sym0: &mut Option, + __sym1: &mut Option, + __sym2: &mut Option, ) -> Result<(Option<()>, Option, __Nonterminal<>), Option> { let mut __result: (Option<()>, Option, __Nonterminal<>); match __lookahead { - Some(Tok::Times(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action8(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + Some(__tok @ Tok::Times(..)) => { + 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::Minus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action8(scale, __sym0, __sym1, __sym2); - return Ok((__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::__actions::__action8(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + Some(__tok @ Tok::Div(..)) => { + let mut __lookbehind = None; + let mut __sym3 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state18(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::__actions::__action8(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + let __nt = super::__actions::__action2(scale, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + Some(Tok::Minus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__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::__actions::__action8(scale, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + let __nt = super::__actions::__action2(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 9b6b4fa..0e77ca9 100644 --- a/lalrpop-test/src/expr_arena.rs +++ b/lalrpop-test/src/expr_arena.rs @@ -26,14 +26,14 @@ mod __parse__Expr { use util::tok::Tok; pub enum __Nonterminal<'ast, > { - Comma_3cExpr_3e(Vec<&'ast Node<'ast>>), - Factor(&'ast Node<'ast>), - ____Expr(&'ast Node<'ast>), - Expr(&'ast Node<'ast>), - _28_3cExpr_3e_20_22_2c_22_29(&'ast Node<'ast>), - _28_3cExpr_3e_20_22_2c_22_29_2a(::std::vec::Vec<&'ast Node<'ast>>), - Expr_3f(::std::option::Option<&'ast Node<'ast>>), Term(&'ast Node<'ast>), + Comma_3cExpr_3e(Vec<&'ast Node<'ast>>), + Expr(&'ast Node<'ast>), + Factor(&'ast Node<'ast>), + Expr_3f(::std::option::Option<&'ast Node<'ast>>), + _28_3cExpr_3e_20_22_2c_22_29_2a(::std::vec::Vec<&'ast Node<'ast>>), + _28_3cExpr_3e_20_22_2c_22_29(&'ast Node<'ast>), + ____Expr(&'ast Node<'ast>), } // State 0 @@ -78,13 +78,13 @@ mod __parse__Expr { // Term = (*) "Num" ["/"] // __Expr = (*) Expr [EOF] // - // "(" -> Shift(S2) - // "*" -> Shift(S6) - // "Num" -> Shift(S1) + // "(" -> Shift(S1) + // "Num" -> Shift(S6) + // "*" -> Shift(S2) // // Term -> S4 - // Factor -> S3 - // Expr -> S5 + // Factor -> S5 + // Expr -> S3 pub fn __state0< 'ast, __TOKENS: Iterator, @@ -101,19 +101,19 @@ mod __parse__Expr { let mut __lookbehind = Some(__loc); let mut __sym0 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state2(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!(__state1(arena, __lookbehind, __lookahead, __tokens, __sym0)); } Some((_, Tok::Num(__tok0), __loc)) => { let mut __lookbehind = Some(__loc); let mut __sym0 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state1(arena, __lookbehind, __lookahead, __tokens, __sym0)); + __result = try!(__state6(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!(__state2(arena, __lookbehind, __lookahead, __tokens, __sym0)); } _ => { return Err(__lookahead); @@ -128,11 +128,11 @@ mod __parse__Expr { } __Nonterminal::Factor(__nt) => { let __sym0 = &mut Some(__nt); - __result = try!(__state3(arena, __lookbehind, __lookahead, __tokens, __sym0)); + __result = try!(__state5(arena, __lookbehind, __lookahead, __tokens, __sym0)); } __Nonterminal::Expr(__nt) => { let __sym0 = &mut Some(__nt); - __result = try!(__state5(arena, __lookbehind, __lookahead, __tokens, __sym0)); + __result = try!(__state3(arena, __lookbehind, __lookahead, __tokens, __sym0)); } _ => { return Ok((__lookbehind, __lookahead, __nt)); @@ -142,63 +142,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::__actions::__action8(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - None => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action8(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action8(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - Some((_, Tok::Times(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action8(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - Some((_, Tok::Div(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action8(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 2 // Expr = (*) Expr "+" Factor [")"] // Expr = (*) Expr "+" Factor ["+"] // Expr = (*) Expr "+" Factor ["-"] @@ -244,13 +187,80 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // + // "(" -> Shift(S12) + // "Num" -> Shift(S10) // "*" -> Shift(S11) - // "(" -> Shift(S10) - // "Num" -> Shift(S12) // - // Expr -> S9 - // Term -> S8 - // Factor -> S7 + // Term -> S7 + // Factor -> S9 + // Expr -> S8 + 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 @ Tok::LParen(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state12(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!(__state10(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)); + } + _ => { + return Err(__lookahead); + } + } + while __sym0.is_some() { + let (__lookbehind, __lookahead, __nt) = __result; + match __nt { + __Nonterminal::Term(__nt) => { + let __sym1 = &mut Some(__nt); + __result = try!(__state7(arena, __lookbehind, __lookahead, __tokens, __sym1)); + } + __Nonterminal::Factor(__nt) => { + let __sym1 = &mut Some(__nt); + __result = try!(__state9(arena, __lookbehind, __lookahead, __tokens, __sym1)); + } + __Nonterminal::Expr(__nt) => { + let __sym1 = &mut Some(__nt); + __result = try!(__state8(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + } + _ => { + return Ok((__lookbehind, __lookahead, __nt)); + } + } + } + return Ok(__result); + } + + // State 2 + // Factor = "*" (*) "(" Comma ")" [EOF] + // Factor = "*" (*) "(" Comma ")" ["*"] + // Factor = "*" (*) "(" Comma ")" ["+"] + // Factor = "*" (*) "(" Comma ")" ["-"] + // Factor = "*" (*) "(" Comma ")" ["/"] + // + // "(" -> Shift(S13) + // pub fn __state2< 'ast, __TOKENS: Iterator, @@ -264,177 +274,20 @@ 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 @ Tok::LParen(..), __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::Num(__tok0), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym1 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state12(arena, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state13(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); } _ => { return Err(__lookahead); } } - while __sym0.is_some() { - let (__lookbehind, __lookahead, __nt) = __result; - match __nt { - __Nonterminal::Expr(__nt) => { - let __sym1 = &mut Some(__nt); - __result = try!(__state9(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); - } - __Nonterminal::Term(__nt) => { - let __sym1 = &mut Some(__nt); - __result = try!(__state8(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)); - } - } - } return Ok(__result); } // State 3 - // Expr = Factor (*) [EOF] - // Expr = Factor (*) ["+"] - // Expr = Factor (*) ["-"] - // Factor = Factor (*) "*" Term [EOF] - // Factor = Factor (*) "*" Term ["*"] - // Factor = Factor (*) "*" Term ["+"] - // Factor = Factor (*) "*" Term ["-"] - // Factor = Factor (*) "*" Term ["/"] - // Factor = Factor (*) "/" Term [EOF] - // Factor = Factor (*) "/" Term ["*"] - // Factor = Factor (*) "/" Term ["+"] - // Factor = Factor (*) "/" Term ["-"] - // Factor = Factor (*) "/" Term ["/"] - // - // "+" -> Reduce(Expr = Factor => Call(ActionFn(3));) - // "*" -> Shift(S13) - // "-" -> Reduce(Expr = Factor => Call(ActionFn(3));) - // "/" -> Shift(S14) - // EOF -> Reduce(Expr = Factor => Call(ActionFn(3));) - // - pub fn __state3< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize,Tok,usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> - { - let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, __tok @ Tok::Times(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym1 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state13(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); - } - Some((_, __tok @ Tok::Div(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym1 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state14(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); - } - Some((_, Tok::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action3(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action3(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - None => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action3(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 4 - // Factor = Term (*) [EOF] - // Factor = Term (*) ["*"] - // Factor = Term (*) ["+"] - // Factor = Term (*) ["-"] - // Factor = Term (*) ["/"] - // - // "*" -> Reduce(Factor = Term => Call(ActionFn(7));) - // "-" -> Reduce(Factor = Term => Call(ActionFn(7));) - // EOF -> Reduce(Factor = Term => Call(ActionFn(7));) - // "/" -> Reduce(Factor = Term => Call(ActionFn(7));) - // "+" -> Reduce(Factor = Term => Call(ActionFn(7));) - // - pub fn __state4< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize,Tok,usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> - { - let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, Tok::Times(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - None => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Div(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 5 // Expr = Expr (*) "+" Factor [EOF] // Expr = Expr (*) "+" Factor ["+"] // Expr = Expr (*) "+" Factor ["-"] @@ -443,11 +296,11 @@ mod __parse__Expr { // Expr = Expr (*) "-" Factor ["-"] // __Expr = Expr (*) [EOF] // - // "-" -> Shift(S15) + // "-" -> Shift(S14) // EOF -> Reduce(__Expr = Expr => Call(ActionFn(0));) - // "+" -> Shift(S16) + // "+" -> Shift(S15) // - pub fn __state5< + pub fn __state3< 'ast, __TOKENS: Iterator, >( @@ -464,13 +317,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!(__state14(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!(__state15(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); } None => { let __sym0 = __sym0.take().unwrap(); @@ -484,16 +337,20 @@ mod __parse__Expr { return Ok(__result); } - // State 6 - // Factor = "*" (*) "(" Comma ")" [EOF] - // Factor = "*" (*) "(" Comma ")" ["*"] - // Factor = "*" (*) "(" Comma ")" ["+"] - // Factor = "*" (*) "(" Comma ")" ["-"] - // Factor = "*" (*) "(" Comma ")" ["/"] + // State 4 + // Factor = Term (*) [EOF] + // Factor = Term (*) ["*"] + // Factor = Term (*) ["+"] + // Factor = Term (*) ["-"] + // Factor = Term (*) ["/"] // - // "(" -> Shift(S17) + // "-" -> Reduce(Factor = Term => Call(ActionFn(7));) + // "*" -> Reduce(Factor = Term => Call(ActionFn(7));) + // "+" -> Reduce(Factor = Term => Call(ActionFn(7));) + // EOF -> Reduce(Factor = Term => Call(ActionFn(7));) + // "/" -> Reduce(Factor = Term => Call(ActionFn(7));) // - pub fn __state6< + pub fn __state4< 'ast, __TOKENS: Iterator, >( @@ -501,46 +358,64 @@ mod __parse__Expr { __lookbehind: Option, __lookahead: Option<(usize,Tok,usize)>, __tokens: &mut __TOKENS, - __sym0: &mut Option, + __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::LParen(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym1 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state17(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action7(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Times(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action7(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action7(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + None => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action7(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Div(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action7(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } _ => { return Err(__lookahead); } } - return Ok(__result); } - // State 7 - // Expr = Factor (*) [")"] + // State 5 + // Expr = Factor (*) [EOF] // Expr = Factor (*) ["+"] // Expr = Factor (*) ["-"] - // Factor = Factor (*) "*" Term [")"] + // Factor = Factor (*) "*" Term [EOF] // Factor = Factor (*) "*" Term ["*"] // Factor = Factor (*) "*" Term ["+"] // Factor = Factor (*) "*" Term ["-"] // Factor = Factor (*) "*" Term ["/"] - // Factor = Factor (*) "/" Term [")"] + // Factor = Factor (*) "/" Term [EOF] // Factor = Factor (*) "/" Term ["*"] // Factor = Factor (*) "/" Term ["+"] // Factor = Factor (*) "/" Term ["-"] // Factor = Factor (*) "/" Term ["/"] // - // "-" -> Reduce(Expr = Factor => Call(ActionFn(3));) - // "/" -> Shift(S18) - // ")" -> Reduce(Expr = Factor => Call(ActionFn(3));) - // "*" -> Shift(S19) + // "/" -> Shift(S17) // "+" -> Reduce(Expr = Factor => Call(ActionFn(3));) + // EOF -> Reduce(Expr = Factor => Call(ActionFn(3));) + // "-" -> Reduce(Expr = Factor => Call(ActionFn(3));) + // "*" -> Shift(S16) // - pub fn __state7< + pub fn __state5< 'ast, __TOKENS: Iterator, >( @@ -557,29 +432,29 @@ mod __parse__Expr { let mut __lookbehind = Some(__loc); let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state18(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + __result = try!(__state17(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::__actions::__action3(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - Some((_, Tok::RParen(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action3(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + __result = try!(__state16(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); } Some((_, Tok::Plus(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __nt = super::__actions::__action3(arena, __sym0); return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); } + None => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action3(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action3(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } _ => { return Err(__lookahead); } @@ -587,20 +462,77 @@ mod __parse__Expr { return Ok(__result); } - // State 8 + // State 6 + // Term = "Num" (*) [EOF] + // Term = "Num" (*) ["*"] + // Term = "Num" (*) ["+"] + // Term = "Num" (*) ["-"] + // Term = "Num" (*) ["/"] + // + // EOF -> Reduce(Term = "Num" => Call(ActionFn(8));) + // "+" -> Reduce(Term = "Num" => Call(ActionFn(8));) + // "-" -> Reduce(Term = "Num" => Call(ActionFn(8));) + // "*" -> Reduce(Term = "Num" => Call(ActionFn(8));) + // "/" -> Reduce(Term = "Num" => Call(ActionFn(8));) + // + pub fn __state6< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + None => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action8(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action8(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action8(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + Some((_, Tok::Times(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action8(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + Some((_, Tok::Div(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action8(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 7 // Factor = Term (*) [")"] // Factor = Term (*) ["*"] // Factor = Term (*) ["+"] // Factor = Term (*) ["-"] // Factor = Term (*) ["/"] // + // "/" -> Reduce(Factor = Term => Call(ActionFn(7));) + // "*" -> Reduce(Factor = Term => Call(ActionFn(7));) + // "-" -> Reduce(Factor = Term => Call(ActionFn(7));) // ")" -> Reduce(Factor = Term => Call(ActionFn(7));) // "+" -> Reduce(Factor = Term => Call(ActionFn(7));) - // "/" -> Reduce(Factor = Term => Call(ActionFn(7));) - // "-" -> Reduce(Factor = Term => Call(ActionFn(7));) - // "*" -> Reduce(Factor = Term => Call(ActionFn(7));) // - pub fn __state8< + pub fn __state7< 'ast, __TOKENS: Iterator, >( @@ -613,6 +545,21 @@ 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::__actions::__action7(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Times(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action7(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action7(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } Some((_, Tok::RParen(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __nt = super::__actions::__action7(arena, __sym0); @@ -623,28 +570,13 @@ mod __parse__Expr { let __nt = super::__actions::__action7(arena, __sym0); return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } - Some((_, Tok::Div(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Times(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } _ => { return Err(__lookahead); } } } - // State 9 + // State 8 // Expr = Expr (*) "+" Factor [")"] // Expr = Expr (*) "+" Factor ["+"] // Expr = Expr (*) "+" Factor ["-"] @@ -657,11 +589,11 @@ mod __parse__Expr { // Term = "(" Expr (*) ")" ["-"] // Term = "(" Expr (*) ")" ["/"] // - // "-" -> Shift(S21) - // ")" -> Shift(S20) - // "+" -> Shift(S22) + // "-" -> Shift(S20) + // ")" -> Shift(S19) + // "+" -> Shift(S18) // - pub fn __state9< + pub fn __state8< 'ast, __TOKENS: Iterator, >( @@ -679,19 +611,87 @@ mod __parse__Expr { let mut __lookbehind = Some(__loc); let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state21(arena, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); + __result = try!(__state20(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!(__state20(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + __result = try!(__state19(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); } Some((_, __tok @ Tok::Plus(..), __loc)) => { let mut __lookbehind = Some(__loc); let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state22(arena, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); + __result = try!(__state18(arena, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + + // State 9 + // Expr = Factor (*) [")"] + // Expr = Factor (*) ["+"] + // Expr = Factor (*) ["-"] + // Factor = Factor (*) "*" Term [")"] + // Factor = Factor (*) "*" Term ["*"] + // Factor = Factor (*) "*" Term ["+"] + // Factor = Factor (*) "*" Term ["-"] + // Factor = Factor (*) "*" Term ["/"] + // Factor = Factor (*) "/" Term [")"] + // Factor = Factor (*) "/" Term ["*"] + // Factor = Factor (*) "/" Term ["+"] + // Factor = Factor (*) "/" Term ["-"] + // Factor = Factor (*) "/" Term ["/"] + // + // "-" -> Reduce(Expr = Factor => Call(ActionFn(3));) + // "*" -> Shift(S21) + // "/" -> Shift(S22) + // "+" -> Reduce(Expr = Factor => Call(ActionFn(3));) + // ")" -> Reduce(Expr = Factor => Call(ActionFn(3));) + // + pub fn __state9< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, __tok @ Tok::Times(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state21(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!(__state22(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action3(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action3(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + Some((_, Tok::RParen(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action3(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); } _ => { return Err(__lookahead); @@ -701,6 +701,98 @@ mod __parse__Expr { } // State 10 + // 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 __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::RParen(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action8(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action8(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action8(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + Some((_, Tok::Times(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action8(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + Some((_, Tok::Div(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action8(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + + // 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 // Expr = (*) Expr "+" Factor [")"] // Expr = (*) Expr "+" Factor ["+"] // Expr = (*) Expr "+" Factor ["-"] @@ -746,14 +838,14 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // + // "(" -> Shift(S12) // "*" -> Shift(S11) - // "(" -> Shift(S10) - // "Num" -> Shift(S12) + // "Num" -> Shift(S10) // - // Term -> S8 - // Factor -> S7 - // Expr -> S23 - pub fn __state10< + // Factor -> S9 + // Term -> S7 + // Expr -> S24 + pub fn __state12< 'ast, __TOKENS: Iterator, >( @@ -766,23 +858,23 @@ mod __parse__Expr { { let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { + Some((_, __tok @ Tok::LParen(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state12(arena, __lookbehind, __lookahead, __tokens, __sym1)); + } Some((_, __tok @ Tok::Times(..), __loc)) => { let mut __lookbehind = Some(__loc); let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); __result = try!(__state11(arena, __lookbehind, __lookahead, __tokens, __sym1)); } - Some((_, __tok @ Tok::LParen(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym1 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state10(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!(__state12(arena, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state10(arena, __lookbehind, __lookahead, __tokens, __sym1)); } _ => { return Err(__lookahead); @@ -791,17 +883,17 @@ mod __parse__Expr { while __sym0.is_some() { let (__lookbehind, __lookahead, __nt) = __result; match __nt { - __Nonterminal::Term(__nt) => { - let __sym1 = &mut Some(__nt); - __result = try!(__state8(arena, __lookbehind, __lookahead, __tokens, __sym1)); - } __Nonterminal::Factor(__nt) => { + let __sym1 = &mut Some(__nt); + __result = try!(__state9(arena, __lookbehind, __lookahead, __tokens, __sym1)); + } + __Nonterminal::Term(__nt) => { let __sym1 = &mut Some(__nt); __result = try!(__state7(arena, __lookbehind, __lookahead, __tokens, __sym1)); } __Nonterminal::Expr(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state23(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + __result = try!(__state24(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); } _ => { return Ok((__lookbehind, __lookahead, __nt)); @@ -811,119 +903,29 @@ mod __parse__Expr { return Ok(__result); } - // State 11 - // Factor = "*" (*) "(" Comma ")" [")"] - // Factor = "*" (*) "(" Comma ")" ["*"] - // Factor = "*" (*) "(" Comma ")" ["+"] - // Factor = "*" (*) "(" Comma ")" ["-"] - // Factor = "*" (*) "(" Comma ")" ["/"] - // - // "(" -> Shift(S24) - // - 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!(__state24(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 12 - // 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 __state12< - '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::__actions::__action8(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - Some((_, Tok::RParen(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action8(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - Some((_, Tok::Times(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action8(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - Some((_, Tok::Div(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action8(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action8(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - // State 13 - // Factor = Factor "*" (*) Term [EOF] - // Factor = Factor "*" (*) Term ["*"] - // Factor = Factor "*" (*) Term ["+"] - // Factor = Factor "*" (*) Term ["-"] - // Factor = Factor "*" (*) Term ["/"] - // Term = (*) "(" Expr ")" [EOF] - // Term = (*) "(" Expr ")" ["*"] - // Term = (*) "(" Expr ")" ["+"] - // Term = (*) "(" Expr ")" ["-"] - // Term = (*) "(" Expr ")" ["/"] - // Term = (*) "Num" [EOF] - // Term = (*) "Num" ["*"] - // Term = (*) "Num" ["+"] - // Term = (*) "Num" ["-"] - // Term = (*) "Num" ["/"] + // ( ",")* = (*) ["("] + // ( ",")* = (*) [")"] + // ( ",")* = (*) ["*"] + // ( ",")* = (*) ["Num"] + // ( ",")* = (*) ( ",")* ( ",") ["("] + // ( ",")* = (*) ( ",")* ( ",") [")"] + // ( ",")* = (*) ( ",")* ( ",") ["*"] + // ( ",")* = (*) ( ",")* ( ",") ["Num"] + // Comma = (*) ( ",")* Expr? [")"] + // Factor = "*" "(" (*) Comma ")" [EOF] + // Factor = "*" "(" (*) Comma ")" ["*"] + // Factor = "*" "(" (*) Comma ")" ["+"] + // Factor = "*" "(" (*) Comma ")" ["-"] + // Factor = "*" "(" (*) Comma ")" ["/"] // - // "Num" -> Shift(S1) - // "(" -> Shift(S2) + // "(" -> Reduce(( ",")* = => Call(ActionFn(13));) + // "*" -> Reduce(( ",")* = => Call(ActionFn(13));) + // "Num" -> Reduce(( ",")* = => Call(ActionFn(13));) + // ")" -> Reduce(( ",")* = => Call(ActionFn(13));) // - // Term -> S25 + // Comma -> S26 + // ( ",")* -> S25 pub fn __state13< 'ast, __TOKENS: Iterator, @@ -932,23 +934,27 @@ mod __parse__Expr { __lookbehind: Option, __lookahead: Option<(usize,Tok,usize)>, __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, + __sym0: &mut Option, __sym1: &mut Option, ) -> 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!(__state1(arena, __lookbehind, __lookahead, __tokens, __sym2)); + Some((_, Tok::LParen(..), _)) => { + let __nt = super::__actions::__action13(arena, ); + __result = (__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); } - Some((_, __tok @ Tok::LParen(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state2(arena, __lookbehind, __lookahead, __tokens, __sym2)); + Some((_, Tok::Times(..), _)) => { + let __nt = super::__actions::__action13(arena, ); + __result = (__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); + } + Some((_, Tok::Num(_), _)) => { + let __nt = super::__actions::__action13(arena, ); + __result = (__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); + } + Some((_, Tok::RParen(..), _)) => { + let __nt = super::__actions::__action13(arena, ); + __result = (__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); } _ => { return Err(__lookahead); @@ -957,9 +963,13 @@ mod __parse__Expr { while __sym1.is_some() { let (__lookbehind, __lookahead, __nt) = __result; match __nt { - __Nonterminal::Term(__nt) => { + __Nonterminal::Comma_3cExpr_3e(__nt) => { let __sym2 = &mut Some(__nt); - __result = try!(__state25(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + __result = try!(__state26(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state25(arena, __lookbehind, __lookahead, __tokens, __sym2)); } _ => { return Ok((__lookbehind, __lookahead, __nt)); @@ -970,72 +980,6 @@ mod __parse__Expr { } // State 14 - // Factor = Factor "/" (*) Term [EOF] - // Factor = Factor "/" (*) Term ["*"] - // Factor = Factor "/" (*) Term ["+"] - // Factor = Factor "/" (*) Term ["-"] - // Factor = Factor "/" (*) Term ["/"] - // Term = (*) "(" Expr ")" [EOF] - // Term = (*) "(" Expr ")" ["*"] - // Term = (*) "(" Expr ")" ["+"] - // Term = (*) "(" Expr ")" ["-"] - // Term = (*) "(" Expr ")" ["/"] - // Term = (*) "Num" [EOF] - // Term = (*) "Num" ["*"] - // Term = (*) "Num" ["+"] - // Term = (*) "Num" ["-"] - // Term = (*) "Num" ["/"] - // - // "(" -> Shift(S2) - // "Num" -> Shift(S1) - // - // Term -> S26 - pub fn __state14< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize,Tok,usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, - ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> - { - let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, __tok @ Tok::LParen(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state2(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!(__state26(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - _ => { - return Ok((__lookbehind, __lookahead, __nt)); - } - } - } - return Ok(__result); - } - - // State 15 // Expr = Expr "-" (*) Factor [EOF] // Expr = Expr "-" (*) Factor ["+"] // Expr = Expr "-" (*) Factor ["-"] @@ -1070,13 +1014,13 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "(" -> Shift(S2) - // "Num" -> Shift(S1) - // "*" -> Shift(S6) + // "(" -> Shift(S1) + // "*" -> Shift(S2) + // "Num" -> Shift(S6) // - // Factor -> S27 // Term -> S4 - pub fn __state15< + // Factor -> S27 + pub fn __state14< 'ast, __TOKENS: Iterator, >( @@ -1094,18 +1038,18 @@ mod __parse__Expr { let mut __lookbehind = Some(__loc); let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state2(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!(__state2(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)); } _ => { @@ -1115,14 +1059,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!(__state27(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } __Nonterminal::Term(__nt) => { let __sym2 = &mut Some(__nt); __result = try!(__state4(arena, __lookbehind, __lookahead, __tokens, __sym2)); } + __Nonterminal::Factor(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state27(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } _ => { return Ok((__lookbehind, __lookahead, __nt)); } @@ -1131,7 +1075,7 @@ mod __parse__Expr { return Ok(__result); } - // State 16 + // State 15 // Expr = Expr "+" (*) Factor [EOF] // Expr = Expr "+" (*) Factor ["+"] // Expr = Expr "+" (*) Factor ["-"] @@ -1166,12 +1110,88 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "*" -> Shift(S6) - // "Num" -> Shift(S1) - // "(" -> Shift(S2) + // "*" -> Shift(S2) + // "(" -> Shift(S1) + // "Num" -> Shift(S6) // - // Factor -> S28 // Term -> S4 + // Factor -> S28 + pub fn __state15< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + __sym1: &mut Option, + ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, __tok @ Tok::Times(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state2(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)); + } + 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)); + } + _ => { + return Err(__lookahead); + } + } + while __sym1.is_some() { + let (__lookbehind, __lookahead, __nt) = __result; + match __nt { + __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state4(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + __Nonterminal::Factor(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state28(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + _ => { + return Ok((__lookbehind, __lookahead, __nt)); + } + } + } + return Ok(__result); + } + + // State 16 + // Factor = Factor "*" (*) Term [EOF] + // Factor = Factor "*" (*) Term ["*"] + // Factor = Factor "*" (*) Term ["+"] + // Factor = Factor "*" (*) Term ["-"] + // Factor = Factor "*" (*) Term ["/"] + // Term = (*) "(" Expr ")" [EOF] + // Term = (*) "(" Expr ")" ["*"] + // Term = (*) "(" Expr ")" ["+"] + // Term = (*) "(" Expr ")" ["-"] + // Term = (*) "(" Expr ")" ["/"] + // Term = (*) "Num" [EOF] + // Term = (*) "Num" ["*"] + // Term = (*) "Num" ["+"] + // Term = (*) "Num" ["-"] + // Term = (*) "Num" ["/"] + // + // "(" -> Shift(S1) + // "Num" -> Shift(S6) + // + // Term -> S29 pub fn __state16< 'ast, __TOKENS: Iterator, @@ -1186,23 +1206,17 @@ mod __parse__Expr { { let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some((_, __tok @ Tok::Times(..), __loc)) => { + Some((_, __tok @ Tok::LParen(..), __loc)) => { let mut __lookbehind = Some(__loc); let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state6(arena, __lookbehind, __lookahead, __tokens, __sym2)); + __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)); - } - Some((_, __tok @ Tok::LParen(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state2(arena, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state6(arena, __lookbehind, __lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); @@ -1211,13 +1225,9 @@ mod __parse__Expr { while __sym1.is_some() { let (__lookbehind, __lookahead, __nt) = __result; match __nt { - __Nonterminal::Factor(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state28(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } __Nonterminal::Term(__nt) => { let __sym2 = &mut Some(__nt); - __result = try!(__state4(arena, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state29(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); } _ => { return Ok((__lookbehind, __lookahead, __nt)); @@ -1228,28 +1238,26 @@ mod __parse__Expr { } // State 17 - // ( ",")* = (*) ["("] - // ( ",")* = (*) [")"] - // ( ",")* = (*) ["*"] - // ( ",")* = (*) ["Num"] - // ( ",")* = (*) ( ",")* ( ",") ["("] - // ( ",")* = (*) ( ",")* ( ",") [")"] - // ( ",")* = (*) ( ",")* ( ",") ["*"] - // ( ",")* = (*) ( ",")* ( ",") ["Num"] - // Comma = (*) ( ",")* Expr? [")"] - // Factor = "*" "(" (*) Comma ")" [EOF] - // Factor = "*" "(" (*) Comma ")" ["*"] - // Factor = "*" "(" (*) Comma ")" ["+"] - // Factor = "*" "(" (*) Comma ")" ["-"] - // Factor = "*" "(" (*) Comma ")" ["/"] + // Factor = Factor "/" (*) Term [EOF] + // Factor = Factor "/" (*) Term ["*"] + // Factor = Factor "/" (*) Term ["+"] + // Factor = Factor "/" (*) Term ["-"] + // Factor = Factor "/" (*) Term ["/"] + // Term = (*) "(" Expr ")" [EOF] + // Term = (*) "(" Expr ")" ["*"] + // Term = (*) "(" Expr ")" ["+"] + // Term = (*) "(" Expr ")" ["-"] + // Term = (*) "(" Expr ")" ["/"] + // Term = (*) "Num" [EOF] + // Term = (*) "Num" ["*"] + // Term = (*) "Num" ["+"] + // Term = (*) "Num" ["-"] + // Term = (*) "Num" ["/"] // - // "Num" -> Reduce(( ",")* = => Call(ActionFn(13));) - // "(" -> Reduce(( ",")* = => Call(ActionFn(13));) - // "*" -> Reduce(( ",")* = => Call(ActionFn(13));) - // ")" -> Reduce(( ",")* = => Call(ActionFn(13));) + // "(" -> Shift(S1) + // "Num" -> Shift(S6) // - // Comma -> S30 - // ( ",")* -> S29 + // Term -> S30 pub fn __state17< 'ast, __TOKENS: Iterator, @@ -1258,27 +1266,23 @@ mod __parse__Expr { __lookbehind: Option, __lookahead: Option<(usize,Tok,usize)>, __tokens: &mut __TOKENS, - __sym0: &mut Option, + __sym0: &mut Option<&'ast Node<'ast>>, __sym1: &mut Option, ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> { let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some((_, Tok::Num(_), _)) => { - let __nt = super::__actions::__action13(arena, ); - __result = (__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); + Some((_, __tok @ Tok::LParen(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state1(arena, __lookbehind, __lookahead, __tokens, __sym2)); } - Some((_, Tok::LParen(..), _)) => { - let __nt = super::__actions::__action13(arena, ); - __result = (__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); - } - Some((_, Tok::Times(..), _)) => { - let __nt = super::__actions::__action13(arena, ); - __result = (__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); - } - Some((_, Tok::RParen(..), _)) => { - let __nt = super::__actions::__action13(arena, ); - __result = (__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); + Some((_, Tok::Num(__tok0), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok0)); + let __lookahead = __tokens.next(); + __result = try!(__state6(arena, __lookbehind, __lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); @@ -1287,14 +1291,10 @@ mod __parse__Expr { while __sym1.is_some() { let (__lookbehind, __lookahead, __nt) = __result; match __nt { - __Nonterminal::Comma_3cExpr_3e(__nt) => { + __Nonterminal::Term(__nt) => { let __sym2 = &mut Some(__nt); __result = try!(__state30(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); } - __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state29(arena, __lookbehind, __lookahead, __tokens, __sym2)); - } _ => { return Ok((__lookbehind, __lookahead, __nt)); } @@ -1304,303 +1304,6 @@ mod __parse__Expr { } // State 18 - // Factor = Factor "/" (*) Term [")"] - // Factor = Factor "/" (*) Term ["*"] - // Factor = Factor "/" (*) Term ["+"] - // Factor = Factor "/" (*) Term ["-"] - // Factor = Factor "/" (*) Term ["/"] - // Term = (*) "(" Expr ")" [")"] - // Term = (*) "(" Expr ")" ["*"] - // Term = (*) "(" Expr ")" ["+"] - // Term = (*) "(" Expr ")" ["-"] - // Term = (*) "(" Expr ")" ["/"] - // Term = (*) "Num" [")"] - // Term = (*) "Num" ["*"] - // Term = (*) "Num" ["+"] - // Term = (*) "Num" ["-"] - // Term = (*) "Num" ["/"] - // - // "(" -> Shift(S10) - // "Num" -> Shift(S12) - // - // Term -> S31 - pub fn __state18< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize,Tok,usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, - ) -> 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!(__state10(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!(__state12(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 [")"] - // Factor = Factor "*" (*) Term ["*"] - // Factor = Factor "*" (*) Term ["+"] - // Factor = Factor "*" (*) Term ["-"] - // Factor = Factor "*" (*) Term ["/"] - // Term = (*) "(" Expr ")" [")"] - // Term = (*) "(" Expr ")" ["*"] - // Term = (*) "(" Expr ")" ["+"] - // Term = (*) "(" Expr ")" ["-"] - // Term = (*) "(" Expr ")" ["/"] - // Term = (*) "Num" [")"] - // Term = (*) "Num" ["*"] - // Term = (*) "Num" ["+"] - // Term = (*) "Num" ["-"] - // Term = (*) "Num" ["/"] - // - // "Num" -> Shift(S12) - // "(" -> Shift(S10) - // - // Term -> S32 - pub fn __state19< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize,Tok,usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, - ) -> 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!(__state12(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!(__state10(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 - // Term = "(" Expr ")" (*) [EOF] - // Term = "(" Expr ")" (*) ["*"] - // Term = "(" Expr ")" (*) ["+"] - // Term = "(" Expr ")" (*) ["-"] - // Term = "(" Expr ")" (*) ["/"] - // - // "*" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) - // "+" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) - // "/" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) - // "-" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) - // EOF -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) - // - pub fn __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>>, - __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::__actions::__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::__actions::__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::__actions::__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::__actions::__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::__actions::__action9(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 21 - // Expr = Expr "-" (*) Factor [")"] - // Expr = Expr "-" (*) Factor ["+"] - // Expr = Expr "-" (*) Factor ["-"] - // Factor = (*) Factor "*" Term [")"] - // Factor = (*) Factor "*" Term ["*"] - // Factor = (*) Factor "*" Term ["+"] - // Factor = (*) Factor "*" Term ["-"] - // Factor = (*) Factor "*" Term ["/"] - // Factor = (*) Factor "/" Term [")"] - // Factor = (*) Factor "/" Term ["*"] - // Factor = (*) Factor "/" Term ["+"] - // Factor = (*) Factor "/" Term ["-"] - // Factor = (*) Factor "/" Term ["/"] - // Factor = (*) Term [")"] - // Factor = (*) Term ["*"] - // Factor = (*) Term ["+"] - // Factor = (*) Term ["-"] - // Factor = (*) Term ["/"] - // Factor = (*) "*" "(" Comma ")" [")"] - // Factor = (*) "*" "(" Comma ")" ["*"] - // Factor = (*) "*" "(" Comma ")" ["+"] - // Factor = (*) "*" "(" Comma ")" ["-"] - // Factor = (*) "*" "(" Comma ")" ["/"] - // Term = (*) "(" Expr ")" [")"] - // Term = (*) "(" Expr ")" ["*"] - // Term = (*) "(" Expr ")" ["+"] - // Term = (*) "(" Expr ")" ["-"] - // Term = (*) "(" Expr ")" ["/"] - // Term = (*) "Num" [")"] - // Term = (*) "Num" ["*"] - // Term = (*) "Num" ["+"] - // Term = (*) "Num" ["-"] - // Term = (*) "Num" ["/"] - // - // "*" -> Shift(S11) - // "Num" -> Shift(S12) - // "(" -> Shift(S10) - // - // Term -> S8 - // Factor -> S33 - pub fn __state21< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize,Tok,usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, - ) -> 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!(__state11(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!(__state12(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!(__state10(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!(__state8(arena, __lookbehind, __lookahead, __tokens, __sym2)); - } - __Nonterminal::Factor(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state33(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - _ => { - return Ok((__lookbehind, __lookahead, __nt)); - } - } - } - return Ok(__result); - } - - // State 22 // Expr = Expr "+" (*) Factor [")"] // Expr = Expr "+" (*) Factor ["+"] // Expr = Expr "+" (*) Factor ["-"] @@ -1635,12 +1338,319 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "Num" -> Shift(S12) + // "Num" -> Shift(S10) // "*" -> Shift(S11) - // "(" -> Shift(S10) + // "(" -> Shift(S12) // - // Term -> S8 - // Factor -> S34 + // Factor -> S31 + // Term -> S7 + pub fn __state18< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + __sym1: &mut Option, + ) -> 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!(__state10(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!(__state11(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + Some((_, __tok @ Tok::LParen(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state12(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + _ => { + return Err(__lookahead); + } + } + while __sym1.is_some() { + let (__lookbehind, __lookahead, __nt) = __result; + match __nt { + __Nonterminal::Factor(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state31(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state7(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + _ => { + return Ok((__lookbehind, __lookahead, __nt)); + } + } + } + return Ok(__result); + } + + // State 19 + // Term = "(" Expr ")" (*) [EOF] + // Term = "(" Expr ")" (*) ["*"] + // Term = "(" Expr ")" (*) ["+"] + // Term = "(" Expr ")" (*) ["-"] + // Term = "(" Expr ")" (*) ["/"] + // + // "*" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) + // EOF -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) + // "+" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) + // "-" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) + // "/" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) + // + pub fn __state19< + '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::__actions::__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::__actions::__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::__actions::__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::__actions::__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::__actions::__action9(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 20 + // Expr = Expr "-" (*) Factor [")"] + // Expr = Expr "-" (*) Factor ["+"] + // Expr = Expr "-" (*) Factor ["-"] + // Factor = (*) Factor "*" Term [")"] + // Factor = (*) Factor "*" Term ["*"] + // Factor = (*) Factor "*" Term ["+"] + // Factor = (*) Factor "*" Term ["-"] + // Factor = (*) Factor "*" Term ["/"] + // Factor = (*) Factor "/" Term [")"] + // Factor = (*) Factor "/" Term ["*"] + // Factor = (*) Factor "/" Term ["+"] + // Factor = (*) Factor "/" Term ["-"] + // Factor = (*) Factor "/" Term ["/"] + // Factor = (*) Term [")"] + // Factor = (*) Term ["*"] + // Factor = (*) Term ["+"] + // Factor = (*) Term ["-"] + // Factor = (*) Term ["/"] + // Factor = (*) "*" "(" Comma ")" [")"] + // Factor = (*) "*" "(" Comma ")" ["*"] + // Factor = (*) "*" "(" Comma ")" ["+"] + // Factor = (*) "*" "(" Comma ")" ["-"] + // Factor = (*) "*" "(" Comma ")" ["/"] + // Term = (*) "(" Expr ")" [")"] + // Term = (*) "(" Expr ")" ["*"] + // Term = (*) "(" Expr ")" ["+"] + // Term = (*) "(" Expr ")" ["-"] + // Term = (*) "(" Expr ")" ["/"] + // Term = (*) "Num" [")"] + // Term = (*) "Num" ["*"] + // Term = (*) "Num" ["+"] + // Term = (*) "Num" ["-"] + // Term = (*) "Num" ["/"] + // + // "Num" -> Shift(S10) + // "(" -> Shift(S12) + // "*" -> Shift(S11) + // + // Term -> S7 + // Factor -> S32 + pub fn __state20< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + __sym1: &mut Option, + ) -> 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!(__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!(__state12(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!(__state11(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + _ => { + return Err(__lookahead); + } + } + while __sym1.is_some() { + let (__lookbehind, __lookahead, __nt) = __result; + match __nt { + __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state7(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + __Nonterminal::Factor(__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 21 + // Factor = Factor "*" (*) Term [")"] + // Factor = Factor "*" (*) Term ["*"] + // Factor = Factor "*" (*) Term ["+"] + // Factor = Factor "*" (*) Term ["-"] + // Factor = Factor "*" (*) Term ["/"] + // Term = (*) "(" Expr ")" [")"] + // Term = (*) "(" Expr ")" ["*"] + // Term = (*) "(" Expr ")" ["+"] + // Term = (*) "(" Expr ")" ["-"] + // Term = (*) "(" Expr ")" ["/"] + // Term = (*) "Num" [")"] + // Term = (*) "Num" ["*"] + // Term = (*) "Num" ["+"] + // Term = (*) "Num" ["-"] + // Term = (*) "Num" ["/"] + // + // "(" -> Shift(S12) + // "Num" -> Shift(S10) + // + // Term -> S33 + pub fn __state21< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + __sym1: &mut Option, + ) -> 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!(__state12(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!(__state10(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!(__state33(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + _ => { + return Ok((__lookbehind, __lookahead, __nt)); + } + } + } + return Ok(__result); + } + + // State 22 + // Factor = Factor "/" (*) Term [")"] + // Factor = Factor "/" (*) Term ["*"] + // Factor = Factor "/" (*) Term ["+"] + // Factor = Factor "/" (*) Term ["-"] + // Factor = Factor "/" (*) Term ["/"] + // Term = (*) "(" Expr ")" [")"] + // Term = (*) "(" Expr ")" ["*"] + // Term = (*) "(" Expr ")" ["+"] + // Term = (*) "(" Expr ")" ["-"] + // Term = (*) "(" Expr ")" ["/"] + // Term = (*) "Num" [")"] + // Term = (*) "Num" ["*"] + // Term = (*) "Num" ["+"] + // Term = (*) "Num" ["-"] + // Term = (*) "Num" ["/"] + // + // "Num" -> Shift(S10) + // "(" -> Shift(S12) + // + // Term -> S34 pub fn __state22< 'ast, __TOKENS: Iterator, @@ -1659,19 +1669,13 @@ mod __parse__Expr { let mut __lookbehind = Some(__loc); let mut __sym2 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state12(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!(__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!(__state10(arena, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state12(arena, __lookbehind, __lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); @@ -1681,10 +1685,6 @@ mod __parse__Expr { let (__lookbehind, __lookahead, __nt) = __result; match __nt { __Nonterminal::Term(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state8(arena, __lookbehind, __lookahead, __tokens, __sym2)); - } - __Nonterminal::Factor(__nt) => { let __sym2 = &mut Some(__nt); __result = try!(__state34(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); } @@ -1697,62 +1697,6 @@ mod __parse__Expr { } // State 23 - // 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(S21) - // ")" -> Shift(S35) - // "+" -> Shift(S22) - // - 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<&'ast Node<'ast>>, - ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> - { - let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, __tok @ Tok::Minus(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state21(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!(__state35(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - Some((_, __tok @ Tok::Plus(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state22(arena, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 24 // ( ",")* = (*) ["("] // ( ",")* = (*) [")"] // ( ",")* = (*) ["*"] @@ -1768,14 +1712,14 @@ mod __parse__Expr { // Factor = "*" "(" (*) Comma ")" ["-"] // Factor = "*" "(" (*) Comma ")" ["/"] // + // ")" -> Reduce(( ",")* = => Call(ActionFn(13));) // "*" -> Reduce(( ",")* = => Call(ActionFn(13));) // "Num" -> Reduce(( ",")* = => Call(ActionFn(13));) - // ")" -> Reduce(( ",")* = => Call(ActionFn(13));) // "(" -> Reduce(( ",")* = => Call(ActionFn(13));) // - // ( ",")* -> S29 - // Comma -> S36 - pub fn __state24< + // ( ",")* -> S25 + // Comma -> S35 + pub fn __state23< 'ast, __TOKENS: Iterator, >( @@ -1789,6 +1733,10 @@ mod __parse__Expr { { let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { + Some((_, Tok::RParen(..), _)) => { + let __nt = super::__actions::__action13(arena, ); + __result = (__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); + } Some((_, Tok::Times(..), _)) => { let __nt = super::__actions::__action13(arena, ); __result = (__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); @@ -1797,10 +1745,6 @@ mod __parse__Expr { let __nt = super::__actions::__action13(arena, ); __result = (__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); } - Some((_, Tok::RParen(..), _)) => { - let __nt = super::__actions::__action13(arena, ); - __result = (__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); - } Some((_, Tok::LParen(..), _)) => { let __nt = super::__actions::__action13(arena, ); __result = (__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); @@ -1814,11 +1758,11 @@ mod __parse__Expr { match __nt { __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt) => { let __sym2 = &mut Some(__nt); - __result = try!(__state29(arena, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state25(arena, __lookbehind, __lookahead, __tokens, __sym2)); } __Nonterminal::Comma_3cExpr_3e(__nt) => { let __sym2 = &mut Some(__nt); - __result = try!(__state36(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + __result = try!(__state35(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); } _ => { return Ok((__lookbehind, __lookahead, __nt)); @@ -1828,297 +1772,63 @@ mod __parse__Expr { return Ok(__result); } + // State 24 + // 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(S18) + // "-" -> Shift(S20) + // ")" -> Shift(S36) + // + pub fn __state24< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + __sym1: &mut Option<&'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!(__state18(arena, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); + } + Some((_, __tok @ Tok::Minus(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state20(arena, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); + } + 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)); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + // State 25 - // 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 __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::Div(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__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::__actions::__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::__actions::__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::__actions::__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::__actions::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 26 - // Factor = Factor "/" Term (*) [EOF] - // Factor = Factor "/" Term (*) ["*"] - // Factor = Factor "/" Term (*) ["+"] - // Factor = Factor "/" Term (*) ["-"] - // Factor = Factor "/" Term (*) ["/"] - // - // "/" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // "*" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // "+" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // "-" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // EOF -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // - 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::Div(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action5(arena, __sym0, __sym1, __sym2); - return Ok((__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::__actions::__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::__actions::__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::__actions::__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::__actions::__action5(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 27 - // Expr = Expr "-" Factor (*) [EOF] - // Expr = Expr "-" Factor (*) ["+"] - // Expr = Expr "-" Factor (*) ["-"] - // Factor = Factor (*) "*" Term [EOF] - // Factor = Factor (*) "*" Term ["*"] - // Factor = Factor (*) "*" Term ["+"] - // Factor = Factor (*) "*" Term ["-"] - // Factor = Factor (*) "*" Term ["/"] - // Factor = Factor (*) "/" Term [EOF] - // Factor = Factor (*) "/" Term ["*"] - // Factor = Factor (*) "/" Term ["+"] - // Factor = Factor (*) "/" Term ["-"] - // Factor = Factor (*) "/" Term ["/"] - // - // "+" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) - // "/" -> Shift(S14) - // EOF -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) - // "-" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) - // "*" -> Shift(S13) - // - pub fn __state27< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize,Tok,usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, - __sym2: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> - { - let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, __tok @ Tok::Div(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym3 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state14(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); - } - Some((_, __tok @ Tok::Times(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym3 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state13(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::__actions::__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::__actions::__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::__actions::__action1(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__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 ["/"] - // - // EOF -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) - // "*" -> Shift(S13) - // "+" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) - // "-" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) - // "/" -> Shift(S14) - // - pub fn __state28< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize,Tok,usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, - __sym2: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> - { - let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, __tok @ Tok::Times(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym3 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state13(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!(__state14(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); - } - None => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__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::__actions::__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::__actions::__action2(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 29 // ( ",") = (*) Expr "," ["("] // ( ",") = (*) Expr "," [")"] // ( ",") = (*) Expr "," ["*"] @@ -2179,17 +1889,17 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "*" -> Shift(S37) - // "Num" -> Shift(S39) + // "Num" -> Shift(S43) + // "(" -> Shift(S44) + // "*" -> Shift(S41) // ")" -> Reduce(Expr? = => Call(ActionFn(12));) - // "(" -> Shift(S40) // - // Expr? -> S38 - // Factor -> S41 - // ( ",") -> S44 - // Expr -> S43 - // Term -> S42 - pub fn __state29< + // Expr? -> S42 + // Expr -> S40 + // ( ",") -> S37 + // Term -> S39 + // Factor -> S38 + pub fn __state25< 'ast, __TOKENS: Iterator, >( @@ -2202,23 +1912,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!(__state37(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!(__state39(arena, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state43(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!(__state40(arena, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state44(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!(__state41(arena, __lookbehind, __lookahead, __tokens, __sym1)); } Some((_, Tok::RParen(..), _)) => { let __nt = super::__actions::__action12(arena, ); @@ -2233,23 +1943,23 @@ mod __parse__Expr { match __nt { __Nonterminal::Expr_3f(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state38(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); - } - __Nonterminal::Factor(__nt) => { - let __sym1 = &mut Some(__nt); - __result = try!(__state41(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)); + __result = try!(__state42(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); } __Nonterminal::Expr(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state43(arena, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state40(arena, __lookbehind, __lookahead, __tokens, __sym1)); + } + __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29(__nt) => { + let __sym1 = &mut Some(__nt); + __result = try!(__state37(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); } __Nonterminal::Term(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state42(arena, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state39(arena, __lookbehind, __lookahead, __tokens, __sym1)); + } + __Nonterminal::Factor(__nt) => { + let __sym1 = &mut Some(__nt); + __result = try!(__state38(arena, __lookbehind, __lookahead, __tokens, __sym1)); } _ => { return Ok((__lookbehind, __lookahead, __nt)); @@ -2259,7 +1969,7 @@ mod __parse__Expr { return Ok(__result); } - // State 30 + // State 26 // Factor = "*" "(" Comma (*) ")" [EOF] // Factor = "*" "(" Comma (*) ")" ["*"] // Factor = "*" "(" Comma (*) ")" ["+"] @@ -2268,7 +1978,7 @@ mod __parse__Expr { // // ")" -> Shift(S45) // - pub fn __state30< + pub fn __state26< 'ast, __TOKENS: Iterator, >( @@ -2296,18 +2006,316 @@ mod __parse__Expr { return Ok(__result); } - // State 31 - // Factor = Factor "/" Term (*) [")"] + // State 27 + // Expr = Expr "-" Factor (*) [EOF] + // Expr = Expr "-" Factor (*) ["+"] + // Expr = Expr "-" Factor (*) ["-"] + // Factor = Factor (*) "*" Term [EOF] + // Factor = Factor (*) "*" Term ["*"] + // Factor = Factor (*) "*" Term ["+"] + // Factor = Factor (*) "*" Term ["-"] + // Factor = Factor (*) "*" Term ["/"] + // Factor = Factor (*) "/" Term [EOF] + // Factor = Factor (*) "/" Term ["*"] + // Factor = Factor (*) "/" Term ["+"] + // Factor = Factor (*) "/" Term ["-"] + // Factor = Factor (*) "/" Term ["/"] + // + // "/" -> Shift(S17) + // "+" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // "*" -> Shift(S16) + // EOF -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // "-" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // + pub fn __state27< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + __sym1: &mut Option, + __sym2: &mut Option<&'ast Node<'ast>>, + ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, __tok @ Tok::Div(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym3 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state17(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!(__state16(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::__actions::__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::__actions::__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::__actions::__action1(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__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 ["/"] + // + // "-" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) + // "*" -> Shift(S16) + // "/" -> Shift(S17) + // "+" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) + // EOF -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) + // + pub fn __state28< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + __sym1: &mut Option, + __sym2: &mut Option<&'ast Node<'ast>>, + ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, __tok @ Tok::Times(..), __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::Div(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym3 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state17(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::__actions::__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::__actions::__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::__actions::__action2(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + + // State 29 + // Factor = Factor "*" Term (*) [EOF] + // Factor = Factor "*" Term (*) ["*"] + // Factor = Factor "*" Term (*) ["+"] + // Factor = Factor "*" Term (*) ["-"] + // Factor = Factor "*" Term (*) ["/"] + // + // "+" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // EOF -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // "*" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // "/" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // "-" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // + pub fn __state29< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + __sym1: &mut Option, + __sym2: &mut Option<&'ast Node<'ast>>, + ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action4(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + None => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action4(arena, __sym0, __sym1, __sym2); + return Ok((__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::__actions::__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::__actions::__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::__actions::__action4(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 30 + // Factor = Factor "/" Term (*) [EOF] // Factor = Factor "/" Term (*) ["*"] // Factor = Factor "/" Term (*) ["+"] // Factor = Factor "/" Term (*) ["-"] // Factor = Factor "/" Term (*) ["/"] // - // "*" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // EOF -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) // "-" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) // "+" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // "*" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) // "/" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // ")" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // + pub fn __state30< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + __sym1: &mut Option, + __sym2: &mut Option<&'ast Node<'ast>>, + ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + None => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__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::__actions::__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::__actions::__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::__actions::__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::__actions::__action5(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + + // 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 ["/"] + // + // "+" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) + // ")" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) + // "/" -> Shift(S22) + // "-" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) + // "*" -> Shift(S21) // pub fn __state31< 'ast, @@ -2324,59 +2332,66 @@ mod __parse__Expr { { let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some((_, Tok::Times(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__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!(__state22(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); } - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__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!(__state21(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::__actions::__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::__actions::__action5(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + let __nt = super::__actions::__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::__actions::__action5(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + let __nt = super::__actions::__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::__actions::__action2(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); } _ => { return Err(__lookahead); } } + return Ok(__result); } // State 32 - // 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(S21) + // ")" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // "-" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // "/" -> Shift(S22) // pub fn __state32< 'ast, @@ -2393,67 +2408,58 @@ mod __parse__Expr { { let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__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!(__state21(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!(__state22(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); } Some((_, Tok::Plus(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__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::__actions::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + let __nt = super::__actions::__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::__actions::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + let __nt = super::__actions::__action1(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); } - Some((_, Tok::Times(..), _)) => { + Some((_, Tok::Minus(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + let __nt = super::__actions::__action1(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); } _ => { return Err(__lookahead); } } + return Ok(__result); } // State 33 - // Expr = Expr "-" Factor (*) [")"] - // Expr = Expr "-" Factor (*) ["+"] - // Expr = Expr "-" Factor (*) ["-"] - // Factor = Factor (*) "*" Term [")"] - // Factor = Factor (*) "*" Term ["*"] - // Factor = Factor (*) "*" Term ["+"] - // Factor = Factor (*) "*" Term ["-"] - // Factor = Factor (*) "*" Term ["/"] - // Factor = Factor (*) "/" Term [")"] - // Factor = Factor (*) "/" Term ["*"] - // Factor = Factor (*) "/" Term ["+"] - // Factor = Factor (*) "/" Term ["-"] - // Factor = Factor (*) "/" Term ["/"] + // Factor = Factor "*" Term (*) [")"] + // Factor = Factor "*" Term (*) ["*"] + // Factor = Factor "*" Term (*) ["+"] + // Factor = Factor "*" Term (*) ["-"] + // Factor = Factor "*" Term (*) ["/"] // - // "-" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) - // "/" -> Shift(S18) - // ")" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) - // "*" -> Shift(S19) - // "+" -> 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 __state33< 'ast, @@ -2470,66 +2476,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!(__state18(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); - } - Some((_, __tok @ Tok::Times(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym3 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state19(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); - } - Some((_, Tok::Minus(..), _)) => { + Some((_, Tok::Times(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action1(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + let __nt = super::__actions::__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::__actions::__action1(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + let __nt = super::__actions::__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::__actions::__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::__actions::__action1(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + let __nt = super::__actions::__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::__actions::__action4(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } _ => { return Err(__lookahead); } } - return Ok(__result); } // State 34 - // Expr = Expr "+" Factor (*) [")"] - // Expr = Expr "+" Factor (*) ["+"] - // Expr = Expr "+" Factor (*) ["-"] - // Factor = Factor (*) "*" Term [")"] - // Factor = Factor (*) "*" Term ["*"] - // Factor = Factor (*) "*" Term ["+"] - // Factor = Factor (*) "*" Term ["-"] - // Factor = Factor (*) "*" Term ["/"] - // Factor = Factor (*) "/" Term [")"] - // Factor = Factor (*) "/" Term ["*"] - // Factor = Factor (*) "/" Term ["+"] - // Factor = Factor (*) "/" Term ["-"] - // Factor = Factor (*) "/" Term ["/"] + // Factor = Factor "/" Term (*) [")"] + // Factor = Factor "/" Term (*) ["*"] + // Factor = Factor "/" Term (*) ["+"] + // Factor = Factor "/" Term (*) ["-"] + // Factor = Factor "/" Term (*) ["/"] // - // ")" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) - // "*" -> Shift(S19) - // "+" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) - // "-" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) - // "/" -> Shift(S18) + // "-" -> 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, @@ -2546,108 +2545,40 @@ 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!(__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::RParen(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action2(arena, __sym0, __sym1, __sym2); - return Ok((__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::__actions::__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::__actions::__action2(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 35 - // 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 __state35< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize,Tok,usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option<&'ast Node<'ast>>, - __sym2: &mut Option, - ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> - { - let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, Tok::RParen(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__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::__actions::__action9(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + let __nt = super::__actions::__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::__actions::__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::__actions::__action9(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + let __nt = super::__actions::__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::__actions::__action9(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + let __nt = super::__actions::__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::__actions::__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::__actions::__action5(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } _ => { return Err(__lookahead); @@ -2655,7 +2586,7 @@ mod __parse__Expr { } } - // State 36 + // State 35 // Factor = "*" "(" Comma (*) ")" [")"] // Factor = "*" "(" Comma (*) ")" ["*"] // Factor = "*" "(" Comma (*) ")" ["+"] @@ -2664,7 +2595,7 @@ mod __parse__Expr { // // ")" -> Shift(S46) // - pub fn __state36< + pub fn __state35< 'ast, __TOKENS: Iterator, >( @@ -2692,7 +2623,335 @@ mod __parse__Expr { return Ok(__result); } + // State 36 + // 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 __state36< + '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::Div(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action9(arena, __sym0, __sym1, __sym2); + return Ok((__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::__actions::__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::__actions::__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::__actions::__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::__actions::__action9(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + // State 37 + // ( ",")* = ( ",")* ( ",") (*) ["("] + // ( ",")* = ( ",")* ( ",") (*) [")"] + // ( ",")* = ( ",")* ( ",") (*) ["*"] + // ( ",")* = ( ",")* ( ",") (*) ["Num"] + // + // "*" -> Reduce(( ",")* = ( ",")*, ( ",") => Call(ActionFn(14));) + // ")" -> Reduce(( ",")* = ( ",")*, ( ",") => Call(ActionFn(14));) + // "Num" -> Reduce(( ",")* = ( ",")*, ( ",") => Call(ActionFn(14));) + // "(" -> Reduce(( ",")* = ( ",")*, ( ",") => Call(ActionFn(14));) + // + pub fn __state37< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<::std::vec::Vec<&'ast Node<'ast>>>, + __sym1: &mut Option<&'ast Node<'ast>>, + ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, Tok::Times(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __nt = super::__actions::__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::__actions::__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::__actions::__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::__actions::__action14(arena, __sym0, __sym1); + return Ok((__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 38 + // Expr = Factor (*) [")"] + // Expr = Factor (*) ["+"] + // Expr = Factor (*) [","] + // Expr = Factor (*) ["-"] + // Factor = Factor (*) "*" Term [")"] + // Factor = Factor (*) "*" Term ["*"] + // Factor = Factor (*) "*" Term ["+"] + // Factor = Factor (*) "*" Term [","] + // Factor = Factor (*) "*" Term ["-"] + // Factor = Factor (*) "*" Term ["/"] + // Factor = Factor (*) "/" Term [")"] + // Factor = Factor (*) "/" Term ["*"] + // Factor = Factor (*) "/" Term ["+"] + // Factor = Factor (*) "/" Term [","] + // Factor = Factor (*) "/" Term ["-"] + // Factor = Factor (*) "/" Term ["/"] + // + // "," -> Reduce(Expr = Factor => Call(ActionFn(3));) + // "/" -> Shift(S47) + // "-" -> Reduce(Expr = Factor => Call(ActionFn(3));) + // "*" -> Shift(S48) + // ")" -> Reduce(Expr = Factor => Call(ActionFn(3));) + // "+" -> Reduce(Expr = Factor => Call(ActionFn(3));) + // + pub fn __state38< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, __tok @ Tok::Div(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state47(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + } + Some((_, __tok @ Tok::Times(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state48(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + } + Some((_, Tok::Comma(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action3(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action3(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + Some((_, Tok::RParen(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action3(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action3(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + + // State 39 + // Factor = Term (*) [")"] + // Factor = Term (*) ["*"] + // Factor = Term (*) ["+"] + // Factor = Term (*) [","] + // Factor = Term (*) ["-"] + // Factor = Term (*) ["/"] + // + // "*" -> Reduce(Factor = Term => Call(ActionFn(7));) + // "+" -> Reduce(Factor = Term => Call(ActionFn(7));) + // ")" -> Reduce(Factor = Term => Call(ActionFn(7));) + // "," -> Reduce(Factor = Term => Call(ActionFn(7));) + // "-" -> Reduce(Factor = Term => Call(ActionFn(7));) + // "/" -> Reduce(Factor = Term => Call(ActionFn(7));) + // + pub fn __state39< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, Tok::Times(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action7(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action7(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::RParen(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action7(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Comma(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action7(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action7(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Div(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action7(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 40 + // ( ",") = Expr (*) "," ["("] + // ( ",") = Expr (*) "," [")"] + // ( ",") = Expr (*) "," ["*"] + // ( ",") = Expr (*) "," ["Num"] + // Expr = Expr (*) "+" Factor [")"] + // Expr = Expr (*) "+" Factor ["+"] + // Expr = Expr (*) "+" Factor [","] + // Expr = Expr (*) "+" Factor ["-"] + // Expr = Expr (*) "-" Factor [")"] + // Expr = Expr (*) "-" Factor ["+"] + // Expr = Expr (*) "-" Factor [","] + // Expr = Expr (*) "-" Factor ["-"] + // Expr? = Expr (*) [")"] + // + // "-" -> Shift(S50) + // "+" -> Shift(S51) + // ")" -> Reduce(Expr? = Expr => Call(ActionFn(11));) + // "," -> Shift(S49) + // + pub fn __state40< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, __tok @ Tok::Minus(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state50(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!(__state51(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + } + Some((_, __tok @ Tok::Comma(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state49(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + } + Some((_, Tok::RParen(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action11(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr_3f(__nt))); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + + // State 41 // Factor = "*" (*) "(" Comma ")" [")"] // Factor = "*" (*) "(" Comma ")" ["*"] // Factor = "*" (*) "(" Comma ")" ["+"] @@ -2700,9 +2959,9 @@ mod __parse__Expr { // Factor = "*" (*) "(" Comma ")" ["-"] // Factor = "*" (*) "(" Comma ")" ["/"] // - // "(" -> Shift(S47) + // "(" -> Shift(S52) // - pub fn __state37< + pub fn __state41< 'ast, __TOKENS: Iterator, >( @@ -2719,7 +2978,7 @@ mod __parse__Expr { let mut __lookbehind = Some(__loc); let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state47(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + __result = try!(__state52(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); } _ => { return Err(__lookahead); @@ -2728,12 +2987,12 @@ mod __parse__Expr { return Ok(__result); } - // State 38 + // State 42 // Comma = ( ",")* Expr? (*) [")"] // // ")" -> Reduce(Comma = ( ",")*, Expr? => Call(ActionFn(10));) // - pub fn __state38< + pub fn __state42< 'ast, __TOKENS: Iterator, >( @@ -2759,7 +3018,7 @@ mod __parse__Expr { } } - // State 39 + // State 43 // Term = "Num" (*) [")"] // Term = "Num" (*) ["*"] // Term = "Num" (*) ["+"] @@ -2767,14 +3026,14 @@ mod __parse__Expr { // Term = "Num" (*) ["-"] // Term = "Num" (*) ["/"] // - // "*" -> Reduce(Term = "Num" => Call(ActionFn(8));) - // "+" -> Reduce(Term = "Num" => Call(ActionFn(8));) - // "/" -> Reduce(Term = "Num" => Call(ActionFn(8));) - // "-" -> Reduce(Term = "Num" => Call(ActionFn(8));) // "," -> Reduce(Term = "Num" => Call(ActionFn(8));) + // "-" -> Reduce(Term = "Num" => Call(ActionFn(8));) // ")" -> Reduce(Term = "Num" => Call(ActionFn(8));) + // "+" -> Reduce(Term = "Num" => Call(ActionFn(8));) + // "*" -> Reduce(Term = "Num" => Call(ActionFn(8));) + // "/" -> Reduce(Term = "Num" => Call(ActionFn(8));) // - pub fn __state39< + pub fn __state43< 'ast, __TOKENS: Iterator, >( @@ -2787,17 +3046,7 @@ 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::__actions::__action8(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - Some((_, Tok::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action8(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } - Some((_, Tok::Div(..), _)) => { + Some((_, Tok::Comma(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __nt = super::__actions::__action8(arena, __sym0); return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); @@ -2807,12 +3056,22 @@ mod __parse__Expr { let __nt = super::__actions::__action8(arena, __sym0); return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); } - Some((_, Tok::Comma(..), _)) => { + Some((_, Tok::RParen(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __nt = super::__actions::__action8(arena, __sym0); return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); } - Some((_, Tok::RParen(..), _)) => { + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action8(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + Some((_, Tok::Times(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action8(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + Some((_, Tok::Div(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __nt = super::__actions::__action8(arena, __sym0); return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); @@ -2823,7 +3082,7 @@ mod __parse__Expr { } } - // State 40 + // State 44 // Expr = (*) Expr "+" Factor [")"] // Expr = (*) Expr "+" Factor ["+"] // Expr = (*) Expr "+" Factor ["-"] @@ -2870,14 +3129,14 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "Num" -> Shift(S12) - // "(" -> Shift(S10) + // "Num" -> Shift(S10) // "*" -> Shift(S11) + // "(" -> Shift(S12) // - // Term -> S8 - // Factor -> S7 - // Expr -> S48 - pub fn __state40< + // Expr -> S53 + // Term -> S7 + // Factor -> S9 + pub fn __state44< 'ast, __TOKENS: Iterator, >( @@ -2894,12 +3153,6 @@ mod __parse__Expr { let mut __lookbehind = Some(__loc); let mut __sym1 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state12(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!(__state10(arena, __lookbehind, __lookahead, __tokens, __sym1)); } Some((_, __tok @ Tok::Times(..), __loc)) => { @@ -2908,6 +3161,12 @@ mod __parse__Expr { let __lookahead = __tokens.next(); __result = try!(__state11(arena, __lookbehind, __lookahead, __tokens, __sym1)); } + Some((_, __tok @ Tok::LParen(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state12(arena, __lookbehind, __lookahead, __tokens, __sym1)); + } _ => { return Err(__lookahead); } @@ -2915,17 +3174,17 @@ mod __parse__Expr { while __sym0.is_some() { let (__lookbehind, __lookahead, __nt) = __result; match __nt { - __Nonterminal::Term(__nt) => { + __Nonterminal::Expr(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state8(arena, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state53(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); } - __Nonterminal::Factor(__nt) => { + __Nonterminal::Term(__nt) => { let __sym1 = &mut Some(__nt); __result = try!(__state7(arena, __lookbehind, __lookahead, __tokens, __sym1)); } - __Nonterminal::Expr(__nt) => { + __Nonterminal::Factor(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state48(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + __result = try!(__state9(arena, __lookbehind, __lookahead, __tokens, __sym1)); } _ => { return Ok((__lookbehind, __lookahead, __nt)); @@ -2935,265 +3194,6 @@ mod __parse__Expr { return Ok(__result); } - // State 41 - // Expr = Factor (*) [")"] - // Expr = Factor (*) ["+"] - // Expr = Factor (*) [","] - // Expr = Factor (*) ["-"] - // Factor = Factor (*) "*" Term [")"] - // Factor = Factor (*) "*" Term ["*"] - // Factor = Factor (*) "*" Term ["+"] - // Factor = Factor (*) "*" Term [","] - // Factor = Factor (*) "*" Term ["-"] - // Factor = Factor (*) "*" Term ["/"] - // Factor = Factor (*) "/" Term [")"] - // Factor = Factor (*) "/" Term ["*"] - // Factor = Factor (*) "/" Term ["+"] - // Factor = Factor (*) "/" Term [","] - // Factor = Factor (*) "/" Term ["-"] - // Factor = Factor (*) "/" Term ["/"] - // - // "/" -> Shift(S50) - // "*" -> Shift(S49) - // ")" -> Reduce(Expr = Factor => Call(ActionFn(3));) - // "," -> Reduce(Expr = Factor => Call(ActionFn(3));) - // "+" -> Reduce(Expr = Factor => Call(ActionFn(3));) - // "-" -> Reduce(Expr = Factor => Call(ActionFn(3));) - // - 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::Div(..), __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::Times(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym1 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state49(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); - } - Some((_, Tok::RParen(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action3(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - Some((_, Tok::Comma(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action3(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - Some((_, Tok::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action3(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action3(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 42 - // Factor = Term (*) [")"] - // Factor = Term (*) ["*"] - // Factor = Term (*) ["+"] - // Factor = Term (*) [","] - // Factor = Term (*) ["-"] - // Factor = Term (*) ["/"] - // - // "*" -> Reduce(Factor = Term => Call(ActionFn(7));) - // ")" -> Reduce(Factor = Term => Call(ActionFn(7));) - // "," -> Reduce(Factor = Term => Call(ActionFn(7));) - // "/" -> Reduce(Factor = Term => Call(ActionFn(7));) - // "-" -> Reduce(Factor = Term => Call(ActionFn(7));) - // "+" -> Reduce(Factor = Term => Call(ActionFn(7));) - // - pub fn __state42< - '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::__actions::__action7(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::RParen(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Comma(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Div(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Minus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 43 - // ( ",") = Expr (*) "," ["("] - // ( ",") = Expr (*) "," [")"] - // ( ",") = Expr (*) "," ["*"] - // ( ",") = Expr (*) "," ["Num"] - // Expr = Expr (*) "+" Factor [")"] - // Expr = Expr (*) "+" Factor ["+"] - // Expr = Expr (*) "+" Factor [","] - // Expr = Expr (*) "+" Factor ["-"] - // Expr = Expr (*) "-" Factor [")"] - // Expr = Expr (*) "-" Factor ["+"] - // Expr = Expr (*) "-" Factor [","] - // Expr = Expr (*) "-" Factor ["-"] - // Expr? = Expr (*) [")"] - // - // "-" -> Shift(S51) - // "," -> Shift(S53) - // "+" -> Shift(S52) - // ")" -> Reduce(Expr? = Expr => Call(ActionFn(11));) - // - pub fn __state43< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize,Tok,usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> - { - let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, __tok @ Tok::Minus(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym1 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state51(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); - } - Some((_, __tok @ Tok::Comma(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym1 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state53(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!(__state52(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); - } - Some((_, Tok::RParen(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action11(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr_3f(__nt))); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 44 - // ( ",")* = ( ",")* ( ",") (*) ["("] - // ( ",")* = ( ",")* ( ",") (*) [")"] - // ( ",")* = ( ",")* ( ",") (*) ["*"] - // ( ",")* = ( ",")* ( ",") (*) ["Num"] - // - // "(" -> Reduce(( ",")* = ( ",")*, ( ",") => Call(ActionFn(14));) - // ")" -> Reduce(( ",")* = ( ",")*, ( ",") => Call(ActionFn(14));) - // "*" -> Reduce(( ",")* = ( ",")*, ( ",") => Call(ActionFn(14));) - // "Num" -> Reduce(( ",")* = ( ",")*, ( ",") => Call(ActionFn(14));) - // - pub fn __state44< - '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::LParen(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __nt = super::__actions::__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::__actions::__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::__actions::__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::__actions::__action14(arena, __sym0, __sym1); - return Ok((__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - // State 45 // Factor = "*" "(" Comma ")" (*) [EOF] // Factor = "*" "(" Comma ")" (*) ["*"] @@ -3202,9 +3202,9 @@ mod __parse__Expr { // Factor = "*" "(" Comma ")" (*) ["/"] // // "+" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) - // "/" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) // "-" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) // "*" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) + // "/" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) // EOF -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) // pub fn __state45< @@ -3231,14 +3231,6 @@ mod __parse__Expr { let __nt = super::__actions::__action6(arena, __sym0, __sym1, __sym2, __sym3); return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } - Some((_, Tok::Div(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __sym3 = __sym3.take().unwrap(); - let __nt = super::__actions::__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(); @@ -3255,6 +3247,14 @@ mod __parse__Expr { let __nt = super::__actions::__action6(arena, __sym0, __sym1, __sym2, __sym3); return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } + Some((_, Tok::Div(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __sym3 = __sym3.take().unwrap(); + let __nt = super::__actions::__action6(arena, __sym0, __sym1, __sym2, __sym3); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } None => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); @@ -3276,10 +3276,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));) // pub fn __state46< @@ -3298,6 +3298,14 @@ mod __parse__Expr { { let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { + Some((_, Tok::Times(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __sym3 = __sym3.take().unwrap(); + let __nt = super::__actions::__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(); @@ -3322,14 +3330,6 @@ mod __parse__Expr { let __nt = super::__actions::__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::__actions::__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(); @@ -3345,209 +3345,6 @@ mod __parse__Expr { } // State 47 - // ( ",")* = (*) ["("] - // ( ",")* = (*) [")"] - // ( ",")* = (*) ["*"] - // ( ",")* = (*) ["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));) - // - // Comma -> S54 - // ( ",")* -> S29 - pub fn __state47< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize,Tok,usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option, - ) -> 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::__actions::__action13(arena, ); - __result = (__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); - } - Some((_, Tok::Num(_), _)) => { - let __nt = super::__actions::__action13(arena, ); - __result = (__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); - } - Some((_, Tok::Times(..), _)) => { - let __nt = super::__actions::__action13(arena, ); - __result = (__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); - } - Some((_, Tok::LParen(..), _)) => { - let __nt = super::__actions::__action13(arena, ); - __result = (__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); - } - _ => { - return Err(__lookahead); - } - } - while __sym1.is_some() { - let (__lookbehind, __lookahead, __nt) = __result; - match __nt { - __Nonterminal::Comma_3cExpr_3e(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state54(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state29(arena, __lookbehind, __lookahead, __tokens, __sym2)); - } - _ => { - return Ok((__lookbehind, __lookahead, __nt)); - } - } - } - return Ok(__result); - } - - // State 48 - // Expr = Expr (*) "+" Factor [")"] - // Expr = Expr (*) "+" Factor ["+"] - // Expr = Expr (*) "+" Factor ["-"] - // Expr = Expr (*) "-" Factor [")"] - // Expr = Expr (*) "-" Factor ["+"] - // Expr = Expr (*) "-" Factor ["-"] - // Term = "(" Expr (*) ")" [")"] - // Term = "(" Expr (*) ")" ["*"] - // Term = "(" Expr (*) ")" ["+"] - // Term = "(" Expr (*) ")" [","] - // Term = "(" Expr (*) ")" ["-"] - // Term = "(" Expr (*) ")" ["/"] - // - // "+" -> Shift(S22) - // "-" -> Shift(S21) - // ")" -> Shift(S55) - // - pub fn __state48< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize,Tok,usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option<&'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::Minus(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state21(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!(__state55(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 49 - // Factor = Factor "*" (*) Term [")"] - // Factor = Factor "*" (*) Term ["*"] - // Factor = Factor "*" (*) Term ["+"] - // Factor = Factor "*" (*) Term [","] - // Factor = Factor "*" (*) Term ["-"] - // Factor = Factor "*" (*) Term ["/"] - // Term = (*) "(" Expr ")" [")"] - // Term = (*) "(" Expr ")" ["*"] - // Term = (*) "(" Expr ")" ["+"] - // Term = (*) "(" Expr ")" [","] - // Term = (*) "(" Expr ")" ["-"] - // Term = (*) "(" Expr ")" ["/"] - // Term = (*) "Num" [")"] - // Term = (*) "Num" ["*"] - // Term = (*) "Num" ["+"] - // Term = (*) "Num" [","] - // Term = (*) "Num" ["-"] - // Term = (*) "Num" ["/"] - // - // "Num" -> Shift(S39) - // "(" -> Shift(S40) - // - // Term -> S56 - pub fn __state49< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize,Tok,usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, - ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> - { - let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, Tok::Num(__tok0), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state39(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!(__state40(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!(__state56(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - _ => { - return Ok((__lookbehind, __lookahead, __nt)); - } - } - } - return Ok(__result); - } - - // State 50 // Factor = Factor "/" (*) Term [")"] // Factor = Factor "/" (*) Term ["*"] // Factor = Factor "/" (*) Term ["+"] @@ -3567,11 +3364,80 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "(" -> Shift(S40) - // "Num" -> Shift(S39) + // "Num" -> Shift(S43) + // "(" -> Shift(S44) // - // Term -> S57 - pub fn __state50< + // 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!(__state43(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!(__state44(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" ["/"] + // + // "(" -> Shift(S44) + // "Num" -> Shift(S43) + // + // Term -> S55 + pub fn __state48< 'ast, __TOKENS: Iterator, >( @@ -3589,13 +3455,13 @@ mod __parse__Expr { let mut __lookbehind = Some(__loc); let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state40(arena, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state44(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!(__state39(arena, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state43(arena, __lookbehind, __lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); @@ -3606,7 +3472,7 @@ mod __parse__Expr { match __nt { __Nonterminal::Term(__nt) => { let __sym2 = &mut Some(__nt); - __result = try!(__state57(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + __result = try!(__state55(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); } _ => { return Ok((__lookbehind, __lookahead, __nt)); @@ -3616,7 +3482,62 @@ mod __parse__Expr { return Ok(__result); } - // State 51 + // State 49 + // ( ",") = 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 __state49< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + __sym1: &mut Option, + ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, Tok::LParen(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __nt = super::__actions::__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::__actions::__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::__actions::__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::__actions::__action15(arena, __sym0, __sym1); + return Ok((__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 50 // Expr = Expr "-" (*) Factor [")"] // Expr = Expr "-" (*) Factor ["+"] // Expr = Expr "-" (*) Factor [","] @@ -3658,13 +3579,13 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "(" -> Shift(S40) - // "*" -> Shift(S37) - // "Num" -> Shift(S39) + // "Num" -> Shift(S43) + // "(" -> Shift(S44) + // "*" -> Shift(S41) // - // Factor -> S58 - // Term -> S42 - pub fn __state51< + // Factor -> S56 + // Term -> S39 + pub fn __state50< 'ast, __TOKENS: Iterator, >( @@ -3678,23 +3599,23 @@ mod __parse__Expr { { let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { + Some((_, Tok::Num(__tok0), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok0)); + let __lookahead = __tokens.next(); + __result = try!(__state43(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!(__state40(arena, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state44(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!(__state37(arena, __lookbehind, __lookahead, __tokens, __sym2)); - } - Some((_, Tok::Num(__tok0), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state39(arena, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state41(arena, __lookbehind, __lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); @@ -3705,11 +3626,11 @@ mod __parse__Expr { match __nt { __Nonterminal::Factor(__nt) => { let __sym2 = &mut Some(__nt); - __result = try!(__state58(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + __result = try!(__state56(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); } __Nonterminal::Term(__nt) => { let __sym2 = &mut Some(__nt); - __result = try!(__state42(arena, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state39(arena, __lookbehind, __lookahead, __tokens, __sym2)); } _ => { return Ok((__lookbehind, __lookahead, __nt)); @@ -3719,7 +3640,7 @@ mod __parse__Expr { return Ok(__result); } - // State 52 + // State 51 // Expr = Expr "+" (*) Factor [")"] // Expr = Expr "+" (*) Factor ["+"] // Expr = Expr "+" (*) Factor [","] @@ -3761,13 +3682,13 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "Num" -> Shift(S39) - // "*" -> Shift(S37) - // "(" -> Shift(S40) + // "*" -> Shift(S41) + // "(" -> Shift(S44) + // "Num" -> Shift(S43) // - // Factor -> S59 - // Term -> S42 - pub fn __state52< + // Factor -> S57 + // Term -> S39 + pub fn __state51< 'ast, __TOKENS: Iterator, >( @@ -3781,23 +3702,23 @@ mod __parse__Expr { { let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some((_, Tok::Num(__tok0), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state39(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!(__state37(arena, __lookbehind, __lookahead, __tokens, __sym2)); + __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!(__state40(arena, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state44(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!(__state43(arena, __lookbehind, __lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); @@ -3808,11 +3729,88 @@ mod __parse__Expr { match __nt { __Nonterminal::Factor(__nt) => { let __sym2 = &mut Some(__nt); - __result = try!(__state59(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + __result = try!(__state57(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); } __Nonterminal::Term(__nt) => { let __sym2 = &mut Some(__nt); - __result = try!(__state42(arena, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state39(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + _ => { + return Ok((__lookbehind, __lookahead, __nt)); + } + } + } + return Ok(__result); + } + + // State 52 + // ( ",")* = (*) ["("] + // ( ",")* = (*) [")"] + // ( ",")* = (*) ["*"] + // ( ",")* = (*) ["Num"] + // ( ",")* = (*) ( ",")* ( ",") ["("] + // ( ",")* = (*) ( ",")* ( ",") [")"] + // ( ",")* = (*) ( ",")* ( ",") ["*"] + // ( ",")* = (*) ( ",")* ( ",") ["Num"] + // Comma = (*) ( ",")* Expr? [")"] + // Factor = "*" "(" (*) Comma ")" [")"] + // Factor = "*" "(" (*) Comma ")" ["*"] + // Factor = "*" "(" (*) Comma ")" ["+"] + // Factor = "*" "(" (*) Comma ")" [","] + // Factor = "*" "(" (*) Comma ")" ["-"] + // Factor = "*" "(" (*) Comma ")" ["/"] + // + // "Num" -> Reduce(( ",")* = => Call(ActionFn(13));) + // "(" -> Reduce(( ",")* = => Call(ActionFn(13));) + // ")" -> Reduce(( ",")* = => Call(ActionFn(13));) + // "*" -> Reduce(( ",")* = => Call(ActionFn(13));) + // + // ( ",")* -> S25 + // Comma -> S58 + pub fn __state52< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + __sym1: &mut Option, + ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, Tok::Num(_), _)) => { + let __nt = super::__actions::__action13(arena, ); + __result = (__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); + } + Some((_, Tok::LParen(..), _)) => { + let __nt = super::__actions::__action13(arena, ); + __result = (__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); + } + Some((_, Tok::RParen(..), _)) => { + let __nt = super::__actions::__action13(arena, ); + __result = (__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); + } + Some((_, Tok::Times(..), _)) => { + let __nt = super::__actions::__action13(arena, ); + __result = (__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); + } + _ => { + return Err(__lookahead); + } + } + while __sym1.is_some() { + let (__lookbehind, __lookahead, __nt) = __result; + match __nt { + __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state25(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + __Nonterminal::Comma_3cExpr_3e(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state58(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); } _ => { return Ok((__lookbehind, __lookahead, __nt)); @@ -3823,15 +3821,22 @@ mod __parse__Expr { } // State 53 - // ( ",") = Expr "," (*) ["("] - // ( ",") = Expr "," (*) [")"] - // ( ",") = Expr "," (*) ["*"] - // ( ",") = Expr "," (*) ["Num"] + // Expr = Expr (*) "+" Factor [")"] + // Expr = Expr (*) "+" Factor ["+"] + // Expr = Expr (*) "+" Factor ["-"] + // Expr = Expr (*) "-" Factor [")"] + // Expr = Expr (*) "-" Factor ["+"] + // Expr = Expr (*) "-" Factor ["-"] + // Term = "(" Expr (*) ")" [")"] + // Term = "(" Expr (*) ")" ["*"] + // Term = "(" Expr (*) ")" ["+"] + // Term = "(" Expr (*) ")" [","] + // Term = "(" Expr (*) ")" ["-"] + // Term = "(" Expr (*) ")" ["/"] // - // "(" -> Reduce(( ",") = Expr, "," => Call(ActionFn(15));) - // "*" -> Reduce(( ",") = Expr, "," => Call(ActionFn(15));) - // "Num" -> Reduce(( ",") = Expr, "," => Call(ActionFn(15));) - // ")" -> Reduce(( ",") = Expr, "," => Call(ActionFn(15));) + // "-" -> Shift(S20) + // "+" -> Shift(S18) + // ")" -> Shift(S59) // pub fn __state53< 'ast, @@ -3841,35 +3846,108 @@ mod __parse__Expr { __lookbehind: Option, __lookahead: Option<(usize,Tok,usize)>, __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, + __sym0: &mut Option, + __sym1: &mut Option<&'ast Node<'ast>>, ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> { let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some((_, Tok::LParen(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __nt = super::__actions::__action15(arena, __sym0, __sym1); - return Ok((__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29(__nt))); + Some((_, __tok @ Tok::Minus(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state20(arena, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); } - Some((_, Tok::Times(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __nt = super::__actions::__action15(arena, __sym0, __sym1); - return Ok((__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29(__nt))); + Some((_, __tok @ Tok::Plus(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state18(arena, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); } - Some((_, Tok::Num(_), _)) => { + Some((_, __tok @ Tok::RParen(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state59(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + + // State 54 + // Factor = Factor "/" Term (*) [")"] + // Factor = Factor "/" Term (*) ["*"] + // Factor = Factor "/" Term (*) ["+"] + // Factor = Factor "/" Term (*) [","] + // Factor = Factor "/" Term (*) ["-"] + // Factor = Factor "/" Term (*) ["/"] + // + // "/" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // "-" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // "+" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // ")" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // "*" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // "," -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // + pub fn __state54< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + __sym1: &mut Option, + __sym2: &mut Option<&'ast Node<'ast>>, + ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, Tok::Div(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); - let __nt = super::__actions::__action15(arena, __sym0, __sym1); - return Ok((__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29(__nt))); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__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::__actions::__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::__actions::__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 __nt = super::__actions::__action15(arena, __sym0, __sym1); - return Ok((__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29(__nt))); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__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::__actions::__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::__actions::__action5(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } _ => { return Err(__lookahead); @@ -3877,7 +3955,259 @@ mod __parse__Expr { } } - // State 54 + // State 55 + // Factor = Factor "*" Term (*) [")"] + // Factor = Factor "*" Term (*) ["*"] + // Factor = Factor "*" Term (*) ["+"] + // Factor = Factor "*" Term (*) [","] + // Factor = Factor "*" Term (*) ["-"] + // Factor = Factor "*" Term (*) ["/"] + // + // "+" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // ")" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // "*" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // "," -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // "/" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // "-" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // + pub fn __state55< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + __sym1: &mut Option, + __sym2: &mut Option<&'ast Node<'ast>>, + ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action4(arena, __sym0, __sym1, __sym2); + return Ok((__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::__actions::__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::__actions::__action4(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Comma(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__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::__actions::__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::__actions::__action4(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 56 + // Expr = Expr "-" Factor (*) [")"] + // Expr = Expr "-" Factor (*) ["+"] + // Expr = Expr "-" Factor (*) [","] + // Expr = Expr "-" Factor (*) ["-"] + // Factor = Factor (*) "*" Term [")"] + // Factor = Factor (*) "*" Term ["*"] + // Factor = Factor (*) "*" Term ["+"] + // Factor = Factor (*) "*" Term [","] + // Factor = Factor (*) "*" Term ["-"] + // Factor = Factor (*) "*" Term ["/"] + // Factor = Factor (*) "/" Term [")"] + // Factor = Factor (*) "/" Term ["*"] + // Factor = Factor (*) "/" Term ["+"] + // Factor = Factor (*) "/" Term [","] + // Factor = Factor (*) "/" Term ["-"] + // Factor = Factor (*) "/" Term ["/"] + // + // "+" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // "*" -> Shift(S48) + // "," -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // "/" -> Shift(S47) + // ")" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // "-" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // + pub fn __state56< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + __sym1: &mut Option, + __sym2: &mut Option<&'ast Node<'ast>>, + ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, __tok @ Tok::Times(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym3 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state48(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); + } + Some((_, __tok @ Tok::Div(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym3 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state47(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action1(arena, __sym0, __sym1, __sym2); + return Ok((__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::__actions::__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::__actions::__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::__actions::__action1(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + + // State 57 + // Expr = Expr "+" Factor (*) [")"] + // Expr = Expr "+" Factor (*) ["+"] + // Expr = Expr "+" Factor (*) [","] + // Expr = Expr "+" Factor (*) ["-"] + // Factor = Factor (*) "*" Term [")"] + // Factor = Factor (*) "*" Term ["*"] + // Factor = Factor (*) "*" Term ["+"] + // Factor = Factor (*) "*" Term [","] + // Factor = Factor (*) "*" Term ["-"] + // Factor = Factor (*) "*" Term ["/"] + // Factor = Factor (*) "/" Term [")"] + // Factor = Factor (*) "/" Term ["*"] + // Factor = Factor (*) "/" Term ["+"] + // Factor = Factor (*) "/" Term [","] + // Factor = Factor (*) "/" Term ["-"] + // Factor = Factor (*) "/" Term ["/"] + // + // "*" -> Shift(S48) + // "-" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) + // "+" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) + // "," -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) + // "/" -> Shift(S47) + // ")" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) + // + pub fn __state57< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + __sym1: &mut Option, + __sym2: &mut Option<&'ast Node<'ast>>, + ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, __tok @ Tok::Times(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym3 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state48(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); + } + Some((_, __tok @ Tok::Div(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym3 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state47(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action2(arena, __sym0, __sym1, __sym2); + return Ok((__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::__actions::__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::__actions::__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::__actions::__action2(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + + // State 58 // Factor = "*" "(" Comma (*) ")" [")"] // Factor = "*" "(" Comma (*) ")" ["*"] // Factor = "*" "(" Comma (*) ")" ["+"] @@ -3887,7 +4217,7 @@ mod __parse__Expr { // // ")" -> Shift(S60) // - pub fn __state54< + pub fn __state58< 'ast, __TOKENS: Iterator, >( @@ -3915,7 +4245,7 @@ mod __parse__Expr { return Ok(__result); } - // State 55 + // State 59 // Term = "(" Expr ")" (*) [")"] // Term = "(" Expr ")" (*) ["*"] // Term = "(" Expr ")" (*) ["+"] @@ -3923,14 +4253,14 @@ 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 __state55< + pub fn __state59< 'ast, __TOKENS: Iterator, >( @@ -3945,7 +4275,7 @@ mod __parse__Expr { { let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some((_, Tok::Minus(..), _)) => { + Some((_, Tok::Div(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); @@ -3959,7 +4289,14 @@ mod __parse__Expr { let __nt = super::__actions::__action9(arena, __sym0, __sym1, __sym2); return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); } - Some((_, Tok::Div(..), _)) => { + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__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(); @@ -3980,349 +4317,12 @@ mod __parse__Expr { let __nt = super::__actions::__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::__actions::__action9(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } _ => { return Err(__lookahead); } } } - // State 56 - // Factor = Factor "*" Term (*) [")"] - // Factor = Factor "*" Term (*) ["*"] - // Factor = Factor "*" Term (*) ["+"] - // Factor = Factor "*" Term (*) [","] - // Factor = Factor "*" Term (*) ["-"] - // Factor = Factor "*" Term (*) ["/"] - // - // "/" -> Reduce(Factor = Factor, "*", Term => 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 __state56< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize,Tok,usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, - __sym2: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> - { - let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, Tok::Div(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__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::__actions::__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::__actions::__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::__actions::__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::__actions::__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::__actions::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 57 - // Factor = Factor "/" Term (*) [")"] - // Factor = Factor "/" Term (*) ["*"] - // Factor = Factor "/" Term (*) ["+"] - // Factor = Factor "/" Term (*) [","] - // Factor = Factor "/" Term (*) ["-"] - // Factor = Factor "/" Term (*) ["/"] - // - // ")" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // "," -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // "/" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // "-" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // "+" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // "*" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // - pub fn __state57< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize,Tok,usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, - __sym2: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> - { - let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, Tok::RParen(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action5(arena, __sym0, __sym1, __sym2); - return Ok((__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::__actions::__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::__actions::__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::__actions::__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::__actions::__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::__actions::__action5(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 58 - // Expr = Expr "-" Factor (*) [")"] - // Expr = Expr "-" Factor (*) ["+"] - // Expr = Expr "-" Factor (*) [","] - // Expr = Expr "-" Factor (*) ["-"] - // Factor = Factor (*) "*" Term [")"] - // Factor = Factor (*) "*" Term ["*"] - // Factor = Factor (*) "*" Term ["+"] - // Factor = Factor (*) "*" Term [","] - // Factor = Factor (*) "*" Term ["-"] - // Factor = Factor (*) "*" Term ["/"] - // Factor = Factor (*) "/" Term [")"] - // Factor = Factor (*) "/" Term ["*"] - // Factor = Factor (*) "/" Term ["+"] - // Factor = Factor (*) "/" Term [","] - // Factor = Factor (*) "/" Term ["-"] - // Factor = Factor (*) "/" Term ["/"] - // - // "," -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) - // "+" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) - // "*" -> Shift(S49) - // ")" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) - // "/" -> Shift(S50) - // "-" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) - // - pub fn __state58< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize,Tok,usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, - __sym2: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> - { - let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, __tok @ Tok::Times(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym3 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state49(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!(__state50(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::__actions::__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::__actions::__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::__actions::__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::__actions::__action1(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 59 - // Expr = Expr "+" Factor (*) [")"] - // Expr = Expr "+" Factor (*) ["+"] - // Expr = Expr "+" Factor (*) [","] - // Expr = Expr "+" Factor (*) ["-"] - // Factor = Factor (*) "*" Term [")"] - // Factor = Factor (*) "*" Term ["*"] - // Factor = Factor (*) "*" Term ["+"] - // Factor = Factor (*) "*" Term [","] - // Factor = Factor (*) "*" Term ["-"] - // Factor = Factor (*) "*" Term ["/"] - // Factor = Factor (*) "/" Term [")"] - // Factor = Factor (*) "/" Term ["*"] - // Factor = Factor (*) "/" Term ["+"] - // Factor = Factor (*) "/" Term [","] - // Factor = Factor (*) "/" Term ["-"] - // Factor = Factor (*) "/" Term ["/"] - // - // ")" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) - // "/" -> Shift(S50) - // "*" -> Shift(S49) - // "+" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) - // "," -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) - // "-" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) - // - pub fn __state59< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize,Tok,usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, - __sym2: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> - { - let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, __tok @ Tok::Div(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym3 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state50(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!(__state49(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::__actions::__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::__actions::__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::__actions::__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::__actions::__action2(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - // State 60 // Factor = "*" "(" Comma ")" (*) [")"] // Factor = "*" "(" Comma ")" (*) ["*"] @@ -4331,12 +4331,12 @@ mod __parse__Expr { // Factor = "*" "(" Comma ")" (*) ["-"] // Factor = "*" "(" Comma ")" (*) ["/"] // + // "," -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) + // "/" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) + // "-" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) // "+" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) // ")" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) // "*" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) - // "," -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) - // "-" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) - // "/" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) // pub fn __state60< 'ast, @@ -4354,6 +4354,30 @@ mod __parse__Expr { { let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { + Some((_, Tok::Comma(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __sym3 = __sym3.take().unwrap(); + let __nt = super::__actions::__action6(arena, __sym0, __sym1, __sym2, __sym3); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Div(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __sym3 = __sym3.take().unwrap(); + let __nt = super::__actions::__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::__actions::__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(); @@ -4378,30 +4402,6 @@ mod __parse__Expr { let __nt = super::__actions::__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::__actions::__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::__actions::__action6(arena, __sym0, __sym1, __sym2, __sym3); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Div(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __sym3 = __sym3.take().unwrap(); - let __nt = super::__actions::__action6(arena, __sym0, __sym1, __sym2, __sym3); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } _ => { return Err(__lookahead); } diff --git a/lalrpop-test/src/loc.rs b/lalrpop-test/src/loc.rs index c627e3f..778ca2c 100644 --- a/lalrpop-test/src/loc.rs +++ b/lalrpop-test/src/loc.rs @@ -24,9 +24,9 @@ mod __parse__Items { pub enum __Nonterminal<> { ____Items(Vec<(Option, Option)>), _40_3c(::std::option::Option), - Spanned_3c_22_2b_22_3e((Option, Option)), - Items(Vec<(Option, Option)>), _40_3e(::std::option::Option), + Items(Vec<(Option, Option)>), + Spanned_3c_22_2b_22_3e((Option, Option)), } // State 0 @@ -41,9 +41,9 @@ mod __parse__Items { // Items = (*) Items "-" ["-"] // __Items = (*) Items [EOF] // + // "+" -> Reduce(Items = => Call(ActionFn(1));) // EOF -> Reduce(Items = => Call(ActionFn(1));) // "-" -> Reduce(Items = => Call(ActionFn(1));) - // "+" -> Reduce(Items = => Call(ActionFn(1));) // // Items -> S1 pub fn __state0< @@ -56,6 +56,10 @@ mod __parse__Items { { let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<>); match __lookahead { + Some((_, Tok::Plus(..), _)) => { + let __nt = super::__actions::__action1(); + __result = (__lookbehind, __lookahead, __Nonterminal::Items(__nt)); + } None => { let __nt = super::__actions::__action1(); __result = (__lookbehind, __lookahead, __Nonterminal::Items(__nt)); @@ -64,10 +68,6 @@ mod __parse__Items { let __nt = super::__actions::__action1(); __result = (__lookbehind, __lookahead, __Nonterminal::Items(__nt)); } - Some((_, Tok::Plus(..), _)) => { - let __nt = super::__actions::__action1(); - __result = (__lookbehind, __lookahead, __Nonterminal::Items(__nt)); - } _ => { return Err(__lookahead); } @@ -99,11 +99,11 @@ mod __parse__Items { // Spanned<"+"> = (*) @< "+" @> ["-"] // __Items = Items (*) [EOF] // - // "+" -> Reduce(@< = => Lookahead;) // EOF -> Reduce(__Items = Items => Call(ActionFn(0));) - // "-" -> Shift(S4) + // "-" -> Shift(S2) + // "+" -> Reduce(@< = => Lookahead;) // - // @< -> S2 + // @< -> S4 // Spanned<"+"> -> S3 pub fn __state1< __TOKENS: Iterator, @@ -120,17 +120,17 @@ mod __parse__Items { let mut __lookbehind = Some(__loc); let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state4(__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!(__state2(__lookbehind, __lookahead, __tokens, __sym0, __sym1)); } None => { let __sym0 = __sym0.take().unwrap(); let __nt = super::__actions::__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)); + __result = (__lookbehind, __lookahead, __Nonterminal::_40_3c(__nt)); + } _ => { return Err(__lookahead); } @@ -140,7 +140,7 @@ mod __parse__Items { match __nt { __Nonterminal::_40_3c(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state2(__lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state4(__lookbehind, __lookahead, __tokens, __sym1)); } __Nonterminal::Spanned_3c_22_2b_22_3e(__nt) => { let __sym1 = &mut Some(__nt); @@ -155,13 +155,103 @@ mod __parse__Items { } // 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::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __nt = super::__actions::__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::__actions::__action3(__sym0, __sym1); + return Ok((__lookbehind, __lookahead, __Nonterminal::Items(__nt))); + } + None => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __nt = super::__actions::__action3(__sym0, __sym1); + return Ok((__lookbehind, __lookahead, __Nonterminal::Items(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 3 + // Items = Items Spanned<"+"> (*) [EOF] + // Items = Items Spanned<"+"> (*) ["+"] + // Items = Items Spanned<"+"> (*) ["-"] + // + // EOF -> Reduce(Items = Items, Spanned<"+"> => Call(ActionFn(2));) + // "+" -> Reduce(Items = Items, Spanned<"+"> => Call(ActionFn(2));) + // "-" -> Reduce(Items = Items, Spanned<"+"> => Call(ActionFn(2));) + // + pub fn __state3< + __TOKENS: Iterator, + >( + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option, Option)>>, + __sym1: &mut Option<(Option, 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::__actions::__action2(__sym0, __sym1); + return Ok((__lookbehind, __lookahead, __Nonterminal::Items(__nt))); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __nt = super::__actions::__action2(__sym0, __sym1); + return Ok((__lookbehind, __lookahead, __Nonterminal::Items(__nt))); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __nt = super::__actions::__action2(__sym0, __sym1); + return Ok((__lookbehind, __lookahead, __Nonterminal::Items(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 4 // Spanned<"+"> = @< (*) "+" @> [EOF] // Spanned<"+"> = @< (*) "+" @> ["+"] // Spanned<"+"> = @< (*) "+" @> ["-"] // // "+" -> Shift(S5) // - pub fn __state2< + pub fn __state4< __TOKENS: Iterator, >( __lookbehind: Option, @@ -185,96 +275,6 @@ mod __parse__Items { return Ok(__result); } - // State 3 - // Items = Items Spanned<"+"> (*) [EOF] - // Items = Items Spanned<"+"> (*) ["+"] - // Items = Items Spanned<"+"> (*) ["-"] - // - // "-" -> Reduce(Items = Items, Spanned<"+"> => Call(ActionFn(2));) - // "+" -> Reduce(Items = Items, Spanned<"+"> => Call(ActionFn(2));) - // EOF -> Reduce(Items = Items, Spanned<"+"> => Call(ActionFn(2));) - // - pub fn __state3< - __TOKENS: Iterator, - >( - __lookbehind: Option, - __lookahead: Option<(usize,Tok,usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option, Option)>>, - __sym1: &mut Option<(Option, 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::__actions::__action2(__sym0, __sym1); - return Ok((__lookbehind, __lookahead, __Nonterminal::Items(__nt))); - } - Some((_, Tok::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __nt = super::__actions::__action2(__sym0, __sym1); - return Ok((__lookbehind, __lookahead, __Nonterminal::Items(__nt))); - } - None => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __nt = super::__actions::__action2(__sym0, __sym1); - return Ok((__lookbehind, __lookahead, __Nonterminal::Items(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 4 - // Items = Items "-" (*) [EOF] - // Items = Items "-" (*) ["+"] - // Items = Items "-" (*) ["-"] - // - // EOF -> Reduce(Items = Items, "-" => Call(ActionFn(3));) - // "+" -> Reduce(Items = Items, "-" => Call(ActionFn(3));) - // "-" -> Reduce(Items = Items, "-" => Call(ActionFn(3));) - // - pub fn __state4< - __TOKENS: Iterator, - >( - __lookbehind: Option, - __lookahead: Option<(usize,Tok,usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option, 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::__actions::__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::__actions::__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::__actions::__action3(__sym0, __sym1); - return Ok((__lookbehind, __lookahead, __Nonterminal::Items(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - // State 5 // @> = (*) [EOF] // @> = (*) ["+"] @@ -336,8 +336,8 @@ mod __parse__Items { // Spanned<"+"> = @< "+" @> (*) ["+"] // Spanned<"+"> = @< "+" @> (*) ["-"] // - // EOF -> Reduce(Spanned<"+"> = @<, "+", @> => Call(ActionFn(4));) // "-" -> Reduce(Spanned<"+"> = @<, "+", @> => Call(ActionFn(4));) + // EOF -> Reduce(Spanned<"+"> = @<, "+", @> => Call(ActionFn(4));) // "+" -> Reduce(Spanned<"+"> = @<, "+", @> => Call(ActionFn(4));) // pub fn __state6< @@ -353,14 +353,14 @@ mod __parse__Items { { let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<>); match __lookahead { - None => { + Some((_, Tok::Minus(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); let __nt = super::__actions::__action4(__sym0, __sym1, __sym2); return Ok((__lookbehind, __lookahead, __Nonterminal::Spanned_3c_22_2b_22_3e(__nt))); } - Some((_, Tok::Minus(..), _)) => { + None => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); diff --git a/lalrpop-test/src/sub.rs b/lalrpop-test/src/sub.rs index 20073dc..8687aba 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), - T(i32), - S(i32), E(i32), + S(i32), + T(i32), } // State 0 @@ -40,12 +40,12 @@ mod __parse__S { // T = (*) "Num" ["-"] // __S = (*) S [EOF] // - // "Num" -> Shift(S1) // "(" -> Shift(S5) + // "Num" -> Shift(S2) // - // T -> S4 - // S -> S2 - // E -> S3 + // T -> S1 + // S -> S3 + // E -> S4 pub fn __state0< __TOKENS: Iterator, >( @@ -56,18 +56,18 @@ 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!(__state1(__lookbehind, __lookahead, __tokens, __sym0)); - } Some(__tok @ Tok::LParen(..)) => { let mut __lookbehind = None; let mut __sym0 = &mut Some((__tok)); let __lookahead = __tokens.next(); __result = try!(__state5(__lookbehind, __lookahead, __tokens, __sym0)); } + Some(Tok::Num(__tok0)) => { + let mut __lookbehind = None; + let mut __sym0 = &mut Some((__tok0)); + let __lookahead = __tokens.next(); + __result = try!(__state2(__lookbehind, __lookahead, __tokens, __sym0)); + } _ => { return Err(__lookahead); } @@ -77,15 +77,15 @@ mod __parse__S { match __nt { __Nonterminal::T(__nt) => { let __sym0 = &mut Some(__nt); - __result = try!(__state4(__lookbehind, __lookahead, __tokens, __sym0)); + __result = try!(__state1(__lookbehind, __lookahead, __tokens, __sym0)); } __Nonterminal::S(__nt) => { let __sym0 = &mut Some(__nt); - __result = try!(__state2(__lookbehind, __lookahead, __tokens, __sym0)); + __result = try!(__state3(__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)); } _ => { return Ok((__lookbehind, __lookahead, __nt)); @@ -95,13 +95,47 @@ mod __parse__S { } // State 1 + // E = T (*) [EOF] + // E = T (*) ["-"] + // + // EOF -> Reduce(E = T => Call(ActionFn(3));) + // "-" -> 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 { + None => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action3(__sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::E(__nt))); + } + Some(Tok::Minus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action3(__sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::E(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 2 // T = "Num" (*) [EOF] // T = "Num" (*) ["-"] // // EOF -> Reduce(T = "Num" => Call(ActionFn(4));) // "-" -> Reduce(T = "Num" => Call(ActionFn(4));) // - pub fn __state1< + pub fn __state2< __TOKENS: Iterator, >( __lookbehind: Option<()>, @@ -128,12 +162,12 @@ mod __parse__S { } } - // State 2 + // State 3 // __S = S (*) [EOF] // // EOF -> Reduce(__S = S => Call(ActionFn(0));) // - pub fn __state2< + pub fn __state3< __TOKENS: Iterator, >( __lookbehind: Option<()>, @@ -155,15 +189,15 @@ mod __parse__S { } } - // State 3 + // State 4 // E = E (*) "-" T [EOF] // E = E (*) "-" T ["-"] // S = E (*) [EOF] // - // "-" -> Shift(S6) // EOF -> Reduce(S = E => Call(ActionFn(1));) + // "-" -> Shift(S6) // - pub fn __state3< + pub fn __state4< __TOKENS: Iterator, >( __lookbehind: Option<()>, @@ -192,40 +226,6 @@ mod __parse__S { return Ok(__result); } - // State 4 - // E = T (*) [EOF] - // E = T (*) ["-"] - // - // "-" -> Reduce(E = T => Call(ActionFn(3));) - // EOF -> Reduce(E = T => Call(ActionFn(3));) - // - 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::Minus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action3(__sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::E(__nt))); - } - None => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action3(__sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::E(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - // State 5 // E = (*) E "-" T [")"] // E = (*) E "-" T ["-"] @@ -238,11 +238,11 @@ mod __parse__S { // T = (*) "Num" [")"] // T = (*) "Num" ["-"] // - // "Num" -> Shift(S9) - // "(" -> Shift(S10) + // "Num" -> Shift(S8) + // "(" -> Shift(S9) // - // E -> S8 - // T -> S7 + // E -> S7 + // T -> S10 pub fn __state5< __TOKENS: Iterator, >( @@ -258,13 +258,13 @@ mod __parse__S { let mut __lookbehind = None; let mut __sym1 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state9(__lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state8(__lookbehind, __lookahead, __tokens, __sym1)); } Some(__tok @ Tok::LParen(..)) => { let mut __lookbehind = None; let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state10(__lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state9(__lookbehind, __lookahead, __tokens, __sym1)); } _ => { return Err(__lookahead); @@ -275,11 +275,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!(__state10(__lookbehind, __lookahead, __tokens, __sym1)); } _ => { return Ok((__lookbehind, __lookahead, __nt)); @@ -297,8 +297,8 @@ mod __parse__S { // T = (*) "Num" [EOF] // T = (*) "Num" ["-"] // - // "Num" -> Shift(S1) // "(" -> Shift(S5) + // "Num" -> Shift(S2) // // T -> S11 pub fn __state6< @@ -313,18 +313,18 @@ mod __parse__S { { let mut __result: (Option<()>, Option, __Nonterminal<>); match __lookahead { - Some(Tok::Num(__tok0)) => { - let mut __lookbehind = None; - let mut __sym2 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state1(__lookbehind, __lookahead, __tokens, __sym2)); - } Some(__tok @ Tok::LParen(..)) => { let mut __lookbehind = None; let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); __result = try!(__state5(__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(__lookbehind, __lookahead, __tokens, __sym2)); + } _ => { return Err(__lookahead); } @@ -345,49 +345,15 @@ mod __parse__S { } // State 7 - // E = T (*) [")"] - // E = T (*) ["-"] - // - // "-" -> Reduce(E = T => Call(ActionFn(3));) - // ")" -> Reduce(E = T => Call(ActionFn(3));) - // - pub fn __state7< - __TOKENS: Iterator, - >( - __lookbehind: Option<()>, - __lookahead: Option, - __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::__actions::__action3(__sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::E(__nt))); - } - Some(Tok::RParen(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action3(__sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::E(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 8 // E = E (*) "-" T [")"] // E = E (*) "-" T ["-"] // T = "(" E (*) ")" [EOF] // T = "(" E (*) ")" ["-"] // - // ")" -> Shift(S13) // "-" -> Shift(S12) + // ")" -> Shift(S13) // - pub fn __state8< + pub fn __state7< __TOKENS: Iterator, >( __lookbehind: Option<()>, @@ -399,18 +365,18 @@ mod __parse__S { { let mut __result: (Option<()>, Option, __Nonterminal<>); match __lookahead { - 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)); - } Some(__tok @ Tok::Minus(..)) => { let mut __lookbehind = None; let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); __result = try!(__state12(__lookbehind, __lookahead, __tokens, __sym1, __sym2)); } + Some(__tok @ Tok::RParen(..)) => { + let mut __lookbehind = None; + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state13(__lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } _ => { return Err(__lookahead); } @@ -418,14 +384,14 @@ mod __parse__S { return Ok(__result); } - // State 9 + // State 8 // T = "Num" (*) [")"] // T = "Num" (*) ["-"] // // ")" -> Reduce(T = "Num" => Call(ActionFn(4));) // "-" -> Reduce(T = "Num" => Call(ActionFn(4));) // - pub fn __state9< + pub fn __state8< __TOKENS: Iterator, >( __lookbehind: Option<()>, @@ -452,7 +418,7 @@ mod __parse__S { } } - // State 10 + // State 9 // E = (*) E "-" T [")"] // E = (*) E "-" T ["-"] // E = (*) T [")"] @@ -464,12 +430,12 @@ mod __parse__S { // T = (*) "Num" [")"] // T = (*) "Num" ["-"] // - // "(" -> Shift(S10) - // "Num" -> Shift(S9) + // "(" -> Shift(S9) + // "Num" -> Shift(S8) // // E -> S14 - // T -> S7 - pub fn __state10< + // T -> S10 + pub fn __state9< __TOKENS: Iterator, >( __lookbehind: Option<()>, @@ -484,13 +450,13 @@ mod __parse__S { let mut __lookbehind = None; let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state10(__lookbehind, __lookahead, __tokens, __sym1)); + __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!(__state9(__lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state8(__lookbehind, __lookahead, __tokens, __sym1)); } _ => { return Err(__lookahead); @@ -505,7 +471,7 @@ mod __parse__S { } __Nonterminal::T(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state7(__lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state10(__lookbehind, __lookahead, __tokens, __sym1)); } _ => { return Ok((__lookbehind, __lookahead, __nt)); @@ -515,6 +481,40 @@ mod __parse__S { return Ok(__result); } + // State 10 + // E = T (*) [")"] + // E = T (*) ["-"] + // + // ")" -> Reduce(E = T => Call(ActionFn(3));) + // "-" -> Reduce(E = T => Call(ActionFn(3));) + // + pub fn __state10< + __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::RParen(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action3(__sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::E(__nt))); + } + Some(Tok::Minus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action3(__sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::E(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + // State 11 // E = E "-" T (*) [EOF] // E = E "-" T (*) ["-"] @@ -563,8 +563,8 @@ mod __parse__S { // T = (*) "Num" [")"] // T = (*) "Num" ["-"] // - // "(" -> Shift(S10) - // "Num" -> Shift(S9) + // "(" -> Shift(S9) + // "Num" -> Shift(S8) // // T -> S15 pub fn __state12< @@ -583,13 +583,13 @@ mod __parse__S { let mut __lookbehind = None; let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state10(__lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state9(__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)); + __result = try!(__state8(__lookbehind, __lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); @@ -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::RParen(..)) => { + Some(Tok::Minus(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); let __nt = super::__actions::__action5(__sym0, __sym1, __sym2); return Ok((__lookbehind, __lookahead, __Nonterminal::T(__nt))); } - Some(Tok::Minus(..)) => { + Some(Tok::RParen(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); diff --git a/lalrpop-test/src/util/lalrpop_tok.rs b/lalrpop-test/src/util/lalrpop_tok.rs new file mode 100644 index 0000000..82cad1e --- /dev/null +++ b/lalrpop-test/src/util/lalrpop_tok.rs @@ -0,0 +1,455 @@ +use std::str::CharIndices; + +use self::Error::*; +use self::Tok::*; + +pub enum Error { + UnrecognizedToken(usize), + UnterminatedEscape(usize), + UnterminatedStringLiteral(usize), + UnterminatedCode(usize), +} + +#[derive(Clone, Debug)] +pub enum Tok<'input> { + // Keywords; + Enum, + Extern, + Grammar, + If, + Mut, + Pub, + Token, + Use, + Where, + + // Identifiers of various kinds: + Escape(&'input str), + Id(&'input str), + MacroId(&'input str), // identifier followed immediately by `<` + Lifetime(&'input str), // includes the `'` + StringLiteral(&'input str), // excludes the `"` + + // Symbols: + Ampersand, + BangEquals, + BangTilde, + Colon, + ColonColon, + Comma, + DotDot, + Equals, + EqualsEquals, + EqualsGreaterThanCode(&'input str), + EqualsGreaterThanLookahead, + EqualsGreaterThanLookbehind, + GreaterThan, + LeftBrace, + LeftBracket, + LeftParen, + LessThan, + Lookahead, // @< + Lookbehind, // @> + Plus, + Question, + RightBrace, + RightBracket, + RightParen, + Semi, + Star, + TildeTilde, + Underscore, +} + +struct Tokenizer<'input> { + text: &'input str, + chars: CharIndices<'input>, + lookahead: Option<(usize, char)>, +} + +macro_rules! eof { + ($x:expr) => { + match $x { Some(v) => v, None => { return None; } } + } +} + +type Spanned = (usize, T, usize); + +const KEYWORDS: &'static [(&'static str, Tok<'static>)] = &[ + ("enum", Enum), + ("extern", Extern), + ("grammar", Grammar), + ("if", If), + ("mut", Mut), + ("pub", Pub), + ("token", Token), + ("use", Use), + ("where", Where), +]; + +impl<'input> Tokenizer<'input> { + fn bump(&mut self) -> Option<(usize, char)> { + self.lookahead = self.chars.next(); + self.lookahead + } + + fn right_arrow(&mut self, idx0: usize) -> Result>, Error> { + // we've seen =>, now we have to choose between: + // + // => code + // =>@< + // =>@> + + let idx1 = match self.lookahead { + Some((_, '@')) => { + match self.bump() { + Some((idx2, '<')) => { + self.bump(); + return Ok((idx0, EqualsGreaterThanLookahead, idx2+1)); + } + Some((idx2, '>')) => { + self.bump(); + return Ok((idx0, EqualsGreaterThanLookbehind, idx2+1)); + } + _ => { + return Err(UnrecognizedToken(idx0)); + } + } + } + + None => { + return Err(UnterminatedCode(idx0)); + } + + Some((idx1, _)) => { idx1 } + }; + + // This is the interesting case. To find the end of the code, + // we have to scan ahead, matching (), [], and {}, and looking + // for a suitable terminator: `,`, `;`, `]`, `}`, or `)`. + let mut balance = 0; // number of unclosed `(` etc + loop { + match self.lookahead { + Some((_, '(')) | + Some((_, '[')) | + Some((_, '{')) => { + balance += 1; + } + + Some((_, ')')) | + Some((_, ']')) | + Some((_, '}')) if balance > 0 => { + balance -= 1; + } + + None if balance == 0 => { + // Note: we do not consume the + // terminator. The code is everything *up + // to but not including* the terminating + // `,`, `;`, etc. + let code = &self.text[idx1..]; + return Ok((idx0, EqualsGreaterThanCode(code), self.text.len())); + } + + Some((idx2, ';')) | + Some((idx2, ',')) | + Some((idx2, ')')) | + Some((idx2, ']')) | + Some((idx2, '}')) if balance == 0 => { + // Note: we do not consume the + // terminator. The code is everything *up + // to but not including* the terminating + // `,`, `;`, etc. + let code = &self.text[idx1..idx2]; + return Ok((idx0, EqualsGreaterThanCode(code), idx2)); + } + + None if balance > 0 => { + // the input should not end with an + // unbalanced number of `{` etc! + return Err(UnterminatedCode(idx0)); + } + + _ => { } + } + + self.bump(); + } + } + + fn escape(&mut self, idx0: usize) -> Result>, Error> { + match self.take_until(|c| c == '`') { + Some(idx1) => { + self.bump(); // consume the '`' + let text: &'input str = &self.text[idx0+1..idx1]; // do not include the `` in the str + Ok((idx0, Escape(text), idx1)) + } + None => { + Err(UnterminatedEscape(idx0)) + } + } + } + + fn string_literal(&mut self, idx0: usize) -> Result>, Error> { + let mut escape = false; + let terminate = |c: char| { + if escape { + escape = false; + false + } else if c == '\\' { + escape = true; + false + } else if c == '"' { + true + } else { + false + } + }; + match self.take_until(terminate) { + Some(idx1) => { + self.bump(); // consume the '"' + let text = &self.text[idx0+1..idx1]; // do not include the `` in the str + Ok((idx0, StringLiteral(text), idx1)) + } + None => { + Err(UnterminatedStringLiteral(idx0)) + } + } + } + + fn lifetime(&mut self, idx0: usize) -> Spanned> { + let (start, word, end) = self.word(idx0); + (start, Lifetime(word), end) + } + + fn identifierish(&mut self, idx0: usize) -> Spanned> { + let (start, word, end) = self.word(idx0); + + let tok = + // search for a keyword first; if none are found, this is + // either a MacroId or an Id, depending on whether there + // is a `<` immediately afterwards + KEYWORDS.iter() + .filter(|&&(w, _)| w == word) + .map(|&(_, ref t)| t.clone()) + .next() + .unwrap_or_else(|| { + match self.lookahead { + Some((_, '<')) => MacroId(word), + _ => Id(word), + } + }); + + (start, tok, end) + } + + fn word(&mut self, idx0: usize) -> Spanned<&'input str> { + match self.take_while(is_identifier_continue) { + Some(end) => (idx0, &self.text[idx0..end], end), + None => (idx0, &self.text[idx0..], self.text.len()), + } + } + + fn take_while(&mut self, mut keep_going: F) -> Option + where F: FnMut(char) -> bool + { + self.take_until(|c| !keep_going(c)) + } + + fn take_until(&mut self, mut terminate: F) -> Option + where F: FnMut(char) -> bool + { + loop { + match self.lookahead { + None => { + return None; + } + Some((idx1, c)) => { + if terminate(c) { + return Some(idx1); + } else { + self.bump(); + } + } + } + } + } +} + +impl<'input> Iterator for Tokenizer<'input> { + type Item = Result>, Error>; + + fn next(&mut self) -> Option>, Error>> { + match self.lookahead { + Some((idx0, '&')) => { + self.bump(); + Some(Ok((idx0, Ampersand, idx0+1))) + } + Some((idx0, '!')) => { + match self.bump() { + Some((idx1, '=')) => { + self.bump(); + Some(Ok((idx0, BangEquals, idx1+1))) + } + Some((idx1, '~')) => { + self.bump(); + Some(Ok((idx0, BangTilde, idx1+1))) + } + _ => { + Some(Err(UnrecognizedToken(idx0))) + } + } + } + Some((idx0, ':')) => { + match self.bump() { + Some((idx1, ':')) => { + self.bump(); + Some(Ok((idx0, ColonColon, idx1+1))) + } + _ => { + Some(Ok((idx0, Colon, idx0+1))) + } + } + } + Some((idx0, ',')) => { + self.bump(); + Some(Ok((idx0, Comma, idx0+1))) + } + Some((idx0, '.')) => { + match self.bump() { + Some((idx1, '.')) => { + self.bump(); + Some(Ok((idx0, DotDot, idx1+1))) + } + _ => { + Some(Err(UnrecognizedToken(idx0))) + } + } + } + Some((idx0, '=')) => { + match self.bump() { + Some((idx1, '=')) => { + self.bump(); + Some(Ok((idx0, EqualsEquals, idx1+1))) + } + Some((_, '>')) => { + self.bump(); + Some(self.right_arrow(idx0)) + } + _ => { + Some(Ok((idx0, Equals, idx0+1))) + } + } + } + Some((idx0, '>')) => { + self.bump(); + Some(Ok((idx0, GreaterThan, idx0+1))) + } + Some((idx0, '{')) => { + self.bump(); + Some(Ok((idx0, LeftBrace, idx0+1))) + } + Some((idx0, '[')) => { + self.bump(); + Some(Ok((idx0, LeftBracket, idx0+1))) + } + Some((idx0, '(')) => { + self.bump(); + Some(Ok((idx0, LeftParen, idx0+1))) + } + Some((idx0, '<')) => { + self.bump(); + Some(Ok((idx0, LessThan, idx0+1))) + } + Some((idx0, '@')) => { + match self.bump() { + Some((idx1, '<')) => { + self.bump(); + Some(Ok((idx0, Lookahead, idx1+1))) + } + Some((idx1, '>')) => { + self.bump(); + Some(Ok((idx0, Lookbehind, idx1+1))) + } + _ => { + Some(Err(UnrecognizedToken(idx0))) + } + } + } + Some((idx0, '+')) => { + self.bump(); + Some(Ok((idx0, Plus, idx0+1))) + } + Some((idx0, '?')) => { + self.bump(); + Some(Ok((idx0, Question, idx0+1))) + } + Some((idx0, '}')) => { + self.bump(); + Some(Ok((idx0, RightBrace, idx0+1))) + } + Some((idx0, ']')) => { + self.bump(); + Some(Ok((idx0, RightBracket, idx0+1))) + } + Some((idx0, ')')) => { + self.bump(); + Some(Ok((idx0, RightParen, idx0+1))) + } + Some((idx0, ';')) => { + self.bump(); + Some(Ok((idx0, Semi, idx0+1))) + } + Some((idx0, '*')) => { + self.bump(); + Some(Ok((idx0, Star, idx0+1))) + } + Some((idx0, '~')) => { + match self.bump() { + Some((idx1, '~')) => { + self.bump(); + Some(Ok((idx0, TildeTilde, idx1+1))) + } + _ => { + Some(Err(UnrecognizedToken(idx0))) + } + } + } + Some((idx0, '_')) => { + self.bump(); + Some(Ok((idx0, Underscore, idx0+1))) + } + Some((idx0, '`')) => { + self.bump(); + Some(self.escape(idx0)) + } + Some((idx0, '\'')) => { + self.bump(); + Some(Ok(self.lifetime(idx0))) + } + Some((idx0, '"')) => { + self.bump(); + Some(self.string_literal(idx0)) + } + Some((idx0, c)) if is_identifier_start(c) => { + Some(Ok(self.identifierish(idx0))) + } + Some((idx, _)) => { + Some(Err(UnrecognizedToken(idx))) + } + None => { + None + } + } + } +} + +fn is_identifier_start(c: char) -> bool { + // for some reason c.is_xid_start() is not stable :( + c.is_alphabetic() || c == '_' +} + +fn is_identifier_continue(c: char) -> bool { + // for some reason c.is_xid_continue() is not stable :( + c.is_alphabetic() || c == '_' || c.is_digit(10) +} diff --git a/lalrpop-test/src/util/mod.rs b/lalrpop-test/src/util/mod.rs index 3c4380e..9912924 100644 --- a/lalrpop-test/src/util/mod.rs +++ b/lalrpop-test/src/util/mod.rs @@ -5,6 +5,7 @@ use util::tok::Tok; // a simple tokenizer pub mod tok; +pub mod lalrpop_tok; pub fn test(parse_fn: F, input: &str,