From 4c74cc6873cb37305d9091c1dd6c502293e5882e Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Sun, 19 Jul 2015 14:03:00 -0400 Subject: [PATCH] Move the LALRPOP tokenizer into lalrpop itself; rename the existing token to lexer; add a few more tests and fix a bug in `test` --- lalrpop-test/src/expr.rs | 1844 +++--- lalrpop-test/src/expr_arena.rs | 4926 ++++++++--------- lalrpop-test/src/loc.rs | 100 +- lalrpop-test/src/sub.rs | 266 +- lalrpop-test/src/util/mod.rs | 1 - lalrpop/src/{token => lexer}/dfa/interpret.rs | 4 +- lalrpop/src/{token => lexer}/dfa/mod.rs | 4 +- lalrpop/src/{token => lexer}/dfa/test.rs | 6 +- lalrpop/src/{token => lexer}/mod.rs | 3 +- lalrpop/src/{token => lexer}/nfa/interpret.rs | 4 +- lalrpop/src/{token => lexer}/nfa/mod.rs | 2 +- lalrpop/src/{token => lexer}/nfa/test.rs | 6 +- lalrpop/src/{token => lexer}/re/mod.rs | 0 lalrpop/src/{token => lexer}/re/test.rs | 0 lalrpop/src/lib.rs | 3 +- .../lalrpop_tok.rs => lalrpop/src/tok/mod.rs | 333 +- lalrpop/src/tok/test.rs | 65 + 17 files changed, 3832 insertions(+), 3735 deletions(-) rename lalrpop/src/{token => lexer}/dfa/interpret.rs (94%) rename lalrpop/src/{token => lexer}/dfa/mod.rs (99%) rename lalrpop/src/{token => lexer}/dfa/test.rs (92%) rename lalrpop/src/{token => lexer}/mod.rs (51%) rename lalrpop/src/{token => lexer}/nfa/interpret.rs (96%) rename lalrpop/src/{token => lexer}/nfa/mod.rs (99%) rename lalrpop/src/{token => lexer}/nfa/test.rs (94%) rename lalrpop/src/{token => lexer}/re/mod.rs (100%) rename lalrpop/src/{token => lexer}/re/test.rs (100%) rename lalrpop-test/src/util/lalrpop_tok.rs => lalrpop/src/tok/mod.rs (56%) create mode 100644 lalrpop/src/tok/test.rs diff --git a/lalrpop-test/src/expr.rs b/lalrpop-test/src/expr.rs index 36a3c5a..4df5a7c 100644 --- a/lalrpop-test/src/expr.rs +++ b/lalrpop-test/src/expr.rs @@ -23,9 +23,9 @@ mod __parse__Expr { use util::tok::Tok; pub enum __Nonterminal<> { - Term(i32), - Factor(i32), ____Expr(i32), + Factor(i32), + Term(i32), Expr(i32), } @@ -66,12 +66,12 @@ mod __parse__Expr { // Term = (*) "Num" ["/"] // __Expr = (*) Expr [EOF] // - // "(" -> Shift(S2) - // "Num" -> Shift(S5) + // "Num" -> Shift(S3) + // "(" -> Shift(S5) // - // Expr -> S4 - // Factor -> S1 - // Term -> S3 + // Factor -> S4 + // Expr -> S1 + // Term -> S2 pub fn __state0< __TOKENS: Iterator, >( @@ -83,16 +83,16 @@ mod __parse__Expr { { let mut __result: (Option<()>, Option, __Nonterminal<>); match __lookahead { - Some(__tok @ Tok::LParen(..)) => { - let mut __lookbehind = None; - let mut __sym0 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__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!(__state3(scale, __lookbehind, __lookahead, __tokens, __sym0)); + } + Some(__tok @ Tok::LParen(..)) => { + let mut __lookbehind = None; + let mut __sym0 = &mut Some((__tok)); + let __lookahead = __tokens.next(); __result = try!(__state5(scale, __lookbehind, __lookahead, __tokens, __sym0)); } _ => { @@ -102,17 +102,17 @@ mod __parse__Expr { loop { let (__lookbehind, __lookahead, __nt) = __result; match __nt { - __Nonterminal::Expr(__nt) => { + __Nonterminal::Factor(__nt) => { let __sym0 = &mut Some(__nt); __result = try!(__state4(scale, __lookbehind, __lookahead, __tokens, __sym0)); } - __Nonterminal::Factor(__nt) => { + __Nonterminal::Expr(__nt) => { let __sym0 = &mut Some(__nt); __result = try!(__state1(scale, __lookbehind, __lookahead, __tokens, __sym0)); } __Nonterminal::Term(__nt) => { let __sym0 = &mut Some(__nt); - __result = try!(__state3(scale, __lookbehind, __lookahead, __tokens, __sym0)); + __result = try!(__state2(scale, __lookbehind, __lookahead, __tokens, __sym0)); } _ => { return Ok((__lookbehind, __lookahead, __nt)); @@ -122,6 +122,167 @@ mod __parse__Expr { } // State 1 + // Expr = Expr (*) "+" Factor [EOF] + // Expr = Expr (*) "+" Factor ["+"] + // Expr = Expr (*) "+" Factor ["-"] + // Expr = Expr (*) "-" Factor [EOF] + // Expr = Expr (*) "-" Factor ["+"] + // Expr = Expr (*) "-" Factor ["-"] + // __Expr = Expr (*) [EOF] + // + // EOF -> Reduce(__Expr = Expr => Call(ActionFn(0));) + // "+" -> Shift(S7) + // "-" -> Shift(S6) + // + 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 @ Tok::Plus(..)) => { + 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 @ Tok::Minus(..)) => { + let mut __lookbehind = None; + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state6(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 2 + // Factor = Term (*) [EOF] + // Factor = Term (*) ["*"] + // Factor = Term (*) ["+"] + // Factor = Term (*) ["-"] + // Factor = Term (*) ["/"] + // + // "-" -> 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));) + // + pub fn __state2< + __TOKENS: Iterator, + >( + scale: i32, + __lookbehind: Option<()>, + __lookahead: Option, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + ) -> Result<(Option<()>, Option, __Nonterminal<>), Option> + { + let mut __result: (Option<()>, Option, __Nonterminal<>); + match __lookahead { + Some(Tok::Minus(..)) => { + 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::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))); + } + 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 3 + // Term = "Num" (*) [EOF] + // Term = "Num" (*) ["*"] + // Term = "Num" (*) ["+"] + // Term = "Num" (*) ["-"] + // Term = "Num" (*) ["/"] + // + // "/" -> Reduce(Term = "Num" => Call(ActionFn(7));) + // "*" -> Reduce(Term = "Num" => Call(ActionFn(7));) + // "-" -> Reduce(Term = "Num" => Call(ActionFn(7));) + // "+" -> Reduce(Term = "Num" => Call(ActionFn(7));) + // EOF -> Reduce(Term = "Num" => Call(ActionFn(7));) + // + 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::Div(..)) => { + 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))); + } + Some(Tok::Minus(..)) => { + 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))); + } + None => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action7(scale, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 4 // Expr = Factor (*) [EOF] // Expr = Factor (*) ["+"] // Expr = Factor (*) ["-"] @@ -136,13 +297,13 @@ mod __parse__Expr { // Factor = Factor (*) "/" Term ["-"] // Factor = Factor (*) "/" Term ["/"] // - // "-" -> Reduce(Expr = Factor => Call(ActionFn(3));) - // "*" -> Shift(S6) // EOF -> Reduce(Expr = Factor => Call(ActionFn(3));) - // "/" -> Shift(S7) + // "*" -> Shift(S8) + // "/" -> Shift(S9) // "+" -> Reduce(Expr = Factor => Call(ActionFn(3));) + // "-" -> Reduce(Expr = Factor => Call(ActionFn(3));) // - pub fn __state1< + pub fn __state4< __TOKENS: Iterator, >( scale: i32, @@ -158,18 +319,13 @@ mod __parse__Expr { let mut __lookbehind = None; let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state6(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + __result = try!(__state8(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); } Some(__tok @ Tok::Div(..)) => { let mut __lookbehind = None; let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state7(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!(__state9(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); } None => { let __sym0 = __sym0.take().unwrap(); @@ -181,6 +337,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); } @@ -188,7 +349,7 @@ mod __parse__Expr { return Ok(__result); } - // State 2 + // State 5 // Expr = (*) Expr "+" Factor [")"] // Expr = (*) Expr "+" Factor ["+"] // Expr = (*) Expr "+" Factor ["-"] @@ -229,13 +390,13 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "(" -> Shift(S11) - // "Num" -> Shift(S9) + // "(" -> Shift(S13) + // "Num" -> Shift(S10) // - // Expr -> S12 - // Term -> S10 - // Factor -> S8 - pub fn __state2< + // Term -> S12 + // Factor -> S11 + // Expr -> S14 + pub fn __state5< __TOKENS: Iterator, >( scale: i32, @@ -251,13 +412,13 @@ mod __parse__Expr { let mut __lookbehind = None; let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state11(scale, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state13(scale, __lookbehind, __lookahead, __tokens, __sym1)); } Some(Tok::Num(__tok0)) => { let mut __lookbehind = None; let mut __sym1 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state9(scale, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state10(scale, __lookbehind, __lookahead, __tokens, __sym1)); } _ => { return Err(__lookahead); @@ -266,17 +427,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!(__state10(scale, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state12(scale, __lookbehind, __lookahead, __tokens, __sym1)); } __Nonterminal::Factor(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state8(scale, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state11(scale, __lookbehind, __lookahead, __tokens, __sym1)); + } + __Nonterminal::Expr(__nt) => { + let __sym1 = &mut Some(__nt); + __result = try!(__state14(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); } _ => { return Ok((__lookbehind, __lookahead, __nt)); @@ -286,173 +447,25 @@ mod __parse__Expr { return Ok(__result); } - // 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));) - // - 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, - >( - scale: i32, - __lookbehind: Option<()>, - __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - ) -> Result<(Option<()>, Option, __Nonterminal<>), Option> - { - let mut __result: (Option<()>, Option, __Nonterminal<>); - match __lookahead { - None => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__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))); - } - 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); - } - } - } - // State 6 - // Factor = Factor "*" (*) Term [EOF] - // Factor = Factor "*" (*) Term ["*"] - // Factor = Factor "*" (*) Term ["+"] - // Factor = Factor "*" (*) Term ["-"] - // Factor = Factor "*" (*) Term ["/"] + // Expr = Expr "-" (*) Factor [EOF] + // Expr = Expr "-" (*) Factor ["+"] + // Expr = Expr "-" (*) Factor ["-"] + // Factor = (*) Factor "*" Term [EOF] + // Factor = (*) Factor "*" Term ["*"] + // Factor = (*) Factor "*" Term ["+"] + // Factor = (*) Factor "*" Term ["-"] + // Factor = (*) Factor "*" Term ["/"] + // Factor = (*) Factor "/" Term [EOF] + // Factor = (*) Factor "/" Term ["*"] + // Factor = (*) Factor "/" Term ["+"] + // Factor = (*) Factor "/" Term ["-"] + // Factor = (*) Factor "/" Term ["/"] + // Factor = (*) Term [EOF] + // Factor = (*) Term ["*"] + // Factor = (*) Term ["+"] + // Factor = (*) Term ["-"] + // Factor = (*) Term ["/"] // Term = (*) "(" Expr ")" [EOF] // Term = (*) "(" Expr ")" ["*"] // Term = (*) "(" Expr ")" ["+"] @@ -464,10 +477,11 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "Num" -> Shift(S5) - // "(" -> Shift(S2) + // "Num" -> Shift(S3) + // "(" -> Shift(S5) // - // Term -> S15 + // Factor -> S15 + // Term -> S2 pub fn __state6< __TOKENS: Iterator, >( @@ -485,13 +499,13 @@ mod __parse__Expr { let mut __lookbehind = None; let mut __sym2 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state5(scale, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state3(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)); + __result = try!(__state5(scale, __lookbehind, __lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); @@ -500,10 +514,14 @@ mod __parse__Expr { while __sym1.is_some() { let (__lookbehind, __lookahead, __nt) = __result; match __nt { - __Nonterminal::Term(__nt) => { + __Nonterminal::Factor(__nt) => { let __sym2 = &mut Some(__nt); __result = try!(__state15(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); } + __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state2(scale, __lookbehind, __lookahead, __tokens, __sym2)); + } _ => { return Ok((__lookbehind, __lookahead, __nt)); } @@ -513,6 +531,154 @@ mod __parse__Expr { } // State 7 + // Expr = Expr "+" (*) Factor [EOF] + // Expr = Expr "+" (*) Factor ["+"] + // Expr = Expr "+" (*) Factor ["-"] + // Factor = (*) Factor "*" Term [EOF] + // Factor = (*) Factor "*" Term ["*"] + // Factor = (*) Factor "*" Term ["+"] + // Factor = (*) Factor "*" Term ["-"] + // Factor = (*) Factor "*" Term ["/"] + // Factor = (*) Factor "/" Term [EOF] + // Factor = (*) Factor "/" Term ["*"] + // Factor = (*) Factor "/" Term ["+"] + // Factor = (*) Factor "/" Term ["-"] + // Factor = (*) Factor "/" Term ["/"] + // Factor = (*) Term [EOF] + // Factor = (*) Term ["*"] + // Factor = (*) Term ["+"] + // Factor = (*) Term ["-"] + // Factor = (*) Term ["/"] + // Term = (*) "(" Expr ")" [EOF] + // Term = (*) "(" Expr ")" ["*"] + // Term = (*) "(" Expr ")" ["+"] + // Term = (*) "(" Expr ")" ["-"] + // Term = (*) "(" Expr ")" ["/"] + // Term = (*) "Num" [EOF] + // Term = (*) "Num" ["*"] + // Term = (*) "Num" ["+"] + // Term = (*) "Num" ["-"] + // Term = (*) "Num" ["/"] + // + // "(" -> Shift(S5) + // "Num" -> Shift(S3) + // + // Term -> S2 + // Factor -> S16 + pub fn __state7< + __TOKENS: Iterator, + >( + scale: i32, + __lookbehind: Option<()>, + __lookahead: Option, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + __sym1: &mut Option, + ) -> Result<(Option<()>, Option, __Nonterminal<>), Option> + { + let mut __result: (Option<()>, Option, __Nonterminal<>); + match __lookahead { + Some(__tok @ Tok::LParen(..)) => { + let mut __lookbehind = None; + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state5(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!(__state3(scale, __lookbehind, __lookahead, __tokens, __sym2)); + } + _ => { + return Err(__lookahead); + } + } + while __sym1.is_some() { + let (__lookbehind, __lookahead, __nt) = __result; + match __nt { + __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state2(scale, __lookbehind, __lookahead, __tokens, __sym2)); + } + __Nonterminal::Factor(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state16(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + _ => { + return Ok((__lookbehind, __lookahead, __nt)); + } + } + } + return Ok(__result); + } + + // State 8 + // Factor = Factor "*" (*) Term [EOF] + // Factor = Factor "*" (*) Term ["*"] + // Factor = Factor "*" (*) Term ["+"] + // Factor = Factor "*" (*) Term ["-"] + // Factor = Factor "*" (*) Term ["/"] + // Term = (*) "(" Expr ")" [EOF] + // Term = (*) "(" Expr ")" ["*"] + // Term = (*) "(" Expr ")" ["+"] + // Term = (*) "(" Expr ")" ["-"] + // Term = (*) "(" Expr ")" ["/"] + // Term = (*) "Num" [EOF] + // Term = (*) "Num" ["*"] + // Term = (*) "Num" ["+"] + // Term = (*) "Num" ["-"] + // Term = (*) "Num" ["/"] + // + // "(" -> Shift(S5) + // "Num" -> Shift(S3) + // + // Term -> 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 @ Tok::LParen(..)) => { + let mut __lookbehind = None; + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state5(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!(__state3(scale, __lookbehind, __lookahead, __tokens, __sym2)); + } + _ => { + return Err(__lookahead); + } + } + while __sym1.is_some() { + let (__lookbehind, __lookahead, __nt) = __result; + match __nt { + __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state17(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + _ => { + return Ok((__lookbehind, __lookahead, __nt)); + } + } + } + return Ok(__result); + } + + // State 9 // Factor = Factor "/" (*) Term [EOF] // Factor = Factor "/" (*) Term ["*"] // Factor = Factor "/" (*) Term ["+"] @@ -529,11 +695,11 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "Num" -> Shift(S5) - // "(" -> Shift(S2) + // "(" -> Shift(S5) + // "Num" -> Shift(S3) // - // Term -> S16 - pub fn __state7< + // Term -> S18 + pub fn __state9< __TOKENS: Iterator, >( scale: i32, @@ -546,17 +712,17 @@ mod __parse__Expr { { let mut __result: (Option<()>, Option, __Nonterminal<>); match __lookahead { - Some(Tok::Num(__tok0)) => { - let mut __lookbehind = None; - let mut __sym2 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state5(scale, __lookbehind, __lookahead, __tokens, __sym2)); - } Some(__tok @ Tok::LParen(..)) => { let mut __lookbehind = None; let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state2(scale, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state5(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!(__state3(scale, __lookbehind, __lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); @@ -567,7 +733,7 @@ mod __parse__Expr { match __nt { __Nonterminal::Term(__nt) => { let __sym2 = &mut Some(__nt); - __result = try!(__state16(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + __result = try!(__state18(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); } _ => { return Ok((__lookbehind, __lookahead, __nt)); @@ -577,7 +743,63 @@ mod __parse__Expr { return Ok(__result); } - // State 8 + // State 10 + // Term = "Num" (*) [")"] + // Term = "Num" (*) ["*"] + // Term = "Num" (*) ["+"] + // Term = "Num" (*) ["-"] + // Term = "Num" (*) ["/"] + // + // "/" -> Reduce(Term = "Num" => Call(ActionFn(7));) + // ")" -> Reduce(Term = "Num" => Call(ActionFn(7));) + // "+" -> Reduce(Term = "Num" => Call(ActionFn(7));) + // "*" -> Reduce(Term = "Num" => Call(ActionFn(7));) + // "-" -> Reduce(Term = "Num" => Call(ActionFn(7));) + // + pub fn __state10< + __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::RParen(..)) => { + 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))); + } + 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 11 // Expr = Factor (*) [")"] // Expr = Factor (*) ["+"] // Expr = Factor (*) ["-"] @@ -593,12 +815,12 @@ mod __parse__Expr { // Factor = Factor (*) "/" Term ["/"] // // ")" -> Reduce(Expr = Factor => Call(ActionFn(3));) - // "/" -> Shift(S18) - // "+" -> Reduce(Expr = Factor => Call(ActionFn(3));) - // "*" -> Shift(S17) + // "/" -> Shift(S19) // "-" -> Reduce(Expr = Factor => Call(ActionFn(3));) + // "+" -> Reduce(Expr = Factor => Call(ActionFn(3));) + // "*" -> Shift(S20) // - pub fn __state8< + pub fn __state11< __TOKENS: Iterator, >( scale: i32, @@ -614,25 +836,25 @@ mod __parse__Expr { let mut __lookbehind = None; let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state18(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + __result = try!(__state19(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); } Some(__tok @ Tok::Times(..)) => { let mut __lookbehind = None; let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state17(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + __result = try!(__state20(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); } Some(Tok::RParen(..)) => { let __sym0 = __sym0.take().unwrap(); let __nt = super::__actions::__action3(scale, __sym0); return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); } - Some(Tok::Plus(..)) => { + Some(Tok::Minus(..)) => { let __sym0 = __sym0.take().unwrap(); let __nt = super::__actions::__action3(scale, __sym0); return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); } - Some(Tok::Minus(..)) => { + Some(Tok::Plus(..)) => { let __sym0 = __sym0.take().unwrap(); let __nt = super::__actions::__action3(scale, __sym0); return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); @@ -644,63 +866,7 @@ mod __parse__Expr { return Ok(__result); } - // State 9 - // Term = "Num" (*) [")"] - // Term = "Num" (*) ["*"] - // Term = "Num" (*) ["+"] - // Term = "Num" (*) ["-"] - // Term = "Num" (*) ["/"] - // - // "/" -> Reduce(Term = "Num" => Call(ActionFn(7));) - // "-" -> Reduce(Term = "Num" => Call(ActionFn(7));) - // "*" -> Reduce(Term = "Num" => Call(ActionFn(7));) - // ")" -> Reduce(Term = "Num" => Call(ActionFn(7));) - // "+" -> Reduce(Term = "Num" => Call(ActionFn(7));) - // - pub fn __state9< - __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::Minus(..)) => { - 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))); - } - Some(Tok::RParen(..)) => { - 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))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 10 + // State 12 // Factor = Term (*) [")"] // Factor = Term (*) ["*"] // Factor = Term (*) ["+"] @@ -708,12 +874,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 __state10< + pub fn __state12< __TOKENS: Iterator, >( scale: i32, @@ -730,16 +896,6 @@ mod __parse__Expr { 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::Minus(..)) => { - 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); @@ -750,13 +906,23 @@ mod __parse__Expr { 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::Minus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action6(scale, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } _ => { return Err(__lookahead); } } } - // State 11 + // State 13 // Expr = (*) Expr "+" Factor [")"] // Expr = (*) Expr "+" Factor ["+"] // Expr = (*) Expr "+" Factor ["-"] @@ -797,13 +963,13 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "(" -> Shift(S11) - // "Num" -> Shift(S9) + // "Num" -> Shift(S10) + // "(" -> Shift(S13) // - // Expr -> S19 - // Term -> S10 - // Factor -> S8 - pub fn __state11< + // Expr -> S21 + // Factor -> S11 + // Term -> S12 + pub fn __state13< __TOKENS: Iterator, >( scale: i32, @@ -815,17 +981,17 @@ mod __parse__Expr { { let mut __result: (Option<()>, Option, __Nonterminal<>); match __lookahead { - Some(__tok @ Tok::LParen(..)) => { - let mut __lookbehind = None; - let mut __sym1 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__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)); + __result = try!(__state10(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!(__state13(scale, __lookbehind, __lookahead, __tokens, __sym1)); } _ => { return Err(__lookahead); @@ -836,15 +1002,15 @@ mod __parse__Expr { match __nt { __Nonterminal::Expr(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state19(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); - } - __Nonterminal::Term(__nt) => { - let __sym1 = &mut Some(__nt); - __result = try!(__state10(scale, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state21(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); } __Nonterminal::Factor(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state8(scale, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state11(scale, __lookbehind, __lookahead, __tokens, __sym1)); + } + __Nonterminal::Term(__nt) => { + let __sym1 = &mut Some(__nt); + __result = try!(__state12(scale, __lookbehind, __lookahead, __tokens, __sym1)); } _ => { return Ok((__lookbehind, __lookahead, __nt)); @@ -854,7 +1020,7 @@ mod __parse__Expr { return Ok(__result); } - // State 12 + // State 14 // Expr = Expr (*) "+" Factor [")"] // Expr = Expr (*) "+" Factor ["+"] // Expr = Expr (*) "+" Factor ["-"] @@ -867,11 +1033,11 @@ mod __parse__Expr { // Term = "(" Expr (*) ")" ["-"] // Term = "(" Expr (*) ")" ["/"] // - // ")" -> Shift(S22) - // "-" -> Shift(S20) - // "+" -> Shift(S21) + // "-" -> Shift(S24) + // ")" -> Shift(S23) + // "+" -> Shift(S22) // - pub fn __state12< + pub fn __state14< __TOKENS: Iterator, >( scale: i32, @@ -884,23 +1050,23 @@ mod __parse__Expr { { 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)); + __result = try!(__state24(scale, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); + } + Some(__tok @ Tok::RParen(..)) => { + let mut __lookbehind = None; + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state23(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)); + __result = try!(__state22(scale, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); } _ => { return Err(__lookahead); @@ -909,184 +1075,26 @@ mod __parse__Expr { 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)); - } - } - } - return Ok(__result); - } - // State 15 - // Factor = Factor "*" Term (*) [EOF] - // Factor = Factor "*" Term (*) ["*"] - // Factor = Factor "*" Term (*) ["+"] - // Factor = Factor "*" Term (*) ["-"] - // Factor = Factor "*" Term (*) ["/"] + // Expr = Expr "-" Factor (*) [EOF] + // Expr = Expr "-" Factor (*) ["+"] + // Expr = Expr "-" Factor (*) ["-"] + // Factor = Factor (*) "*" Term [EOF] + // Factor = Factor (*) "*" Term ["*"] + // Factor = Factor (*) "*" Term ["+"] + // Factor = Factor (*) "*" Term ["-"] + // Factor = Factor (*) "*" Term ["/"] + // Factor = Factor (*) "/" Term [EOF] + // Factor = Factor (*) "/" Term ["*"] + // Factor = Factor (*) "/" Term ["+"] + // Factor = Factor (*) "/" Term ["-"] + // Factor = Factor (*) "/" Term ["/"] // - // "*" -> 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));) + // "-" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // "+" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // EOF -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // "/" -> Shift(S9) + // "*" -> Shift(S8) // pub fn __state15< __TOKENS: Iterator, @@ -1102,59 +1110,66 @@ mod __parse__Expr { { let mut __result: (Option<()>, Option, __Nonterminal<>); match __lookahead { - Some(Tok::Times(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__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!(__state9(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!(__state8(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))); + 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::__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))); + 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::__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 16 - // Factor = Factor "/" Term (*) [EOF] - // Factor = Factor "/" Term (*) ["*"] - // Factor = Factor "/" Term (*) ["+"] - // Factor = Factor "/" Term (*) ["-"] - // Factor = Factor "/" Term (*) ["/"] + // Expr = Expr "+" Factor (*) [EOF] + // Expr = Expr "+" Factor (*) ["+"] + // Expr = Expr "+" Factor (*) ["-"] + // Factor = Factor (*) "*" Term [EOF] + // Factor = Factor (*) "*" Term ["*"] + // Factor = Factor (*) "*" Term ["+"] + // Factor = Factor (*) "*" Term ["-"] + // Factor = Factor (*) "*" Term ["/"] + // Factor = Factor (*) "/" Term [EOF] + // Factor = Factor (*) "/" Term ["*"] + // Factor = Factor (*) "/" Term ["+"] + // Factor = Factor (*) "/" Term ["-"] + // Factor = Factor (*) "/" Term ["/"] // - // "/" -> 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));) + // "*" -> Shift(S8) + // "/" -> Shift(S9) + // "+" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) + // "-" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) + // EOF -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) // pub fn __state16< __TOKENS: Iterator, @@ -1170,13 +1185,141 @@ 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!(__state8(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!(__state9(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::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))); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + + // State 17 + // 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 __state17< + __TOKENS: Iterator, + >( + scale: i32, + __lookbehind: Option<()>, + __lookahead: Option, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + __sym1: &mut Option, + __sym2: &mut Option, + ) -> Result<(Option<()>, Option, __Nonterminal<>), Option> + { + let mut __result: (Option<()>, Option, __Nonterminal<>); + match __lookahead { + Some(Tok::Minus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__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::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::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))); } + 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); + } + } + } + + // State 18 + // 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));) + // EOF -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // "-" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // "+" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // + pub fn __state18< + __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::Times(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); @@ -1184,7 +1327,7 @@ mod __parse__Expr { let __nt = super::__actions::__action5(scale, __sym0, __sym1, __sym2); return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } - Some(Tok::Minus(..)) => { + Some(Tok::Div(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); @@ -1198,6 +1341,13 @@ mod __parse__Expr { 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))); + } Some(Tok::Plus(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); @@ -1211,12 +1361,12 @@ mod __parse__Expr { } } - // State 17 - // Factor = Factor "*" (*) Term [")"] - // Factor = Factor "*" (*) Term ["*"] - // Factor = Factor "*" (*) Term ["+"] - // Factor = Factor "*" (*) Term ["-"] - // Factor = Factor "*" (*) Term ["/"] + // State 19 + // Factor = Factor "/" (*) Term [")"] + // Factor = Factor "/" (*) Term ["*"] + // Factor = Factor "/" (*) Term ["+"] + // Factor = Factor "/" (*) Term ["-"] + // Factor = Factor "/" (*) Term ["/"] // Term = (*) "(" Expr ")" [")"] // Term = (*) "(" Expr ")" ["*"] // Term = (*) "(" Expr ")" ["+"] @@ -1228,11 +1378,11 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "Num" -> Shift(S9) - // "(" -> Shift(S11) + // "(" -> Shift(S13) + // "Num" -> Shift(S10) // // Term -> S25 - pub fn __state17< + pub fn __state19< __TOKENS: Iterator, >( scale: i32, @@ -1245,17 +1395,17 @@ mod __parse__Expr { { let mut __result: (Option<()>, Option, __Nonterminal<>); match __lookahead { - Some(Tok::Num(__tok0)) => { - let mut __lookbehind = None; - let mut __sym2 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state9(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!(__state11(scale, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state13(scale, __lookbehind, __lookahead, __tokens, __sym2)); + } + Some(Tok::Num(__tok0)) => { + let mut __lookbehind = None; + let mut __sym2 = &mut Some((__tok0)); + let __lookahead = __tokens.next(); + __result = try!(__state10(scale, __lookbehind, __lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); @@ -1276,12 +1426,12 @@ mod __parse__Expr { return Ok(__result); } - // State 18 - // Factor = Factor "/" (*) Term [")"] - // Factor = Factor "/" (*) Term ["*"] - // Factor = Factor "/" (*) Term ["+"] - // Factor = Factor "/" (*) Term ["-"] - // Factor = Factor "/" (*) Term ["/"] + // State 20 + // Factor = Factor "*" (*) Term [")"] + // Factor = Factor "*" (*) Term ["*"] + // Factor = Factor "*" (*) Term ["+"] + // Factor = Factor "*" (*) Term ["-"] + // Factor = Factor "*" (*) Term ["/"] // Term = (*) "(" Expr ")" [")"] // Term = (*) "(" Expr ")" ["*"] // Term = (*) "(" Expr ")" ["+"] @@ -1293,11 +1443,11 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "(" -> Shift(S11) - // "Num" -> Shift(S9) + // "Num" -> Shift(S10) + // "(" -> Shift(S13) // // Term -> S26 - pub fn __state18< + pub fn __state20< __TOKENS: Iterator, >( scale: i32, @@ -1310,17 +1460,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!(__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!(__state9(scale, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state10(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!(__state13(scale, __lookbehind, __lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); @@ -1341,7 +1491,7 @@ mod __parse__Expr { return Ok(__result); } - // State 19 + // State 21 // Expr = Expr (*) "+" Factor [")"] // Expr = Expr (*) "+" Factor ["+"] // Expr = Expr (*) "+" Factor ["-"] @@ -1354,11 +1504,11 @@ mod __parse__Expr { // Term = "(" Expr (*) ")" ["-"] // Term = "(" Expr (*) ")" ["/"] // + // "+" -> Shift(S22) + // "-" -> Shift(S24) // ")" -> Shift(S27) - // "+" -> Shift(S21) - // "-" -> Shift(S20) // - pub fn __state19< + pub fn __state21< __TOKENS: Iterator, >( scale: i32, @@ -1371,24 +1521,24 @@ mod __parse__Expr { { let mut __result: (Option<()>, Option, __Nonterminal<>); match __lookahead { + Some(__tok @ Tok::Plus(..)) => { + let mut __lookbehind = None; + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state22(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!(__state24(scale, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); + } Some(__tok @ Tok::RParen(..)) => { let mut __lookbehind = None; let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); __result = try!(__state27(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); } @@ -1396,90 +1546,7 @@ mod __parse__Expr { return Ok(__result); } - // State 20 - // Expr = Expr "-" (*) Factor [")"] - // Expr = Expr "-" (*) Factor ["+"] - // Expr = Expr "-" (*) Factor ["-"] - // Factor = (*) Factor "*" Term [")"] - // Factor = (*) Factor "*" Term ["*"] - // Factor = (*) Factor "*" Term ["+"] - // Factor = (*) Factor "*" Term ["-"] - // Factor = (*) Factor "*" Term ["/"] - // Factor = (*) Factor "/" Term [")"] - // Factor = (*) Factor "/" Term ["*"] - // Factor = (*) Factor "/" Term ["+"] - // Factor = (*) Factor "/" Term ["-"] - // Factor = (*) Factor "/" Term ["/"] - // Factor = (*) Term [")"] - // Factor = (*) Term ["*"] - // Factor = (*) Term ["+"] - // Factor = (*) Term ["-"] - // Factor = (*) Term ["/"] - // Term = (*) "(" Expr ")" [")"] - // Term = (*) "(" Expr ")" ["*"] - // Term = (*) "(" Expr ")" ["+"] - // Term = (*) "(" Expr ")" ["-"] - // Term = (*) "(" Expr ")" ["/"] - // Term = (*) "Num" [")"] - // Term = (*) "Num" ["*"] - // Term = (*) "Num" ["+"] - // Term = (*) "Num" ["-"] - // Term = (*) "Num" ["/"] - // - // "(" -> Shift(S11) - // "Num" -> Shift(S9) - // - // Term -> S10 - // Factor -> S28 - pub fn __state20< - __TOKENS: Iterator, - >( - scale: i32, - __lookbehind: Option<()>, - __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option, - ) -> Result<(Option<()>, Option, __Nonterminal<>), Option> - { - let mut __result: (Option<()>, Option, __Nonterminal<>); - match __lookahead { - Some(__tok @ Tok::LParen(..)) => { - let mut __lookbehind = None; - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __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!(__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!(__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)); - } - } - } - return Ok(__result); - } - - // State 21 + // State 22 // Expr = Expr "+" (*) Factor [")"] // Expr = Expr "+" (*) Factor ["+"] // Expr = Expr "+" (*) Factor ["-"] @@ -1509,12 +1576,12 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "(" -> Shift(S11) - // "Num" -> Shift(S9) + // "(" -> Shift(S13) + // "Num" -> Shift(S10) // - // Factor -> S29 - // Term -> S10 - pub fn __state21< + // Term -> S12 + // Factor -> S28 + pub fn __state22< __TOKENS: Iterator, >( scale: i32, @@ -1531,13 +1598,13 @@ mod __parse__Expr { let mut __lookbehind = None; let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state11(scale, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state13(scale, __lookbehind, __lookahead, __tokens, __sym2)); } Some(Tok::Num(__tok0)) => { let mut __lookbehind = None; let mut __sym2 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state9(scale, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state10(scale, __lookbehind, __lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); @@ -1546,13 +1613,13 @@ mod __parse__Expr { while __sym1.is_some() { let (__lookbehind, __lookahead, __nt) = __result; match __nt { - __Nonterminal::Factor(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state29(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } __Nonterminal::Term(__nt) => { let __sym2 = &mut Some(__nt); - __result = try!(__state10(scale, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state12(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)); @@ -1562,20 +1629,20 @@ mod __parse__Expr { return Ok(__result); } - // State 22 + // State 23 // Term = "(" Expr ")" (*) [EOF] // Term = "(" Expr ")" (*) ["*"] // Term = "(" Expr ")" (*) ["+"] // Term = "(" Expr ")" (*) ["-"] // Term = "(" Expr ")" (*) ["/"] // - // EOF -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) // "/" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) - // "-" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) // "+" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) + // EOF -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) + // "-" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) // "*" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) // - pub fn __state22< + pub fn __state23< __TOKENS: Iterator, >( scale: i32, @@ -1589,13 +1656,6 @@ mod __parse__Expr { { let mut __result: (Option<()>, Option, __Nonterminal<>); match __lookahead { - None => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__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(); @@ -1603,14 +1663,21 @@ mod __parse__Expr { let __nt = super::__actions::__action8(scale, __sym0, __sym1, __sym2); return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); } - Some(Tok::Minus(..)) => { + Some(Tok::Plus(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); let __nt = super::__actions::__action8(scale, __sym0, __sym1, __sym2); return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); } - Some(Tok::Plus(..)) => { + None => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + 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(); @@ -1630,102 +1697,41 @@ mod __parse__Expr { } } - // State 23 - // Expr = Expr "-" Factor (*) [EOF] - // Expr = Expr "-" Factor (*) ["+"] - // Expr = Expr "-" Factor (*) ["-"] - // Factor = Factor (*) "*" Term [EOF] - // Factor = Factor (*) "*" Term ["*"] - // Factor = Factor (*) "*" Term ["+"] - // Factor = Factor (*) "*" Term ["-"] - // Factor = Factor (*) "*" Term ["/"] - // Factor = Factor (*) "/" Term [EOF] - // Factor = Factor (*) "/" Term ["*"] - // Factor = Factor (*) "/" Term ["+"] - // Factor = Factor (*) "/" Term ["-"] - // Factor = Factor (*) "/" Term ["/"] - // - // "+" -> 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));) - // - pub fn __state23< - __TOKENS: Iterator, - >( - scale: i32, - __lookbehind: Option<()>, - __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option, - __sym2: &mut Option, - ) -> Result<(Option<()>, Option, __Nonterminal<>), Option> - { - let mut __result: (Option<()>, Option, __Nonterminal<>); - match __lookahead { - Some(__tok @ Tok::Times(..)) => { - let mut __lookbehind = None; - let mut __sym3 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state6(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!(__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); - } - } - return Ok(__result); - } - // State 24 - // Expr = Expr "+" Factor (*) [EOF] - // Expr = Expr "+" Factor (*) ["+"] - // Expr = Expr "+" Factor (*) ["-"] - // Factor = Factor (*) "*" Term [EOF] - // Factor = Factor (*) "*" Term ["*"] - // Factor = Factor (*) "*" Term ["+"] - // Factor = Factor (*) "*" Term ["-"] - // Factor = Factor (*) "*" Term ["/"] - // Factor = Factor (*) "/" Term [EOF] - // Factor = Factor (*) "/" Term ["*"] - // Factor = Factor (*) "/" Term ["+"] - // Factor = Factor (*) "/" Term ["-"] - // Factor = Factor (*) "/" Term ["/"] + // Expr = Expr "-" (*) Factor [")"] + // Expr = Expr "-" (*) Factor ["+"] + // Expr = Expr "-" (*) Factor ["-"] + // Factor = (*) Factor "*" Term [")"] + // Factor = (*) Factor "*" Term ["*"] + // Factor = (*) Factor "*" Term ["+"] + // Factor = (*) Factor "*" Term ["-"] + // Factor = (*) Factor "*" Term ["/"] + // Factor = (*) Factor "/" Term [")"] + // Factor = (*) Factor "/" Term ["*"] + // Factor = (*) Factor "/" Term ["+"] + // Factor = (*) Factor "/" Term ["-"] + // Factor = (*) Factor "/" Term ["/"] + // Factor = (*) Term [")"] + // Factor = (*) Term ["*"] + // Factor = (*) Term ["+"] + // Factor = (*) Term ["-"] + // Factor = (*) Term ["/"] + // Term = (*) "(" Expr ")" [")"] + // Term = (*) "(" Expr ")" ["*"] + // Term = (*) "(" Expr ")" ["+"] + // Term = (*) "(" Expr ")" ["-"] + // Term = (*) "(" Expr ")" ["/"] + // Term = (*) "Num" [")"] + // Term = (*) "Num" ["*"] + // Term = (*) "Num" ["+"] + // Term = (*) "Num" ["-"] + // Term = (*) "Num" ["/"] // - // "-" -> 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));) + // "(" -> Shift(S13) + // "Num" -> Shift(S10) // + // Factor -> S29 + // Term -> S12 pub fn __state24< __TOKENS: Iterator, >( @@ -1735,63 +1741,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!(__state7(scale, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); + __result = try!(__state13(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!(__state6(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::__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))); + __result = try!(__state10(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!(__state29(scale, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state12(scale, __lookbehind, __lookahead, __tokens, __sym2)); + } + _ => { + return Ok((__lookbehind, __lookahead, __nt)); + } + } + } return Ok(__result); } // State 25 - // Factor = Factor "*" Term (*) [")"] - // Factor = Factor "*" Term (*) ["*"] - // Factor = Factor "*" Term (*) ["+"] - // Factor = Factor "*" Term (*) ["-"] - // Factor = Factor "*" Term (*) ["/"] + // Factor = Factor "/" Term (*) [")"] + // Factor = Factor "/" Term (*) ["*"] + // Factor = Factor "/" Term (*) ["+"] + // Factor = Factor "/" Term (*) ["-"] + // Factor = Factor "/" Term (*) ["/"] // - // "-" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) - // ")" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) - // "+" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) - // "/" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) - // "*" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // ")" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // "*" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // "-" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // "+" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // "/" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) // pub fn __state25< __TOKENS: Iterator, @@ -1807,39 +1807,39 @@ mod __parse__Expr { { let mut __result: (Option<()>, Option, __Nonterminal<>); match __lookahead { - Some(Tok::Minus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__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::__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::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))); + } + 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))); + } + Some(Tok::Div(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action5(scale, __sym0, __sym1, __sym2); return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } _ => { @@ -1849,17 +1849,17 @@ mod __parse__Expr { } // State 26 - // Factor = Factor "/" Term (*) [")"] - // Factor = Factor "/" Term (*) ["*"] - // Factor = Factor "/" Term (*) ["+"] - // Factor = Factor "/" Term (*) ["-"] - // Factor = Factor "/" Term (*) ["/"] + // Factor = Factor "*" Term (*) [")"] + // Factor = Factor "*" Term (*) ["*"] + // Factor = Factor "*" Term (*) ["+"] + // Factor = Factor "*" Term (*) ["-"] + // Factor = Factor "*" Term (*) ["/"] // - // "-" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // "/" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // ")" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // "+" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // "*" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // ")" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // "-" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // "/" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // "+" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // "*" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) // pub fn __state26< __TOKENS: Iterator, @@ -1875,39 +1875,39 @@ mod __parse__Expr { { let mut __result: (Option<()>, Option, __Nonterminal<>); match __lookahead { + Some(Tok::RParen(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__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))); } Some(Tok::Div(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action5(scale, __sym0, __sym1, __sym2); - return Ok((__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(scale, __sym0, __sym1, __sym2); + 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::__action5(scale, __sym0, __sym1, __sym2); + 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::__action5(scale, __sym0, __sym1, __sym2); + let __nt = super::__actions::__action4(scale, __sym0, __sym1, __sym2); return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } _ => { @@ -1923,8 +1923,8 @@ mod __parse__Expr { // Term = "(" Expr ")" (*) ["-"] // Term = "(" Expr ")" (*) ["/"] // - // "+" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) // "-" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) + // "+" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) // "/" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) // ")" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) // "*" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) @@ -1943,14 +1943,14 @@ mod __parse__Expr { { let mut __result: (Option<()>, Option, __Nonterminal<>); match __lookahead { - Some(Tok::Plus(..)) => { + Some(Tok::Minus(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); let __nt = super::__actions::__action8(scale, __sym0, __sym1, __sym2); return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); } - Some(Tok::Minus(..)) => { + Some(Tok::Plus(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); @@ -1985,9 +1985,9 @@ mod __parse__Expr { } // State 28 - // Expr = Expr "-" Factor (*) [")"] - // Expr = Expr "-" Factor (*) ["+"] - // Expr = Expr "-" Factor (*) ["-"] + // Expr = Expr "+" Factor (*) [")"] + // Expr = Expr "+" Factor (*) ["+"] + // Expr = Expr "+" Factor (*) ["-"] // Factor = Factor (*) "*" Term [")"] // Factor = Factor (*) "*" Term ["*"] // Factor = Factor (*) "*" Term ["+"] @@ -1999,11 +1999,11 @@ mod __parse__Expr { // Factor = Factor (*) "/" Term ["-"] // Factor = Factor (*) "/" Term ["/"] // - // "*" -> 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));) + // ")" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) + // "/" -> Shift(S19) + // "+" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) + // "-" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) + // "*" -> Shift(S20) // pub fn __state28< __TOKENS: Iterator, @@ -2019,37 +2019,37 @@ 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!(__state17(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!(__state18(scale, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); + __result = try!(__state19(scale, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); + } + Some(__tok @ Tok::Times(..)) => { + let mut __lookbehind = None; + let mut __sym3 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state20(scale, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); } Some(Tok::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); + 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::__action1(scale, __sym0, __sym1, __sym2); + 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::__action1(scale, __sym0, __sym1, __sym2); + let __nt = super::__actions::__action2(scale, __sym0, __sym1, __sym2); return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); } _ => { @@ -2060,9 +2060,9 @@ mod __parse__Expr { } // State 29 - // Expr = Expr "+" Factor (*) [")"] - // Expr = Expr "+" Factor (*) ["+"] - // Expr = Expr "+" Factor (*) ["-"] + // Expr = Expr "-" Factor (*) [")"] + // Expr = Expr "-" Factor (*) ["+"] + // Expr = Expr "-" Factor (*) ["-"] // Factor = Factor (*) "*" Term [")"] // Factor = Factor (*) "*" Term ["*"] // Factor = Factor (*) "*" Term ["+"] @@ -2074,11 +2074,11 @@ mod __parse__Expr { // Factor = Factor (*) "/" Term ["-"] // Factor = Factor (*) "/" Term ["/"] // - // "*" -> 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) + // "+" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // ")" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // "/" -> Shift(S19) + // "-" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // "*" -> Shift(S20) // pub fn __state29< __TOKENS: Iterator, @@ -2094,37 +2094,37 @@ 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!(__state17(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!(__state18(scale, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); + __result = try!(__state19(scale, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); + } + Some(__tok @ Tok::Times(..)) => { + let mut __lookbehind = None; + let mut __sym3 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state20(scale, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); + } + Some(Tok::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::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); + 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::__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); + let __nt = super::__actions::__action1(scale, __sym0, __sym1, __sym2); return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); } _ => { diff --git a/lalrpop-test/src/expr_arena.rs b/lalrpop-test/src/expr_arena.rs index 0e77ca9..c1997cf 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, > { - 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>), + Term(&'ast Node<'ast>), ____Expr(&'ast Node<'ast>), + Expr(&'ast Node<'ast>), + Expr_3f(::std::option::Option<&'ast Node<'ast>>), + Factor(&'ast Node<'ast>), + _28_3cExpr_3e_20_22_2c_22_29_2a(::std::vec::Vec<&'ast Node<'ast>>), } // State 0 @@ -78,13 +78,13 @@ mod __parse__Expr { // Term = (*) "Num" ["/"] // __Expr = (*) Expr [EOF] // - // "(" -> Shift(S1) + // "*" -> Shift(S1) + // "(" -> Shift(S2) // "Num" -> Shift(S6) - // "*" -> Shift(S2) // - // Term -> S4 - // Factor -> S5 - // Expr -> S3 + // Expr -> S4 + // Factor -> S3 + // Term -> S5 pub fn __state0< 'ast, __TOKENS: Iterator, @@ -97,24 +97,24 @@ mod __parse__Expr { { let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some((_, __tok @ Tok::LParen(..), __loc)) => { + Some((_, __tok @ Tok::Times(..), __loc)) => { let mut __lookbehind = Some(__loc); let mut __sym0 = &mut Some((__tok)); let __lookahead = __tokens.next(); __result = try!(__state1(arena, __lookbehind, __lookahead, __tokens, __sym0)); } + Some((_, __tok @ Tok::LParen(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym0 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state2(arena, __lookbehind, __lookahead, __tokens, __sym0)); + } Some((_, Tok::Num(__tok0), __loc)) => { let mut __lookbehind = Some(__loc); let mut __sym0 = &mut Some((__tok0)); let __lookahead = __tokens.next(); __result = try!(__state6(arena, __lookbehind, __lookahead, __tokens, __sym0)); } - 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); } @@ -122,18 +122,18 @@ mod __parse__Expr { loop { let (__lookbehind, __lookahead, __nt) = __result; match __nt { - __Nonterminal::Term(__nt) => { + __Nonterminal::Expr(__nt) => { let __sym0 = &mut Some(__nt); __result = try!(__state4(arena, __lookbehind, __lookahead, __tokens, __sym0)); } __Nonterminal::Factor(__nt) => { - let __sym0 = &mut Some(__nt); - __result = try!(__state5(arena, __lookbehind, __lookahead, __tokens, __sym0)); - } - __Nonterminal::Expr(__nt) => { let __sym0 = &mut Some(__nt); __result = try!(__state3(arena, __lookbehind, __lookahead, __tokens, __sym0)); } + __Nonterminal::Term(__nt) => { + let __sym0 = &mut Some(__nt); + __result = try!(__state5(arena, __lookbehind, __lookahead, __tokens, __sym0)); + } _ => { return Ok((__lookbehind, __lookahead, __nt)); } @@ -142,6 +142,41 @@ mod __parse__Expr { } // State 1 + // Factor = "*" (*) "(" Comma ")" [EOF] + // Factor = "*" (*) "(" Comma ")" ["*"] + // Factor = "*" (*) "(" Comma ")" ["+"] + // Factor = "*" (*) "(" Comma ")" ["-"] + // Factor = "*" (*) "(" Comma ")" ["/"] + // + // "(" -> Shift(S7) + // + pub fn __state1< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + ) -> 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!(__state7(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + + // State 2 // Expr = (*) Expr "+" Factor [")"] // Expr = (*) Expr "+" Factor ["+"] // Expr = (*) Expr "+" Factor ["-"] @@ -187,80 +222,13 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "(" -> Shift(S12) - // "Num" -> Shift(S10) + // "(" -> Shift(S9) // "*" -> Shift(S11) + // "Num" -> Shift(S8) // - // 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) - // + // Expr -> S10 + // Factor -> S13 + // Term -> S12 pub fn __state2< 'ast, __TOKENS: Iterator, @@ -278,123 +246,48 @@ mod __parse__Expr { let mut __lookbehind = Some(__loc); let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state13(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + __result = try!(__state9(arena, __lookbehind, __lookahead, __tokens, __sym1)); + } + Some((_, __tok @ Tok::Times(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state11(arena, __lookbehind, __lookahead, __tokens, __sym1)); + } + Some((_, Tok::Num(__tok0), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym1 = &mut Some((__tok0)); + let __lookahead = __tokens.next(); + __result = try!(__state8(arena, __lookbehind, __lookahead, __tokens, __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!(__state10(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + } + __Nonterminal::Factor(__nt) => { + let __sym1 = &mut Some(__nt); + __result = try!(__state13(arena, __lookbehind, __lookahead, __tokens, __sym1)); + } + __Nonterminal::Term(__nt) => { + let __sym1 = &mut Some(__nt); + __result = try!(__state12(arena, __lookbehind, __lookahead, __tokens, __sym1)); + } + _ => { + return Ok((__lookbehind, __lookahead, __nt)); + } + } + } 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] - // - // "-" -> Shift(S14) - // EOF -> Reduce(__Expr = Expr => Call(ActionFn(0));) - // "+" -> Shift(S15) - // - pub fn __state3< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize,Tok,usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> - { - let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, __tok @ Tok::Minus(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym1 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__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!(__state15(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); - } - None => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action0(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));) - // "+" -> Reduce(Factor = Term => Call(ActionFn(7));) - // EOF -> 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::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); - } - } - } - - // State 5 // Expr = Factor (*) [EOF] // Expr = Factor (*) ["+"] // Expr = Factor (*) ["-"] @@ -409,11 +302,121 @@ mod __parse__Expr { // Factor = Factor (*) "/" Term ["-"] // Factor = Factor (*) "/" Term ["/"] // - // "/" -> Shift(S17) // "+" -> Reduce(Expr = Factor => Call(ActionFn(3));) - // EOF -> Reduce(Expr = Factor => Call(ActionFn(3));) // "-" -> Reduce(Expr = Factor => Call(ActionFn(3));) - // "*" -> Shift(S16) + // "*" -> Shift(S14) + // EOF -> Reduce(Expr = Factor => Call(ActionFn(3));) + // "/" -> Shift(S15) + // + 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!(__state14(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!(__state15(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 + // Expr = Expr (*) "+" Factor [EOF] + // Expr = Expr (*) "+" Factor ["+"] + // Expr = Expr (*) "+" Factor ["-"] + // Expr = Expr (*) "-" Factor [EOF] + // Expr = Expr (*) "-" Factor ["+"] + // Expr = Expr (*) "-" Factor ["-"] + // __Expr = Expr (*) [EOF] + // + // "-" -> Shift(S17) + // EOF -> Reduce(__Expr = Expr => Call(ActionFn(0));) + // "+" -> Shift(S16) + // + pub fn __state4< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, __tok @ Tok::Minus(..), __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 @ 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)); + } + None => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action0(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::____Expr(__nt))); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + + // State 5 + // Factor = Term (*) [EOF] + // Factor = Term (*) ["*"] + // Factor = Term (*) ["+"] + // Factor = Term (*) ["-"] + // Factor = Term (*) ["/"] + // + // "*" -> Reduce(Factor = Term => Call(ActionFn(7));) + // "/" -> Reduce(Factor = Term => Call(ActionFn(7));) + // "+" -> Reduce(Factor = Term => Call(ActionFn(7));) + // "-" -> Reduce(Factor = Term => Call(ActionFn(7));) + // EOF -> Reduce(Factor = Term => Call(ActionFn(7));) // pub fn __state5< 'ast, @@ -428,38 +431,35 @@ 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 __sym1 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state17(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + Some((_, Tok::Times(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action7(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } - Some((_, __tok @ Tok::Times(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym1 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state16(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + 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::__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))); + 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::__action3(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); + 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))); } _ => { return Err(__lookahead); } } - return Ok(__result); } // State 6 @@ -469,11 +469,11 @@ mod __parse__Expr { // 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));) + // EOF -> Reduce(Term = "Num" => Call(ActionFn(8));) // "/" -> Reduce(Term = "Num" => Call(ActionFn(8));) + // "-" -> Reduce(Term = "Num" => Call(ActionFn(8));) // pub fn __state6< 'ast, @@ -488,31 +488,31 @@ mod __parse__Expr { { 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))); } + None => { + 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); } @@ -520,18 +520,28 @@ mod __parse__Expr { } // State 7 - // Factor = Term (*) [")"] - // Factor = Term (*) ["*"] - // Factor = Term (*) ["+"] - // Factor = Term (*) ["-"] - // Factor = Term (*) ["/"] + // ( ",")* = (*) ["("] + // ( ",")* = (*) [")"] + // ( ",")* = (*) ["*"] + // ( ",")* = (*) ["Num"] + // ( ",")* = (*) ( ",")* ( ",") ["("] + // ( ",")* = (*) ( ",")* ( ",") [")"] + // ( ",")* = (*) ( ",")* ( ",") ["*"] + // ( ",")* = (*) ( ",")* ( ",") ["Num"] + // Comma = (*) ( ",")* Expr? [")"] + // Factor = "*" "(" (*) Comma ")" [EOF] + // Factor = "*" "(" (*) Comma ")" ["*"] + // Factor = "*" "(" (*) Comma ")" ["+"] + // Factor = "*" "(" (*) Comma ")" ["-"] + // Factor = "*" "(" (*) Comma ")" ["/"] // - // "/" -> 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(( ",")* = => Call(ActionFn(13));) + // "Num" -> Reduce(( ",")* = => Call(ActionFn(13));) + // "(" -> Reduce(( ",")* = => Call(ActionFn(13));) + // ")" -> Reduce(( ",")* = => Call(ActionFn(13));) // + // Comma -> S19 + // ( ",")* -> S18 pub fn __state7< 'ast, __TOKENS: Iterator, @@ -540,167 +550,52 @@ 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::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))); + let __nt = super::__actions::__action13(arena, ); + __result = (__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__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::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 __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))); + 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!(__state19(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!(__state18(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + _ => { + return Ok((__lookbehind, __lookahead, __nt)); + } + } + } + return Ok(__result); } // State 8 - // 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(S20) - // ")" -> Shift(S19) - // "+" -> Shift(S18) - // - pub fn __state8< - '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!(__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!(__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!(__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); - } - } - return Ok(__result); - } - - // State 10 // Term = "Num" (*) [")"] // Term = "Num" (*) ["*"] // Term = "Num" (*) ["+"] @@ -708,12 +603,12 @@ mod __parse__Expr { // 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));) // - pub fn __state10< + pub fn __state8< 'ast, __TOKENS: Iterator, >( @@ -731,68 +626,33 @@ mod __parse__Expr { 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::Minus(..), _)) => { + 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::Plus(..), _)) => { + 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 + // State 9 // Expr = (*) Expr "+" Factor [")"] // Expr = (*) Expr "+" Factor ["+"] // Expr = (*) Expr "+" Factor ["-"] @@ -838,14 +698,137 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "(" -> Shift(S12) + // "Num" -> Shift(S8) + // "(" -> Shift(S9) // "*" -> Shift(S11) - // "Num" -> Shift(S10) // - // Factor -> S9 - // Term -> S7 - // Expr -> S24 - pub fn __state12< + // Factor -> S13 + // Expr -> S20 + // Term -> S12 + pub fn __state9< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, Tok::Num(__tok0), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym1 = &mut Some((__tok0)); + let __lookahead = __tokens.next(); + __result = try!(__state8(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!(__state9(arena, __lookbehind, __lookahead, __tokens, __sym1)); + } + Some((_, __tok @ Tok::Times(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state11(arena, __lookbehind, __lookahead, __tokens, __sym1)); + } + _ => { + return Err(__lookahead); + } + } + while __sym0.is_some() { + let (__lookbehind, __lookahead, __nt) = __result; + match __nt { + __Nonterminal::Factor(__nt) => { + let __sym1 = &mut Some(__nt); + __result = try!(__state13(arena, __lookbehind, __lookahead, __tokens, __sym1)); + } + __Nonterminal::Expr(__nt) => { + let __sym1 = &mut Some(__nt); + __result = try!(__state20(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + } + __Nonterminal::Term(__nt) => { + let __sym1 = &mut Some(__nt); + __result = try!(__state12(arena, __lookbehind, __lookahead, __tokens, __sym1)); + } + _ => { + 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(S21) + // "+" -> Shift(S22) + // "-" -> Shift(S23) + // + pub fn __state10< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + __sym1: &mut Option<&'ast Node<'ast>>, + ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, __tok @ Tok::RParen(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state21(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + Some((_, __tok @ Tok::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!(__state23(arena, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + + // State 11 + // Factor = "*" (*) "(" Comma ")" [")"] + // Factor = "*" (*) "(" Comma ")" ["*"] + // Factor = "*" (*) "(" Comma ")" ["+"] + // Factor = "*" (*) "(" Comma ")" ["-"] + // Factor = "*" (*) "(" Comma ")" ["/"] + // + // "(" -> Shift(S24) + // + pub fn __state11< 'ast, __TOKENS: Iterator, >( @@ -862,70 +845,93 @@ mod __parse__Expr { 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::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)); + __result = try!(__state24(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); } _ => { return Err(__lookahead); } } - while __sym0.is_some() { - let (__lookbehind, __lookahead, __nt) = __result; - match __nt { - __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!(__state24(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); - } - _ => { - return Ok((__lookbehind, __lookahead, __nt)); - } - } - } return Ok(__result); } + // State 12 + // Factor = Term (*) [")"] + // Factor = Term (*) ["*"] + // Factor = Term (*) ["+"] + // Factor = Term (*) ["-"] + // Factor = Term (*) ["/"] + // + // "+" -> Reduce(Factor = Term => Call(ActionFn(7));) + // "*" -> Reduce(Factor = Term => Call(ActionFn(7));) + // "/" -> Reduce(Factor = Term => Call(ActionFn(7));) + // "-" -> Reduce(Factor = Term => Call(ActionFn(7));) + // ")" -> Reduce(Factor = Term => Call(ActionFn(7));) + // + pub fn __state12< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, Tok::Plus(..), _)) => { + 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::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::RParen(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action7(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + // State 13 - // ( ",")* = (*) ["("] - // ( ",")* = (*) [")"] - // ( ",")* = (*) ["*"] - // ( ",")* = (*) ["Num"] - // ( ",")* = (*) ( ",")* ( ",") ["("] - // ( ",")* = (*) ( ",")* ( ",") [")"] - // ( ",")* = (*) ( ",")* ( ",") ["*"] - // ( ",")* = (*) ( ",")* ( ",") ["Num"] - // Comma = (*) ( ",")* Expr? [")"] - // Factor = "*" "(" (*) Comma ")" [EOF] - // Factor = "*" "(" (*) Comma ")" ["*"] - // Factor = "*" "(" (*) Comma ")" ["+"] - // Factor = "*" "(" (*) Comma ")" ["-"] - // Factor = "*" "(" (*) Comma ")" ["/"] + // 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(( ",")* = => Call(ActionFn(13));) - // "*" -> Reduce(( ",")* = => Call(ActionFn(13));) - // "Num" -> Reduce(( ",")* = => Call(ActionFn(13));) - // ")" -> Reduce(( ",")* = => Call(ActionFn(13));) + // "*" -> Shift(S25) + // "/" -> Shift(S26) + // "-" -> Reduce(Expr = Factor => Call(ActionFn(3));) + // ")" -> Reduce(Expr = Factor => Call(ActionFn(3));) + // "+" -> Reduce(Expr = Factor => Call(ActionFn(3));) // - // Comma -> S26 - // ( ",")* -> S25 pub fn __state13< 'ast, __TOKENS: Iterator, @@ -934,75 +940,51 @@ mod __parse__Expr { __lookbehind: Option, __lookahead: Option<(usize,Tok,usize)>, __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &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::LParen(..), _)) => { - let __nt = super::__actions::__action13(arena, ); - __result = (__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); + Some((_, __tok @ Tok::Times(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state25(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); } - Some((_, Tok::Times(..), _)) => { - let __nt = super::__actions::__action13(arena, ); - __result = (__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); + Some((_, __tok @ Tok::Div(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state26(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); } - 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::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action3(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); } Some((_, Tok::RParen(..), _)) => { - let __nt = super::__actions::__action13(arena, ); - __result = (__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); + 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); } } - while __sym1.is_some() { - let (__lookbehind, __lookahead, __nt) = __result; - match __nt { - __Nonterminal::Comma_3cExpr_3e(__nt) => { - let __sym2 = &mut Some(__nt); - __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)); - } - } - } return Ok(__result); } // State 14 - // Expr = Expr "-" (*) Factor [EOF] - // Expr = Expr "-" (*) Factor ["+"] - // Expr = Expr "-" (*) Factor ["-"] - // Factor = (*) Factor "*" Term [EOF] - // Factor = (*) Factor "*" Term ["*"] - // Factor = (*) Factor "*" Term ["+"] - // Factor = (*) Factor "*" Term ["-"] - // Factor = (*) Factor "*" Term ["/"] - // Factor = (*) Factor "/" Term [EOF] - // Factor = (*) Factor "/" Term ["*"] - // Factor = (*) Factor "/" Term ["+"] - // Factor = (*) Factor "/" Term ["-"] - // Factor = (*) Factor "/" Term ["/"] - // Factor = (*) Term [EOF] - // Factor = (*) Term ["*"] - // Factor = (*) Term ["+"] - // Factor = (*) Term ["-"] - // Factor = (*) Term ["/"] - // Factor = (*) "*" "(" Comma ")" [EOF] - // Factor = (*) "*" "(" Comma ")" ["*"] - // Factor = (*) "*" "(" Comma ")" ["+"] - // Factor = (*) "*" "(" Comma ")" ["-"] - // Factor = (*) "*" "(" Comma ")" ["/"] + // Factor = Factor "*" (*) Term [EOF] + // Factor = Factor "*" (*) Term ["*"] + // Factor = Factor "*" (*) Term ["+"] + // Factor = Factor "*" (*) Term ["-"] + // Factor = Factor "*" (*) Term ["/"] // Term = (*) "(" Expr ")" [EOF] // Term = (*) "(" Expr ")" ["*"] // Term = (*) "(" Expr ")" ["+"] @@ -1014,12 +996,10 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "(" -> Shift(S1) - // "*" -> Shift(S2) + // "(" -> Shift(S2) // "Num" -> Shift(S6) // - // Term -> S4 - // Factor -> S27 + // Term -> S27 pub fn __state14< 'ast, __TOKENS: Iterator, @@ -1035,12 +1015,6 @@ mod __parse__Expr { let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { Some((_, __tok @ Tok::LParen(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__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(); @@ -1060,10 +1034,6 @@ mod __parse__Expr { 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!(__state27(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); } @@ -1076,6 +1046,72 @@ mod __parse__Expr { } // State 15 + // Factor = Factor "/" (*) Term [EOF] + // Factor = Factor "/" (*) Term ["*"] + // Factor = Factor "/" (*) Term ["+"] + // Factor = Factor "/" (*) Term ["-"] + // Factor = Factor "/" (*) Term ["/"] + // Term = (*) "(" Expr ")" [EOF] + // Term = (*) "(" Expr ")" ["*"] + // Term = (*) "(" Expr ")" ["+"] + // Term = (*) "(" Expr ")" ["-"] + // Term = (*) "(" Expr ")" ["/"] + // Term = (*) "Num" [EOF] + // Term = (*) "Num" ["*"] + // Term = (*) "Num" ["+"] + // Term = (*) "Num" ["-"] + // Term = (*) "Num" ["/"] + // + // "Num" -> Shift(S6) + // "(" -> Shift(S2) + // + // Term -> 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::Num(__tok0), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok0)); + let __lookahead = __tokens.next(); + __result = try!(__state6(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + Some((_, __tok @ Tok::LParen(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state2(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + _ => { + return Err(__lookahead); + } + } + while __sym1.is_some() { + let (__lookbehind, __lookahead, __nt) = __result; + match __nt { + __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state28(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + _ => { + return Ok((__lookbehind, __lookahead, __nt)); + } + } + } + return Ok(__result); + } + + // State 16 // Expr = Expr "+" (*) Factor [EOF] // Expr = Expr "+" (*) Factor ["+"] // Expr = Expr "+" (*) Factor ["-"] @@ -1110,88 +1146,12 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "*" -> Shift(S2) - // "(" -> Shift(S1) // "Num" -> Shift(S6) + // "*" -> Shift(S1) + // "(" -> Shift(S2) // - // 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 + // Term -> S5 + // Factor -> S29 pub fn __state16< 'ast, __TOKENS: Iterator, @@ -1206,18 +1166,24 @@ mod __parse__Expr { { let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some((_, __tok @ Tok::LParen(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state1(arena, __lookbehind, __lookahead, __tokens, __sym2)); - } Some((_, Tok::Num(__tok0), __loc)) => { let mut __lookbehind = Some(__loc); let mut __sym2 = &mut Some((__tok0)); let __lookahead = __tokens.next(); __result = try!(__state6(arena, __lookbehind, __lookahead, __tokens, __sym2)); } + Some((_, __tok @ Tok::Times(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__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)); + } _ => { return Err(__lookahead); } @@ -1226,6 +1192,10 @@ mod __parse__Expr { let (__lookbehind, __lookahead, __nt) = __result; match __nt { __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state5(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + __Nonterminal::Factor(__nt) => { let __sym2 = &mut Some(__nt); __result = try!(__state29(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); } @@ -1238,11 +1208,29 @@ mod __parse__Expr { } // State 17 - // Factor = Factor "/" (*) Term [EOF] - // Factor = Factor "/" (*) Term ["*"] - // Factor = Factor "/" (*) Term ["+"] - // Factor = Factor "/" (*) Term ["-"] - // Factor = Factor "/" (*) Term ["/"] + // Expr = Expr "-" (*) Factor [EOF] + // Expr = Expr "-" (*) Factor ["+"] + // Expr = Expr "-" (*) Factor ["-"] + // Factor = (*) Factor "*" Term [EOF] + // Factor = (*) Factor "*" Term ["*"] + // Factor = (*) Factor "*" Term ["+"] + // Factor = (*) Factor "*" Term ["-"] + // Factor = (*) Factor "*" Term ["/"] + // Factor = (*) Factor "/" Term [EOF] + // Factor = (*) Factor "/" Term ["*"] + // Factor = (*) Factor "/" Term ["+"] + // Factor = (*) Factor "/" Term ["-"] + // Factor = (*) Factor "/" Term ["/"] + // Factor = (*) Term [EOF] + // Factor = (*) Term ["*"] + // Factor = (*) Term ["+"] + // Factor = (*) Term ["-"] + // Factor = (*) Term ["/"] + // Factor = (*) "*" "(" Comma ")" [EOF] + // Factor = (*) "*" "(" Comma ")" ["*"] + // Factor = (*) "*" "(" Comma ")" ["+"] + // Factor = (*) "*" "(" Comma ")" ["-"] + // Factor = (*) "*" "(" Comma ")" ["/"] // Term = (*) "(" Expr ")" [EOF] // Term = (*) "(" Expr ")" ["*"] // Term = (*) "(" Expr ")" ["+"] @@ -1254,10 +1242,12 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "(" -> Shift(S1) + // "(" -> Shift(S2) // "Num" -> Shift(S6) + // "*" -> Shift(S1) // - // Term -> S30 + // Term -> S5 + // Factor -> S30 pub fn __state17< 'ast, __TOKENS: Iterator, @@ -1276,7 +1266,7 @@ mod __parse__Expr { let mut __lookbehind = Some(__loc); let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state1(arena, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state2(arena, __lookbehind, __lookahead, __tokens, __sym2)); } Some((_, Tok::Num(__tok0), __loc)) => { let mut __lookbehind = Some(__loc); @@ -1284,6 +1274,12 @@ mod __parse__Expr { let __lookahead = __tokens.next(); __result = try!(__state6(arena, __lookbehind, __lookahead, __tokens, __sym2)); } + Some((_, __tok @ Tok::Times(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state1(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } _ => { return Err(__lookahead); } @@ -1292,6 +1288,10 @@ mod __parse__Expr { let (__lookbehind, __lookahead, __nt) = __result; match __nt { __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state5(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + __Nonterminal::Factor(__nt) => { let __sym2 = &mut Some(__nt); __result = try!(__state30(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); } @@ -1304,531 +1304,6 @@ mod __parse__Expr { } // State 18 - // Expr = Expr "+" (*) Factor [")"] - // Expr = Expr "+" (*) Factor ["+"] - // Expr = Expr "+" (*) Factor ["-"] - // Factor = (*) Factor "*" Term [")"] - // Factor = (*) Factor "*" Term ["*"] - // Factor = (*) Factor "*" Term ["+"] - // Factor = (*) Factor "*" Term ["-"] - // Factor = (*) Factor "*" Term ["/"] - // Factor = (*) Factor "/" Term [")"] - // Factor = (*) Factor "/" Term ["*"] - // Factor = (*) Factor "/" Term ["+"] - // Factor = (*) Factor "/" Term ["-"] - // Factor = (*) Factor "/" Term ["/"] - // Factor = (*) Term [")"] - // Factor = (*) Term ["*"] - // Factor = (*) Term ["+"] - // Factor = (*) Term ["-"] - // Factor = (*) Term ["/"] - // 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(S11) - // "(" -> Shift(S12) - // - // 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, - >( - 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)); - } - _ => { - return Err(__lookahead); - } - } - while __sym1.is_some() { - let (__lookbehind, __lookahead, __nt) = __result; - match __nt { - __Nonterminal::Term(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state34(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - _ => { - return Ok((__lookbehind, __lookahead, __nt)); - } - } - } - return Ok(__result); - } - - // State 23 - // ( ",")* = (*) ["("] - // ( ",")* = (*) [")"] - // ( ",")* = (*) ["*"] - // ( ",")* = (*) ["Num"] - // ( ",")* = (*) ( ",")* ( ",") ["("] - // ( ",")* = (*) ( ",")* ( ",") [")"] - // ( ",")* = (*) ( ",")* ( ",") ["*"] - // ( ",")* = (*) ( ",")* ( ",") ["Num"] - // Comma = (*) ( ",")* Expr? [")"] - // Factor = "*" "(" (*) Comma ")" [")"] - // Factor = "*" "(" (*) Comma ")" ["*"] - // Factor = "*" "(" (*) Comma ")" ["+"] - // Factor = "*" "(" (*) Comma ")" ["-"] - // Factor = "*" "(" (*) Comma ")" ["/"] - // - // ")" -> Reduce(( ",")* = => Call(ActionFn(13));) - // "*" -> Reduce(( ",")* = => Call(ActionFn(13));) - // "Num" -> Reduce(( ",")* = => Call(ActionFn(13));) - // "(" -> Reduce(( ",")* = => Call(ActionFn(13));) - // - // ( ",")* -> S25 - // Comma -> S35 - pub fn __state23< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize,Tok,usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option, - ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> - { - let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, Tok::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)); - } - 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)); - } - _ => { - 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!(__state35(arena, __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 (*) ")" ["/"] - // - // "+" -> 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 // ( ",") = (*) Expr "," ["("] // ( ",") = (*) Expr "," [")"] // ( ",") = (*) Expr "," ["*"] @@ -1889,17 +1364,17 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "Num" -> Shift(S43) - // "(" -> Shift(S44) - // "*" -> Shift(S41) + // "Num" -> Shift(S31) + // "*" -> Shift(S35) // ")" -> Reduce(Expr? = => Call(ActionFn(12));) + // "(" -> Shift(S36) // - // Expr? -> S42 - // Expr -> S40 - // ( ",") -> S37 - // Term -> S39 - // Factor -> S38 - pub fn __state25< + // ( ",") -> S32 + // Factor -> S34 + // Expr? -> S37 + // Expr -> S33 + // Term -> S38 + pub fn __state18< 'ast, __TOKENS: Iterator, >( @@ -1916,19 +1391,19 @@ mod __parse__Expr { let mut __lookbehind = Some(__loc); let mut __sym1 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __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!(__state44(arena, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state31(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)); + __result = try!(__state35(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!(__state36(arena, __lookbehind, __lookahead, __tokens, __sym1)); } Some((_, Tok::RParen(..), _)) => { let __nt = super::__actions::__action12(arena, ); @@ -1941,23 +1416,23 @@ mod __parse__Expr { while __sym0.is_some() { let (__lookbehind, __lookahead, __nt) = __result; match __nt { - __Nonterminal::Expr_3f(__nt) => { - let __sym1 = &mut Some(__nt); - __result = try!(__state42(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); - } - __Nonterminal::Expr(__nt) => { - let __sym1 = &mut Some(__nt); - __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!(__state32(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + } + __Nonterminal::Factor(__nt) => { + let __sym1 = &mut Some(__nt); + __result = try!(__state34(arena, __lookbehind, __lookahead, __tokens, __sym1)); + } + __Nonterminal::Expr_3f(__nt) => { let __sym1 = &mut Some(__nt); __result = try!(__state37(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); } - __Nonterminal::Term(__nt) => { + __Nonterminal::Expr(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state39(arena, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state33(arena, __lookbehind, __lookahead, __tokens, __sym1)); } - __Nonterminal::Factor(__nt) => { + __Nonterminal::Term(__nt) => { let __sym1 = &mut Some(__nt); __result = try!(__state38(arena, __lookbehind, __lookahead, __tokens, __sym1)); } @@ -1969,16 +1444,16 @@ mod __parse__Expr { return Ok(__result); } - // State 26 + // State 19 // Factor = "*" "(" Comma (*) ")" [EOF] // Factor = "*" "(" Comma (*) ")" ["*"] // Factor = "*" "(" Comma (*) ")" ["+"] // Factor = "*" "(" Comma (*) ")" ["-"] // Factor = "*" "(" Comma (*) ")" ["/"] // - // ")" -> Shift(S45) + // ")" -> Shift(S39) // - pub fn __state26< + pub fn __state19< 'ast, __TOKENS: Iterator, >( @@ -1997,7 +1472,7 @@ mod __parse__Expr { let mut __lookbehind = Some(__loc); let mut __sym3 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state45(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2, __sym3)); + __result = try!(__state39(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2, __sym3)); } _ => { return Err(__lookahead); @@ -2006,26 +1481,543 @@ mod __parse__Expr { return Ok(__result); } - // 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 ["/"] + // State 20 + // Expr = Expr (*) "+" Factor [")"] + // Expr = Expr (*) "+" Factor ["+"] + // Expr = Expr (*) "+" Factor ["-"] + // Expr = Expr (*) "-" Factor [")"] + // Expr = Expr (*) "-" Factor ["+"] + // Expr = Expr (*) "-" Factor ["-"] + // Term = "(" Expr (*) ")" [")"] + // Term = "(" Expr (*) ")" ["*"] + // Term = "(" Expr (*) ")" ["+"] + // Term = "(" Expr (*) ")" ["-"] + // Term = "(" Expr (*) ")" ["/"] // - // "/" -> Shift(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));) + // "+" -> Shift(S22) + // ")" -> Shift(S40) + // "-" -> Shift(S23) + // + pub fn __state20< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + __sym1: &mut Option<&'ast Node<'ast>>, + ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, __tok @ Tok::Plus(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state22(arena, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); + } + Some((_, __tok @ Tok::RParen(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state40(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + Some((_, __tok @ Tok::Minus(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state23(arena, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + + // State 21 + // 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 __state21< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + __sym1: &mut Option<&'ast Node<'ast>>, + __sym2: &mut Option, + ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + 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))); + } + 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::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::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 22 + // 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(S8) + // "(" -> Shift(S9) + // + // Term -> S12 + // Factor -> S41 + pub fn __state22< + '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!(__state8(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!(__state9(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + _ => { + return Err(__lookahead); + } + } + while __sym1.is_some() { + let (__lookbehind, __lookahead, __nt) = __result; + match __nt { + __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state12(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + __Nonterminal::Factor(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state41(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + _ => { + return Ok((__lookbehind, __lookahead, __nt)); + } + } + } + return Ok(__result); + } + + // State 23 + // Expr = Expr "-" (*) Factor [")"] + // Expr = Expr "-" (*) Factor ["+"] + // Expr = Expr "-" (*) Factor ["-"] + // Factor = (*) Factor "*" Term [")"] + // Factor = (*) Factor "*" Term ["*"] + // Factor = (*) Factor "*" Term ["+"] + // Factor = (*) Factor "*" Term ["-"] + // Factor = (*) Factor "*" Term ["/"] + // Factor = (*) Factor "/" Term [")"] + // Factor = (*) Factor "/" Term ["*"] + // Factor = (*) Factor "/" Term ["+"] + // Factor = (*) Factor "/" Term ["-"] + // Factor = (*) Factor "/" Term ["/"] + // Factor = (*) Term [")"] + // Factor = (*) Term ["*"] + // Factor = (*) Term ["+"] + // Factor = (*) Term ["-"] + // Factor = (*) Term ["/"] + // Factor = (*) "*" "(" Comma ")" [")"] + // Factor = (*) "*" "(" Comma ")" ["*"] + // Factor = (*) "*" "(" Comma ")" ["+"] + // Factor = (*) "*" "(" Comma ")" ["-"] + // Factor = (*) "*" "(" Comma ")" ["/"] + // Term = (*) "(" Expr ")" [")"] + // Term = (*) "(" Expr ")" ["*"] + // Term = (*) "(" Expr ")" ["+"] + // Term = (*) "(" Expr ")" ["-"] + // Term = (*) "(" Expr ")" ["/"] + // Term = (*) "Num" [")"] + // Term = (*) "Num" ["*"] + // Term = (*) "Num" ["+"] + // Term = (*) "Num" ["-"] + // Term = (*) "Num" ["/"] + // + // "Num" -> Shift(S8) + // "*" -> Shift(S11) + // "(" -> Shift(S9) + // + // Term -> S12 + // Factor -> S42 + pub fn __state23< + '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!(__state8(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!(__state9(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + _ => { + return Err(__lookahead); + } + } + while __sym1.is_some() { + let (__lookbehind, __lookahead, __nt) = __result; + match __nt { + __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state12(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + __Nonterminal::Factor(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state42(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + _ => { + return Ok((__lookbehind, __lookahead, __nt)); + } + } + } + return Ok(__result); + } + + // State 24 + // ( ",")* = (*) ["("] + // ( ",")* = (*) [")"] + // ( ",")* = (*) ["*"] + // ( ",")* = (*) ["Num"] + // ( ",")* = (*) ( ",")* ( ",") ["("] + // ( ",")* = (*) ( ",")* ( ",") [")"] + // ( ",")* = (*) ( ",")* ( ",") ["*"] + // ( ",")* = (*) ( ",")* ( ",") ["Num"] + // Comma = (*) ( ",")* Expr? [")"] + // Factor = "*" "(" (*) Comma ")" [")"] + // Factor = "*" "(" (*) Comma ")" ["*"] + // Factor = "*" "(" (*) Comma ")" ["+"] + // Factor = "*" "(" (*) Comma ")" ["-"] + // Factor = "*" "(" (*) Comma ")" ["/"] + // + // "*" -> Reduce(( ",")* = => Call(ActionFn(13));) + // "Num" -> Reduce(( ",")* = => Call(ActionFn(13));) + // "(" -> Reduce(( ",")* = => Call(ActionFn(13));) + // ")" -> Reduce(( ",")* = => Call(ActionFn(13));) + // + // Comma -> S43 + // ( ",")* -> S18 + 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, + ) -> 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 __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::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)); + } + _ => { + 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!(__state43(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!(__state18(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + _ => { + return Ok((__lookbehind, __lookahead, __nt)); + } + } + } + return Ok(__result); + } + + // State 25 + // Factor = Factor "*" (*) Term [")"] + // Factor = Factor "*" (*) Term ["*"] + // Factor = Factor "*" (*) Term ["+"] + // Factor = Factor "*" (*) Term ["-"] + // Factor = Factor "*" (*) Term ["/"] + // Term = (*) "(" Expr ")" [")"] + // Term = (*) "(" Expr ")" ["*"] + // Term = (*) "(" Expr ")" ["+"] + // Term = (*) "(" Expr ")" ["-"] + // Term = (*) "(" Expr ")" ["/"] + // Term = (*) "Num" [")"] + // Term = (*) "Num" ["*"] + // Term = (*) "Num" ["+"] + // Term = (*) "Num" ["-"] + // Term = (*) "Num" ["/"] + // + // "Num" -> Shift(S8) + // "(" -> Shift(S9) + // + // Term -> S44 + pub fn __state25< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + __sym1: &mut Option, + ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, Tok::Num(__tok0), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok0)); + let __lookahead = __tokens.next(); + __result = try!(__state8(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!(__state9(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + _ => { + return Err(__lookahead); + } + } + while __sym1.is_some() { + let (__lookbehind, __lookahead, __nt) = __result; + match __nt { + __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state44(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + _ => { + return Ok((__lookbehind, __lookahead, __nt)); + } + } + } + return Ok(__result); + } + + // State 26 + // 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(S8) + // "(" -> Shift(S9) + // + // Term -> S45 + 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, + ) -> 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!(__state8(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!(__state9(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + _ => { + return Err(__lookahead); + } + } + while __sym1.is_some() { + let (__lookbehind, __lookahead, __nt) = __result; + match __nt { + __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state45(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + _ => { + return Ok((__lookbehind, __lookahead, __nt)); + } + } + } + return Ok(__result); + } + + // State 27 + // Factor = Factor "*" Term (*) [EOF] + // Factor = Factor "*" Term (*) ["*"] + // Factor = Factor "*" Term (*) ["+"] + // Factor = Factor "*" Term (*) ["-"] + // Factor = Factor "*" Term (*) ["/"] + // + // "*" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // 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 __state27< 'ast, @@ -2042,66 +2034,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!(__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(..), _)) => { + 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))); } 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))); + 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::__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))); + } + 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))); } _ => { return Err(__lookahead); } } - return Ok(__result); } // State 28 - // Expr = Expr "+" Factor (*) [EOF] - // Expr = Expr "+" Factor (*) ["+"] - // Expr = Expr "+" Factor (*) ["-"] - // Factor = Factor (*) "*" Term [EOF] - // Factor = Factor (*) "*" Term ["*"] - // Factor = Factor (*) "*" Term ["+"] - // Factor = Factor (*) "*" Term ["-"] - // Factor = Factor (*) "*" Term ["/"] - // Factor = Factor (*) "/" Term [EOF] - // Factor = Factor (*) "/" Term ["*"] - // Factor = Factor (*) "/" Term ["+"] - // Factor = Factor (*) "/" Term ["-"] - // Factor = Factor (*) "/" Term ["/"] + // Factor = Factor "/" Term (*) [EOF] + // Factor = Factor "/" Term (*) ["*"] + // Factor = Factor "/" Term (*) ["+"] + // Factor = Factor "/" Term (*) ["-"] + // Factor = Factor "/" Term (*) ["/"] // - // "-" -> 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));) + // "+" -> 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(5));) // pub fn __state28< 'ast, @@ -2118,58 +2103,67 @@ 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!(__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))); + 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))); } 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))); + 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))); } _ => { return Err(__lookahead); } } - return Ok(__result); } // State 29 - // Factor = Factor "*" Term (*) [EOF] - // Factor = Factor "*" Term (*) ["*"] - // Factor = Factor "*" Term (*) ["+"] - // Factor = Factor "*" Term (*) ["-"] - // Factor = Factor "*" Term (*) ["/"] + // Expr = Expr "+" Factor (*) [EOF] + // Expr = Expr "+" Factor (*) ["+"] + // Expr = Expr "+" Factor (*) ["-"] + // Factor = Factor (*) "*" Term [EOF] + // Factor = Factor (*) "*" Term ["*"] + // Factor = Factor (*) "*" Term ["+"] + // Factor = Factor (*) "*" Term ["-"] + // Factor = Factor (*) "*" Term ["/"] + // Factor = Factor (*) "/" Term [EOF] + // Factor = Factor (*) "/" Term ["*"] + // Factor = Factor (*) "/" Term ["+"] + // Factor = Factor (*) "/" Term ["-"] + // Factor = Factor (*) "/" Term ["/"] // - // "+" -> Reduce(Factor = Factor, "*", Term => 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));) + // "*" -> Shift(S14) + // "-" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) + // EOF -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) + // "+" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) + // "/" -> Shift(S15) // pub fn __state29< 'ast, @@ -2186,59 +2180,66 @@ mod __parse__Expr { { let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some((_, Tok::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__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!(__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::__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 @ Tok::Div(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym3 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state15(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); } Some((_, Tok::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::__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))); + } + 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))); } _ => { return Err(__lookahead); } } + return Ok(__result); } // State 30 - // Factor = Factor "/" Term (*) [EOF] - // Factor = Factor "/" Term (*) ["*"] - // Factor = Factor "/" Term (*) ["+"] - // Factor = Factor "/" Term (*) ["-"] - // Factor = Factor "/" Term (*) ["/"] + // Expr = Expr "-" Factor (*) [EOF] + // Expr = Expr "-" Factor (*) ["+"] + // Expr = Expr "-" Factor (*) ["-"] + // Factor = Factor (*) "*" Term [EOF] + // Factor = Factor (*) "*" Term ["*"] + // Factor = Factor (*) "*" Term ["+"] + // Factor = Factor (*) "*" Term ["-"] + // Factor = Factor (*) "*" Term ["/"] + // Factor = Factor (*) "/" Term [EOF] + // Factor = Factor (*) "/" Term ["*"] + // Factor = Factor (*) "/" Term ["+"] + // Factor = Factor (*) "/" Term ["-"] + // Factor = Factor (*) "/" Term ["/"] // - // EOF -> Reduce(Factor = Factor, "/", Term => 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));) + // EOF -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // "/" -> Shift(S15) + // "*" -> Shift(S14) + // "-" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // "+" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) // pub fn __state30< 'ast, @@ -2255,67 +2256,60 @@ 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!(__state15(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!(__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::__action5(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::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))); + 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::__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))); + let __nt = super::__actions::__action1(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); } _ => { return Err(__lookahead); } } + return Ok(__result); } // 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 ["/"] + // Term = "Num" (*) [")"] + // Term = "Num" (*) ["*"] + // Term = "Num" (*) ["+"] + // Term = "Num" (*) [","] + // Term = "Num" (*) ["-"] + // Term = "Num" (*) ["/"] // - // "+" -> 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) + // "-" -> 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 __state31< 'ast, @@ -2325,385 +2319,59 @@ mod __parse__Expr { __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>>, + __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::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 __nt = super::__actions::__action8(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); } - Some((_, __tok @ Tok::Times(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym3 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state21(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); + Some((_, Tok::Comma(..), _)) => { + 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::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 __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))); + let __nt = super::__actions::__action8(arena, __sym0); + 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::__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))); + let __nt = super::__actions::__action8(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); } _ => { return Err(__lookahead); } } - return Ok(__result); } // State 32 - // Expr = Expr "-" Factor (*) [")"] - // Expr = Expr "-" Factor (*) ["+"] - // Expr = Expr "-" Factor (*) ["-"] - // Factor = Factor (*) "*" Term [")"] - // Factor = Factor (*) "*" Term ["*"] - // Factor = Factor (*) "*" Term ["+"] - // Factor = Factor (*) "*" Term ["-"] - // Factor = Factor (*) "*" Term ["/"] - // Factor = Factor (*) "/" Term [")"] - // Factor = Factor (*) "/" Term ["*"] - // Factor = Factor (*) "/" Term ["+"] - // Factor = Factor (*) "/" Term ["-"] - // Factor = Factor (*) "/" Term ["/"] - // - // "+" -> 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, - __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!(__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::__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 33 - // Factor = Factor "*" Term (*) [")"] - // Factor = Factor "*" Term (*) ["*"] - // Factor = Factor "*" Term (*) ["+"] - // Factor = Factor "*" Term (*) ["-"] - // Factor = Factor "*" Term (*) ["/"] - // - // "*" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) - // ")" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) - // "-" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) - // "+" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) - // "/" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) - // - pub fn __state33< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize,Tok,usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, - __sym2: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> - { - let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, Tok::Times(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__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::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::__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); - } - } - } - - // State 34 - // Factor = Factor "/" Term (*) [")"] - // Factor = Factor "/" Term (*) ["*"] - // Factor = Factor "/" Term (*) ["+"] - // Factor = Factor "/" Term (*) ["-"] - // Factor = Factor "/" Term (*) ["/"] - // - // "-" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // "*" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // "/" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // ")" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // "+" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) - // - pub fn __state34< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize,Tok,usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, - __sym2: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> - { - let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, Tok::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::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))); - } - 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); - } - } - } - - // State 35 - // Factor = "*" "(" Comma (*) ")" [")"] - // Factor = "*" "(" Comma (*) ")" ["*"] - // Factor = "*" "(" Comma (*) ")" ["+"] - // Factor = "*" "(" Comma (*) ")" ["-"] - // Factor = "*" "(" Comma (*) ")" ["/"] - // - // ")" -> Shift(S46) - // - 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, - __sym2: &mut Option>>, - ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> - { - let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, __tok @ Tok::RParen(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym3 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state46(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2, __sym3)); - } - _ => { - return Err(__lookahead); - } - } - 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));) + // ")" -> Reduce(( ",")* = ( ",")*, ( ",") => Call(ActionFn(14));) + // "*" -> Reduce(( ",")* = ( ",")*, ( ",") => Call(ActionFn(14));) // - pub fn __state37< + pub fn __state32< 'ast, __TOKENS: Iterator, >( @@ -2717,18 +2385,6 @@ mod __parse__Expr { { let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some((_, Tok::Times(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __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(); @@ -2741,13 +2397,88 @@ mod __parse__Expr { 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))); + } _ => { return Err(__lookahead); } } } - // State 38 + // State 33 + // ( ",") = Expr (*) "," ["("] + // ( ",") = Expr (*) "," [")"] + // ( ",") = Expr (*) "," ["*"] + // ( ",") = Expr (*) "," ["Num"] + // Expr = Expr (*) "+" Factor [")"] + // Expr = Expr (*) "+" Factor ["+"] + // Expr = Expr (*) "+" Factor [","] + // Expr = Expr (*) "+" Factor ["-"] + // Expr = Expr (*) "-" Factor [")"] + // Expr = Expr (*) "-" Factor ["+"] + // Expr = Expr (*) "-" Factor [","] + // Expr = Expr (*) "-" Factor ["-"] + // Expr? = Expr (*) [")"] + // + // ")" -> Reduce(Expr? = Expr => Call(ActionFn(11));) + // "," -> Shift(S46) + // "+" -> Shift(S48) + // "-" -> Shift(S47) + // + pub fn __state33< + '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::Comma(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state46(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!(__state48(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + } + Some((_, __tok @ Tok::Minus(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state47(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 34 // Expr = Factor (*) [")"] // Expr = Factor (*) ["+"] // Expr = Factor (*) [","] @@ -2766,13 +2497,13 @@ mod __parse__Expr { // 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));) + // "*" -> Shift(S49) + // "/" -> Shift(S50) + // ")" -> Reduce(Expr = Factor => Call(ActionFn(3));) // - pub fn __state38< + pub fn __state34< 'ast, __TOKENS: Iterator, >( @@ -2785,164 +2516,37 @@ 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 __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 @ 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::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::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::__action11(arena, __sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::Expr_3f(__nt))); + let __nt = super::__actions::__action3(arena, __sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); } _ => { return Err(__lookahead); @@ -2951,7 +2555,7 @@ mod __parse__Expr { return Ok(__result); } - // State 41 + // State 35 // Factor = "*" (*) "(" Comma ")" [")"] // Factor = "*" (*) "(" Comma ")" ["*"] // Factor = "*" (*) "(" Comma ")" ["+"] @@ -2959,9 +2563,9 @@ mod __parse__Expr { // Factor = "*" (*) "(" Comma ")" ["-"] // Factor = "*" (*) "(" Comma ")" ["/"] // - // "(" -> Shift(S52) + // "(" -> Shift(S51) // - pub fn __state41< + pub fn __state35< 'ast, __TOKENS: Iterator, >( @@ -2978,7 +2582,7 @@ mod __parse__Expr { let mut __lookbehind = Some(__loc); let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state52(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); + __result = try!(__state51(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); } _ => { return Err(__lookahead); @@ -2987,102 +2591,7 @@ mod __parse__Expr { return Ok(__result); } - // State 42 - // Comma = ( ",")* Expr? (*) [")"] - // - // ")" -> Reduce(Comma = ( ",")*, Expr? => Call(ActionFn(10));) - // - pub fn __state42< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize,Tok,usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option<::std::vec::Vec<&'ast Node<'ast>>>, - __sym1: &mut Option<::std::option::Option<&'ast Node<'ast>>>, - ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> - { - let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, Tok::RParen(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __nt = super::__actions::__action10(arena, __sym0, __sym1); - return Ok((__lookbehind, __lookahead, __Nonterminal::Comma_3cExpr_3e(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 43 - // Term = "Num" (*) [")"] - // Term = "Num" (*) ["*"] - // Term = "Num" (*) ["+"] - // Term = "Num" (*) [","] - // Term = "Num" (*) ["-"] - // Term = "Num" (*) ["/"] - // - // "," -> Reduce(Term = "Num" => Call(ActionFn(8));) - // "-" -> Reduce(Term = "Num" => Call(ActionFn(8));) - // ")" -> Reduce(Term = "Num" => Call(ActionFn(8));) - // "+" -> Reduce(Term = "Num" => Call(ActionFn(8));) - // "*" -> Reduce(Term = "Num" => Call(ActionFn(8));) - // "/" -> Reduce(Term = "Num" => Call(ActionFn(8));) - // - pub fn __state43< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - __lookbehind: Option, - __lookahead: Option<(usize,Tok,usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> - { - let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); - match __lookahead { - Some((_, Tok::Comma(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__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::RParen(..), _)) => { - 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 44 + // State 36 // Expr = (*) Expr "+" Factor [")"] // Expr = (*) Expr "+" Factor ["+"] // Expr = (*) Expr "+" Factor ["-"] @@ -3129,14 +2638,14 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "Num" -> Shift(S10) + // "(" -> Shift(S9) + // "Num" -> Shift(S8) // "*" -> Shift(S11) - // "(" -> Shift(S12) // - // Expr -> S53 - // Term -> S7 - // Factor -> S9 - pub fn __state44< + // Term -> S12 + // Expr -> S52 + // Factor -> S13 + pub fn __state36< 'ast, __TOKENS: Iterator, >( @@ -3149,11 +2658,17 @@ 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!(__state9(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)); + __result = try!(__state8(arena, __lookbehind, __lookahead, __tokens, __sym1)); } Some((_, __tok @ Tok::Times(..), __loc)) => { let mut __lookbehind = Some(__loc); @@ -3161,12 +2676,6 @@ 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); } @@ -3174,17 +2683,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!(__state53(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); - } __Nonterminal::Term(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state7(arena, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state12(arena, __lookbehind, __lookahead, __tokens, __sym1)); + } + __Nonterminal::Expr(__nt) => { + let __sym1 = &mut Some(__nt); + __result = try!(__state52(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1)); } __Nonterminal::Factor(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state9(arena, __lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state13(arena, __lookbehind, __lookahead, __tokens, __sym1)); } _ => { return Ok((__lookbehind, __lookahead, __nt)); @@ -3194,20 +2703,115 @@ mod __parse__Expr { return Ok(__result); } - // State 45 + // State 37 + // Comma = ( ",")* Expr? (*) [")"] + // + // ")" -> Reduce(Comma = ( ",")*, Expr? => Call(ActionFn(10));) + // + 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<::std::option::Option<&'ast Node<'ast>>>, + ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, Tok::RParen(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __nt = super::__actions::__action10(arena, __sym0, __sym1); + return Ok((__lookbehind, __lookahead, __Nonterminal::Comma_3cExpr_3e(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 38 + // 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 __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::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))); + } + Some((_, Tok::RParen(..), _)) => { + 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 39 // Factor = "*" "(" Comma ")" (*) [EOF] // Factor = "*" "(" Comma ")" (*) ["*"] // Factor = "*" "(" Comma ")" (*) ["+"] // Factor = "*" "(" Comma ")" (*) ["-"] // Factor = "*" "(" Comma ")" (*) ["/"] // - // "+" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) - // "-" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) - // "*" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) // "/" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) + // "*" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) + // "-" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) // EOF -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) + // "+" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) // - pub fn __state45< + pub fn __state39< 'ast, __TOKENS: Iterator, >( @@ -3223,15 +2827,7 @@ mod __parse__Expr { { let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some((_, Tok::Plus(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __sym3 = __sym3.take().unwrap(); - let __nt = super::__actions::__action6(arena, __sym0, __sym1, __sym2, __sym3); - return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); - } - Some((_, Tok::Minus(..), _)) => { + Some((_, Tok::Div(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); @@ -3247,7 +2843,7 @@ mod __parse__Expr { let __nt = super::__actions::__action6(arena, __sym0, __sym1, __sym2, __sym3); return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } - Some((_, Tok::Div(..), _)) => { + Some((_, Tok::Minus(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); @@ -3263,26 +2859,251 @@ mod __parse__Expr { 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(); + 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); } } } - // State 46 - // Factor = "*" "(" Comma ")" (*) [")"] - // Factor = "*" "(" Comma ")" (*) ["*"] - // Factor = "*" "(" Comma ")" (*) ["+"] - // Factor = "*" "(" Comma ")" (*) ["-"] - // Factor = "*" "(" Comma ")" (*) ["/"] + // State 40 + // Term = "(" Expr ")" (*) [")"] + // Term = "(" Expr ")" (*) ["*"] + // Term = "(" Expr ")" (*) ["+"] + // Term = "(" Expr ")" (*) ["-"] + // Term = "(" Expr ")" (*) ["/"] // - // "*" -> 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(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 __state46< + pub fn __state40< + '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::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::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::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 41 + // Expr = Expr "+" Factor (*) [")"] + // Expr = Expr "+" Factor (*) ["+"] + // Expr = Expr "+" Factor (*) ["-"] + // Factor = Factor (*) "*" Term [")"] + // Factor = Factor (*) "*" Term ["*"] + // Factor = Factor (*) "*" Term ["+"] + // Factor = Factor (*) "*" Term ["-"] + // Factor = Factor (*) "*" Term ["/"] + // Factor = Factor (*) "/" Term [")"] + // Factor = Factor (*) "/" Term ["*"] + // Factor = Factor (*) "/" Term ["+"] + // Factor = Factor (*) "/" Term ["-"] + // Factor = Factor (*) "/" Term ["/"] + // + // "/" -> Shift(S26) + // "+" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) + // "*" -> Shift(S25) + // ")" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) + // "-" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) + // + 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>>, + __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!(__state26(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); + } + Some((_, __tok @ Tok::Times(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym3 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state25(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); + } + Some((_, Tok::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::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::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 42 + // 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(1));) + // "*" -> Shift(S25) + // ")" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // "/" -> Shift(S26) + // "-" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // + 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>>, + __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!(__state25(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!(__state26(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::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 43 + // Factor = "*" "(" Comma (*) ")" [")"] + // Factor = "*" "(" Comma (*) ")" ["*"] + // Factor = "*" "(" Comma (*) ")" ["+"] + // Factor = "*" "(" Comma (*) ")" ["-"] + // Factor = "*" "(" Comma (*) ")" ["/"] + // + // ")" -> Shift(S53) + // + pub fn __state43< 'ast, __TOKENS: Iterator, >( @@ -3293,49 +3114,84 @@ mod __parse__Expr { __sym0: &mut Option, __sym1: &mut Option, __sym2: &mut Option>>, - __sym3: &mut Option, ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> { let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some((_, Tok::Times(..), _)) => { + Some((_, __tok @ Tok::RParen(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym3 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state53(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2, __sym3)); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + + // State 44 + // Factor = Factor "*" Term (*) [")"] + // Factor = Factor "*" Term (*) ["*"] + // Factor = Factor "*" Term (*) ["+"] + // Factor = Factor "*" Term (*) ["-"] + // Factor = Factor "*" Term (*) ["/"] + // + // "+" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // ")" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // "/" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // "-" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // "*" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // + pub fn __state44< + '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 __sym3 = __sym3.take().unwrap(); - let __nt = super::__actions::__action6(arena, __sym0, __sym1, __sym2, __sym3); + 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 __sym3 = __sym3.take().unwrap(); - let __nt = super::__actions::__action6(arena, __sym0, __sym1, __sym2, __sym3); + 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 __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(); - let __sym2 = __sym2.take().unwrap(); - let __sym3 = __sym3.take().unwrap(); - let __nt = super::__actions::__action6(arena, __sym0, __sym1, __sym2, __sym3); + 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 __sym3 = __sym3.take().unwrap(); - let __nt = super::__actions::__action6(arena, __sym0, __sym1, __sym2, __sym3); + 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))); } _ => { @@ -3344,31 +3200,20 @@ mod __parse__Expr { } } - // State 47 - // Factor = Factor "/" (*) Term [")"] - // Factor = Factor "/" (*) Term ["*"] - // Factor = Factor "/" (*) Term ["+"] - // Factor = Factor "/" (*) Term [","] - // Factor = Factor "/" (*) Term ["-"] - // Factor = Factor "/" (*) Term ["/"] - // Term = (*) "(" Expr ")" [")"] - // Term = (*) "(" Expr ")" ["*"] - // Term = (*) "(" Expr ")" ["+"] - // Term = (*) "(" Expr ")" [","] - // Term = (*) "(" Expr ")" ["-"] - // Term = (*) "(" Expr ")" ["/"] - // Term = (*) "Num" [")"] - // Term = (*) "Num" ["*"] - // Term = (*) "Num" ["+"] - // Term = (*) "Num" [","] - // Term = (*) "Num" ["-"] - // Term = (*) "Num" ["/"] + // State 45 + // Factor = Factor "/" Term (*) [")"] + // Factor = Factor "/" Term (*) ["*"] + // Factor = Factor "/" Term (*) ["+"] + // Factor = Factor "/" Term (*) ["-"] + // Factor = Factor "/" Term (*) ["/"] // - // "Num" -> Shift(S43) - // "(" -> Shift(S44) + // "+" -> 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));) // - // Term -> S54 - pub fn __state47< + pub fn __state45< 'ast, __TOKENS: Iterator, >( @@ -3378,122 +3223,64 @@ mod __parse__Expr { __tokens: &mut __TOKENS, __sym0: &mut Option<&'ast Node<'ast>>, __sym1: &mut Option, + __sym2: &mut Option<&'ast Node<'ast>>, ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> { let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some((_, Tok::Num(__tok0), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state43(arena, __lookbehind, __lookahead, __tokens, __sym2)); + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action5(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } - Some((_, __tok @ Tok::LParen(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state44(arena, __lookbehind, __lookahead, __tokens, __sym2)); + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__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::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); } } - 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, - >( - 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!(__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); - } - } - while __sym1.is_some() { - let (__lookbehind, __lookahead, __nt) = __result; - match __nt { - __Nonterminal::Term(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state55(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - _ => { - return Ok((__lookbehind, __lookahead, __nt)); - } - } - } - return Ok(__result); - } - - // State 49 + // State 46 // ( ",") = 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));) + // "(" -> Reduce(( ",") = Expr, "," => Call(ActionFn(15));) // - pub fn __state49< + pub fn __state46< 'ast, __TOKENS: Iterator, >( @@ -3507,12 +3294,6 @@ mod __parse__Expr { { 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(); @@ -3531,13 +3312,19 @@ mod __parse__Expr { let __nt = super::__actions::__action15(arena, __sym0, __sym1); return Ok((__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29(__nt))); } + Some((_, Tok::LParen(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __nt = super::__actions::__action15(arena, __sym0, __sym1); + return Ok((__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29(__nt))); + } _ => { return Err(__lookahead); } } } - // State 50 + // State 47 // Expr = Expr "-" (*) Factor [")"] // Expr = Expr "-" (*) Factor ["+"] // Expr = Expr "-" (*) Factor [","] @@ -3579,13 +3366,13 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "Num" -> Shift(S43) - // "(" -> Shift(S44) - // "*" -> Shift(S41) + // "(" -> Shift(S36) + // "Num" -> Shift(S31) + // "*" -> Shift(S35) // - // Factor -> S56 - // Term -> S39 - pub fn __state50< + // Term -> S38 + // Factor -> S54 + pub fn __state47< 'ast, __TOKENS: Iterator, >( @@ -3599,23 +3386,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!(__state44(arena, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state36(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!(__state31(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!(__state41(arena, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state35(arena, __lookbehind, __lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); @@ -3624,13 +3411,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!(__state56(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } __Nonterminal::Term(__nt) => { let __sym2 = &mut Some(__nt); - __result = try!(__state39(arena, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state38(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + __Nonterminal::Factor(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state54(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); } _ => { return Ok((__lookbehind, __lookahead, __nt)); @@ -3640,7 +3427,7 @@ mod __parse__Expr { return Ok(__result); } - // State 51 + // State 48 // Expr = Expr "+" (*) Factor [")"] // Expr = Expr "+" (*) Factor ["+"] // Expr = Expr "+" (*) Factor [","] @@ -3682,13 +3469,13 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "*" -> Shift(S41) - // "(" -> Shift(S44) - // "Num" -> Shift(S43) + // "Num" -> Shift(S31) + // "(" -> Shift(S36) + // "*" -> Shift(S35) // - // Factor -> S57 - // Term -> S39 - pub fn __state51< + // Term -> S38 + // Factor -> S55 + pub fn __state48< 'ast, __TOKENS: Iterator, >( @@ -3702,23 +3489,23 @@ mod __parse__Expr { { let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some((_, __tok @ Tok::Times(..), __loc)) => { + Some((_, Tok::Num(__tok0), __loc)) => { let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok)); + let mut __sym2 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state41(arena, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state31(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)); + __result = try!(__state36(arena, __lookbehind, __lookahead, __tokens, __sym2)); } - Some((_, Tok::Num(__tok0), __loc)) => { + Some((_, __tok @ Tok::Times(..), __loc)) => { let mut __lookbehind = Some(__loc); - let mut __sym2 = &mut Some((__tok0)); + let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state43(arena, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state35(arena, __lookbehind, __lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); @@ -3727,13 +3514,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!(__state57(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } __Nonterminal::Term(__nt) => { let __sym2 = &mut Some(__nt); - __result = try!(__state39(arena, __lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state38(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + __Nonterminal::Factor(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state55(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); } _ => { return Ok((__lookbehind, __lookahead, __nt)); @@ -3743,7 +3530,145 @@ mod __parse__Expr { return Ok(__result); } - // State 52 + // State 49 + // Factor = Factor "*" (*) Term [")"] + // Factor = Factor "*" (*) Term ["*"] + // Factor = Factor "*" (*) Term ["+"] + // Factor = Factor "*" (*) Term [","] + // Factor = Factor "*" (*) Term ["-"] + // Factor = Factor "*" (*) Term ["/"] + // Term = (*) "(" Expr ")" [")"] + // Term = (*) "(" Expr ")" ["*"] + // Term = (*) "(" Expr ")" ["+"] + // Term = (*) "(" Expr ")" [","] + // Term = (*) "(" Expr ")" ["-"] + // Term = (*) "(" Expr ")" ["/"] + // Term = (*) "Num" [")"] + // Term = (*) "Num" ["*"] + // Term = (*) "Num" ["+"] + // Term = (*) "Num" [","] + // Term = (*) "Num" ["-"] + // Term = (*) "Num" ["/"] + // + // "(" -> Shift(S36) + // "Num" -> Shift(S31) + // + // 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 @ Tok::LParen(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state36(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!(__state31(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 ["+"] + // 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(S36) + // "Num" -> Shift(S31) + // + // Term -> S57 + pub fn __state50< + '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!(__state36(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!(__state31(arena, __lookbehind, __lookahead, __tokens, __sym2)); + } + _ => { + return Err(__lookahead); + } + } + while __sym1.is_some() { + let (__lookbehind, __lookahead, __nt) = __result; + match __nt { + __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state57(arena, __lookbehind, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + _ => { + return Ok((__lookbehind, __lookahead, __nt)); + } + } + } + return Ok(__result); + } + + // State 51 // ( ",")* = (*) ["("] // ( ",")* = (*) [")"] // ( ",")* = (*) ["*"] @@ -3760,14 +3685,14 @@ mod __parse__Expr { // Factor = "*" "(" (*) Comma ")" ["-"] // Factor = "*" "(" (*) Comma ")" ["/"] // - // "Num" -> Reduce(( ",")* = => Call(ActionFn(13));) // "(" -> Reduce(( ",")* = => Call(ActionFn(13));) - // ")" -> Reduce(( ",")* = => Call(ActionFn(13));) + // "Num" -> Reduce(( ",")* = => Call(ActionFn(13));) // "*" -> Reduce(( ",")* = => Call(ActionFn(13));) + // ")" -> Reduce(( ",")* = => Call(ActionFn(13));) // - // ( ",")* -> S25 + // ( ",")* -> S18 // Comma -> S58 - pub fn __state52< + pub fn __state51< 'ast, __TOKENS: Iterator, >( @@ -3781,15 +3706,11 @@ mod __parse__Expr { { 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(..), _)) => { + Some((_, Tok::Num(_), _)) => { let __nt = super::__actions::__action13(arena, ); __result = (__lookbehind, __lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); } @@ -3797,6 +3718,10 @@ 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)); + } _ => { return Err(__lookahead); } @@ -3806,7 +3731,7 @@ mod __parse__Expr { 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)); + __result = try!(__state18(arena, __lookbehind, __lookahead, __tokens, __sym2)); } __Nonterminal::Comma_3cExpr_3e(__nt) => { let __sym2 = &mut Some(__nt); @@ -3820,7 +3745,7 @@ mod __parse__Expr { return Ok(__result); } - // State 53 + // State 52 // Expr = Expr (*) "+" Factor [")"] // Expr = Expr (*) "+" Factor ["+"] // Expr = Expr (*) "+" Factor ["-"] @@ -3834,11 +3759,11 @@ mod __parse__Expr { // Term = "(" Expr (*) ")" ["-"] // Term = "(" Expr (*) ")" ["/"] // - // "-" -> Shift(S20) - // "+" -> Shift(S18) + // "-" -> Shift(S23) + // "+" -> Shift(S22) // ")" -> Shift(S59) // - pub fn __state53< + pub fn __state52< 'ast, __TOKENS: Iterator, >( @@ -3856,13 +3781,13 @@ mod __parse__Expr { let mut __lookbehind = Some(__loc); let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state20(arena, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); + __result = try!(__state23(arena, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); } Some((_, __tok @ Tok::Plus(..), __loc)) => { let mut __lookbehind = Some(__loc); let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state18(arena, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); + __result = try!(__state22(arena, __lookbehind, __lookahead, __tokens, __sym1, __sym2)); } Some((_, __tok @ Tok::RParen(..), __loc)) => { let mut __lookbehind = Some(__loc); @@ -3877,163 +3802,82 @@ mod __parse__Expr { return Ok(__result); } + // State 53 + // Factor = "*" "(" Comma ")" (*) [")"] + // Factor = "*" "(" Comma ")" (*) ["*"] + // Factor = "*" "(" Comma ")" (*) ["+"] + // Factor = "*" "(" Comma ")" (*) ["-"] + // Factor = "*" "(" Comma ")" (*) ["/"] + // + // ")" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) + // "*" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) + // "-" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) + // "/" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) + // "+" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) + // + pub fn __state53< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + __sym1: &mut Option, + __sym2: &mut Option>>, + __sym3: &mut Option, + ) -> Result<(Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, Tok::RParen(..), _)) => { + 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::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(); + 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::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __sym3 = __sym3.take().unwrap(); + let __nt = super::__actions::__action6(arena, __sym0, __sym1, __sym2, __sym3); + return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + // 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 __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 __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); - } - } - } - - // 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 (*) [","] @@ -4051,14 +3895,14 @@ mod __parse__Expr { // 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));) + // "," -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // "*" -> Shift(S49) // "-" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // "/" -> Shift(S50) // - pub fn __state56< + pub fn __state54< 'ast, __TOKENS: Iterator, >( @@ -4077,13 +3921,20 @@ mod __parse__Expr { let mut __lookbehind = Some(__loc); let mut __sym3 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state48(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); + __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!(__state47(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); + __result = try!(__state50(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::__action1(arena, __sym0, __sym1, __sym2); + return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); } Some((_, Tok::Plus(..), _)) => { let __sym0 = __sym0.take().unwrap(); @@ -4099,13 +3950,6 @@ mod __parse__Expr { 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(); @@ -4120,7 +3964,7 @@ mod __parse__Expr { return Ok(__result); } - // State 57 + // State 55 // Expr = Expr "+" Factor (*) [")"] // Expr = Expr "+" Factor (*) ["+"] // Expr = Expr "+" Factor (*) [","] @@ -4138,14 +3982,14 @@ mod __parse__Expr { // 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) + // "*" -> Shift(S49) + // "-" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) + // "/" -> Shift(S50) // ")" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) + // "," -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) // - pub fn __state57< + pub fn __state55< 'ast, __TOKENS: Iterator, >( @@ -4164,20 +4008,13 @@ mod __parse__Expr { let mut __lookbehind = Some(__loc); let mut __sym3 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state48(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); + __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!(__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))); + __result = try!(__state50(arena, __lookbehind, __lookahead, __tokens, __sym2, __sym3)); } Some((_, Tok::Plus(..), _)) => { let __sym0 = __sym0.take().unwrap(); @@ -4186,7 +4023,7 @@ mod __parse__Expr { let __nt = super::__actions::__action2(arena, __sym0, __sym1, __sym2); return Ok((__lookbehind, __lookahead, __Nonterminal::Expr(__nt))); } - Some((_, Tok::Comma(..), _)) => { + Some((_, Tok::Minus(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); @@ -4200,6 +4037,13 @@ mod __parse__Expr { 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))); + } _ => { return Err(__lookahead); } @@ -4207,6 +4051,162 @@ mod __parse__Expr { return Ok(__result); } + // 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::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::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::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::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::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))); + } + _ => { + 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::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::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::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::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 58 // Factor = "*" "(" Comma (*) ")" [")"] // Factor = "*" "(" Comma (*) ")" ["*"] @@ -4253,12 +4253,12 @@ mod __parse__Expr { // Term = "(" Expr ")" (*) ["-"] // Term = "(" Expr ")" (*) ["/"] // - // "/" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) - // "," -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) // "-" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) // "+" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) - // ")" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) // "*" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) + // ")" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) + // "/" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) + // "," -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) // pub fn __state59< 'ast, @@ -4275,20 +4275,6 @@ mod __parse__Expr { { let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some((_, Tok::Div(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __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::Comma(..), _)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action9(arena, __sym0, __sym1, __sym2); - return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); - } Some((_, Tok::Minus(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); @@ -4303,6 +4289,13 @@ mod __parse__Expr { 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::RParen(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); @@ -4310,7 +4303,14 @@ mod __parse__Expr { let __nt = super::__actions::__action9(arena, __sym0, __sym1, __sym2); return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt))); } - Some((_, Tok::Times(..), _)) => { + 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::Comma(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); @@ -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));) // pub fn __state60< 'ast, @@ -4354,14 +4354,6 @@ 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(); @@ -4378,6 +4370,14 @@ 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::Plus(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); @@ -4386,7 +4386,7 @@ mod __parse__Expr { let __nt = super::__actions::__action6(arena, __sym0, __sym1, __sym2, __sym3); return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } - Some((_, Tok::RParen(..), _)) => { + Some((_, Tok::Times(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); @@ -4394,7 +4394,7 @@ mod __parse__Expr { let __nt = super::__actions::__action6(arena, __sym0, __sym1, __sym2, __sym3); return Ok((__lookbehind, __lookahead, __Nonterminal::Factor(__nt))); } - Some((_, Tok::Times(..), _)) => { + Some((_, Tok::RParen(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); diff --git a/lalrpop-test/src/loc.rs b/lalrpop-test/src/loc.rs index 778ca2c..f765793 100644 --- a/lalrpop-test/src/loc.rs +++ b/lalrpop-test/src/loc.rs @@ -23,10 +23,10 @@ mod __parse__Items { pub enum __Nonterminal<> { ____Items(Vec<(Option, Option)>), - _40_3c(::std::option::Option), - _40_3e(::std::option::Option), Items(Vec<(Option, Option)>), + _40_3e(::std::option::Option), Spanned_3c_22_2b_22_3e((Option, Option)), + _40_3c(::std::option::Option), } // State 0 @@ -103,8 +103,8 @@ mod __parse__Items { // "-" -> Shift(S2) // "+" -> Reduce(@< = => Lookahead;) // - // @< -> S4 - // Spanned<"+"> -> S3 + // @< -> S3 + // Spanned<"+"> -> S4 pub fn __state1< __TOKENS: Iterator, >( @@ -140,11 +140,11 @@ mod __parse__Items { match __nt { __Nonterminal::_40_3c(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state4(__lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state3(__lookbehind, __lookahead, __tokens, __sym1)); } __Nonterminal::Spanned_3c_22_2b_22_3e(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state3(__lookbehind, __lookahead, __tokens, __sym0, __sym1)); + __result = try!(__state4(__lookbehind, __lookahead, __tokens, __sym0, __sym1)); } _ => { return Ok((__lookbehind, __lookahead, __nt)); @@ -159,8 +159,8 @@ mod __parse__Items { // Items = Items "-" (*) ["+"] // Items = Items "-" (*) ["-"] // - // "+" -> Reduce(Items = Items, "-" => Call(ActionFn(3));) // "-" -> Reduce(Items = Items, "-" => Call(ActionFn(3));) + // "+" -> Reduce(Items = Items, "-" => Call(ActionFn(3));) // EOF -> Reduce(Items = Items, "-" => Call(ActionFn(3));) // pub fn __state2< @@ -175,13 +175,13 @@ mod __parse__Items { { let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<>); match __lookahead { - Some((_, Tok::Plus(..), _)) => { + 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))); } - Some((_, Tok::Minus(..), _)) => { + Some((_, Tok::Plus(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __nt = super::__actions::__action3(__sym0, __sym1); @@ -200,6 +200,37 @@ mod __parse__Items { } // State 3 + // Spanned<"+"> = @< (*) "+" @> [EOF] + // Spanned<"+"> = @< (*) "+" @> ["+"] + // Spanned<"+"> = @< (*) "+" @> ["-"] + // + // "+" -> Shift(S5) + // + pub fn __state3< + __TOKENS: Iterator, + >( + __lookbehind: Option, + __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<::std::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 @ Tok::Plus(..), __loc)) => { + let mut __lookbehind = Some(__loc); + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state5(__lookbehind, __lookahead, __tokens, __sym0, __sym1)); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + + // State 4 // Items = Items Spanned<"+"> (*) [EOF] // Items = Items Spanned<"+"> (*) ["+"] // Items = Items Spanned<"+"> (*) ["-"] @@ -208,7 +239,7 @@ mod __parse__Items { // "+" -> Reduce(Items = Items, Spanned<"+"> => Call(ActionFn(2));) // "-" -> Reduce(Items = Items, Spanned<"+"> => Call(ActionFn(2));) // - pub fn __state3< + pub fn __state4< __TOKENS: Iterator, >( __lookbehind: Option, @@ -244,37 +275,6 @@ mod __parse__Items { } } - // State 4 - // Spanned<"+"> = @< (*) "+" @> [EOF] - // Spanned<"+"> = @< (*) "+" @> ["+"] - // Spanned<"+"> = @< (*) "+" @> ["-"] - // - // "+" -> Shift(S5) - // - pub fn __state4< - __TOKENS: Iterator, - >( - __lookbehind: Option, - __lookahead: Option<(usize,Tok,usize)>, - __tokens: &mut __TOKENS, - __sym0: &mut Option<::std::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 @ Tok::Plus(..), __loc)) => { - let mut __lookbehind = Some(__loc); - let mut __sym1 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state5(__lookbehind, __lookahead, __tokens, __sym0, __sym1)); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - // State 5 // @> = (*) [EOF] // @> = (*) ["+"] @@ -283,9 +283,9 @@ mod __parse__Items { // Spanned<"+"> = @< "+" (*) @> ["+"] // Spanned<"+"> = @< "+" (*) @> ["-"] // - // EOF -> Reduce(@> = => Lookbehind;) // "-" -> Reduce(@> = => Lookbehind;) // "+" -> Reduce(@> = => Lookbehind;) + // EOF -> Reduce(@> = => Lookbehind;) // // @> -> S6 pub fn __state5< @@ -300,10 +300,6 @@ mod __parse__Items { { let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<>); match __lookahead { - None => { - let __nt = ::std::clone::Clone::clone(&__lookbehind); - __result = (__lookbehind, __lookahead, __Nonterminal::_40_3e(__nt)); - } Some((_, Tok::Minus(..), _)) => { let __nt = ::std::clone::Clone::clone(&__lookbehind); __result = (__lookbehind, __lookahead, __Nonterminal::_40_3e(__nt)); @@ -312,6 +308,10 @@ mod __parse__Items { let __nt = ::std::clone::Clone::clone(&__lookbehind); __result = (__lookbehind, __lookahead, __Nonterminal::_40_3e(__nt)); } + None => { + let __nt = ::std::clone::Clone::clone(&__lookbehind); + __result = (__lookbehind, __lookahead, __Nonterminal::_40_3e(__nt)); + } _ => { return Err(__lookahead); } @@ -336,9 +336,9 @@ mod __parse__Items { // Spanned<"+"> = @< "+" @> (*) ["+"] // Spanned<"+"> = @< "+" @> (*) ["-"] // - // "-" -> Reduce(Spanned<"+"> = @<, "+", @> => Call(ActionFn(4));) - // 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< __TOKENS: Iterator, @@ -353,7 +353,7 @@ mod __parse__Items { { let mut __result: (Option, Option<(usize,Tok,usize)>, __Nonterminal<>); match __lookahead { - Some((_, Tok::Minus(..), _)) => { + Some((_, Tok::Plus(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); @@ -367,7 +367,7 @@ mod __parse__Items { let __nt = super::__actions::__action4(__sym0, __sym1, __sym2); return Ok((__lookbehind, __lookahead, __Nonterminal::Spanned_3c_22_2b_22_3e(__nt))); } - Some((_, Tok::Plus(..), _)) => { + Some((_, Tok::Minus(..), _)) => { 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 8687aba..0f429f6 100644 --- a/lalrpop-test/src/sub.rs +++ b/lalrpop-test/src/sub.rs @@ -22,10 +22,10 @@ mod __parse__S { use util::tok::Tok; pub enum __Nonterminal<> { - ____S(i32), E(i32), S(i32), T(i32), + ____S(i32), } // State 0 @@ -40,12 +40,12 @@ mod __parse__S { // T = (*) "Num" ["-"] // __S = (*) S [EOF] // - // "(" -> Shift(S5) // "Num" -> Shift(S2) + // "(" -> Shift(S4) // - // T -> S1 // S -> S3 - // E -> S4 + // E -> S1 + // T -> S5 pub fn __state0< __TOKENS: Iterator, >( @@ -56,18 +56,18 @@ mod __parse__S { { let mut __result: (Option<()>, Option, __Nonterminal<>); match __lookahead { - Some(__tok @ Tok::LParen(..)) => { - let mut __lookbehind = None; - let mut __sym0 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__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)); } + Some(__tok @ Tok::LParen(..)) => { + let mut __lookbehind = None; + let mut __sym0 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state4(__lookbehind, __lookahead, __tokens, __sym0)); + } _ => { return Err(__lookahead); } @@ -75,17 +75,17 @@ mod __parse__S { loop { let (__lookbehind, __lookahead, __nt) = __result; match __nt { - __Nonterminal::T(__nt) => { - let __sym0 = &mut Some(__nt); - __result = try!(__state1(__lookbehind, __lookahead, __tokens, __sym0)); - } __Nonterminal::S(__nt) => { let __sym0 = &mut Some(__nt); __result = try!(__state3(__lookbehind, __lookahead, __tokens, __sym0)); } __Nonterminal::E(__nt) => { let __sym0 = &mut Some(__nt); - __result = try!(__state4(__lookbehind, __lookahead, __tokens, __sym0)); + __result = try!(__state1(__lookbehind, __lookahead, __tokens, __sym0)); + } + __Nonterminal::T(__nt) => { + let __sym0 = &mut Some(__nt); + __result = try!(__state5(__lookbehind, __lookahead, __tokens, __sym0)); } _ => { return Ok((__lookbehind, __lookahead, __nt)); @@ -95,11 +95,12 @@ mod __parse__S { } // State 1 - // E = T (*) [EOF] - // E = T (*) ["-"] + // E = E (*) "-" T [EOF] + // E = E (*) "-" T ["-"] + // S = E (*) [EOF] // - // EOF -> Reduce(E = T => Call(ActionFn(3));) - // "-" -> Reduce(E = T => Call(ActionFn(3));) + // "-" -> Shift(S6) + // EOF -> Reduce(S = E => Call(ActionFn(1));) // pub fn __state1< __TOKENS: Iterator, @@ -112,28 +113,30 @@ mod __parse__S { { let mut __result: (Option<()>, Option, __Nonterminal<>); match __lookahead { + Some(__tok @ Tok::Minus(..)) => { + let mut __lookbehind = None; + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state6(__lookbehind, __lookahead, __tokens, __sym0, __sym1)); + } None => { let __sym0 = __sym0.take().unwrap(); - let __nt = super::__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))); + let __nt = super::__actions::__action1(__sym0); + return Ok((__lookbehind, __lookahead, __Nonterminal::S(__nt))); } _ => { return Err(__lookahead); } } + return Ok(__result); } // State 2 // T = "Num" (*) [EOF] // T = "Num" (*) ["-"] // - // EOF -> Reduce(T = "Num" => Call(ActionFn(4));) // "-" -> Reduce(T = "Num" => Call(ActionFn(4));) + // EOF -> Reduce(T = "Num" => Call(ActionFn(4));) // pub fn __state2< __TOKENS: Iterator, @@ -146,12 +149,12 @@ mod __parse__S { { let mut __result: (Option<()>, Option, __Nonterminal<>); match __lookahead { - None => { + Some(Tok::Minus(..)) => { let __sym0 = __sym0.take().unwrap(); let __nt = super::__actions::__action4(__sym0); return Ok((__lookbehind, __lookahead, __Nonterminal::T(__nt))); } - Some(Tok::Minus(..)) => { + None => { let __sym0 = __sym0.take().unwrap(); let __nt = super::__actions::__action4(__sym0); return Ok((__lookbehind, __lookahead, __Nonterminal::T(__nt))); @@ -190,43 +193,6 @@ mod __parse__S { } // State 4 - // E = E (*) "-" T [EOF] - // E = E (*) "-" T ["-"] - // S = E (*) [EOF] - // - // EOF -> Reduce(S = E => Call(ActionFn(1));) - // "-" -> Shift(S6) - // - pub fn __state4< - __TOKENS: Iterator, - >( - __lookbehind: Option<()>, - __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - ) -> Result<(Option<()>, Option, __Nonterminal<>), Option> - { - let mut __result: (Option<()>, Option, __Nonterminal<>); - match __lookahead { - Some(__tok @ Tok::Minus(..)) => { - let mut __lookbehind = None; - let mut __sym1 = &mut Some((__tok)); - let __lookahead = __tokens.next(); - __result = try!(__state6(__lookbehind, __lookahead, __tokens, __sym0, __sym1)); - } - None => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action1(__sym0); - return Ok((__lookbehind, __lookahead, __Nonterminal::S(__nt))); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 5 // E = (*) E "-" T [")"] // E = (*) E "-" T ["-"] // E = (*) T [")"] @@ -238,12 +204,12 @@ mod __parse__S { // T = (*) "Num" [")"] // T = (*) "Num" ["-"] // - // "Num" -> Shift(S8) - // "(" -> Shift(S9) + // "Num" -> Shift(S9) + // "(" -> Shift(S10) // // E -> S7 - // T -> S10 - pub fn __state5< + // T -> S8 + pub fn __state4< __TOKENS: Iterator, >( __lookbehind: Option<()>, @@ -258,13 +224,13 @@ mod __parse__S { let mut __lookbehind = None; let mut __sym1 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state8(__lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state9(__lookbehind, __lookahead, __tokens, __sym1)); } Some(__tok @ Tok::LParen(..)) => { let mut __lookbehind = None; let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state9(__lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state10(__lookbehind, __lookahead, __tokens, __sym1)); } _ => { return Err(__lookahead); @@ -279,7 +245,7 @@ mod __parse__S { } __Nonterminal::T(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state10(__lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state8(__lookbehind, __lookahead, __tokens, __sym1)); } _ => { return Ok((__lookbehind, __lookahead, __nt)); @@ -289,6 +255,40 @@ mod __parse__S { return Ok(__result); } + // State 5 + // E = T (*) [EOF] + // E = T (*) ["-"] + // + // "-" -> Reduce(E = T => Call(ActionFn(3));) + // EOF -> Reduce(E = T => Call(ActionFn(3));) + // + pub fn __state5< + __TOKENS: Iterator, + >( + __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 6 // E = E "-" (*) T [EOF] // E = E "-" (*) T ["-"] @@ -297,7 +297,7 @@ mod __parse__S { // T = (*) "Num" [EOF] // T = (*) "Num" ["-"] // - // "(" -> Shift(S5) + // "(" -> Shift(S4) // "Num" -> Shift(S2) // // T -> S11 @@ -317,7 +317,7 @@ mod __parse__S { let mut __lookbehind = None; let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state5(__lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state4(__lookbehind, __lookahead, __tokens, __sym2)); } Some(Tok::Num(__tok0)) => { let mut __lookbehind = None; @@ -385,13 +385,47 @@ mod __parse__S { } // State 8 + // E = T (*) [")"] + // E = T (*) ["-"] + // + // "-" -> Reduce(E = T => Call(ActionFn(3));) + // ")" -> Reduce(E = T => Call(ActionFn(3));) + // + pub fn __state8< + __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 9 // T = "Num" (*) [")"] // T = "Num" (*) ["-"] // // ")" -> Reduce(T = "Num" => Call(ActionFn(4));) // "-" -> Reduce(T = "Num" => Call(ActionFn(4));) // - pub fn __state8< + pub fn __state9< __TOKENS: Iterator, >( __lookbehind: Option<()>, @@ -418,7 +452,7 @@ mod __parse__S { } } - // State 9 + // State 10 // E = (*) E "-" T [")"] // E = (*) E "-" T ["-"] // E = (*) T [")"] @@ -430,12 +464,12 @@ mod __parse__S { // T = (*) "Num" [")"] // T = (*) "Num" ["-"] // - // "(" -> Shift(S9) - // "Num" -> Shift(S8) + // "(" -> Shift(S10) + // "Num" -> Shift(S9) // + // T -> S8 // E -> S14 - // T -> S10 - pub fn __state9< + pub fn __state10< __TOKENS: Iterator, >( __lookbehind: Option<()>, @@ -450,13 +484,13 @@ mod __parse__S { let mut __lookbehind = None; let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state9(__lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state10(__lookbehind, __lookahead, __tokens, __sym1)); } Some(Tok::Num(__tok0)) => { let mut __lookbehind = None; let mut __sym1 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state8(__lookbehind, __lookahead, __tokens, __sym1)); + __result = try!(__state9(__lookbehind, __lookahead, __tokens, __sym1)); } _ => { return Err(__lookahead); @@ -465,14 +499,14 @@ mod __parse__S { while __sym0.is_some() { let (__lookbehind, __lookahead, __nt) = __result; match __nt { + __Nonterminal::T(__nt) => { + let __sym1 = &mut Some(__nt); + __result = try!(__state8(__lookbehind, __lookahead, __tokens, __sym1)); + } __Nonterminal::E(__nt) => { let __sym1 = &mut Some(__nt); __result = try!(__state14(__lookbehind, __lookahead, __tokens, __sym0, __sym1)); } - __Nonterminal::T(__nt) => { - let __sym1 = &mut Some(__nt); - __result = try!(__state10(__lookbehind, __lookahead, __tokens, __sym1)); - } _ => { return Ok((__lookbehind, __lookahead, __nt)); } @@ -481,40 +515,6 @@ 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(S9) - // "Num" -> Shift(S8) + // "Num" -> Shift(S9) + // "(" -> Shift(S10) // // T -> S15 pub fn __state12< @@ -579,17 +579,17 @@ mod __parse__S { { 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!(__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!(__state8(__lookbehind, __lookahead, __tokens, __sym2)); + __result = try!(__state9(__lookbehind, __lookahead, __tokens, __sym2)); + } + Some(__tok @ Tok::LParen(..)) => { + let mut __lookbehind = None; + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state10(__lookbehind, __lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); @@ -614,8 +614,8 @@ mod __parse__S { // T = "(" E ")" (*) [EOF] // T = "(" E ")" (*) ["-"] // - // EOF -> Reduce(T = "(", E, ")" => Call(ActionFn(5));) // "-" -> Reduce(T = "(", E, ")" => Call(ActionFn(5));) + // EOF -> Reduce(T = "(", E, ")" => Call(ActionFn(5));) // pub fn __state13< __TOKENS: Iterator, @@ -630,14 +630,14 @@ mod __parse__S { { let mut __result: (Option<()>, Option, __Nonterminal<>); match __lookahead { - None => { + Some(Tok::Minus(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); let __nt = super::__actions::__action5(__sym0, __sym1, __sym2); return Ok((__lookbehind, __lookahead, __Nonterminal::T(__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/util/mod.rs b/lalrpop-test/src/util/mod.rs index 9912924..3c4380e 100644 --- a/lalrpop-test/src/util/mod.rs +++ b/lalrpop-test/src/util/mod.rs @@ -5,7 +5,6 @@ use util::tok::Tok; // a simple tokenizer pub mod tok; -pub mod lalrpop_tok; pub fn test(parse_fn: F, input: &str, diff --git a/lalrpop/src/token/dfa/interpret.rs b/lalrpop/src/lexer/dfa/interpret.rs similarity index 94% rename from lalrpop/src/token/dfa/interpret.rs rename to lalrpop/src/lexer/dfa/interpret.rs index cfcb492..921b6fc 100644 --- a/lalrpop/src/token/dfa/interpret.rs +++ b/lalrpop/src/lexer/dfa/interpret.rs @@ -1,5 +1,5 @@ -use token::dfa::{DFA, Kind, NFAIndex, START}; -use token::re::Test; +use lexer::dfa::{DFA, Kind, NFAIndex, START}; +use lexer::re::Test; pub fn interpret<'text>(dfa: &DFA, input: &'text str) -> Option<(NFAIndex, &'text str)> { let mut longest: Option<(NFAIndex, usize)> = None; diff --git a/lalrpop/src/token/dfa/mod.rs b/lalrpop/src/lexer/dfa/mod.rs similarity index 99% rename from lalrpop/src/token/dfa/mod.rs rename to lalrpop/src/lexer/dfa/mod.rs index f0e6705..58bed3b 100644 --- a/lalrpop/src/token/dfa/mod.rs +++ b/lalrpop/src/lexer/dfa/mod.rs @@ -4,8 +4,8 @@ use kernel_set::{Kernel, KernelSet}; use std::fmt::{Debug, Display, Formatter, Error}; use std::rc::Rc; -use token::re; -use token::nfa::{self, NFA, NFAStateIndex}; +use lexer::re; +use lexer::nfa::{self, NFA, NFAStateIndex}; use util::Set; #[cfg(test)] diff --git a/lalrpop/src/token/dfa/test.rs b/lalrpop/src/lexer/dfa/test.rs similarity index 92% rename from lalrpop/src/token/dfa/test.rs rename to lalrpop/src/lexer/dfa/test.rs index 64fbb31..5ae4fdd 100644 --- a/lalrpop/src/token/dfa/test.rs +++ b/lalrpop/src/lexer/dfa/test.rs @@ -1,6 +1,6 @@ -use token::dfa::{self, Ambiguity, DFA, NFAIndex, Precedence}; -use token::dfa::interpret::interpret; -use token::re; +use lexer::dfa::{self, Ambiguity, DFA, NFAIndex, Precedence}; +use lexer::dfa::interpret::interpret; +use lexer::re; fn dfa(inputs: &[(&str, Precedence)]) -> Result { let regexs: Result, _> = inputs.iter().map(|&(s, _)| re::parse_regex(s)).collect(); diff --git a/lalrpop/src/token/mod.rs b/lalrpop/src/lexer/mod.rs similarity index 51% rename from lalrpop/src/token/mod.rs rename to lalrpop/src/lexer/mod.rs index fded880..80781a2 100644 --- a/lalrpop/src/token/mod.rs +++ b/lalrpop/src/lexer/mod.rs @@ -1,7 +1,6 @@ #![allow(dead_code)] // tokenizer, which is not yet deployed. -//! Code related to the builtin tokenizer, which is based on regular -//! expressions. +//! Code related to generating tokenizers. mod dfa; mod re; diff --git a/lalrpop/src/token/nfa/interpret.rs b/lalrpop/src/lexer/nfa/interpret.rs similarity index 96% rename from lalrpop/src/token/nfa/interpret.rs rename to lalrpop/src/lexer/nfa/interpret.rs index 5f8a1f0..9c6e6f4 100644 --- a/lalrpop/src/token/nfa/interpret.rs +++ b/lalrpop/src/lexer/nfa/interpret.rs @@ -1,7 +1,7 @@ //! A depth-first interpreter for NFAs. -use token::nfa::{NFA, NFAStateIndex, START, StateKind, Noop, Other}; -use token::re::Test; +use lexer::nfa::{NFA, NFAStateIndex, START, StateKind, Noop, Other}; +use lexer::re::Test; use std::cmp::max; /// Interpret `nfa` applied to `test`, returning the longest matching diff --git a/lalrpop/src/token/nfa/mod.rs b/lalrpop/src/lexer/nfa/mod.rs similarity index 99% rename from lalrpop/src/token/nfa/mod.rs rename to lalrpop/src/lexer/nfa/mod.rs index 0eba922..24085c7 100644 --- a/lalrpop/src/token/nfa/mod.rs +++ b/lalrpop/src/lexer/nfa/mod.rs @@ -4,7 +4,7 @@ use std::fmt::{Debug, Formatter, Error}; use std::usize; -use token::re::{Regex, Alternative, Elem, RepeatOp, Test}; +use lexer::re::{Regex, Alternative, Elem, RepeatOp, Test}; #[cfg(test)] mod interpret; diff --git a/lalrpop/src/token/nfa/test.rs b/lalrpop/src/lexer/nfa/test.rs similarity index 94% rename from lalrpop/src/token/nfa/test.rs rename to lalrpop/src/lexer/nfa/test.rs index 1cd6b4d..0e72b9e 100644 --- a/lalrpop/src/token/nfa/test.rs +++ b/lalrpop/src/lexer/nfa/test.rs @@ -1,6 +1,6 @@ -use token::nfa::{NFA, Noop, Other, StateKind}; -use token::nfa::interpret::interpret; -use token::re::{self, Test}; +use lexer::nfa::{NFA, Noop, Other, StateKind}; +use lexer::nfa::interpret::interpret; +use lexer::re::{self, Test}; #[test] fn edge_iter() { diff --git a/lalrpop/src/token/re/mod.rs b/lalrpop/src/lexer/re/mod.rs similarity index 100% rename from lalrpop/src/token/re/mod.rs rename to lalrpop/src/lexer/re/mod.rs diff --git a/lalrpop/src/token/re/test.rs b/lalrpop/src/lexer/re/test.rs similarity index 100% rename from lalrpop/src/token/re/test.rs rename to lalrpop/src/lexer/re/test.rs diff --git a/lalrpop/src/lib.rs b/lalrpop/src/lib.rs index 6a41b33..80b396d 100644 --- a/lalrpop/src/lib.rs +++ b/lalrpop/src/lib.rs @@ -23,11 +23,12 @@ mod rust; mod build; mod grammar; mod intern; +mod lexer; mod lr1; mod normalize; mod parser; mod kernel_set; -mod token; +mod tok; mod util; #[cfg(test)] mod generate; diff --git a/lalrpop-test/src/util/lalrpop_tok.rs b/lalrpop/src/tok/mod.rs similarity index 56% rename from lalrpop-test/src/util/lalrpop_tok.rs rename to lalrpop/src/tok/mod.rs index 82cad1e..fa9474e 100644 --- a/lalrpop-test/src/util/lalrpop_tok.rs +++ b/lalrpop/src/tok/mod.rs @@ -1,8 +1,14 @@ +//! A tokenizer for use in LALRPOP itself. + use std::str::CharIndices; use self::Error::*; use self::Tok::*; +#[cfg(test)] +mod test; + +#[derive(Clone, Debug, PartialEq, Eq)] pub enum Error { UnrecognizedToken(usize), UnterminatedEscape(usize), @@ -10,7 +16,7 @@ pub enum Error { UnterminatedCode(usize), } -#[derive(Clone, Debug)] +#[derive(Clone, Debug, PartialEq, Eq)] pub enum Tok<'input> { // Keywords; Enum, @@ -85,9 +91,19 @@ const KEYWORDS: &'static [(&'static str, Tok<'static>)] = &[ ("token", Token), ("use", Use), ("where", Where), -]; + ]; impl<'input> Tokenizer<'input> { + fn new(text: &'input str) -> Tokenizer<'input> { + let mut t = Tokenizer { + text: text, + chars: text.char_indices(), + lookahead: None + }; + t.bump(); + t + } + fn bump(&mut self) -> Option<(usize, char)> { self.lookahead = self.chars.next(); self.lookahead @@ -280,166 +296,183 @@ 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))) + loop { + return 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, ':')) => { + 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, ',')) => { + 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, '=')) => { + 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, 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, 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 - } + 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, '/')) => { + match self.bump() { + Some((_, '/')) => { + self.take_until(|c| c == '\n'); + continue; + } + _ => { + Some(Err(UnrecognizedToken(idx0))) + } + } + } + Some((idx0, c)) if is_identifier_start(c) => { + Some(Ok(self.identifierish(idx0))) + } + Some((_, c)) if c.is_whitespace() => { + self.bump(); + continue; + } + Some((idx, _)) => { + Some(Err(UnrecognizedToken(idx))) + } + None => { + None + } + }; } } } diff --git a/lalrpop/src/tok/test.rs b/lalrpop/src/tok/test.rs new file mode 100644 index 0000000..03daaed --- /dev/null +++ b/lalrpop/src/tok/test.rs @@ -0,0 +1,65 @@ +use super::{is_identifier_start, is_identifier_continue, Tok, Tokenizer}; +use super::Tok::*; + +fn test(input: &str, + expected: Vec<(&str, Tok)>) +{ + // use $ to signal EOL because it can be replaced with a single space + // for spans, and because it applies also to r#XXX# style strings: + let input = input.replace("$", "\n"); + + let tokenizer = Tokenizer::new(&input); + let len = expected.len(); + for (token, (expected_span, expected_tok)) in tokenizer.zip(expected.into_iter()) { + println!("token: {:?}", token); + let expected_start = expected_span.find("~").unwrap(); + let expected_end = expected_span.rfind("~").unwrap() + 1; + assert_eq!(Ok((expected_start, expected_tok, expected_end)), token); + } + + let tokenizer = Tokenizer::new(&input); + assert_eq!(None, tokenizer.skip(len).next()); +} + +#[test] +fn identifier_start1() { + assert!(is_identifier_start('f')); +} + +#[test] +fn identifier_continue1() { + assert!(is_identifier_continue('o')); +} + +#[test] +fn basic() { + test("extern foo", vec![ + ("~~~~~~ ", Extern), + (" ~~~", Id("foo")), + ]); +} + +#[test] +fn eol_comment() { + test("extern // This is a comment$ foo", vec![ + ("~~~~~~ ", Extern), + (" ~~~", Id("foo")), + ]); +} + +#[test] +fn code1() { + test("=> a(b, c),", vec![ + ("~~~~~~~~~~ ", EqualsGreaterThanCode(" a(b, c)")), + (" ~", Comma), + ]); +} + +#[test] +#[should_panic] +fn code_forgot_comma() { + test("=> a(b, c),", vec![ + ("~~~~~~~~~~ ", EqualsGreaterThanCode(" a(b, c)")), + // intentionally forget the comma token; this is more of a test of `test` + ]); +}