From fad838a361d779354cfbd27268129b882262bbd9 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Fri, 17 Jul 2015 09:07:13 -0400 Subject: [PATCH] modify recursive ascent to expect (loc, enum, loc) when a location type is specified, and modify test tokenizer to provide it --- lalrpop-test/src/expr.rs | 1578 ++++----- lalrpop-test/src/expr_arena.lalrpop | 2 +- lalrpop-test/src/expr_arena.rs | 5030 +++++++++++++-------------- lalrpop-test/src/main.rs | 6 +- lalrpop-test/src/sub.rs | 536 +-- lalrpop-test/src/util/mod.rs | 22 + lalrpop-test/src/util/tok.rs | 31 +- lalrpop/src/grammar/repr.rs | 7 +- lalrpop/src/lr1/ascent.rs | 61 +- 9 files changed, 3664 insertions(+), 3609 deletions(-) diff --git a/lalrpop-test/src/expr.rs b/lalrpop-test/src/expr.rs index b098c91..1311c79 100644 --- a/lalrpop-test/src/expr.rs +++ b/lalrpop-test/src/expr.rs @@ -23,10 +23,10 @@ mod __parse__Expr { use util::tok::Tok; pub enum __Nonterminal<> { - Expr(i32), - Term(i32), - Factor(i32), ____Expr(i32), + Term(i32), + Expr(i32), + Factor(i32), } // State 0 @@ -69,9 +69,9 @@ mod __parse__Expr { // "Num" -> Shift(S2) // "(" -> Shift(S1) // - // Term -> S5 - // Expr -> S4 - // Factor -> S3 + // Factor -> S5 + // Term -> S4 + // Expr -> S3 pub fn __state0< __TOKENS: Iterator, >( @@ -88,7 +88,7 @@ mod __parse__Expr { __result = try!(__state2(scale, __lookahead, __tokens, __sym0)); } Some(__tok @ Tok::LParen(..)) => { - let mut __sym0 = &mut Some(__tok); + let mut __sym0 = &mut Some((__tok)); let __lookahead = __tokens.next(); __result = try!(__state1(scale, __lookahead, __tokens, __sym0)); } @@ -99,15 +99,15 @@ mod __parse__Expr { loop { let (__lookahead, __nt) = __result; match __nt { - __Nonterminal::Term(__nt) => { + __Nonterminal::Factor(__nt) => { let __sym0 = &mut Some(__nt); __result = try!(__state5(scale, __lookahead, __tokens, __sym0)); } - __Nonterminal::Expr(__nt) => { + __Nonterminal::Term(__nt) => { let __sym0 = &mut Some(__nt); __result = try!(__state4(scale, __lookahead, __tokens, __sym0)); } - __Nonterminal::Factor(__nt) => { + __Nonterminal::Expr(__nt) => { let __sym0 = &mut Some(__nt); __result = try!(__state3(scale, __lookahead, __tokens, __sym0)); } @@ -159,11 +159,11 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "Num" -> Shift(S9) - // "(" -> Shift(S7) + // "Num" -> Shift(S8) + // "(" -> Shift(S9) // // Expr -> S10 - // Term -> S8 + // Term -> S7 // Factor -> S6 pub fn __state1< __TOKENS: Iterator, @@ -179,12 +179,12 @@ mod __parse__Expr { Some(Tok::Num(__tok0)) => { let mut __sym1 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state9(scale, __lookahead, __tokens, __sym1)); + __result = try!(__state8(scale, __lookahead, __tokens, __sym1)); } Some(__tok @ Tok::LParen(..)) => { - let mut __sym1 = &mut Some(__tok); + let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state7(scale, __lookahead, __tokens, __sym1)); + __result = try!(__state9(scale, __lookahead, __tokens, __sym1)); } _ => { return Err(__lookahead); @@ -199,7 +199,7 @@ mod __parse__Expr { } __Nonterminal::Term(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state8(scale, __lookahead, __tokens, __sym1)); + __result = try!(__state7(scale, __lookahead, __tokens, __sym1)); } __Nonterminal::Factor(__nt) => { let __sym1 = &mut Some(__nt); @@ -220,11 +220,11 @@ mod __parse__Expr { // Term = "Num" (*) ["-"] // Term = "Num" (*) ["/"] // - // "+" -> Reduce(Term = "Num" => ActionFn(7);) - // EOF -> Reduce(Term = "Num" => ActionFn(7);) - // "-" -> Reduce(Term = "Num" => ActionFn(7);) - // "/" -> Reduce(Term = "Num" => ActionFn(7);) - // "*" -> Reduce(Term = "Num" => ActionFn(7);) + // 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 __state2< __TOKENS: Iterator, @@ -237,31 +237,31 @@ mod __parse__Expr { { let mut __result: (Option, __Nonterminal<>); match __lookahead { - Some(Tok::Plus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(scale, __sym0); - return Ok((__lookahead, __Nonterminal::Term(__nt))); - } None => { let __sym0 = __sym0.take().unwrap(); let __nt = super::__actions::__action7(scale, __sym0); return Ok((__lookahead, __Nonterminal::Term(__nt))); } - Some(Tok::Minus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(scale, __sym0); - return Ok((__lookahead, __Nonterminal::Term(__nt))); - } Some(Tok::Div(..)) => { let __sym0 = __sym0.take().unwrap(); let __nt = super::__actions::__action7(scale, __sym0); return Ok((__lookahead, __Nonterminal::Term(__nt))); } + Some(Tok::Minus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action7(scale, __sym0); + return Ok((__lookahead, __Nonterminal::Term(__nt))); + } Some(Tok::Times(..)) => { let __sym0 = __sym0.take().unwrap(); let __nt = super::__actions::__action7(scale, __sym0); return Ok((__lookahead, __Nonterminal::Term(__nt))); } + Some(Tok::Plus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action7(scale, __sym0); + return Ok((__lookahead, __Nonterminal::Term(__nt))); + } _ => { return Err(__lookahead); } @@ -269,6 +269,107 @@ mod __parse__Expr { } // State 3 + // Expr = Expr (*) "+" Factor [EOF] + // Expr = Expr (*) "+" Factor ["+"] + // Expr = Expr (*) "+" Factor ["-"] + // Expr = Expr (*) "-" Factor [EOF] + // Expr = Expr (*) "-" Factor ["+"] + // Expr = Expr (*) "-" Factor ["-"] + // __Expr = Expr (*) [EOF] + // + // "+" -> Shift(S11) + // "-" -> Shift(S12) + // EOF -> Reduce(__Expr = Expr => Call(ActionFn(0));) + // + pub fn __state3< + __TOKENS: Iterator, + >( + scale: i32, + mut __lookahead: Option, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + ) -> Result<(Option, __Nonterminal<>), Option> + { + let mut __result: (Option, __Nonterminal<>); + match __lookahead { + Some(__tok @ Tok::Plus(..)) => { + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state11(scale, __lookahead, __tokens, __sym0, __sym1)); + } + Some(__tok @ Tok::Minus(..)) => { + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state12(scale, __lookahead, __tokens, __sym0, __sym1)); + } + None => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action0(scale, __sym0); + return Ok((__lookahead, __Nonterminal::____Expr(__nt))); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + + // State 4 + // Factor = Term (*) [EOF] + // Factor = Term (*) ["*"] + // Factor = Term (*) ["+"] + // Factor = Term (*) ["-"] + // Factor = Term (*) ["/"] + // + // "*" -> Reduce(Factor = Term => Call(ActionFn(6));) + // "/" -> Reduce(Factor = Term => Call(ActionFn(6));) + // "-" -> Reduce(Factor = Term => Call(ActionFn(6));) + // "+" -> Reduce(Factor = Term => Call(ActionFn(6));) + // EOF -> Reduce(Factor = Term => Call(ActionFn(6));) + // + pub fn __state4< + __TOKENS: Iterator, + >( + scale: i32, + mut __lookahead: Option, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + ) -> Result<(Option, __Nonterminal<>), Option> + { + let mut __result: (Option, __Nonterminal<>); + match __lookahead { + Some(Tok::Times(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action6(scale, __sym0); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + Some(Tok::Div(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action6(scale, __sym0); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + Some(Tok::Minus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action6(scale, __sym0); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + Some(Tok::Plus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action6(scale, __sym0); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + None => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action6(scale, __sym0); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 5 // Expr = Factor (*) [EOF] // Expr = Factor (*) ["+"] // Expr = Factor (*) ["-"] @@ -283,113 +384,11 @@ mod __parse__Expr { // Factor = Factor (*) "/" Term ["-"] // Factor = Factor (*) "/" Term ["/"] // - // "/" -> Shift(S12) - // "+" -> Reduce(Expr = Factor => ActionFn(3);) - // EOF -> Reduce(Expr = Factor => ActionFn(3);) - // "-" -> Reduce(Expr = Factor => ActionFn(3);) - // "*" -> Shift(S11) - // - pub fn __state3< - __TOKENS: Iterator, - >( - scale: i32, - mut __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - ) -> Result<(Option, __Nonterminal<>), Option> - { - let mut __result: (Option, __Nonterminal<>); - match __lookahead { - Some(__tok @ Tok::Div(..)) => { - let mut __sym1 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state12(scale, __lookahead, __tokens, __sym0, __sym1)); - } - Some(__tok @ Tok::Times(..)) => { - let mut __sym1 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state11(scale, __lookahead, __tokens, __sym0, __sym1)); - } - Some(Tok::Plus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action3(scale, __sym0); - return Ok((__lookahead, __Nonterminal::Expr(__nt))); - } - None => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action3(scale, __sym0); - return Ok((__lookahead, __Nonterminal::Expr(__nt))); - } - Some(Tok::Minus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action3(scale, __sym0); - return Ok((__lookahead, __Nonterminal::Expr(__nt))); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 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(S14) - // "+" -> Shift(S13) - // EOF -> Reduce(__Expr = Expr => ActionFn(0);) - // - pub fn __state4< - __TOKENS: Iterator, - >( - scale: i32, - mut __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - ) -> Result<(Option, __Nonterminal<>), Option> - { - let mut __result: (Option, __Nonterminal<>); - match __lookahead { - Some(__tok @ Tok::Minus(..)) => { - let mut __sym1 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state14(scale, __lookahead, __tokens, __sym0, __sym1)); - } - Some(__tok @ Tok::Plus(..)) => { - let mut __sym1 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state13(scale, __lookahead, __tokens, __sym0, __sym1)); - } - None => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action0(scale, __sym0); - return Ok((__lookahead, __Nonterminal::____Expr(__nt))); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 5 - // Factor = Term (*) [EOF] - // Factor = Term (*) ["*"] - // Factor = Term (*) ["+"] - // Factor = Term (*) ["-"] - // Factor = Term (*) ["/"] - // - // "+" -> Reduce(Factor = Term => ActionFn(6);) - // "*" -> Reduce(Factor = Term => ActionFn(6);) - // "-" -> Reduce(Factor = Term => ActionFn(6);) - // "/" -> Reduce(Factor = Term => ActionFn(6);) - // EOF -> Reduce(Factor = Term => ActionFn(6);) + // EOF -> Reduce(Expr = Factor => Call(ActionFn(3));) + // "*" -> Shift(S14) + // "/" -> Shift(S13) + // "-" -> Reduce(Expr = Factor => Call(ActionFn(3));) + // "+" -> Reduce(Expr = Factor => Call(ActionFn(3));) // pub fn __state5< __TOKENS: Iterator, @@ -402,35 +401,36 @@ mod __parse__Expr { { let mut __result: (Option, __Nonterminal<>); match __lookahead { - Some(Tok::Plus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action6(scale, __sym0); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); + Some(__tok @ Tok::Times(..)) => { + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state14(scale, __lookahead, __tokens, __sym0, __sym1)); } - Some(Tok::Times(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action6(scale, __sym0); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Minus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action6(scale, __sym0); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Div(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action6(scale, __sym0); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); + Some(__tok @ Tok::Div(..)) => { + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state13(scale, __lookahead, __tokens, __sym0, __sym1)); } None => { let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action6(scale, __sym0); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); + let __nt = super::__actions::__action3(scale, __sym0); + return Ok((__lookahead, __Nonterminal::Expr(__nt))); + } + Some(Tok::Minus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action3(scale, __sym0); + return Ok((__lookahead, __Nonterminal::Expr(__nt))); + } + Some(Tok::Plus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action3(scale, __sym0); + return Ok((__lookahead, __Nonterminal::Expr(__nt))); } _ => { return Err(__lookahead); } } + return Ok(__result); } // State 6 @@ -448,11 +448,11 @@ mod __parse__Expr { // Factor = Factor (*) "/" Term ["-"] // Factor = Factor (*) "/" Term ["/"] // + // "+" -> Reduce(Expr = Factor => Call(ActionFn(3));) // "*" -> Shift(S16) - // "-" -> Reduce(Expr = Factor => ActionFn(3);) // "/" -> Shift(S15) - // ")" -> Reduce(Expr = Factor => ActionFn(3);) - // "+" -> Reduce(Expr = Factor => ActionFn(3);) + // "-" -> Reduce(Expr = Factor => Call(ActionFn(3));) + // ")" -> Reduce(Expr = Factor => Call(ActionFn(3));) // pub fn __state6< __TOKENS: Iterator, @@ -466,15 +466,20 @@ mod __parse__Expr { let mut __result: (Option, __Nonterminal<>); match __lookahead { Some(__tok @ Tok::Times(..)) => { - let mut __sym1 = &mut Some(__tok); + let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); __result = try!(__state16(scale, __lookahead, __tokens, __sym0, __sym1)); } Some(__tok @ Tok::Div(..)) => { - let mut __sym1 = &mut Some(__tok); + let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); __result = try!(__state15(scale, __lookahead, __tokens, __sym0, __sym1)); } + Some(Tok::Plus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action3(scale, __sym0); + return Ok((__lookahead, __Nonterminal::Expr(__nt))); + } Some(Tok::Minus(..)) => { let __sym0 = __sym0.take().unwrap(); let __nt = super::__actions::__action3(scale, __sym0); @@ -485,11 +490,6 @@ mod __parse__Expr { let __nt = super::__actions::__action3(scale, __sym0); return Ok((__lookahead, __Nonterminal::Expr(__nt))); } - Some(Tok::Plus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action3(scale, __sym0); - return Ok((__lookahead, __Nonterminal::Expr(__nt))); - } _ => { return Err(__lookahead); } @@ -498,6 +498,116 @@ mod __parse__Expr { } // State 7 + // Factor = Term (*) [")"] + // Factor = Term (*) ["*"] + // Factor = Term (*) ["+"] + // Factor = Term (*) ["-"] + // Factor = Term (*) ["/"] + // + // "+" -> Reduce(Factor = Term => Call(ActionFn(6));) + // "*" -> Reduce(Factor = Term => Call(ActionFn(6));) + // ")" -> Reduce(Factor = Term => Call(ActionFn(6));) + // "-" -> Reduce(Factor = Term => Call(ActionFn(6));) + // "/" -> Reduce(Factor = Term => Call(ActionFn(6));) + // + pub fn __state7< + __TOKENS: Iterator, + >( + scale: i32, + mut __lookahead: Option, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + ) -> Result<(Option, __Nonterminal<>), Option> + { + let mut __result: (Option, __Nonterminal<>); + match __lookahead { + Some(Tok::Plus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action6(scale, __sym0); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + Some(Tok::Times(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action6(scale, __sym0); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + Some(Tok::RParen(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action6(scale, __sym0); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + Some(Tok::Minus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action6(scale, __sym0); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + Some(Tok::Div(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action6(scale, __sym0); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 8 + // 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 __state8< + __TOKENS: Iterator, + >( + scale: i32, + mut __lookahead: Option, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + ) -> Result<(Option, __Nonterminal<>), Option> + { + let mut __result: (Option, __Nonterminal<>); + match __lookahead { + Some(Tok::Div(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action7(scale, __sym0); + return Ok((__lookahead, __Nonterminal::Term(__nt))); + } + Some(Tok::RParen(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action7(scale, __sym0); + return Ok((__lookahead, __Nonterminal::Term(__nt))); + } + Some(Tok::Plus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action7(scale, __sym0); + return Ok((__lookahead, __Nonterminal::Term(__nt))); + } + Some(Tok::Times(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action7(scale, __sym0); + return Ok((__lookahead, __Nonterminal::Term(__nt))); + } + Some(Tok::Minus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action7(scale, __sym0); + return Ok((__lookahead, __Nonterminal::Term(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 9 // Expr = (*) Expr "+" Factor [")"] // Expr = (*) Expr "+" Factor ["+"] // Expr = (*) Expr "+" Factor ["-"] @@ -538,13 +648,13 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "(" -> Shift(S7) - // "Num" -> Shift(S9) + // "(" -> Shift(S9) + // "Num" -> Shift(S8) // - // Factor -> S6 + // Term -> S7 // Expr -> S17 - // Term -> S8 - pub fn __state7< + // Factor -> S6 + pub fn __state9< __TOKENS: Iterator, >( scale: i32, @@ -556,14 +666,14 @@ mod __parse__Expr { let mut __result: (Option, __Nonterminal<>); match __lookahead { Some(__tok @ Tok::LParen(..)) => { - let mut __sym1 = &mut Some(__tok); + let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state7(scale, __lookahead, __tokens, __sym1)); + __result = try!(__state9(scale, __lookahead, __tokens, __sym1)); } Some(Tok::Num(__tok0)) => { let mut __sym1 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state9(scale, __lookahead, __tokens, __sym1)); + __result = try!(__state8(scale, __lookahead, __tokens, __sym1)); } _ => { return Err(__lookahead); @@ -572,17 +682,17 @@ mod __parse__Expr { while __sym0.is_some() { let (__lookahead, __nt) = __result; match __nt { - __Nonterminal::Factor(__nt) => { + __Nonterminal::Term(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state6(scale, __lookahead, __tokens, __sym1)); + __result = try!(__state7(scale, __lookahead, __tokens, __sym1)); } __Nonterminal::Expr(__nt) => { let __sym1 = &mut Some(__nt); __result = try!(__state17(scale, __lookahead, __tokens, __sym0, __sym1)); } - __Nonterminal::Term(__nt) => { + __Nonterminal::Factor(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state8(scale, __lookahead, __tokens, __sym1)); + __result = try!(__state6(scale, __lookahead, __tokens, __sym1)); } _ => { return Ok((__lookahead, __nt)); @@ -592,116 +702,6 @@ mod __parse__Expr { return Ok(__result); } - // State 8 - // Factor = Term (*) [")"] - // Factor = Term (*) ["*"] - // Factor = Term (*) ["+"] - // Factor = Term (*) ["-"] - // Factor = Term (*) ["/"] - // - // "+" -> Reduce(Factor = Term => ActionFn(6);) - // "/" -> Reduce(Factor = Term => ActionFn(6);) - // ")" -> Reduce(Factor = Term => ActionFn(6);) - // "*" -> Reduce(Factor = Term => ActionFn(6);) - // "-" -> Reduce(Factor = Term => ActionFn(6);) - // - pub fn __state8< - __TOKENS: Iterator, - >( - scale: i32, - mut __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - ) -> Result<(Option, __Nonterminal<>), Option> - { - let mut __result: (Option, __Nonterminal<>); - match __lookahead { - Some(Tok::Plus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action6(scale, __sym0); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Div(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action6(scale, __sym0); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::RParen(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action6(scale, __sym0); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Times(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action6(scale, __sym0); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Minus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action6(scale, __sym0); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 9 - // Term = "Num" (*) [")"] - // Term = "Num" (*) ["*"] - // Term = "Num" (*) ["+"] - // Term = "Num" (*) ["-"] - // Term = "Num" (*) ["/"] - // - // "*" -> Reduce(Term = "Num" => ActionFn(7);) - // "+" -> Reduce(Term = "Num" => ActionFn(7);) - // ")" -> Reduce(Term = "Num" => ActionFn(7);) - // "-" -> Reduce(Term = "Num" => ActionFn(7);) - // "/" -> Reduce(Term = "Num" => ActionFn(7);) - // - pub fn __state9< - __TOKENS: Iterator, - >( - scale: i32, - mut __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - ) -> Result<(Option, __Nonterminal<>), Option> - { - let mut __result: (Option, __Nonterminal<>); - match __lookahead { - Some(Tok::Times(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(scale, __sym0); - return Ok((__lookahead, __Nonterminal::Term(__nt))); - } - Some(Tok::Plus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(scale, __sym0); - return Ok((__lookahead, __Nonterminal::Term(__nt))); - } - Some(Tok::RParen(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(scale, __sym0); - return Ok((__lookahead, __Nonterminal::Term(__nt))); - } - Some(Tok::Minus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(scale, __sym0); - return Ok((__lookahead, __Nonterminal::Term(__nt))); - } - Some(Tok::Div(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(scale, __sym0); - return Ok((__lookahead, __Nonterminal::Term(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - // State 10 // Expr = Expr (*) "+" Factor [")"] // Expr = Expr (*) "+" Factor ["+"] @@ -715,9 +715,9 @@ mod __parse__Expr { // Term = "(" Expr (*) ")" ["-"] // Term = "(" Expr (*) ")" ["/"] // - // "-" -> Shift(S20) - // ")" -> Shift(S18) - // "+" -> Shift(S19) + // "-" -> Shift(S19) + // ")" -> Shift(S20) + // "+" -> Shift(S18) // pub fn __state10< __TOKENS: Iterator, @@ -732,20 +732,20 @@ mod __parse__Expr { let mut __result: (Option, __Nonterminal<>); match __lookahead { Some(__tok @ Tok::Minus(..)) => { - let mut __sym2 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state20(scale, __lookahead, __tokens, __sym1, __sym2)); - } - Some(__tok @ Tok::RParen(..)) => { - let mut __sym2 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state18(scale, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - Some(__tok @ Tok::Plus(..)) => { - let mut __sym2 = &mut Some(__tok); + let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); __result = try!(__state19(scale, __lookahead, __tokens, __sym1, __sym2)); } + Some(__tok @ Tok::RParen(..)) => { + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state20(scale, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + Some(__tok @ Tok::Plus(..)) => { + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state18(scale, __lookahead, __tokens, __sym1, __sym2)); + } _ => { return Err(__lookahead); } @@ -754,130 +754,6 @@ mod __parse__Expr { } // State 11 - // Factor = Factor "*" (*) Term [EOF] - // Factor = Factor "*" (*) Term ["*"] - // Factor = Factor "*" (*) Term ["+"] - // Factor = Factor "*" (*) Term ["-"] - // Factor = Factor "*" (*) Term ["/"] - // Term = (*) "(" Expr ")" [EOF] - // Term = (*) "(" Expr ")" ["*"] - // Term = (*) "(" Expr ")" ["+"] - // Term = (*) "(" Expr ")" ["-"] - // Term = (*) "(" Expr ")" ["/"] - // Term = (*) "Num" [EOF] - // Term = (*) "Num" ["*"] - // Term = (*) "Num" ["+"] - // Term = (*) "Num" ["-"] - // Term = (*) "Num" ["/"] - // - // "Num" -> Shift(S2) - // "(" -> Shift(S1) - // - // Term -> S21 - pub fn __state11< - __TOKENS: Iterator, - >( - scale: i32, - mut __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option, - ) -> Result<(Option, __Nonterminal<>), Option> - { - let mut __result: (Option, __Nonterminal<>); - match __lookahead { - Some(Tok::Num(__tok0)) => { - let mut __sym2 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state2(scale, __lookahead, __tokens, __sym2)); - } - Some(__tok @ Tok::LParen(..)) => { - let mut __sym2 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state1(scale, __lookahead, __tokens, __sym2)); - } - _ => { - return Err(__lookahead); - } - } - while __sym1.is_some() { - let (__lookahead, __nt) = __result; - match __nt { - __Nonterminal::Term(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state21(scale, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - _ => { - return Ok((__lookahead, __nt)); - } - } - } - return Ok(__result); - } - - // State 12 - // Factor = Factor "/" (*) Term [EOF] - // Factor = Factor "/" (*) Term ["*"] - // Factor = Factor "/" (*) Term ["+"] - // Factor = Factor "/" (*) Term ["-"] - // Factor = Factor "/" (*) Term ["/"] - // Term = (*) "(" Expr ")" [EOF] - // Term = (*) "(" Expr ")" ["*"] - // Term = (*) "(" Expr ")" ["+"] - // Term = (*) "(" Expr ")" ["-"] - // Term = (*) "(" Expr ")" ["/"] - // Term = (*) "Num" [EOF] - // Term = (*) "Num" ["*"] - // Term = (*) "Num" ["+"] - // Term = (*) "Num" ["-"] - // Term = (*) "Num" ["/"] - // - // "Num" -> Shift(S2) - // "(" -> Shift(S1) - // - // Term -> S22 - pub fn __state12< - __TOKENS: Iterator, - >( - scale: i32, - mut __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option, - ) -> Result<(Option, __Nonterminal<>), Option> - { - let mut __result: (Option, __Nonterminal<>); - match __lookahead { - Some(Tok::Num(__tok0)) => { - let mut __sym2 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state2(scale, __lookahead, __tokens, __sym2)); - } - Some(__tok @ Tok::LParen(..)) => { - let mut __sym2 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state1(scale, __lookahead, __tokens, __sym2)); - } - _ => { - return Err(__lookahead); - } - } - while __sym1.is_some() { - let (__lookahead, __nt) = __result; - match __nt { - __Nonterminal::Term(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state22(scale, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - _ => { - return Ok((__lookahead, __nt)); - } - } - } - return Ok(__result); - } - - // State 13 // Expr = Expr "+" (*) Factor [EOF] // Expr = Expr "+" (*) Factor ["+"] // Expr = Expr "+" (*) Factor ["-"] @@ -907,12 +783,12 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "(" -> Shift(S1) // "Num" -> Shift(S2) + // "(" -> Shift(S1) // - // Factor -> S23 - // Term -> S5 - pub fn __state13< + // Factor -> S21 + // Term -> S4 + pub fn __state11< __TOKENS: Iterator, >( scale: i32, @@ -924,16 +800,16 @@ mod __parse__Expr { { let mut __result: (Option, __Nonterminal<>); match __lookahead { - Some(__tok @ Tok::LParen(..)) => { - let mut __sym2 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state1(scale, __lookahead, __tokens, __sym2)); - } Some(Tok::Num(__tok0)) => { let mut __sym2 = &mut Some((__tok0)); let __lookahead = __tokens.next(); __result = try!(__state2(scale, __lookahead, __tokens, __sym2)); } + Some(__tok @ Tok::LParen(..)) => { + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state1(scale, __lookahead, __tokens, __sym2)); + } _ => { return Err(__lookahead); } @@ -943,11 +819,11 @@ mod __parse__Expr { match __nt { __Nonterminal::Factor(__nt) => { let __sym2 = &mut Some(__nt); - __result = try!(__state23(scale, __lookahead, __tokens, __sym0, __sym1, __sym2)); + __result = try!(__state21(scale, __lookahead, __tokens, __sym0, __sym1, __sym2)); } __Nonterminal::Term(__nt) => { let __sym2 = &mut Some(__nt); - __result = try!(__state5(scale, __lookahead, __tokens, __sym2)); + __result = try!(__state4(scale, __lookahead, __tokens, __sym2)); } _ => { return Ok((__lookahead, __nt)); @@ -957,7 +833,7 @@ mod __parse__Expr { return Ok(__result); } - // State 14 + // State 12 // Expr = Expr "-" (*) Factor [EOF] // Expr = Expr "-" (*) Factor ["+"] // Expr = Expr "-" (*) Factor ["-"] @@ -990,9 +866,9 @@ mod __parse__Expr { // "(" -> Shift(S1) // "Num" -> Shift(S2) // - // Term -> S5 - // Factor -> S24 - pub fn __state14< + // Factor -> S22 + // Term -> S4 + pub fn __state12< __TOKENS: Iterator, >( scale: i32, @@ -1005,7 +881,7 @@ mod __parse__Expr { let mut __result: (Option, __Nonterminal<>); match __lookahead { Some(__tok @ Tok::LParen(..)) => { - let mut __sym2 = &mut Some(__tok); + let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); __result = try!(__state1(scale, __lookahead, __tokens, __sym2)); } @@ -1021,11 +897,135 @@ mod __parse__Expr { while __sym1.is_some() { let (__lookahead, __nt) = __result; match __nt { + __Nonterminal::Factor(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state22(scale, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } __Nonterminal::Term(__nt) => { let __sym2 = &mut Some(__nt); - __result = try!(__state5(scale, __lookahead, __tokens, __sym2)); + __result = try!(__state4(scale, __lookahead, __tokens, __sym2)); } - __Nonterminal::Factor(__nt) => { + _ => { + return Ok((__lookahead, __nt)); + } + } + } + return Ok(__result); + } + + // State 13 + // Factor = Factor "/" (*) Term [EOF] + // Factor = Factor "/" (*) Term ["*"] + // Factor = Factor "/" (*) Term ["+"] + // Factor = Factor "/" (*) Term ["-"] + // Factor = Factor "/" (*) Term ["/"] + // Term = (*) "(" Expr ")" [EOF] + // Term = (*) "(" Expr ")" ["*"] + // Term = (*) "(" Expr ")" ["+"] + // Term = (*) "(" Expr ")" ["-"] + // Term = (*) "(" Expr ")" ["/"] + // Term = (*) "Num" [EOF] + // Term = (*) "Num" ["*"] + // Term = (*) "Num" ["+"] + // Term = (*) "Num" ["-"] + // Term = (*) "Num" ["/"] + // + // "Num" -> Shift(S2) + // "(" -> Shift(S1) + // + // Term -> S23 + pub fn __state13< + __TOKENS: Iterator, + >( + scale: i32, + mut __lookahead: Option, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + __sym1: &mut Option, + ) -> Result<(Option, __Nonterminal<>), Option> + { + let mut __result: (Option, __Nonterminal<>); + match __lookahead { + Some(Tok::Num(__tok0)) => { + let mut __sym2 = &mut Some((__tok0)); + let __lookahead = __tokens.next(); + __result = try!(__state2(scale, __lookahead, __tokens, __sym2)); + } + Some(__tok @ Tok::LParen(..)) => { + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state1(scale, __lookahead, __tokens, __sym2)); + } + _ => { + return Err(__lookahead); + } + } + while __sym1.is_some() { + let (__lookahead, __nt) = __result; + match __nt { + __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state23(scale, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + _ => { + return Ok((__lookahead, __nt)); + } + } + } + return Ok(__result); + } + + // State 14 + // Factor = Factor "*" (*) Term [EOF] + // Factor = Factor "*" (*) Term ["*"] + // Factor = Factor "*" (*) Term ["+"] + // Factor = Factor "*" (*) Term ["-"] + // Factor = Factor "*" (*) Term ["/"] + // Term = (*) "(" Expr ")" [EOF] + // Term = (*) "(" Expr ")" ["*"] + // Term = (*) "(" Expr ")" ["+"] + // Term = (*) "(" Expr ")" ["-"] + // Term = (*) "(" Expr ")" ["/"] + // Term = (*) "Num" [EOF] + // Term = (*) "Num" ["*"] + // Term = (*) "Num" ["+"] + // Term = (*) "Num" ["-"] + // Term = (*) "Num" ["/"] + // + // "Num" -> Shift(S2) + // "(" -> Shift(S1) + // + // Term -> S24 + pub fn __state14< + __TOKENS: Iterator, + >( + scale: i32, + mut __lookahead: Option, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + __sym1: &mut Option, + ) -> Result<(Option, __Nonterminal<>), Option> + { + let mut __result: (Option, __Nonterminal<>); + match __lookahead { + Some(Tok::Num(__tok0)) => { + let mut __sym2 = &mut Some((__tok0)); + let __lookahead = __tokens.next(); + __result = try!(__state2(scale, __lookahead, __tokens, __sym2)); + } + Some(__tok @ Tok::LParen(..)) => { + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state1(scale, __lookahead, __tokens, __sym2)); + } + _ => { + return Err(__lookahead); + } + } + while __sym1.is_some() { + let (__lookahead, __nt) = __result; + match __nt { + __Nonterminal::Term(__nt) => { let __sym2 = &mut Some(__nt); __result = try!(__state24(scale, __lookahead, __tokens, __sym0, __sym1, __sym2)); } @@ -1054,8 +1054,8 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "(" -> Shift(S7) - // "Num" -> Shift(S9) + // "(" -> Shift(S9) + // "Num" -> Shift(S8) // // Term -> S25 pub fn __state15< @@ -1071,14 +1071,14 @@ mod __parse__Expr { let mut __result: (Option, __Nonterminal<>); match __lookahead { Some(__tok @ Tok::LParen(..)) => { - let mut __sym2 = &mut Some(__tok); + let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state7(scale, __lookahead, __tokens, __sym2)); + __result = try!(__state9(scale, __lookahead, __tokens, __sym2)); } Some(Tok::Num(__tok0)) => { let mut __sym2 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state9(scale, __lookahead, __tokens, __sym2)); + __result = try!(__state8(scale, __lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); @@ -1116,8 +1116,8 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "(" -> Shift(S7) - // "Num" -> Shift(S9) + // "(" -> Shift(S9) + // "Num" -> Shift(S8) // // Term -> S26 pub fn __state16< @@ -1133,14 +1133,14 @@ mod __parse__Expr { let mut __result: (Option, __Nonterminal<>); match __lookahead { Some(__tok @ Tok::LParen(..)) => { - let mut __sym2 = &mut Some(__tok); + let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state7(scale, __lookahead, __tokens, __sym2)); + __result = try!(__state9(scale, __lookahead, __tokens, __sym2)); } Some(Tok::Num(__tok0)) => { let mut __sym2 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state9(scale, __lookahead, __tokens, __sym2)); + __result = try!(__state8(scale, __lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); @@ -1174,9 +1174,9 @@ mod __parse__Expr { // Term = "(" Expr (*) ")" ["-"] // Term = "(" Expr (*) ")" ["/"] // - // "-" -> Shift(S20) // ")" -> Shift(S27) - // "+" -> Shift(S19) + // "-" -> Shift(S19) + // "+" -> Shift(S18) // pub fn __state17< __TOKENS: Iterator, @@ -1190,21 +1190,21 @@ mod __parse__Expr { { let mut __result: (Option, __Nonterminal<>); match __lookahead { - Some(__tok @ Tok::Minus(..)) => { - let mut __sym2 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state20(scale, __lookahead, __tokens, __sym1, __sym2)); - } Some(__tok @ Tok::RParen(..)) => { - let mut __sym2 = &mut Some(__tok); + let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); __result = try!(__state27(scale, __lookahead, __tokens, __sym0, __sym1, __sym2)); } - Some(__tok @ Tok::Plus(..)) => { - let mut __sym2 = &mut Some(__tok); + Some(__tok @ Tok::Minus(..)) => { + let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); __result = try!(__state19(scale, __lookahead, __tokens, __sym1, __sym2)); } + Some(__tok @ Tok::Plus(..)) => { + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state18(scale, __lookahead, __tokens, __sym1, __sym2)); + } _ => { return Err(__lookahead); } @@ -1213,73 +1213,6 @@ mod __parse__Expr { } // State 18 - // Term = "(" Expr ")" (*) [EOF] - // Term = "(" Expr ")" (*) ["*"] - // Term = "(" Expr ")" (*) ["+"] - // Term = "(" Expr ")" (*) ["-"] - // Term = "(" Expr ")" (*) ["/"] - // - // "-" -> Reduce(Term = "(", Expr, ")" => ActionFn(8);) - // "+" -> Reduce(Term = "(", Expr, ")" => ActionFn(8);) - // "/" -> Reduce(Term = "(", Expr, ")" => ActionFn(8);) - // "*" -> Reduce(Term = "(", Expr, ")" => ActionFn(8);) - // EOF -> Reduce(Term = "(", Expr, ")" => ActionFn(8);) - // - pub fn __state18< - __TOKENS: Iterator, - >( - scale: i32, - mut __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option, - __sym2: &mut Option, - ) -> Result<(Option, __Nonterminal<>), Option> - { - let mut __result: (Option, __Nonterminal<>); - match __lookahead { - Some(Tok::Minus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action8(scale, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Term(__nt))); - } - Some(Tok::Plus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action8(scale, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Term(__nt))); - } - Some(Tok::Div(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action8(scale, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Term(__nt))); - } - Some(Tok::Times(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action8(scale, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Term(__nt))); - } - None => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action8(scale, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Term(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 19 // Expr = Expr "+" (*) Factor [")"] // Expr = Expr "+" (*) Factor ["+"] // Expr = Expr "+" (*) Factor ["-"] @@ -1309,12 +1242,12 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "Num" -> Shift(S9) - // "(" -> Shift(S7) + // "(" -> Shift(S9) + // "Num" -> Shift(S8) // - // Term -> S8 // Factor -> S28 - pub fn __state19< + // Term -> S7 + pub fn __state18< __TOKENS: Iterator, >( scale: i32, @@ -1326,15 +1259,15 @@ mod __parse__Expr { { let mut __result: (Option, __Nonterminal<>); match __lookahead { - Some(Tok::Num(__tok0)) => { - let mut __sym2 = &mut Some((__tok0)); + Some(__tok @ Tok::LParen(..)) => { + let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); __result = try!(__state9(scale, __lookahead, __tokens, __sym2)); } - Some(__tok @ Tok::LParen(..)) => { - let mut __sym2 = &mut Some(__tok); + Some(Tok::Num(__tok0)) => { + let mut __sym2 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state7(scale, __lookahead, __tokens, __sym2)); + __result = try!(__state8(scale, __lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); @@ -1343,14 +1276,14 @@ mod __parse__Expr { while __sym1.is_some() { let (__lookahead, __nt) = __result; match __nt { - __Nonterminal::Term(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state8(scale, __lookahead, __tokens, __sym2)); - } __Nonterminal::Factor(__nt) => { let __sym2 = &mut Some(__nt); __result = try!(__state28(scale, __lookahead, __tokens, __sym0, __sym1, __sym2)); } + __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state7(scale, __lookahead, __tokens, __sym2)); + } _ => { return Ok((__lookahead, __nt)); } @@ -1359,7 +1292,7 @@ mod __parse__Expr { return Ok(__result); } - // State 20 + // State 19 // Expr = Expr "-" (*) Factor [")"] // Expr = Expr "-" (*) Factor ["+"] // Expr = Expr "-" (*) Factor ["-"] @@ -1389,12 +1322,12 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "(" -> Shift(S7) - // "Num" -> Shift(S9) + // "(" -> Shift(S9) + // "Num" -> Shift(S8) // + // Term -> S7 // Factor -> S29 - // Term -> S8 - pub fn __state20< + pub fn __state19< __TOKENS: Iterator, >( scale: i32, @@ -1407,14 +1340,14 @@ mod __parse__Expr { let mut __result: (Option, __Nonterminal<>); match __lookahead { Some(__tok @ Tok::LParen(..)) => { - let mut __sym2 = &mut Some(__tok); + let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state7(scale, __lookahead, __tokens, __sym2)); + __result = try!(__state9(scale, __lookahead, __tokens, __sym2)); } Some(Tok::Num(__tok0)) => { let mut __sym2 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state9(scale, __lookahead, __tokens, __sym2)); + __result = try!(__state8(scale, __lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); @@ -1423,14 +1356,14 @@ mod __parse__Expr { while __sym1.is_some() { let (__lookahead, __nt) = __result; match __nt { + __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state7(scale, __lookahead, __tokens, __sym2)); + } __Nonterminal::Factor(__nt) => { let __sym2 = &mut Some(__nt); __result = try!(__state29(scale, __lookahead, __tokens, __sym0, __sym1, __sym2)); } - __Nonterminal::Term(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state8(scale, __lookahead, __tokens, __sym2)); - } _ => { return Ok((__lookahead, __nt)); } @@ -1439,141 +1372,74 @@ mod __parse__Expr { return Ok(__result); } + // State 20 + // Term = "(" Expr ")" (*) [EOF] + // Term = "(" Expr ")" (*) ["*"] + // Term = "(" Expr ")" (*) ["+"] + // Term = "(" Expr ")" (*) ["-"] + // Term = "(" Expr ")" (*) ["/"] + // + // "-" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) + // "*" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) + // "+" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) + // "/" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) + // EOF -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) + // + pub fn __state20< + __TOKENS: Iterator, + >( + scale: i32, + mut __lookahead: Option, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + __sym1: &mut Option, + __sym2: &mut Option, + ) -> Result<(Option, __Nonterminal<>), Option> + { + let mut __result: (Option, __Nonterminal<>); + match __lookahead { + Some(Tok::Minus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action8(scale, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Term(__nt))); + } + Some(Tok::Times(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action8(scale, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Term(__nt))); + } + Some(Tok::Plus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action8(scale, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Term(__nt))); + } + Some(Tok::Div(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action8(scale, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Term(__nt))); + } + None => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action8(scale, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Term(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + // State 21 - // Factor = Factor "*" Term (*) [EOF] - // Factor = Factor "*" Term (*) ["*"] - // Factor = Factor "*" Term (*) ["+"] - // Factor = Factor "*" Term (*) ["-"] - // Factor = Factor "*" Term (*) ["/"] - // - // EOF -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) - // "*" -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) - // "/" -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) - // "-" -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) - // "+" -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) - // - pub fn __state21< - __TOKENS: Iterator, - >( - scale: i32, - mut __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option, - __sym2: &mut Option, - ) -> Result<(Option, __Nonterminal<>), Option> - { - let mut __result: (Option, __Nonterminal<>); - match __lookahead { - None => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action4(scale, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Times(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action4(scale, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Div(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action4(scale, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Minus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action4(scale, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Plus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action4(scale, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 22 - // Factor = Factor "/" Term (*) [EOF] - // Factor = Factor "/" Term (*) ["*"] - // Factor = Factor "/" Term (*) ["+"] - // Factor = Factor "/" Term (*) ["-"] - // Factor = Factor "/" Term (*) ["/"] - // - // "*" -> Reduce(Factor = Factor, "/", Term => ActionFn(5);) - // EOF -> Reduce(Factor = Factor, "/", Term => ActionFn(5);) - // "-" -> Reduce(Factor = Factor, "/", Term => ActionFn(5);) - // "/" -> Reduce(Factor = Factor, "/", Term => ActionFn(5);) - // "+" -> Reduce(Factor = Factor, "/", Term => ActionFn(5);) - // - pub fn __state22< - __TOKENS: Iterator, - >( - scale: i32, - mut __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option, - __sym2: &mut Option, - ) -> Result<(Option, __Nonterminal<>), Option> - { - let mut __result: (Option, __Nonterminal<>); - match __lookahead { - Some(Tok::Times(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action5(scale, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - None => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action5(scale, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Minus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action5(scale, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Div(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action5(scale, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Plus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action5(scale, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 23 // Expr = Expr "+" Factor (*) [EOF] // Expr = Expr "+" Factor (*) ["+"] // Expr = Expr "+" Factor (*) ["-"] @@ -1588,13 +1454,13 @@ mod __parse__Expr { // Factor = Factor (*) "/" Term ["-"] // Factor = Factor (*) "/" Term ["/"] // - // "/" -> Shift(S12) - // EOF -> Reduce(Expr = Expr, "+", Factor => ActionFn(2);) - // "+" -> Reduce(Expr = Expr, "+", Factor => ActionFn(2);) - // "-" -> Reduce(Expr = Expr, "+", Factor => ActionFn(2);) - // "*" -> Shift(S11) + // "*" -> Shift(S14) + // "+" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) + // "-" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) + // "/" -> Shift(S13) + // EOF -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) // - pub fn __state23< + pub fn __state21< __TOKENS: Iterator, >( scale: i32, @@ -1607,22 +1473,15 @@ mod __parse__Expr { { let mut __result: (Option, __Nonterminal<>); match __lookahead { - Some(__tok @ Tok::Div(..)) => { - let mut __sym3 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state12(scale, __lookahead, __tokens, __sym2, __sym3)); - } Some(__tok @ Tok::Times(..)) => { - let mut __sym3 = &mut Some(__tok); + let mut __sym3 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state11(scale, __lookahead, __tokens, __sym2, __sym3)); + __result = try!(__state14(scale, __lookahead, __tokens, __sym2, __sym3)); } - None => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action2(scale, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Expr(__nt))); + Some(__tok @ Tok::Div(..)) => { + let mut __sym3 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state13(scale, __lookahead, __tokens, __sym2, __sym3)); } Some(Tok::Plus(..)) => { let __sym0 = __sym0.take().unwrap(); @@ -1638,6 +1497,13 @@ mod __parse__Expr { let __nt = super::__actions::__action2(scale, __sym0, __sym1, __sym2); return Ok((__lookahead, __Nonterminal::Expr(__nt))); } + None => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action2(scale, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Expr(__nt))); + } _ => { return Err(__lookahead); } @@ -1645,7 +1511,7 @@ mod __parse__Expr { return Ok(__result); } - // State 24 + // State 22 // Expr = Expr "-" Factor (*) [EOF] // Expr = Expr "-" Factor (*) ["+"] // Expr = Expr "-" Factor (*) ["-"] @@ -1660,11 +1526,142 @@ mod __parse__Expr { // Factor = Factor (*) "/" Term ["-"] // Factor = Factor (*) "/" Term ["/"] // - // "/" -> Shift(S12) - // "+" -> Reduce(Expr = Expr, "-", Factor => ActionFn(1);) - // "*" -> Shift(S11) - // "-" -> Reduce(Expr = Expr, "-", Factor => ActionFn(1);) - // EOF -> Reduce(Expr = Expr, "-", Factor => ActionFn(1);) + // EOF -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // "/" -> Shift(S13) + // "*" -> Shift(S14) + // "+" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // "-" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // + pub fn __state22< + __TOKENS: Iterator, + >( + scale: i32, + mut __lookahead: Option, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + __sym1: &mut Option, + __sym2: &mut Option, + ) -> Result<(Option, __Nonterminal<>), Option> + { + let mut __result: (Option, __Nonterminal<>); + match __lookahead { + Some(__tok @ Tok::Div(..)) => { + let mut __sym3 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state13(scale, __lookahead, __tokens, __sym2, __sym3)); + } + Some(__tok @ Tok::Times(..)) => { + let mut __sym3 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state14(scale, __lookahead, __tokens, __sym2, __sym3)); + } + None => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action1(scale, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Expr(__nt))); + } + Some(Tok::Plus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action1(scale, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Expr(__nt))); + } + Some(Tok::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((__lookahead, __Nonterminal::Expr(__nt))); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + + // State 23 + // Factor = Factor "/" Term (*) [EOF] + // Factor = Factor "/" Term (*) ["*"] + // Factor = Factor "/" Term (*) ["+"] + // Factor = Factor "/" Term (*) ["-"] + // Factor = Factor "/" Term (*) ["/"] + // + // EOF -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // "*" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // "-" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // "+" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // "/" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // + pub fn __state23< + __TOKENS: Iterator, + >( + scale: i32, + mut __lookahead: Option, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + __sym1: &mut Option, + __sym2: &mut Option, + ) -> Result<(Option, __Nonterminal<>), Option> + { + let mut __result: (Option, __Nonterminal<>); + match __lookahead { + None => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action5(scale, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + Some(Tok::Times(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action5(scale, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + Some(Tok::Minus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action5(scale, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + Some(Tok::Plus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action5(scale, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + Some(Tok::Div(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action5(scale, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 24 + // Factor = Factor "*" Term (*) [EOF] + // Factor = Factor "*" Term (*) ["*"] + // Factor = Factor "*" Term (*) ["+"] + // Factor = Factor "*" Term (*) ["-"] + // Factor = Factor "*" Term (*) ["/"] + // + // "*" -> Reduce(Factor = Factor, "*", Term => 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 __state24< __TOKENS: Iterator, @@ -1679,42 +1676,45 @@ mod __parse__Expr { { let mut __result: (Option, __Nonterminal<>); match __lookahead { - Some(__tok @ Tok::Div(..)) => { - let mut __sym3 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state12(scale, __lookahead, __tokens, __sym2, __sym3)); - } - Some(__tok @ Tok::Times(..)) => { - let mut __sym3 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state11(scale, __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(scale, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Expr(__nt))); - } - Some(Tok::Minus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action1(scale, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Expr(__nt))); + let __nt = super::__actions::__action4(scale, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); } None => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action1(scale, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Expr(__nt))); + let __nt = super::__actions::__action4(scale, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + Some(Tok::Minus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action4(scale, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + Some(Tok::Plus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action4(scale, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + Some(Tok::Div(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action4(scale, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); } _ => { return Err(__lookahead); } } - return Ok(__result); } // State 25 @@ -1724,11 +1724,11 @@ mod __parse__Expr { // Factor = Factor "/" Term (*) ["-"] // Factor = Factor "/" Term (*) ["/"] // - // "+" -> Reduce(Factor = Factor, "/", Term => ActionFn(5);) - // "*" -> Reduce(Factor = Factor, "/", Term => ActionFn(5);) - // ")" -> Reduce(Factor = Factor, "/", Term => ActionFn(5);) - // "/" -> Reduce(Factor = Factor, "/", Term => ActionFn(5);) - // "-" -> Reduce(Factor = Factor, "/", Term => ActionFn(5);) + // "*" -> Reduce(Factor = Factor, "/", Term => 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, @@ -1743,13 +1743,6 @@ mod __parse__Expr { { let mut __result: (Option, __Nonterminal<>); match __lookahead { - Some(Tok::Plus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action5(scale, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } Some(Tok::Times(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); @@ -1764,6 +1757,13 @@ mod __parse__Expr { let __nt = super::__actions::__action5(scale, __sym0, __sym1, __sym2); return Ok((__lookahead, __Nonterminal::Factor(__nt))); } + Some(Tok::Minus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action5(scale, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } Some(Tok::Div(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); @@ -1771,7 +1771,7 @@ mod __parse__Expr { let __nt = super::__actions::__action5(scale, __sym0, __sym1, __sym2); return Ok((__lookahead, __Nonterminal::Factor(__nt))); } - Some(Tok::Minus(..)) => { + Some(Tok::Plus(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); @@ -1791,11 +1791,11 @@ mod __parse__Expr { // Factor = Factor "*" Term (*) ["-"] // Factor = Factor "*" Term (*) ["/"] // - // "*" -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) - // "/" -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) - // ")" -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) - // "+" -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) - // "-" -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) + // ")" -> Reduce(Factor = Factor, "*", Term => 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, @@ -1810,7 +1810,7 @@ mod __parse__Expr { { let mut __result: (Option, __Nonterminal<>); match __lookahead { - Some(Tok::Times(..)) => { + Some(Tok::RParen(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); @@ -1824,7 +1824,7 @@ mod __parse__Expr { let __nt = super::__actions::__action4(scale, __sym0, __sym1, __sym2); return Ok((__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(); @@ -1858,11 +1858,11 @@ mod __parse__Expr { // Term = "(" Expr ")" (*) ["-"] // Term = "(" Expr ")" (*) ["/"] // - // "+" -> Reduce(Term = "(", Expr, ")" => ActionFn(8);) - // ")" -> Reduce(Term = "(", Expr, ")" => ActionFn(8);) - // "*" -> Reduce(Term = "(", Expr, ")" => ActionFn(8);) - // "-" -> Reduce(Term = "(", Expr, ")" => ActionFn(8);) - // "/" -> Reduce(Term = "(", Expr, ")" => ActionFn(8);) + // "/" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) + // "+" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) + // "*" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) + // ")" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) + // "-" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(8));) // pub fn __state27< __TOKENS: Iterator, @@ -1877,14 +1877,14 @@ mod __parse__Expr { { let mut __result: (Option, __Nonterminal<>); match __lookahead { - Some(Tok::Plus(..)) => { + Some(Tok::Div(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); let __nt = super::__actions::__action8(scale, __sym0, __sym1, __sym2); return Ok((__lookahead, __Nonterminal::Term(__nt))); } - Some(Tok::RParen(..)) => { + Some(Tok::Plus(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); @@ -1898,14 +1898,14 @@ mod __parse__Expr { let __nt = super::__actions::__action8(scale, __sym0, __sym1, __sym2); return Ok((__lookahead, __Nonterminal::Term(__nt))); } - Some(Tok::Minus(..)) => { + Some(Tok::RParen(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); let __nt = super::__actions::__action8(scale, __sym0, __sym1, __sym2); return Ok((__lookahead, __Nonterminal::Term(__nt))); } - Some(Tok::Div(..)) => { + Some(Tok::Minus(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); @@ -1933,11 +1933,11 @@ mod __parse__Expr { // Factor = Factor (*) "/" Term ["-"] // Factor = Factor (*) "/" Term ["/"] // + // ")" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) // "/" -> Shift(S15) - // ")" -> Reduce(Expr = Expr, "+", Factor => ActionFn(2);) - // "-" -> Reduce(Expr = Expr, "+", Factor => ActionFn(2);) + // "+" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) // "*" -> Shift(S16) - // "+" -> Reduce(Expr = Expr, "+", Factor => ActionFn(2);) + // "-" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) // pub fn __state28< __TOKENS: Iterator, @@ -1953,12 +1953,12 @@ mod __parse__Expr { let mut __result: (Option, __Nonterminal<>); match __lookahead { Some(__tok @ Tok::Div(..)) => { - let mut __sym3 = &mut Some(__tok); + let mut __sym3 = &mut Some((__tok)); let __lookahead = __tokens.next(); __result = try!(__state15(scale, __lookahead, __tokens, __sym2, __sym3)); } Some(__tok @ Tok::Times(..)) => { - let mut __sym3 = &mut Some(__tok); + let mut __sym3 = &mut Some((__tok)); let __lookahead = __tokens.next(); __result = try!(__state16(scale, __lookahead, __tokens, __sym2, __sym3)); } @@ -1969,14 +1969,14 @@ mod __parse__Expr { let __nt = super::__actions::__action2(scale, __sym0, __sym1, __sym2); return Ok((__lookahead, __Nonterminal::Expr(__nt))); } - Some(Tok::Minus(..)) => { + Some(Tok::Plus(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); let __nt = super::__actions::__action2(scale, __sym0, __sym1, __sym2); return Ok((__lookahead, __Nonterminal::Expr(__nt))); } - Some(Tok::Plus(..)) => { + Some(Tok::Minus(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); @@ -2005,11 +2005,11 @@ mod __parse__Expr { // Factor = Factor (*) "/" Term ["-"] // Factor = Factor (*) "/" Term ["/"] // + // ")" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) // "/" -> Shift(S15) - // "-" -> Reduce(Expr = Expr, "-", Factor => ActionFn(1);) - // "+" -> Reduce(Expr = Expr, "-", Factor => ActionFn(1);) + // "-" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // "+" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) // "*" -> Shift(S16) - // ")" -> Reduce(Expr = Expr, "-", Factor => ActionFn(1);) // pub fn __state29< __TOKENS: Iterator, @@ -2025,15 +2025,22 @@ mod __parse__Expr { let mut __result: (Option, __Nonterminal<>); match __lookahead { Some(__tok @ Tok::Div(..)) => { - let mut __sym3 = &mut Some(__tok); + let mut __sym3 = &mut Some((__tok)); let __lookahead = __tokens.next(); __result = try!(__state15(scale, __lookahead, __tokens, __sym2, __sym3)); } Some(__tok @ Tok::Times(..)) => { - let mut __sym3 = &mut Some(__tok); + let mut __sym3 = &mut Some((__tok)); let __lookahead = __tokens.next(); __result = try!(__state16(scale, __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); + return Ok((__lookahead, __Nonterminal::Expr(__nt))); + } Some(Tok::Minus(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); @@ -2048,13 +2055,6 @@ mod __parse__Expr { let __nt = super::__actions::__action1(scale, __sym0, __sym1, __sym2); return Ok((__lookahead, __Nonterminal::Expr(__nt))); } - Some(Tok::RParen(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action1(scale, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Expr(__nt))); - } _ => { return Err(__lookahead); } diff --git a/lalrpop-test/src/expr_arena.lalrpop b/lalrpop-test/src/expr_arena.lalrpop index 84ba571..57e47d2 100644 --- a/lalrpop-test/src/expr_arena.lalrpop +++ b/lalrpop-test/src/expr_arena.lalrpop @@ -4,7 +4,7 @@ use util::tok::Tok; grammar<'ast>(arena: &'ast Arena<'ast>); extern token { - type Location = u32; + type Location = usize; enum Tok { "(" => Tok::LParen(..), diff --git a/lalrpop-test/src/expr_arena.rs b/lalrpop-test/src/expr_arena.rs index 8eac297..826888d 100644 --- a/lalrpop-test/src/expr_arena.rs +++ b/lalrpop-test/src/expr_arena.rs @@ -5,11 +5,11 @@ use util::tok::Tok; #[allow(non_snake_case)] pub fn parse_Expr< 'ast, - __TOKENS: IntoIterator, + __TOKENS: IntoIterator, >( arena: &'ast Arena<'ast>, __tokens: __TOKENS, -) -> Result<(Option, &'ast Node<'ast>), Option> +) -> Result<(Option<(usize,Tok,usize)>, &'ast Node<'ast>), Option<(usize,Tok,usize)>> { let mut __tokens = __tokens.into_iter(); let __lookahead = __tokens.next(); @@ -27,13 +27,13 @@ mod __parse__Expr { pub enum __Nonterminal<'ast, > { _28_3cExpr_3e_20_22_2c_22_29(&'ast Node<'ast>), + Factor(&'ast Node<'ast>), + Expr_3f(::std::option::Option<&'ast Node<'ast>>), Comma_3cExpr_3e(Vec<&'ast Node<'ast>>), _28_3cExpr_3e_20_22_2c_22_29_2a(::std::vec::Vec<&'ast Node<'ast>>), - Expr(&'ast Node<'ast>), - Factor(&'ast Node<'ast>), - Term(&'ast Node<'ast>), ____Expr(&'ast Node<'ast>), - Expr_3f(::std::option::Option<&'ast Node<'ast>>), + Term(&'ast Node<'ast>), + Expr(&'ast Node<'ast>), } // State 0 @@ -78,38 +78,38 @@ mod __parse__Expr { // Term = (*) "Num" ["/"] // __Expr = (*) Expr [EOF] // - // "*" -> Shift(S5) - // "(" -> Shift(S3) - // "Num" -> Shift(S6) + // "*" -> Shift(S6) + // "(" -> Shift(S5) + // "Num" -> Shift(S1) // - // Expr -> S4 - // Term -> S2 - // Factor -> S1 + // Expr -> S2 + // Term -> S3 + // Factor -> S4 pub fn __state0< 'ast, - __TOKENS: Iterator, + __TOKENS: Iterator, >( arena: &'ast Arena<'ast>, - mut __lookahead: Option, + mut __lookahead: Option<(usize,Tok,usize)>, __tokens: &mut __TOKENS, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> + ) -> Result<(Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> { - let mut __result: (Option, __Nonterminal<'ast, >); + let mut __result: (Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some(__tok @ Tok::Times(..)) => { - let mut __sym0 = &mut Some(__tok); + Some((_, __tok @ Tok::Times(..), _)) => { + let mut __sym0 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state6(arena, __lookahead, __tokens, __sym0)); + } + Some((_, __tok @ Tok::LParen(..), _)) => { + let mut __sym0 = &mut Some((__tok)); let __lookahead = __tokens.next(); __result = try!(__state5(arena, __lookahead, __tokens, __sym0)); } - Some(__tok @ Tok::LParen(..)) => { - let mut __sym0 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state3(arena, __lookahead, __tokens, __sym0)); - } - Some(Tok::Num(__tok0)) => { + Some((_, Tok::Num(__tok0), _)) => { let mut __sym0 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state6(arena, __lookahead, __tokens, __sym0)); + __result = try!(__state1(arena, __lookahead, __tokens, __sym0)); } _ => { return Err(__lookahead); @@ -120,15 +120,15 @@ mod __parse__Expr { match __nt { __Nonterminal::Expr(__nt) => { let __sym0 = &mut Some(__nt); - __result = try!(__state4(arena, __lookahead, __tokens, __sym0)); + __result = try!(__state2(arena, __lookahead, __tokens, __sym0)); } __Nonterminal::Term(__nt) => { let __sym0 = &mut Some(__nt); - __result = try!(__state2(arena, __lookahead, __tokens, __sym0)); + __result = try!(__state3(arena, __lookahead, __tokens, __sym0)); } __Nonterminal::Factor(__nt) => { let __sym0 = &mut Some(__nt); - __result = try!(__state1(arena, __lookahead, __tokens, __sym0)); + __result = try!(__state4(arena, __lookahead, __tokens, __sym0)); } _ => { return Ok((__lookahead, __nt)); @@ -138,6 +138,165 @@ mod __parse__Expr { } // State 1 + // Term = "Num" (*) [EOF] + // Term = "Num" (*) ["*"] + // Term = "Num" (*) ["+"] + // Term = "Num" (*) ["-"] + // Term = "Num" (*) ["/"] + // + // "*" -> Reduce(Term = "Num" => Call(ActionFn(8));) + // "-" -> Reduce(Term = "Num" => Call(ActionFn(8));) + // "/" -> Reduce(Term = "Num" => Call(ActionFn(8));) + // "+" -> Reduce(Term = "Num" => Call(ActionFn(8));) + // EOF -> Reduce(Term = "Num" => Call(ActionFn(8));) + // + pub fn __state1< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + mut __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + ) -> Result<(Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, Tok::Times(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action8(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Term(__nt))); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action8(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Term(__nt))); + } + Some((_, Tok::Div(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action8(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Term(__nt))); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action8(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Term(__nt))); + } + None => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action8(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Term(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 2 + // Expr = Expr (*) "+" Factor [EOF] + // Expr = Expr (*) "+" Factor ["+"] + // Expr = Expr (*) "+" Factor ["-"] + // Expr = Expr (*) "-" Factor [EOF] + // Expr = Expr (*) "-" Factor ["+"] + // Expr = Expr (*) "-" Factor ["-"] + // __Expr = Expr (*) [EOF] + // + // "-" -> Shift(S7) + // EOF -> Reduce(__Expr = Expr => Call(ActionFn(0));) + // "+" -> Shift(S8) + // + pub fn __state2< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + mut __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + ) -> Result<(Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, __tok @ Tok::Minus(..), _)) => { + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state7(arena, __lookahead, __tokens, __sym0, __sym1)); + } + Some((_, __tok @ Tok::Plus(..), _)) => { + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state8(arena, __lookahead, __tokens, __sym0, __sym1)); + } + None => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action0(arena, __sym0); + return Ok((__lookahead, __Nonterminal::____Expr(__nt))); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + + // State 3 + // Factor = Term (*) [EOF] + // Factor = Term (*) ["*"] + // Factor = Term (*) ["+"] + // Factor = Term (*) ["-"] + // Factor = Term (*) ["/"] + // + // "+" -> Reduce(Factor = Term => Call(ActionFn(7));) + // EOF -> Reduce(Factor = Term => Call(ActionFn(7));) + // "*" -> Reduce(Factor = Term => Call(ActionFn(7));) + // "-" -> Reduce(Factor = Term => Call(ActionFn(7));) + // "/" -> Reduce(Factor = Term => Call(ActionFn(7));) + // + pub fn __state3< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + mut __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + ) -> Result<(Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (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((__lookahead, __Nonterminal::Factor(__nt))); + } + None => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action7(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Times(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action7(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action7(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Div(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action7(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 4 // Expr = Factor (*) [EOF] // Expr = Factor (*) ["+"] // Expr = Factor (*) ["-"] @@ -152,45 +311,45 @@ mod __parse__Expr { // Factor = Factor (*) "/" Term ["-"] // Factor = Factor (*) "/" Term ["/"] // - // "/" -> Shift(S8) - // EOF -> Reduce(Expr = Factor => ActionFn(3);) - // "*" -> Shift(S7) - // "+" -> Reduce(Expr = Factor => ActionFn(3);) - // "-" -> Reduce(Expr = Factor => ActionFn(3);) + // "/" -> Shift(S10) + // "*" -> Shift(S9) + // EOF -> Reduce(Expr = Factor => Call(ActionFn(3));) + // "+" -> Reduce(Expr = Factor => Call(ActionFn(3));) + // "-" -> Reduce(Expr = Factor => Call(ActionFn(3));) // - pub fn __state1< + pub fn __state4< 'ast, - __TOKENS: Iterator, + __TOKENS: Iterator, >( arena: &'ast Arena<'ast>, - mut __lookahead: Option, + mut __lookahead: Option<(usize,Tok,usize)>, __tokens: &mut __TOKENS, __sym0: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> + ) -> Result<(Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> { - let mut __result: (Option, __Nonterminal<'ast, >); + let mut __result: (Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some(__tok @ Tok::Div(..)) => { - let mut __sym1 = &mut Some(__tok); + Some((_, __tok @ Tok::Div(..), _)) => { + let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state8(arena, __lookahead, __tokens, __sym0, __sym1)); + __result = try!(__state10(arena, __lookahead, __tokens, __sym0, __sym1)); } - Some(__tok @ Tok::Times(..)) => { - let mut __sym1 = &mut Some(__tok); + Some((_, __tok @ Tok::Times(..), _)) => { + let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state7(arena, __lookahead, __tokens, __sym0, __sym1)); + __result = try!(__state9(arena, __lookahead, __tokens, __sym0, __sym1)); } None => { let __sym0 = __sym0.take().unwrap(); let __nt = super::__actions::__action3(arena, __sym0); return Ok((__lookahead, __Nonterminal::Expr(__nt))); } - Some(Tok::Plus(..)) => { + Some((_, Tok::Plus(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __nt = super::__actions::__action3(arena, __sym0); return Ok((__lookahead, __Nonterminal::Expr(__nt))); } - Some(Tok::Minus(..)) => { + Some((_, Tok::Minus(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __nt = super::__actions::__action3(arena, __sym0); return Ok((__lookahead, __Nonterminal::Expr(__nt))); @@ -202,63 +361,7 @@ mod __parse__Expr { return Ok(__result); } - // State 2 - // Factor = Term (*) [EOF] - // Factor = Term (*) ["*"] - // Factor = Term (*) ["+"] - // Factor = Term (*) ["-"] - // Factor = Term (*) ["/"] - // - // EOF -> Reduce(Factor = Term => ActionFn(7);) - // "/" -> Reduce(Factor = Term => ActionFn(7);) - // "-" -> Reduce(Factor = Term => ActionFn(7);) - // "+" -> Reduce(Factor = Term => ActionFn(7);) - // "*" -> Reduce(Factor = Term => ActionFn(7);) - // - pub fn __state2< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - mut __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> - { - let mut __result: (Option, __Nonterminal<'ast, >); - match __lookahead { - None => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Div(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Minus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Plus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Times(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 3 + // State 5 // Expr = (*) Expr "+" Factor [")"] // Expr = (*) Expr "+" Factor ["+"] // Expr = (*) Expr "+" Factor ["-"] @@ -304,39 +407,39 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "*" -> Shift(S9) - // "Num" -> Shift(S14) - // "(" -> Shift(S13) + // "(" -> Shift(S11) + // "Num" -> Shift(S16) + // "*" -> Shift(S14) // - // Factor -> S10 - // Expr -> S11 - // Term -> S12 - pub fn __state3< + // Factor -> S13 + // Term -> S15 + // Expr -> S12 + pub fn __state5< 'ast, - __TOKENS: Iterator, + __TOKENS: Iterator, >( arena: &'ast Arena<'ast>, - mut __lookahead: Option, + mut __lookahead: Option<(usize,Tok,usize)>, __tokens: &mut __TOKENS, __sym0: &mut Option, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> + ) -> Result<(Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> { - let mut __result: (Option, __Nonterminal<'ast, >); + let mut __result: (Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some(__tok @ Tok::Times(..)) => { - let mut __sym1 = &mut Some(__tok); + Some((_, __tok @ Tok::LParen(..), _)) => { + let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state9(arena, __lookahead, __tokens, __sym1)); + __result = try!(__state11(arena, __lookahead, __tokens, __sym1)); } - Some(Tok::Num(__tok0)) => { + Some((_, Tok::Num(__tok0), _)) => { let mut __sym1 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state14(arena, __lookahead, __tokens, __sym1)); + __result = try!(__state16(arena, __lookahead, __tokens, __sym1)); } - Some(__tok @ Tok::LParen(..)) => { - let mut __sym1 = &mut Some(__tok); + Some((_, __tok @ Tok::Times(..), _)) => { + let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state13(arena, __lookahead, __tokens, __sym1)); + __result = try!(__state14(arena, __lookahead, __tokens, __sym1)); } _ => { return Err(__lookahead); @@ -347,15 +450,15 @@ mod __parse__Expr { match __nt { __Nonterminal::Factor(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state10(arena, __lookahead, __tokens, __sym1)); - } - __Nonterminal::Expr(__nt) => { - let __sym1 = &mut Some(__nt); - __result = try!(__state11(arena, __lookahead, __tokens, __sym0, __sym1)); + __result = try!(__state13(arena, __lookahead, __tokens, __sym1)); } __Nonterminal::Term(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state12(arena, __lookahead, __tokens, __sym1)); + __result = try!(__state15(arena, __lookahead, __tokens, __sym1)); + } + __Nonterminal::Expr(__nt) => { + let __sym1 = &mut Some(__nt); + __result = try!(__state12(arena, __lookahead, __tokens, __sym0, __sym1)); } _ => { return Ok((__lookahead, __nt)); @@ -365,54 +468,7 @@ mod __parse__Expr { 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(S16) - // EOF -> Reduce(__Expr = Expr => ActionFn(0);) - // "+" -> Shift(S15) - // - pub fn __state4< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - mut __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> - { - let mut __result: (Option, __Nonterminal<'ast, >); - match __lookahead { - Some(__tok @ Tok::Minus(..)) => { - let mut __sym1 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state16(arena, __lookahead, __tokens, __sym0, __sym1)); - } - Some(__tok @ Tok::Plus(..)) => { - let mut __sym1 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state15(arena, __lookahead, __tokens, __sym0, __sym1)); - } - None => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action0(arena, __sym0); - return Ok((__lookahead, __Nonterminal::____Expr(__nt))); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 5 + // State 6 // Factor = "*" (*) "(" Comma ")" [EOF] // Factor = "*" (*) "(" Comma ")" ["*"] // Factor = "*" (*) "(" Comma ")" ["+"] @@ -421,20 +477,20 @@ mod __parse__Expr { // // "(" -> Shift(S17) // - pub fn __state5< + pub fn __state6< 'ast, - __TOKENS: Iterator, + __TOKENS: Iterator, >( arena: &'ast Arena<'ast>, - mut __lookahead: Option, + mut __lookahead: Option<(usize,Tok,usize)>, __tokens: &mut __TOKENS, __sym0: &mut Option, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> + ) -> Result<(Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> { - let mut __result: (Option, __Nonterminal<'ast, >); + let mut __result: (Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some(__tok @ Tok::LParen(..)) => { - let mut __sym1 = &mut Some(__tok); + Some((_, __tok @ Tok::LParen(..), _)) => { + let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); __result = try!(__state17(arena, __lookahead, __tokens, __sym0, __sym1)); } @@ -445,63 +501,191 @@ mod __parse__Expr { return Ok(__result); } - // State 6 - // Term = "Num" (*) [EOF] - // Term = "Num" (*) ["*"] - // Term = "Num" (*) ["+"] - // Term = "Num" (*) ["-"] - // Term = "Num" (*) ["/"] + // State 7 + // Expr = Expr "-" (*) Factor [EOF] + // Expr = Expr "-" (*) Factor ["+"] + // Expr = Expr "-" (*) Factor ["-"] + // Factor = (*) Factor "*" Term [EOF] + // Factor = (*) Factor "*" Term ["*"] + // Factor = (*) Factor "*" Term ["+"] + // Factor = (*) Factor "*" Term ["-"] + // Factor = (*) Factor "*" Term ["/"] + // Factor = (*) Factor "/" Term [EOF] + // Factor = (*) Factor "/" Term ["*"] + // Factor = (*) Factor "/" Term ["+"] + // Factor = (*) Factor "/" Term ["-"] + // Factor = (*) Factor "/" Term ["/"] + // Factor = (*) Term [EOF] + // Factor = (*) Term ["*"] + // Factor = (*) Term ["+"] + // Factor = (*) Term ["-"] + // Factor = (*) Term ["/"] + // Factor = (*) "*" "(" Comma ")" [EOF] + // Factor = (*) "*" "(" Comma ")" ["*"] + // Factor = (*) "*" "(" Comma ")" ["+"] + // Factor = (*) "*" "(" Comma ")" ["-"] + // Factor = (*) "*" "(" Comma ")" ["/"] + // Term = (*) "(" Expr ")" [EOF] + // Term = (*) "(" Expr ")" ["*"] + // Term = (*) "(" Expr ")" ["+"] + // Term = (*) "(" Expr ")" ["-"] + // Term = (*) "(" Expr ")" ["/"] + // Term = (*) "Num" [EOF] + // Term = (*) "Num" ["*"] + // Term = (*) "Num" ["+"] + // Term = (*) "Num" ["-"] + // Term = (*) "Num" ["/"] // - // "+" -> Reduce(Term = "Num" => ActionFn(8);) - // "-" -> Reduce(Term = "Num" => ActionFn(8);) - // "/" -> Reduce(Term = "Num" => ActionFn(8);) - // EOF -> Reduce(Term = "Num" => ActionFn(8);) - // "*" -> Reduce(Term = "Num" => ActionFn(8);) + // "*" -> Shift(S6) + // "(" -> Shift(S5) + // "Num" -> Shift(S1) // - pub fn __state6< + // Term -> S3 + // Factor -> S18 + pub fn __state7< 'ast, - __TOKENS: Iterator, + __TOKENS: Iterator, >( arena: &'ast Arena<'ast>, - mut __lookahead: Option, + mut __lookahead: Option<(usize,Tok,usize)>, __tokens: &mut __TOKENS, - __sym0: &mut Option, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> + __sym0: &mut Option<&'ast Node<'ast>>, + __sym1: &mut Option, + ) -> Result<(Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> { - let mut __result: (Option, __Nonterminal<'ast, >); + let mut __result: (Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some(Tok::Plus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action8(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Term(__nt))); + Some((_, __tok @ Tok::Times(..), _)) => { + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state6(arena, __lookahead, __tokens, __sym2)); } - Some(Tok::Minus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action8(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Term(__nt))); + Some((_, __tok @ Tok::LParen(..), _)) => { + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state5(arena, __lookahead, __tokens, __sym2)); } - Some(Tok::Div(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action8(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Term(__nt))); - } - None => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action8(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Term(__nt))); - } - Some(Tok::Times(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action8(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Term(__nt))); + Some((_, Tok::Num(__tok0), _)) => { + let mut __sym2 = &mut Some((__tok0)); + let __lookahead = __tokens.next(); + __result = try!(__state1(arena, __lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); } } + while __sym1.is_some() { + let (__lookahead, __nt) = __result; + match __nt { + __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state3(arena, __lookahead, __tokens, __sym2)); + } + __Nonterminal::Factor(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state18(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + _ => { + return Ok((__lookahead, __nt)); + } + } + } + return Ok(__result); } - // State 7 + // State 8 + // Expr = Expr "+" (*) Factor [EOF] + // Expr = Expr "+" (*) Factor ["+"] + // Expr = Expr "+" (*) Factor ["-"] + // Factor = (*) Factor "*" Term [EOF] + // Factor = (*) Factor "*" Term ["*"] + // Factor = (*) Factor "*" Term ["+"] + // Factor = (*) Factor "*" Term ["-"] + // Factor = (*) Factor "*" Term ["/"] + // Factor = (*) Factor "/" Term [EOF] + // Factor = (*) Factor "/" Term ["*"] + // Factor = (*) Factor "/" Term ["+"] + // Factor = (*) Factor "/" Term ["-"] + // Factor = (*) Factor "/" Term ["/"] + // Factor = (*) Term [EOF] + // Factor = (*) Term ["*"] + // Factor = (*) Term ["+"] + // Factor = (*) Term ["-"] + // Factor = (*) Term ["/"] + // Factor = (*) "*" "(" Comma ")" [EOF] + // Factor = (*) "*" "(" Comma ")" ["*"] + // Factor = (*) "*" "(" Comma ")" ["+"] + // Factor = (*) "*" "(" Comma ")" ["-"] + // Factor = (*) "*" "(" Comma ")" ["/"] + // Term = (*) "(" Expr ")" [EOF] + // Term = (*) "(" Expr ")" ["*"] + // Term = (*) "(" Expr ")" ["+"] + // Term = (*) "(" Expr ")" ["-"] + // Term = (*) "(" Expr ")" ["/"] + // Term = (*) "Num" [EOF] + // Term = (*) "Num" ["*"] + // Term = (*) "Num" ["+"] + // Term = (*) "Num" ["-"] + // Term = (*) "Num" ["/"] + // + // "*" -> Shift(S6) + // "Num" -> Shift(S1) + // "(" -> Shift(S5) + // + // Term -> S3 + // Factor -> S19 + pub fn __state8< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + mut __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + __sym1: &mut Option, + ) -> Result<(Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, __tok @ Tok::Times(..), _)) => { + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state6(arena, __lookahead, __tokens, __sym2)); + } + Some((_, Tok::Num(__tok0), _)) => { + let mut __sym2 = &mut Some((__tok0)); + let __lookahead = __tokens.next(); + __result = try!(__state1(arena, __lookahead, __tokens, __sym2)); + } + Some((_, __tok @ Tok::LParen(..), _)) => { + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state5(arena, __lookahead, __tokens, __sym2)); + } + _ => { + return Err(__lookahead); + } + } + while __sym1.is_some() { + let (__lookahead, __nt) = __result; + match __nt { + __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state3(arena, __lookahead, __tokens, __sym2)); + } + __Nonterminal::Factor(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state19(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + _ => { + return Ok((__lookahead, __nt)); + } + } + } + return Ok(__result); + } + + // State 9 // Factor = Factor "*" (*) Term [EOF] // Factor = Factor "*" (*) Term ["*"] // Factor = Factor "*" (*) Term ["+"] @@ -518,32 +702,32 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "Num" -> Shift(S6) - // "(" -> Shift(S3) + // "(" -> Shift(S5) + // "Num" -> Shift(S1) // - // Term -> S18 - pub fn __state7< + // Term -> S20 + pub fn __state9< 'ast, - __TOKENS: Iterator, + __TOKENS: Iterator, >( arena: &'ast Arena<'ast>, - mut __lookahead: Option, + mut __lookahead: Option<(usize,Tok,usize)>, __tokens: &mut __TOKENS, __sym0: &mut Option<&'ast Node<'ast>>, __sym1: &mut Option, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> + ) -> Result<(Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> { - let mut __result: (Option, __Nonterminal<'ast, >); + let mut __result: (Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some(Tok::Num(__tok0)) => { + Some((_, __tok @ Tok::LParen(..), _)) => { + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state5(arena, __lookahead, __tokens, __sym2)); + } + Some((_, Tok::Num(__tok0), _)) => { let mut __sym2 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state6(arena, __lookahead, __tokens, __sym2)); - } - Some(__tok @ Tok::LParen(..)) => { - let mut __sym2 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state3(arena, __lookahead, __tokens, __sym2)); + __result = try!(__state1(arena, __lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); @@ -554,7 +738,7 @@ mod __parse__Expr { match __nt { __Nonterminal::Term(__nt) => { let __sym2 = &mut Some(__nt); - __result = try!(__state18(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); + __result = try!(__state20(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); } _ => { return Ok((__lookahead, __nt)); @@ -564,7 +748,7 @@ mod __parse__Expr { return Ok(__result); } - // State 8 + // State 10 // Factor = Factor "/" (*) Term [EOF] // Factor = Factor "/" (*) Term ["*"] // Factor = Factor "/" (*) Term ["+"] @@ -581,32 +765,32 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "(" -> Shift(S3) - // "Num" -> Shift(S6) + // "(" -> Shift(S5) + // "Num" -> Shift(S1) // - // Term -> S19 - pub fn __state8< + // Term -> S21 + pub fn __state10< 'ast, - __TOKENS: Iterator, + __TOKENS: Iterator, >( arena: &'ast Arena<'ast>, - mut __lookahead: Option, + mut __lookahead: Option<(usize,Tok,usize)>, __tokens: &mut __TOKENS, __sym0: &mut Option<&'ast Node<'ast>>, __sym1: &mut Option, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> + ) -> Result<(Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> { - let mut __result: (Option, __Nonterminal<'ast, >); + let mut __result: (Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some(__tok @ Tok::LParen(..)) => { - let mut __sym2 = &mut Some(__tok); + Some((_, __tok @ Tok::LParen(..), _)) => { + let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state3(arena, __lookahead, __tokens, __sym2)); + __result = try!(__state5(arena, __lookahead, __tokens, __sym2)); } - Some(Tok::Num(__tok0)) => { + Some((_, Tok::Num(__tok0), _)) => { let mut __sym2 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state6(arena, __lookahead, __tokens, __sym2)); + __result = try!(__state1(arena, __lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); @@ -617,7 +801,7 @@ mod __parse__Expr { match __nt { __Nonterminal::Term(__nt) => { let __sym2 = &mut Some(__nt); - __result = try!(__state19(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); + __result = try!(__state21(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); } _ => { return Ok((__lookahead, __nt)); @@ -627,213 +811,7 @@ mod __parse__Expr { return Ok(__result); } - // State 9 - // Factor = "*" (*) "(" Comma ")" [")"] - // Factor = "*" (*) "(" Comma ")" ["*"] - // Factor = "*" (*) "(" Comma ")" ["+"] - // Factor = "*" (*) "(" Comma ")" ["-"] - // Factor = "*" (*) "(" Comma ")" ["/"] - // - // "(" -> Shift(S20) - // - pub fn __state9< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - mut __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> - { - let mut __result: (Option, __Nonterminal<'ast, >); - match __lookahead { - Some(__tok @ Tok::LParen(..)) => { - let mut __sym1 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state20(arena, __lookahead, __tokens, __sym0, __sym1)); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 10 - // Expr = Factor (*) [")"] - // Expr = Factor (*) ["+"] - // Expr = Factor (*) ["-"] - // Factor = Factor (*) "*" Term [")"] - // Factor = Factor (*) "*" Term ["*"] - // Factor = Factor (*) "*" Term ["+"] - // Factor = Factor (*) "*" Term ["-"] - // Factor = Factor (*) "*" Term ["/"] - // Factor = Factor (*) "/" Term [")"] - // Factor = Factor (*) "/" Term ["*"] - // Factor = Factor (*) "/" Term ["+"] - // Factor = Factor (*) "/" Term ["-"] - // Factor = Factor (*) "/" Term ["/"] - // - // "+" -> Reduce(Expr = Factor => ActionFn(3);) - // "-" -> Reduce(Expr = Factor => ActionFn(3);) - // "*" -> Shift(S22) - // "/" -> Shift(S21) - // ")" -> Reduce(Expr = Factor => ActionFn(3);) - // - pub fn __state10< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - mut __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> - { - let mut __result: (Option, __Nonterminal<'ast, >); - match __lookahead { - Some(__tok @ Tok::Times(..)) => { - let mut __sym1 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state22(arena, __lookahead, __tokens, __sym0, __sym1)); - } - Some(__tok @ Tok::Div(..)) => { - let mut __sym1 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state21(arena, __lookahead, __tokens, __sym0, __sym1)); - } - Some(Tok::Plus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action3(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Expr(__nt))); - } - Some(Tok::Minus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action3(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Expr(__nt))); - } - Some(Tok::RParen(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action3(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Expr(__nt))); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - // State 11 - // Expr = Expr (*) "+" Factor [")"] - // Expr = Expr (*) "+" Factor ["+"] - // Expr = Expr (*) "+" Factor ["-"] - // Expr = Expr (*) "-" Factor [")"] - // Expr = Expr (*) "-" Factor ["+"] - // Expr = Expr (*) "-" Factor ["-"] - // Term = "(" Expr (*) ")" [EOF] - // Term = "(" Expr (*) ")" ["*"] - // Term = "(" Expr (*) ")" ["+"] - // Term = "(" Expr (*) ")" ["-"] - // Term = "(" Expr (*) ")" ["/"] - // - // "-" -> Shift(S23) - // ")" -> Shift(S24) - // "+" -> Shift(S25) - // - pub fn __state11< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - mut __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> - { - let mut __result: (Option, __Nonterminal<'ast, >); - match __lookahead { - Some(__tok @ Tok::Minus(..)) => { - let mut __sym2 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state23(arena, __lookahead, __tokens, __sym1, __sym2)); - } - Some(__tok @ Tok::RParen(..)) => { - let mut __sym2 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state24(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - Some(__tok @ Tok::Plus(..)) => { - let mut __sym2 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state25(arena, __lookahead, __tokens, __sym1, __sym2)); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 12 - // Factor = Term (*) [")"] - // Factor = Term (*) ["*"] - // Factor = Term (*) ["+"] - // Factor = Term (*) ["-"] - // Factor = Term (*) ["/"] - // - // "*" -> Reduce(Factor = Term => ActionFn(7);) - // ")" -> Reduce(Factor = Term => ActionFn(7);) - // "-" -> Reduce(Factor = Term => ActionFn(7);) - // "+" -> Reduce(Factor = Term => ActionFn(7);) - // "/" -> Reduce(Factor = Term => ActionFn(7);) - // - pub fn __state12< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - mut __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> - { - let mut __result: (Option, __Nonterminal<'ast, >); - match __lookahead { - Some(Tok::Times(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::RParen(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Minus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Plus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Div(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 13 // Expr = (*) Expr "+" Factor [")"] // Expr = (*) Expr "+" Factor ["+"] // Expr = (*) Expr "+" Factor ["-"] @@ -879,40 +857,40 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "(" -> Shift(S13) - // "*" -> Shift(S9) - // "Num" -> Shift(S14) + // "*" -> Shift(S14) + // "(" -> Shift(S11) + // "Num" -> Shift(S16) // - // Expr -> S26 - // Term -> S12 - // Factor -> S10 - pub fn __state13< + // Factor -> S13 + // Term -> S15 + // Expr -> S22 + pub fn __state11< 'ast, - __TOKENS: Iterator, + __TOKENS: Iterator, >( arena: &'ast Arena<'ast>, - mut __lookahead: Option, + mut __lookahead: Option<(usize,Tok,usize)>, __tokens: &mut __TOKENS, __sym0: &mut Option, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> + ) -> Result<(Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> { - let mut __result: (Option, __Nonterminal<'ast, >); + let mut __result: (Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some(__tok @ Tok::LParen(..)) => { - let mut __sym1 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state13(arena, __lookahead, __tokens, __sym1)); - } - Some(__tok @ Tok::Times(..)) => { - let mut __sym1 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state9(arena, __lookahead, __tokens, __sym1)); - } - Some(Tok::Num(__tok0)) => { - let mut __sym1 = &mut Some((__tok0)); + Some((_, __tok @ Tok::Times(..), _)) => { + let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); __result = try!(__state14(arena, __lookahead, __tokens, __sym1)); } + Some((_, __tok @ Tok::LParen(..), _)) => { + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state11(arena, __lookahead, __tokens, __sym1)); + } + Some((_, Tok::Num(__tok0), _)) => { + let mut __sym1 = &mut Some((__tok0)); + let __lookahead = __tokens.next(); + __result = try!(__state16(arena, __lookahead, __tokens, __sym1)); + } _ => { return Err(__lookahead); } @@ -920,17 +898,17 @@ mod __parse__Expr { while __sym0.is_some() { let (__lookahead, __nt) = __result; match __nt { - __Nonterminal::Expr(__nt) => { + __Nonterminal::Factor(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state26(arena, __lookahead, __tokens, __sym0, __sym1)); + __result = try!(__state13(arena, __lookahead, __tokens, __sym1)); } __Nonterminal::Term(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state12(arena, __lookahead, __tokens, __sym1)); + __result = try!(__state15(arena, __lookahead, __tokens, __sym1)); } - __Nonterminal::Factor(__nt) => { + __Nonterminal::Expr(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state10(arena, __lookahead, __tokens, __sym1)); + __result = try!(__state22(arena, __lookahead, __tokens, __sym0, __sym1)); } _ => { return Ok((__lookahead, __nt)); @@ -940,244 +918,266 @@ mod __parse__Expr { return Ok(__result); } + // State 12 + // Expr = Expr (*) "+" Factor [")"] + // Expr = Expr (*) "+" Factor ["+"] + // Expr = Expr (*) "+" Factor ["-"] + // Expr = Expr (*) "-" Factor [")"] + // Expr = Expr (*) "-" Factor ["+"] + // Expr = Expr (*) "-" Factor ["-"] + // Term = "(" Expr (*) ")" [EOF] + // Term = "(" Expr (*) ")" ["*"] + // Term = "(" Expr (*) ")" ["+"] + // Term = "(" Expr (*) ")" ["-"] + // Term = "(" Expr (*) ")" ["/"] + // + // "+" -> Shift(S23) + // ")" -> Shift(S24) + // "-" -> Shift(S25) + // + pub fn __state12< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + mut __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + __sym1: &mut Option<&'ast Node<'ast>>, + ) -> Result<(Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, __tok @ Tok::Plus(..), _)) => { + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state23(arena, __lookahead, __tokens, __sym1, __sym2)); + } + Some((_, __tok @ Tok::RParen(..), _)) => { + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state24(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + Some((_, __tok @ Tok::Minus(..), _)) => { + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state25(arena, __lookahead, __tokens, __sym1, __sym2)); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + + // State 13 + // Expr = Factor (*) [")"] + // Expr = Factor (*) ["+"] + // Expr = Factor (*) ["-"] + // Factor = Factor (*) "*" Term [")"] + // Factor = Factor (*) "*" Term ["*"] + // Factor = Factor (*) "*" Term ["+"] + // Factor = Factor (*) "*" Term ["-"] + // Factor = Factor (*) "*" Term ["/"] + // Factor = Factor (*) "/" Term [")"] + // Factor = Factor (*) "/" Term ["*"] + // Factor = Factor (*) "/" Term ["+"] + // Factor = Factor (*) "/" Term ["-"] + // Factor = Factor (*) "/" Term ["/"] + // + // "-" -> Reduce(Expr = Factor => Call(ActionFn(3));) + // "*" -> Shift(S26) + // ")" -> Reduce(Expr = Factor => Call(ActionFn(3));) + // "+" -> Reduce(Expr = Factor => Call(ActionFn(3));) + // "/" -> Shift(S27) + // + pub fn __state13< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + mut __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + ) -> Result<(Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, __tok @ Tok::Times(..), _)) => { + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state26(arena, __lookahead, __tokens, __sym0, __sym1)); + } + Some((_, __tok @ Tok::Div(..), _)) => { + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state27(arena, __lookahead, __tokens, __sym0, __sym1)); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action3(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Expr(__nt))); + } + Some((_, Tok::RParen(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action3(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Expr(__nt))); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action3(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Expr(__nt))); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + // State 14 + // Factor = "*" (*) "(" Comma ")" [")"] + // Factor = "*" (*) "(" Comma ")" ["*"] + // Factor = "*" (*) "(" Comma ")" ["+"] + // Factor = "*" (*) "(" Comma ")" ["-"] + // Factor = "*" (*) "(" Comma ")" ["/"] + // + // "(" -> Shift(S28) + // + pub fn __state14< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + mut __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + ) -> Result<(Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, __tok @ Tok::LParen(..), _)) => { + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state28(arena, __lookahead, __tokens, __sym0, __sym1)); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + + // State 15 + // 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 __state15< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + mut __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + ) -> Result<(Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (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((__lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Times(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action7(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::RParen(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action7(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action7(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action7(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 16 // Term = "Num" (*) [")"] // Term = "Num" (*) ["*"] // Term = "Num" (*) ["+"] // Term = "Num" (*) ["-"] // Term = "Num" (*) ["/"] // - // "+" -> Reduce(Term = "Num" => ActionFn(8);) - // "*" -> Reduce(Term = "Num" => ActionFn(8);) - // "-" -> Reduce(Term = "Num" => ActionFn(8);) - // "/" -> Reduce(Term = "Num" => ActionFn(8);) - // ")" -> Reduce(Term = "Num" => ActionFn(8);) + // "/" -> Reduce(Term = "Num" => 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 __state14< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - mut __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> - { - let mut __result: (Option, __Nonterminal<'ast, >); - match __lookahead { - Some(Tok::Plus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action8(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Term(__nt))); - } - Some(Tok::Times(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action8(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Term(__nt))); - } - Some(Tok::Minus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action8(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Term(__nt))); - } - Some(Tok::Div(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action8(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Term(__nt))); - } - Some(Tok::RParen(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action8(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Term(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 15 - // Expr = Expr "+" (*) Factor [EOF] - // Expr = Expr "+" (*) Factor ["+"] - // Expr = Expr "+" (*) Factor ["-"] - // Factor = (*) Factor "*" Term [EOF] - // Factor = (*) Factor "*" Term ["*"] - // Factor = (*) Factor "*" Term ["+"] - // Factor = (*) Factor "*" Term ["-"] - // Factor = (*) Factor "*" Term ["/"] - // Factor = (*) Factor "/" Term [EOF] - // Factor = (*) Factor "/" Term ["*"] - // Factor = (*) Factor "/" Term ["+"] - // Factor = (*) Factor "/" Term ["-"] - // Factor = (*) Factor "/" Term ["/"] - // Factor = (*) Term [EOF] - // Factor = (*) Term ["*"] - // Factor = (*) Term ["+"] - // Factor = (*) Term ["-"] - // Factor = (*) Term ["/"] - // Factor = (*) "*" "(" Comma ")" [EOF] - // Factor = (*) "*" "(" Comma ")" ["*"] - // Factor = (*) "*" "(" Comma ")" ["+"] - // Factor = (*) "*" "(" Comma ")" ["-"] - // Factor = (*) "*" "(" Comma ")" ["/"] - // Term = (*) "(" Expr ")" [EOF] - // Term = (*) "(" Expr ")" ["*"] - // Term = (*) "(" Expr ")" ["+"] - // Term = (*) "(" Expr ")" ["-"] - // Term = (*) "(" Expr ")" ["/"] - // Term = (*) "Num" [EOF] - // Term = (*) "Num" ["*"] - // Term = (*) "Num" ["+"] - // Term = (*) "Num" ["-"] - // Term = (*) "Num" ["/"] - // - // "Num" -> Shift(S6) - // "*" -> Shift(S5) - // "(" -> Shift(S3) - // - // Factor -> S27 - // Term -> S2 - pub fn __state15< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - mut __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> - { - let mut __result: (Option, __Nonterminal<'ast, >); - match __lookahead { - Some(Tok::Num(__tok0)) => { - let mut __sym2 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state6(arena, __lookahead, __tokens, __sym2)); - } - Some(__tok @ Tok::Times(..)) => { - let mut __sym2 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state5(arena, __lookahead, __tokens, __sym2)); - } - Some(__tok @ Tok::LParen(..)) => { - let mut __sym2 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state3(arena, __lookahead, __tokens, __sym2)); - } - _ => { - return Err(__lookahead); - } - } - while __sym1.is_some() { - let (__lookahead, __nt) = __result; - match __nt { - __Nonterminal::Factor(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state27(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - __Nonterminal::Term(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state2(arena, __lookahead, __tokens, __sym2)); - } - _ => { - return Ok((__lookahead, __nt)); - } - } - } - return Ok(__result); - } - - // State 16 - // Expr = Expr "-" (*) Factor [EOF] - // Expr = Expr "-" (*) Factor ["+"] - // Expr = Expr "-" (*) Factor ["-"] - // Factor = (*) Factor "*" Term [EOF] - // Factor = (*) Factor "*" Term ["*"] - // Factor = (*) Factor "*" Term ["+"] - // Factor = (*) Factor "*" Term ["-"] - // Factor = (*) Factor "*" Term ["/"] - // Factor = (*) Factor "/" Term [EOF] - // Factor = (*) Factor "/" Term ["*"] - // Factor = (*) Factor "/" Term ["+"] - // Factor = (*) Factor "/" Term ["-"] - // Factor = (*) Factor "/" Term ["/"] - // Factor = (*) Term [EOF] - // Factor = (*) Term ["*"] - // Factor = (*) Term ["+"] - // Factor = (*) Term ["-"] - // Factor = (*) Term ["/"] - // Factor = (*) "*" "(" Comma ")" [EOF] - // Factor = (*) "*" "(" Comma ")" ["*"] - // Factor = (*) "*" "(" Comma ")" ["+"] - // Factor = (*) "*" "(" Comma ")" ["-"] - // Factor = (*) "*" "(" Comma ")" ["/"] - // Term = (*) "(" Expr ")" [EOF] - // Term = (*) "(" Expr ")" ["*"] - // Term = (*) "(" Expr ")" ["+"] - // Term = (*) "(" Expr ")" ["-"] - // Term = (*) "(" Expr ")" ["/"] - // Term = (*) "Num" [EOF] - // Term = (*) "Num" ["*"] - // Term = (*) "Num" ["+"] - // Term = (*) "Num" ["-"] - // Term = (*) "Num" ["/"] - // - // "(" -> Shift(S3) - // "*" -> Shift(S5) - // "Num" -> Shift(S6) - // - // Term -> S2 - // Factor -> S28 pub fn __state16< 'ast, - __TOKENS: Iterator, + __TOKENS: Iterator, >( arena: &'ast Arena<'ast>, - mut __lookahead: Option, + mut __lookahead: Option<(usize,Tok,usize)>, __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> + __sym0: &mut Option, + ) -> Result<(Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> { - let mut __result: (Option, __Nonterminal<'ast, >); + let mut __result: (Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some(__tok @ Tok::LParen(..)) => { - let mut __sym2 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state3(arena, __lookahead, __tokens, __sym2)); + Some((_, Tok::Div(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action8(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Term(__nt))); } - Some(__tok @ Tok::Times(..)) => { - let mut __sym2 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state5(arena, __lookahead, __tokens, __sym2)); + Some((_, Tok::RParen(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action8(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Term(__nt))); } - Some(Tok::Num(__tok0)) => { - let mut __sym2 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state6(arena, __lookahead, __tokens, __sym2)); + Some((_, Tok::Times(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action8(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Term(__nt))); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action8(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Term(__nt))); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action8(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Term(__nt))); } _ => { return Err(__lookahead); } } - while __sym1.is_some() { - let (__lookahead, __nt) = __result; - match __nt { - __Nonterminal::Term(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state2(arena, __lookahead, __tokens, __sym2)); - } - __Nonterminal::Factor(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state28(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - _ => { - return Ok((__lookahead, __nt)); - } - } - } - return Ok(__result); } // State 17 @@ -1196,39 +1196,39 @@ mod __parse__Expr { // Factor = "*" "(" (*) Comma ")" ["-"] // Factor = "*" "(" (*) Comma ")" ["/"] // - // "(" -> Reduce(( ",")* = => ActionFn(13);) - // "*" -> Reduce(( ",")* = => ActionFn(13);) - // ")" -> Reduce(( ",")* = => ActionFn(13);) - // "Num" -> Reduce(( ",")* = => ActionFn(13);) + // ")" -> Reduce(( ",")* = => Call(ActionFn(13));) + // "*" -> Reduce(( ",")* = => Call(ActionFn(13));) + // "(" -> Reduce(( ",")* = => Call(ActionFn(13));) + // "Num" -> Reduce(( ",")* = => Call(ActionFn(13));) // - // ( ",")* -> S29 - // Comma -> S30 + // ( ",")* -> S30 + // Comma -> S29 pub fn __state17< 'ast, - __TOKENS: Iterator, + __TOKENS: Iterator, >( arena: &'ast Arena<'ast>, - mut __lookahead: Option, + mut __lookahead: Option<(usize,Tok,usize)>, __tokens: &mut __TOKENS, __sym0: &mut Option, __sym1: &mut Option, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> + ) -> Result<(Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> { - let mut __result: (Option, __Nonterminal<'ast, >); + let mut __result: (Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some(Tok::LParen(..)) => { + Some((_, Tok::RParen(..), _)) => { let __nt = super::__actions::__action13(arena, ); __result = (__lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); } - Some(Tok::Times(..)) => { + Some((_, Tok::Times(..), _)) => { let __nt = super::__actions::__action13(arena, ); __result = (__lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); } - Some(Tok::RParen(..)) => { + Some((_, Tok::LParen(..), _)) => { let __nt = super::__actions::__action13(arena, ); __result = (__lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); } - Some(Tok::Num(_)) => { + Some((_, Tok::Num(_), _)) => { let __nt = super::__actions::__action13(arena, ); __result = (__lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); } @@ -1241,11 +1241,11 @@ mod __parse__Expr { match __nt { __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt) => { let __sym2 = &mut Some(__nt); - __result = try!(__state29(arena, __lookahead, __tokens, __sym2)); + __result = try!(__state30(arena, __lookahead, __tokens, __sym2)); } __Nonterminal::Comma_3cExpr_3e(__nt) => { let __sym2 = &mut Some(__nt); - __result = try!(__state30(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); + __result = try!(__state29(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); } _ => { return Ok((__lookahead, __nt)); @@ -1256,40 +1256,200 @@ mod __parse__Expr { } // State 18 + // Expr = Expr "-" Factor (*) [EOF] + // Expr = Expr "-" Factor (*) ["+"] + // Expr = Expr "-" Factor (*) ["-"] + // Factor = Factor (*) "*" Term [EOF] + // Factor = Factor (*) "*" Term ["*"] + // Factor = Factor (*) "*" Term ["+"] + // Factor = Factor (*) "*" Term ["-"] + // Factor = Factor (*) "*" Term ["/"] + // Factor = Factor (*) "/" Term [EOF] + // Factor = Factor (*) "/" Term ["*"] + // Factor = Factor (*) "/" Term ["+"] + // Factor = Factor (*) "/" Term ["-"] + // Factor = Factor (*) "/" Term ["/"] + // + // EOF -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // "*" -> Shift(S9) + // "-" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // "/" -> Shift(S10) + // "+" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // + pub fn __state18< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + mut __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<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, __tok @ Tok::Times(..), _)) => { + let mut __sym3 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state9(arena, __lookahead, __tokens, __sym2, __sym3)); + } + Some((_, __tok @ Tok::Div(..), _)) => { + let mut __sym3 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state10(arena, __lookahead, __tokens, __sym2, __sym3)); + } + None => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action1(arena, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Expr(__nt))); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action1(arena, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Expr(__nt))); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action1(arena, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Expr(__nt))); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + + // State 19 + // Expr = Expr "+" Factor (*) [EOF] + // Expr = Expr "+" Factor (*) ["+"] + // Expr = Expr "+" Factor (*) ["-"] + // Factor = Factor (*) "*" Term [EOF] + // Factor = Factor (*) "*" Term ["*"] + // Factor = Factor (*) "*" Term ["+"] + // Factor = Factor (*) "*" Term ["-"] + // Factor = Factor (*) "*" Term ["/"] + // Factor = Factor (*) "/" Term [EOF] + // Factor = Factor (*) "/" Term ["*"] + // Factor = Factor (*) "/" Term ["+"] + // Factor = Factor (*) "/" Term ["-"] + // Factor = Factor (*) "/" Term ["/"] + // + // "-" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) + // "*" -> Shift(S9) + // EOF -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) + // "+" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) + // "/" -> Shift(S10) + // + pub fn __state19< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + mut __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<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, __tok @ Tok::Times(..), _)) => { + let mut __sym3 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state9(arena, __lookahead, __tokens, __sym2, __sym3)); + } + Some((_, __tok @ Tok::Div(..), _)) => { + let mut __sym3 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state10(arena, __lookahead, __tokens, __sym2, __sym3)); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action2(arena, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Expr(__nt))); + } + None => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action2(arena, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Expr(__nt))); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action2(arena, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Expr(__nt))); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + + // State 20 // Factor = Factor "*" Term (*) [EOF] // Factor = Factor "*" Term (*) ["*"] // Factor = Factor "*" Term (*) ["+"] // Factor = Factor "*" Term (*) ["-"] // Factor = Factor "*" Term (*) ["/"] // - // "-" -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) - // "*" -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) - // EOF -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) - // "/" -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) - // "+" -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) + // "-" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // "/" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // "*" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // "+" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // EOF -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) // - pub fn __state18< + pub fn __state20< 'ast, - __TOKENS: Iterator, + __TOKENS: Iterator, >( arena: &'ast Arena<'ast>, - mut __lookahead: Option, + mut __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, __Nonterminal<'ast, >), Option> + ) -> Result<(Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> { - let mut __result: (Option, __Nonterminal<'ast, >); + let mut __result: (Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some(Tok::Minus(..)) => { + Some((_, Tok::Minus(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); let __nt = super::__actions::__action4(arena, __sym0, __sym1, __sym2); return Ok((__lookahead, __Nonterminal::Factor(__nt))); } - Some(Tok::Times(..)) => { + Some((_, Tok::Div(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action4(arena, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Times(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action4(arena, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Plus(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); @@ -1303,61 +1463,47 @@ mod __parse__Expr { let __nt = super::__actions::__action4(arena, __sym0, __sym1, __sym2); return Ok((__lookahead, __Nonterminal::Factor(__nt))); } - Some(Tok::Div(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Plus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } _ => { return Err(__lookahead); } } } - // State 19 + // State 21 // Factor = Factor "/" Term (*) [EOF] // Factor = Factor "/" Term (*) ["*"] // Factor = Factor "/" Term (*) ["+"] // Factor = Factor "/" Term (*) ["-"] // Factor = Factor "/" Term (*) ["/"] // - // "/" -> Reduce(Factor = Factor, "/", Term => ActionFn(5);) - // "-" -> Reduce(Factor = Factor, "/", Term => ActionFn(5);) - // EOF -> Reduce(Factor = Factor, "/", Term => ActionFn(5);) - // "*" -> Reduce(Factor = Factor, "/", Term => ActionFn(5);) - // "+" -> Reduce(Factor = Factor, "/", Term => ActionFn(5);) + // "+" -> Reduce(Factor = Factor, "/", Term => 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 __state19< + pub fn __state21< 'ast, - __TOKENS: Iterator, + __TOKENS: Iterator, >( arena: &'ast Arena<'ast>, - mut __lookahead: Option, + mut __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, __Nonterminal<'ast, >), Option> + ) -> Result<(Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> { - let mut __result: (Option, __Nonterminal<'ast, >); + let mut __result: (Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some(Tok::Div(..)) => { + Some((_, Tok::Plus(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); let __nt = super::__actions::__action5(arena, __sym0, __sym1, __sym2); return Ok((__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(); @@ -1371,14 +1517,14 @@ mod __parse__Expr { let __nt = super::__actions::__action5(arena, __sym0, __sym1, __sym2); return Ok((__lookahead, __Nonterminal::Factor(__nt))); } - Some(Tok::Times(..)) => { + Some((_, Tok::Times(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); let __nt = super::__actions::__action5(arena, __sym0, __sym1, __sym2); return Ok((__lookahead, __Nonterminal::Factor(__nt))); } - Some(Tok::Plus(..)) => { + Some((_, Tok::Minus(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); @@ -1391,368 +1537,59 @@ mod __parse__Expr { } } - // State 20 - // ( ",")* = (*) ["("] - // ( ",")* = (*) [")"] - // ( ",")* = (*) ["*"] - // ( ",")* = (*) ["Num"] - // ( ",")* = (*) ( ",")* ( ",") ["("] - // ( ",")* = (*) ( ",")* ( ",") [")"] - // ( ",")* = (*) ( ",")* ( ",") ["*"] - // ( ",")* = (*) ( ",")* ( ",") ["Num"] - // Comma = (*) ( ",")* Expr? [")"] - // Factor = "*" "(" (*) Comma ")" [")"] - // Factor = "*" "(" (*) Comma ")" ["*"] - // Factor = "*" "(" (*) Comma ")" ["+"] - // Factor = "*" "(" (*) Comma ")" ["-"] - // Factor = "*" "(" (*) Comma ")" ["/"] - // - // "Num" -> Reduce(( ",")* = => ActionFn(13);) - // ")" -> Reduce(( ",")* = => ActionFn(13);) - // "(" -> Reduce(( ",")* = => ActionFn(13);) - // "*" -> Reduce(( ",")* = => ActionFn(13);) - // - // ( ",")* -> S29 - // Comma -> S31 - pub fn __state20< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - mut __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> - { - let mut __result: (Option, __Nonterminal<'ast, >); - match __lookahead { - Some(Tok::Num(_)) => { - let __nt = super::__actions::__action13(arena, ); - __result = (__lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); - } - Some(Tok::RParen(..)) => { - let __nt = super::__actions::__action13(arena, ); - __result = (__lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); - } - Some(Tok::LParen(..)) => { - let __nt = super::__actions::__action13(arena, ); - __result = (__lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); - } - Some(Tok::Times(..)) => { - let __nt = super::__actions::__action13(arena, ); - __result = (__lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); - } - _ => { - return Err(__lookahead); - } - } - while __sym1.is_some() { - let (__lookahead, __nt) = __result; - match __nt { - __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state29(arena, __lookahead, __tokens, __sym2)); - } - __Nonterminal::Comma_3cExpr_3e(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state31(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - _ => { - return Ok((__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" ["/"] - // - // "Num" -> Shift(S14) - // "(" -> Shift(S13) - // - // Term -> S32 - pub fn __state21< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - mut __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> - { - let mut __result: (Option, __Nonterminal<'ast, >); - match __lookahead { - Some(Tok::Num(__tok0)) => { - let mut __sym2 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state14(arena, __lookahead, __tokens, __sym2)); - } - Some(__tok @ Tok::LParen(..)) => { - let mut __sym2 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state13(arena, __lookahead, __tokens, __sym2)); - } - _ => { - return Err(__lookahead); - } - } - while __sym1.is_some() { - let (__lookahead, __nt) = __result; - match __nt { - __Nonterminal::Term(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state32(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - _ => { - return Ok((__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" ["/"] + // Expr = Expr (*) "+" Factor [")"] + // Expr = Expr (*) "+" Factor ["+"] + // Expr = Expr (*) "+" Factor ["-"] + // Expr = Expr (*) "-" Factor [")"] + // Expr = Expr (*) "-" Factor ["+"] + // Expr = Expr (*) "-" Factor ["-"] + // Term = "(" Expr (*) ")" [")"] + // Term = "(" Expr (*) ")" ["*"] + // Term = "(" Expr (*) ")" ["+"] + // Term = "(" Expr (*) ")" ["-"] + // Term = "(" Expr (*) ")" ["/"] // - // "Num" -> Shift(S14) - // "(" -> Shift(S13) + // "-" -> Shift(S25) + // "+" -> Shift(S23) + // ")" -> Shift(S31) // - // Term -> S33 pub fn __state22< 'ast, - __TOKENS: Iterator, + __TOKENS: Iterator, >( arena: &'ast Arena<'ast>, - mut __lookahead: Option, + mut __lookahead: Option<(usize,Tok,usize)>, __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> + __sym0: &mut Option, + __sym1: &mut Option<&'ast Node<'ast>>, + ) -> Result<(Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> { - let mut __result: (Option, __Nonterminal<'ast, >); + let mut __result: (Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some(Tok::Num(__tok0)) => { - let mut __sym2 = &mut Some((__tok0)); + Some((_, __tok @ Tok::Minus(..), _)) => { + let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state14(arena, __lookahead, __tokens, __sym2)); + __result = try!(__state25(arena, __lookahead, __tokens, __sym1, __sym2)); } - Some(__tok @ Tok::LParen(..)) => { - let mut __sym2 = &mut Some(__tok); + Some((_, __tok @ Tok::Plus(..), _)) => { + let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state13(arena, __lookahead, __tokens, __sym2)); + __result = try!(__state23(arena, __lookahead, __tokens, __sym1, __sym2)); + } + Some((_, __tok @ Tok::RParen(..), _)) => { + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state31(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); } _ => { return Err(__lookahead); } } - while __sym1.is_some() { - let (__lookahead, __nt) = __result; - match __nt { - __Nonterminal::Term(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state33(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - _ => { - return Ok((__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" ["/"] - // - // "(" -> Shift(S13) - // "*" -> Shift(S9) - // "Num" -> Shift(S14) - // - // Factor -> S34 - // Term -> S12 - pub fn __state23< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - mut __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> - { - let mut __result: (Option, __Nonterminal<'ast, >); - match __lookahead { - Some(__tok @ Tok::LParen(..)) => { - let mut __sym2 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state13(arena, __lookahead, __tokens, __sym2)); - } - Some(__tok @ Tok::Times(..)) => { - let mut __sym2 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state9(arena, __lookahead, __tokens, __sym2)); - } - Some(Tok::Num(__tok0)) => { - let mut __sym2 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state14(arena, __lookahead, __tokens, __sym2)); - } - _ => { - return Err(__lookahead); - } - } - while __sym1.is_some() { - let (__lookahead, __nt) = __result; - match __nt { - __Nonterminal::Factor(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state34(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - __Nonterminal::Term(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state12(arena, __lookahead, __tokens, __sym2)); - } - _ => { - return Ok((__lookahead, __nt)); - } - } - } - return Ok(__result); - } - - // State 24 - // Term = "(" Expr ")" (*) [EOF] - // Term = "(" Expr ")" (*) ["*"] - // Term = "(" Expr ")" (*) ["+"] - // Term = "(" Expr ")" (*) ["-"] - // Term = "(" Expr ")" (*) ["/"] - // - // "*" -> Reduce(Term = "(", Expr, ")" => ActionFn(9);) - // EOF -> Reduce(Term = "(", Expr, ")" => ActionFn(9);) - // "-" -> Reduce(Term = "(", Expr, ")" => ActionFn(9);) - // "/" -> Reduce(Term = "(", Expr, ")" => ActionFn(9);) - // "+" -> Reduce(Term = "(", Expr, ")" => ActionFn(9);) - // - pub fn __state24< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - mut __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option<&'ast Node<'ast>>, - __sym2: &mut Option, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> - { - let mut __result: (Option, __Nonterminal<'ast, >); - match __lookahead { - Some(Tok::Times(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action9(arena, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Term(__nt))); - } - None => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action9(arena, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Term(__nt))); - } - Some(Tok::Minus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action9(arena, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Term(__nt))); - } - Some(Tok::Div(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action9(arena, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Term(__nt))); - } - Some(Tok::Plus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action9(arena, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Term(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 25 // Expr = Expr "+" (*) Factor [")"] // Expr = Expr "+" (*) Factor ["+"] // Expr = Expr "+" (*) Factor ["-"] @@ -1787,39 +1624,39 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "*" -> Shift(S9) - // "Num" -> Shift(S14) - // "(" -> Shift(S13) + // "*" -> Shift(S14) + // "Num" -> Shift(S16) + // "(" -> Shift(S11) // - // Factor -> S35 - // Term -> S12 - pub fn __state25< + // Factor -> S32 + // Term -> S15 + pub fn __state23< 'ast, - __TOKENS: Iterator, + __TOKENS: Iterator, >( arena: &'ast Arena<'ast>, - mut __lookahead: Option, + mut __lookahead: Option<(usize,Tok,usize)>, __tokens: &mut __TOKENS, __sym0: &mut Option<&'ast Node<'ast>>, __sym1: &mut Option, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> + ) -> Result<(Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> { - let mut __result: (Option, __Nonterminal<'ast, >); + let mut __result: (Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some(__tok @ Tok::Times(..)) => { - let mut __sym2 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state9(arena, __lookahead, __tokens, __sym2)); - } - Some(Tok::Num(__tok0)) => { - let mut __sym2 = &mut Some((__tok0)); + Some((_, __tok @ Tok::Times(..), _)) => { + let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); __result = try!(__state14(arena, __lookahead, __tokens, __sym2)); } - Some(__tok @ Tok::LParen(..)) => { - let mut __sym2 = &mut Some(__tok); + Some((_, Tok::Num(__tok0), _)) => { + let mut __sym2 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state13(arena, __lookahead, __tokens, __sym2)); + __result = try!(__state16(arena, __lookahead, __tokens, __sym2)); + } + Some((_, __tok @ Tok::LParen(..), _)) => { + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state11(arena, __lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); @@ -1830,11 +1667,171 @@ mod __parse__Expr { match __nt { __Nonterminal::Factor(__nt) => { let __sym2 = &mut Some(__nt); - __result = try!(__state35(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); + __result = try!(__state32(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); } __Nonterminal::Term(__nt) => { let __sym2 = &mut Some(__nt); - __result = try!(__state12(arena, __lookahead, __tokens, __sym2)); + __result = try!(__state15(arena, __lookahead, __tokens, __sym2)); + } + _ => { + return Ok((__lookahead, __nt)); + } + } + } + return Ok(__result); + } + + // State 24 + // Term = "(" Expr ")" (*) [EOF] + // Term = "(" Expr ")" (*) ["*"] + // Term = "(" Expr ")" (*) ["+"] + // Term = "(" Expr ")" (*) ["-"] + // Term = "(" Expr ")" (*) ["/"] + // + // "+" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) + // "-" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) + // "/" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) + // "*" -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) + // EOF -> Reduce(Term = "(", Expr, ")" => Call(ActionFn(9));) + // + pub fn __state24< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + mut __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + __sym1: &mut Option<&'ast Node<'ast>>, + __sym2: &mut Option, + ) -> Result<(Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (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::__action9(arena, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Term(__nt))); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action9(arena, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Term(__nt))); + } + Some((_, Tok::Div(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action9(arena, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Term(__nt))); + } + Some((_, Tok::Times(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action9(arena, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Term(__nt))); + } + None => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action9(arena, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Term(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 25 + // Expr = Expr "-" (*) Factor [")"] + // Expr = Expr "-" (*) Factor ["+"] + // Expr = Expr "-" (*) Factor ["-"] + // Factor = (*) Factor "*" Term [")"] + // Factor = (*) Factor "*" Term ["*"] + // Factor = (*) Factor "*" Term ["+"] + // Factor = (*) Factor "*" Term ["-"] + // Factor = (*) Factor "*" Term ["/"] + // Factor = (*) Factor "/" Term [")"] + // Factor = (*) Factor "/" Term ["*"] + // Factor = (*) Factor "/" Term ["+"] + // Factor = (*) Factor "/" Term ["-"] + // Factor = (*) Factor "/" Term ["/"] + // Factor = (*) 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) + // "*" -> Shift(S14) + // "Num" -> Shift(S16) + // + // Term -> S15 + // Factor -> S33 + pub fn __state25< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + mut __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + __sym1: &mut Option, + ) -> Result<(Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, __tok @ Tok::LParen(..), _)) => { + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state11(arena, __lookahead, __tokens, __sym2)); + } + Some((_, __tok @ Tok::Times(..), _)) => { + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state14(arena, __lookahead, __tokens, __sym2)); + } + Some((_, Tok::Num(__tok0), _)) => { + let mut __sym2 = &mut Some((__tok0)); + let __lookahead = __tokens.next(); + __result = try!(__state16(arena, __lookahead, __tokens, __sym2)); + } + _ => { + return Err(__lookahead); + } + } + while __sym1.is_some() { + let (__lookahead, __nt) = __result; + match __nt { + __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state15(arena, __lookahead, __tokens, __sym2)); + } + __Nonterminal::Factor(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state33(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); } _ => { return Ok((__lookahead, __nt)); @@ -1845,195 +1842,233 @@ mod __parse__Expr { } // State 26 - // Expr = Expr (*) "+" Factor [")"] - // Expr = Expr (*) "+" Factor ["+"] - // Expr = Expr (*) "+" Factor ["-"] - // Expr = Expr (*) "-" Factor [")"] - // Expr = Expr (*) "-" Factor ["+"] - // Expr = Expr (*) "-" Factor ["-"] - // Term = "(" Expr (*) ")" [")"] - // Term = "(" Expr (*) ")" ["*"] - // Term = "(" Expr (*) ")" ["+"] - // Term = "(" Expr (*) ")" ["-"] - // Term = "(" Expr (*) ")" ["/"] + // 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(S23) - // "+" -> Shift(S25) - // ")" -> Shift(S36) + // "(" -> Shift(S11) + // "Num" -> Shift(S16) // + // Term -> S34 pub fn __state26< 'ast, - __TOKENS: Iterator, + __TOKENS: Iterator, >( arena: &'ast Arena<'ast>, - mut __lookahead: Option, + mut __lookahead: Option<(usize,Tok,usize)>, __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> + __sym0: &mut Option<&'ast Node<'ast>>, + __sym1: &mut Option, + ) -> Result<(Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> { - let mut __result: (Option, __Nonterminal<'ast, >); + let mut __result: (Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some(__tok @ Tok::Minus(..)) => { - let mut __sym2 = &mut Some(__tok); + Some((_, __tok @ Tok::LParen(..), _)) => { + let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state23(arena, __lookahead, __tokens, __sym1, __sym2)); + __result = try!(__state11(arena, __lookahead, __tokens, __sym2)); } - Some(__tok @ Tok::Plus(..)) => { - let mut __sym2 = &mut Some(__tok); + Some((_, Tok::Num(__tok0), _)) => { + let mut __sym2 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state25(arena, __lookahead, __tokens, __sym1, __sym2)); - } - Some(__tok @ Tok::RParen(..)) => { - let mut __sym2 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state36(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); + __result = try!(__state16(arena, __lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); } } + while __sym1.is_some() { + let (__lookahead, __nt) = __result; + match __nt { + __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state34(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + _ => { + return Ok((__lookahead, __nt)); + } + } + } 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 ["/"] + // Factor = Factor "/" (*) Term [")"] + // Factor = Factor "/" (*) Term ["*"] + // Factor = Factor "/" (*) Term ["+"] + // Factor = Factor "/" (*) Term ["-"] + // Factor = Factor "/" (*) Term ["/"] + // Term = (*) "(" Expr ")" [")"] + // Term = (*) "(" Expr ")" ["*"] + // Term = (*) "(" Expr ")" ["+"] + // Term = (*) "(" Expr ")" ["-"] + // Term = (*) "(" Expr ")" ["/"] + // Term = (*) "Num" [")"] + // Term = (*) "Num" ["*"] + // Term = (*) "Num" ["+"] + // Term = (*) "Num" ["-"] + // Term = (*) "Num" ["/"] // - // "+" -> Reduce(Expr = Expr, "+", Factor => ActionFn(2);) - // "*" -> Shift(S7) - // "-" -> Reduce(Expr = Expr, "+", Factor => ActionFn(2);) - // EOF -> Reduce(Expr = Expr, "+", Factor => ActionFn(2);) - // "/" -> Shift(S8) + // "(" -> Shift(S11) + // "Num" -> Shift(S16) // + // Term -> S35 pub fn __state27< 'ast, - __TOKENS: Iterator, + __TOKENS: Iterator, >( arena: &'ast Arena<'ast>, - mut __lookahead: Option, + mut __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, __Nonterminal<'ast, >), Option> + ) -> Result<(Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> { - let mut __result: (Option, __Nonterminal<'ast, >); + let mut __result: (Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some(__tok @ Tok::Times(..)) => { - let mut __sym3 = &mut Some(__tok); + Some((_, __tok @ Tok::LParen(..), _)) => { + let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state7(arena, __lookahead, __tokens, __sym2, __sym3)); + __result = try!(__state11(arena, __lookahead, __tokens, __sym2)); } - Some(__tok @ Tok::Div(..)) => { - let mut __sym3 = &mut Some(__tok); + Some((_, Tok::Num(__tok0), _)) => { + let mut __sym2 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state8(arena, __lookahead, __tokens, __sym2, __sym3)); - } - Some(Tok::Plus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action2(arena, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Expr(__nt))); - } - Some(Tok::Minus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action2(arena, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Expr(__nt))); - } - None => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action2(arena, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Expr(__nt))); + __result = try!(__state16(arena, __lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); } } + while __sym1.is_some() { + let (__lookahead, __nt) = __result; + match __nt { + __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state35(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + _ => { + return Ok((__lookahead, __nt)); + } + } + } 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 ["/"] + // ( ",")* = (*) ["("] + // ( ",")* = (*) [")"] + // ( ",")* = (*) ["*"] + // ( ",")* = (*) ["Num"] + // ( ",")* = (*) ( ",")* ( ",") ["("] + // ( ",")* = (*) ( ",")* ( ",") [")"] + // ( ",")* = (*) ( ",")* ( ",") ["*"] + // ( ",")* = (*) ( ",")* ( ",") ["Num"] + // Comma = (*) ( ",")* Expr? [")"] + // Factor = "*" "(" (*) Comma ")" [")"] + // Factor = "*" "(" (*) Comma ")" ["*"] + // Factor = "*" "(" (*) Comma ")" ["+"] + // Factor = "*" "(" (*) Comma ")" ["-"] + // Factor = "*" "(" (*) Comma ")" ["/"] // - // "-" -> Reduce(Expr = Expr, "-", Factor => ActionFn(1);) - // "+" -> Reduce(Expr = Expr, "-", Factor => ActionFn(1);) - // EOF -> Reduce(Expr = Expr, "-", Factor => ActionFn(1);) - // "*" -> Shift(S7) - // "/" -> Shift(S8) + // "*" -> Reduce(( ",")* = => Call(ActionFn(13));) + // "(" -> Reduce(( ",")* = => Call(ActionFn(13));) + // ")" -> Reduce(( ",")* = => Call(ActionFn(13));) + // "Num" -> Reduce(( ",")* = => Call(ActionFn(13));) // + // ( ",")* -> S30 + // Comma -> S36 pub fn __state28< 'ast, - __TOKENS: Iterator, + __TOKENS: Iterator, >( arena: &'ast Arena<'ast>, - mut __lookahead: Option, + mut __lookahead: Option<(usize,Tok,usize)>, __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, + __sym0: &mut Option, __sym1: &mut Option, - __sym2: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> + ) -> Result<(Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> { - let mut __result: (Option, __Nonterminal<'ast, >); + let mut __result: (Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some(__tok @ Tok::Times(..)) => { - let mut __sym3 = &mut Some(__tok); + Some((_, Tok::Times(..), _)) => { + let __nt = super::__actions::__action13(arena, ); + __result = (__lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); + } + Some((_, Tok::LParen(..), _)) => { + let __nt = super::__actions::__action13(arena, ); + __result = (__lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); + } + Some((_, Tok::RParen(..), _)) => { + let __nt = super::__actions::__action13(arena, ); + __result = (__lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); + } + Some((_, Tok::Num(_), _)) => { + let __nt = super::__actions::__action13(arena, ); + __result = (__lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); + } + _ => { + return Err(__lookahead); + } + } + while __sym1.is_some() { + let (__lookahead, __nt) = __result; + match __nt { + __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state30(arena, __lookahead, __tokens, __sym2)); + } + __Nonterminal::Comma_3cExpr_3e(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state36(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + _ => { + return Ok((__lookahead, __nt)); + } + } + } + return Ok(__result); + } + + // State 29 + // Factor = "*" "(" Comma (*) ")" [EOF] + // Factor = "*" "(" Comma (*) ")" ["*"] + // Factor = "*" "(" Comma (*) ")" ["+"] + // Factor = "*" "(" Comma (*) ")" ["-"] + // Factor = "*" "(" Comma (*) ")" ["/"] + // + // ")" -> Shift(S37) + // + pub fn __state29< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + mut __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + __sym1: &mut Option, + __sym2: &mut Option>>, + ) -> Result<(Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, __tok @ Tok::RParen(..), _)) => { + let mut __sym3 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state7(arena, __lookahead, __tokens, __sym2, __sym3)); - } - Some(__tok @ Tok::Div(..)) => { - let mut __sym3 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state8(arena, __lookahead, __tokens, __sym2, __sym3)); - } - Some(Tok::Minus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action1(arena, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Expr(__nt))); - } - Some(Tok::Plus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action1(arena, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Expr(__nt))); - } - None => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action1(arena, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Expr(__nt))); + __result = try!(__state37(arena, __lookahead, __tokens, __sym0, __sym1, __sym2, __sym3)); } _ => { return Err(__lookahead); @@ -2042,7 +2077,7 @@ mod __parse__Expr { return Ok(__result); } - // State 29 + // State 30 // ( ",") = (*) Expr "," ["("] // ( ",") = (*) Expr "," [")"] // ( ",") = (*) Expr "," ["*"] @@ -2103,44 +2138,44 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "Num" -> Shift(S44) + // "(" -> Shift(S39) // "*" -> Shift(S41) - // "(" -> Shift(S37) - // ")" -> Reduce(Expr? = => ActionFn(12);) + // "Num" -> Shift(S45) + // ")" -> Reduce(Expr? = => Call(ActionFn(12));) // - // Term -> S39 + // Term -> S38 + // Expr? -> S44 // ( ",") -> S40 - // Expr? -> S42 - // Factor -> S38 - // Expr -> S43 - pub fn __state29< + // Factor -> S43 + // Expr -> S42 + pub fn __state30< 'ast, - __TOKENS: Iterator, + __TOKENS: Iterator, >( arena: &'ast Arena<'ast>, - mut __lookahead: Option, + mut __lookahead: Option<(usize,Tok,usize)>, __tokens: &mut __TOKENS, __sym0: &mut Option<::std::vec::Vec<&'ast Node<'ast>>>, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> + ) -> Result<(Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> { - let mut __result: (Option, __Nonterminal<'ast, >); + let mut __result: (Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some(Tok::Num(__tok0)) => { - let mut __sym1 = &mut Some((__tok0)); + Some((_, __tok @ Tok::LParen(..), _)) => { + let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state44(arena, __lookahead, __tokens, __sym1)); + __result = try!(__state39(arena, __lookahead, __tokens, __sym1)); } - Some(__tok @ Tok::Times(..)) => { - let mut __sym1 = &mut Some(__tok); + Some((_, __tok @ Tok::Times(..), _)) => { + let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); __result = try!(__state41(arena, __lookahead, __tokens, __sym1)); } - Some(__tok @ Tok::LParen(..)) => { - let mut __sym1 = &mut Some(__tok); + Some((_, Tok::Num(__tok0), _)) => { + let mut __sym1 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state37(arena, __lookahead, __tokens, __sym1)); + __result = try!(__state45(arena, __lookahead, __tokens, __sym1)); } - Some(Tok::RParen(..)) => { + Some((_, Tok::RParen(..), _)) => { let __nt = super::__actions::__action12(arena, ); __result = (__lookahead, __Nonterminal::Expr_3f(__nt)); } @@ -2153,23 +2188,23 @@ mod __parse__Expr { match __nt { __Nonterminal::Term(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state39(arena, __lookahead, __tokens, __sym1)); + __result = try!(__state38(arena, __lookahead, __tokens, __sym1)); + } + __Nonterminal::Expr_3f(__nt) => { + let __sym1 = &mut Some(__nt); + __result = try!(__state44(arena, __lookahead, __tokens, __sym0, __sym1)); } __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29(__nt) => { let __sym1 = &mut Some(__nt); __result = try!(__state40(arena, __lookahead, __tokens, __sym0, __sym1)); } - __Nonterminal::Expr_3f(__nt) => { - let __sym1 = &mut Some(__nt); - __result = try!(__state42(arena, __lookahead, __tokens, __sym0, __sym1)); - } __Nonterminal::Factor(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state38(arena, __lookahead, __tokens, __sym1)); + __result = try!(__state43(arena, __lookahead, __tokens, __sym1)); } __Nonterminal::Expr(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state43(arena, __lookahead, __tokens, __sym1)); + __result = try!(__state42(arena, __lookahead, __tokens, __sym1)); } _ => { return Ok((__lookahead, __nt)); @@ -2179,286 +2214,75 @@ mod __parse__Expr { return Ok(__result); } - // State 30 - // Factor = "*" "(" Comma (*) ")" [EOF] - // Factor = "*" "(" Comma (*) ")" ["*"] - // Factor = "*" "(" Comma (*) ")" ["+"] - // Factor = "*" "(" Comma (*) ")" ["-"] - // Factor = "*" "(" Comma (*) ")" ["/"] - // - // ")" -> Shift(S45) - // - pub fn __state30< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - mut __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option, - __sym2: &mut Option>>, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> - { - let mut __result: (Option, __Nonterminal<'ast, >); - match __lookahead { - Some(__tok @ Tok::RParen(..)) => { - let mut __sym3 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state45(arena, __lookahead, __tokens, __sym0, __sym1, __sym2, __sym3)); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - // State 31 - // Factor = "*" "(" Comma (*) ")" [")"] - // Factor = "*" "(" Comma (*) ")" ["*"] - // Factor = "*" "(" Comma (*) ")" ["+"] - // Factor = "*" "(" Comma (*) ")" ["-"] - // Factor = "*" "(" Comma (*) ")" ["/"] + // Term = "(" Expr ")" (*) [")"] + // Term = "(" Expr ")" (*) ["*"] + // Term = "(" Expr ")" (*) ["+"] + // Term = "(" Expr ")" (*) ["-"] + // Term = "(" Expr ")" (*) ["/"] // - // ")" -> Shift(S46) + // "*" -> 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 __state31< 'ast, - __TOKENS: Iterator, + __TOKENS: Iterator, >( arena: &'ast Arena<'ast>, - mut __lookahead: Option, + mut __lookahead: Option<(usize,Tok,usize)>, __tokens: &mut __TOKENS, __sym0: &mut Option, - __sym1: &mut Option, - __sym2: &mut Option>>, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> + __sym1: &mut Option<&'ast Node<'ast>>, + __sym2: &mut Option, + ) -> Result<(Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> { - let mut __result: (Option, __Nonterminal<'ast, >); + let mut __result: (Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some(__tok @ Tok::RParen(..)) => { - let mut __sym3 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state46(arena, __lookahead, __tokens, __sym0, __sym1, __sym2, __sym3)); + Some((_, Tok::Times(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action9(arena, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Term(__nt))); + } + Some((_, Tok::Div(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action9(arena, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Term(__nt))); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action9(arena, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Term(__nt))); + } + Some((_, Tok::RParen(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action9(arena, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Term(__nt))); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action9(arena, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Term(__nt))); } _ => { return Err(__lookahead); } } - return Ok(__result); } // State 32 - // Factor = Factor "/" Term (*) [")"] - // Factor = Factor "/" Term (*) ["*"] - // Factor = Factor "/" Term (*) ["+"] - // Factor = Factor "/" Term (*) ["-"] - // Factor = Factor "/" Term (*) ["/"] - // - // "-" -> Reduce(Factor = Factor, "/", Term => ActionFn(5);) - // ")" -> Reduce(Factor = Factor, "/", Term => ActionFn(5);) - // "/" -> Reduce(Factor = Factor, "/", Term => ActionFn(5);) - // "+" -> Reduce(Factor = Factor, "/", Term => ActionFn(5);) - // "*" -> Reduce(Factor = Factor, "/", Term => ActionFn(5);) - // - pub fn __state32< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - mut __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, - __sym2: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> - { - let mut __result: (Option, __Nonterminal<'ast, >); - match __lookahead { - Some(Tok::Minus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action5(arena, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::RParen(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action5(arena, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Div(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action5(arena, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Plus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action5(arena, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Times(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action5(arena, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 33 - // Factor = Factor "*" Term (*) [")"] - // Factor = Factor "*" Term (*) ["*"] - // Factor = Factor "*" Term (*) ["+"] - // Factor = Factor "*" Term (*) ["-"] - // Factor = Factor "*" Term (*) ["/"] - // - // "-" -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) - // "*" -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) - // "+" -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) - // ")" -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) - // "/" -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) - // - pub fn __state33< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - mut __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, - __sym2: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> - { - let mut __result: (Option, __Nonterminal<'ast, >); - match __lookahead { - Some(Tok::Minus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Times(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Plus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::RParen(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Div(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 34 - // Expr = Expr "-" Factor (*) [")"] - // Expr = Expr "-" Factor (*) ["+"] - // Expr = Expr "-" Factor (*) ["-"] - // Factor = Factor (*) "*" Term [")"] - // Factor = Factor (*) "*" Term ["*"] - // Factor = Factor (*) "*" Term ["+"] - // Factor = Factor (*) "*" Term ["-"] - // Factor = Factor (*) "*" Term ["/"] - // Factor = Factor (*) "/" Term [")"] - // Factor = Factor (*) "/" Term ["*"] - // Factor = Factor (*) "/" Term ["+"] - // Factor = Factor (*) "/" Term ["-"] - // Factor = Factor (*) "/" Term ["/"] - // - // "+" -> Reduce(Expr = Expr, "-", Factor => ActionFn(1);) - // "*" -> Shift(S22) - // "-" -> Reduce(Expr = Expr, "-", Factor => ActionFn(1);) - // ")" -> Reduce(Expr = Expr, "-", Factor => ActionFn(1);) - // "/" -> Shift(S21) - // - pub fn __state34< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - mut __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, - __sym2: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> - { - let mut __result: (Option, __Nonterminal<'ast, >); - match __lookahead { - Some(__tok @ Tok::Times(..)) => { - let mut __sym3 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state22(arena, __lookahead, __tokens, __sym2, __sym3)); - } - Some(__tok @ Tok::Div(..)) => { - let mut __sym3 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state21(arena, __lookahead, __tokens, __sym2, __sym3)); - } - Some(Tok::Plus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action1(arena, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Expr(__nt))); - } - Some(Tok::Minus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action1(arena, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Expr(__nt))); - } - Some(Tok::RParen(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action1(arena, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Expr(__nt))); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 35 // Expr = Expr "+" Factor (*) [")"] // Expr = Expr "+" Factor (*) ["+"] // Expr = Expr "+" Factor (*) ["-"] @@ -2473,51 +2297,51 @@ mod __parse__Expr { // Factor = Factor (*) "/" Term ["-"] // Factor = Factor (*) "/" Term ["/"] // - // "/" -> Shift(S21) - // "+" -> Reduce(Expr = Expr, "+", Factor => ActionFn(2);) - // "-" -> Reduce(Expr = Expr, "+", Factor => ActionFn(2);) - // "*" -> Shift(S22) - // ")" -> Reduce(Expr = Expr, "+", Factor => ActionFn(2);) + // "/" -> Shift(S27) + // "-" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) + // ")" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) + // "*" -> Shift(S26) + // "+" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) // - pub fn __state35< + pub fn __state32< 'ast, - __TOKENS: Iterator, + __TOKENS: Iterator, >( arena: &'ast Arena<'ast>, - mut __lookahead: Option, + mut __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, __Nonterminal<'ast, >), Option> + ) -> Result<(Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> { - let mut __result: (Option, __Nonterminal<'ast, >); + let mut __result: (Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some(__tok @ Tok::Div(..)) => { - let mut __sym3 = &mut Some(__tok); + Some((_, __tok @ Tok::Div(..), _)) => { + let mut __sym3 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state21(arena, __lookahead, __tokens, __sym2, __sym3)); + __result = try!(__state27(arena, __lookahead, __tokens, __sym2, __sym3)); } - Some(__tok @ Tok::Times(..)) => { - let mut __sym3 = &mut Some(__tok); + Some((_, __tok @ Tok::Times(..), _)) => { + let mut __sym3 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state22(arena, __lookahead, __tokens, __sym2, __sym3)); + __result = try!(__state26(arena, __lookahead, __tokens, __sym2, __sym3)); } - Some(Tok::Plus(..)) => { + Some((_, Tok::Minus(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); let __nt = super::__actions::__action2(arena, __sym0, __sym1, __sym2); return Ok((__lookahead, __Nonterminal::Expr(__nt))); } - Some(Tok::Minus(..)) => { + Some((_, Tok::RParen(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); let __nt = super::__actions::__action2(arena, __sym0, __sym1, __sym2); return Ok((__lookahead, __Nonterminal::Expr(__nt))); } - Some(Tok::RParen(..)) => { + Some((_, Tok::Plus(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); @@ -2531,67 +2355,140 @@ mod __parse__Expr { return Ok(__result); } - // State 36 - // Term = "(" Expr ")" (*) [")"] - // Term = "(" Expr ")" (*) ["*"] - // Term = "(" Expr ")" (*) ["+"] - // Term = "(" Expr ")" (*) ["-"] - // Term = "(" Expr ")" (*) ["/"] + // State 33 + // Expr = Expr "-" Factor (*) [")"] + // Expr = Expr "-" Factor (*) ["+"] + // Expr = Expr "-" Factor (*) ["-"] + // Factor = Factor (*) "*" Term [")"] + // Factor = Factor (*) "*" Term ["*"] + // Factor = Factor (*) "*" Term ["+"] + // Factor = Factor (*) "*" Term ["-"] + // Factor = Factor (*) "*" Term ["/"] + // Factor = Factor (*) "/" Term [")"] + // Factor = Factor (*) "/" Term ["*"] + // Factor = Factor (*) "/" Term ["+"] + // Factor = Factor (*) "/" Term ["-"] + // Factor = Factor (*) "/" Term ["/"] // - // ")" -> Reduce(Term = "(", Expr, ")" => ActionFn(9);) - // "/" -> Reduce(Term = "(", Expr, ")" => ActionFn(9);) - // "*" -> Reduce(Term = "(", Expr, ")" => ActionFn(9);) - // "+" -> Reduce(Term = "(", Expr, ")" => ActionFn(9);) - // "-" -> Reduce(Term = "(", Expr, ")" => ActionFn(9);) + // "*" -> Shift(S26) + // "-" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // "/" -> Shift(S27) + // ")" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // "+" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) // - pub fn __state36< + pub fn __state33< 'ast, - __TOKENS: Iterator, + __TOKENS: Iterator, >( arena: &'ast Arena<'ast>, - mut __lookahead: Option, + mut __lookahead: Option<(usize,Tok,usize)>, __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option<&'ast Node<'ast>>, - __sym2: &mut Option, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> + __sym0: &mut Option<&'ast Node<'ast>>, + __sym1: &mut Option, + __sym2: &mut Option<&'ast Node<'ast>>, + ) -> Result<(Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> { - let mut __result: (Option, __Nonterminal<'ast, >); + let mut __result: (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((__lookahead, __Nonterminal::Term(__nt))); + Some((_, __tok @ Tok::Times(..), _)) => { + let mut __sym3 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state26(arena, __lookahead, __tokens, __sym2, __sym3)); } - Some(Tok::Div(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action9(arena, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Term(__nt))); + Some((_, __tok @ Tok::Div(..), _)) => { + let mut __sym3 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state27(arena, __lookahead, __tokens, __sym2, __sym3)); } - Some(Tok::Times(..)) => { + Some((_, Tok::Minus(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action9(arena, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Term(__nt))); + let __nt = super::__actions::__action1(arena, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Expr(__nt))); } - Some(Tok::Plus(..)) => { + Some((_, Tok::RParen(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action9(arena, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Term(__nt))); + let __nt = super::__actions::__action1(arena, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Expr(__nt))); } - Some(Tok::Minus(..)) => { + Some((_, Tok::Plus(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action9(arena, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Term(__nt))); + let __nt = super::__actions::__action1(arena, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Expr(__nt))); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + + // State 34 + // Factor = Factor "*" Term (*) [")"] + // Factor = Factor "*" Term (*) ["*"] + // Factor = Factor "*" Term (*) ["+"] + // Factor = Factor "*" Term (*) ["-"] + // Factor = Factor "*" Term (*) ["/"] + // + // "*" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(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 __state34< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + mut __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<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (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((__lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action4(arena, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Div(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action4(arena, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action4(arena, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::RParen(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action4(arena, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); } _ => { return Err(__lookahead); @@ -2599,7 +2496,247 @@ mod __parse__Expr { } } + // State 35 + // 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 __state35< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + mut __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<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, Tok::RParen(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action5(arena, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Div(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action5(arena, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action5(arena, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action5(arena, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Times(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action5(arena, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 36 + // Factor = "*" "(" Comma (*) ")" [")"] + // Factor = "*" "(" Comma (*) ")" ["*"] + // Factor = "*" "(" Comma (*) ")" ["+"] + // Factor = "*" "(" Comma (*) ")" ["-"] + // Factor = "*" "(" Comma (*) ")" ["/"] + // + // ")" -> Shift(S46) + // + pub fn __state36< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + mut __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + __sym1: &mut Option, + __sym2: &mut Option>>, + ) -> Result<(Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, __tok @ Tok::RParen(..), _)) => { + let mut __sym3 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state46(arena, __lookahead, __tokens, __sym0, __sym1, __sym2, __sym3)); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + // State 37 + // Factor = "*" "(" Comma ")" (*) [EOF] + // Factor = "*" "(" Comma ")" (*) ["*"] + // Factor = "*" "(" Comma ")" (*) ["+"] + // Factor = "*" "(" Comma ")" (*) ["-"] + // Factor = "*" "(" Comma ")" (*) ["/"] + // + // "+" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) + // "-" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) + // EOF -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) + // "/" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) + // "*" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) + // + pub fn __state37< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + mut __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + __sym1: &mut Option, + __sym2: &mut Option>>, + __sym3: &mut Option, + ) -> Result<(Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (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((__lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __sym3 = __sym3.take().unwrap(); + let __nt = super::__actions::__action6(arena, __sym0, __sym1, __sym2, __sym3); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + None => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __sym3 = __sym3.take().unwrap(); + let __nt = super::__actions::__action6(arena, __sym0, __sym1, __sym2, __sym3); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::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((__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((__lookahead, __Nonterminal::Factor(__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>, + mut __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + ) -> Result<(Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (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((__lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action7(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::RParen(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action7(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Times(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action7(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Comma(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action7(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action7(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 39 // Expr = (*) Expr "+" Factor [")"] // Expr = (*) Expr "+" Factor ["+"] // Expr = (*) Expr "+" Factor ["-"] @@ -2646,40 +2783,40 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "*" -> Shift(S9) - // "(" -> Shift(S13) - // "Num" -> Shift(S14) + // "*" -> Shift(S14) + // "(" -> Shift(S11) + // "Num" -> Shift(S16) // - // Term -> S12 + // Term -> S15 + // Factor -> S13 // Expr -> S47 - // Factor -> S10 - pub fn __state37< + pub fn __state39< 'ast, - __TOKENS: Iterator, + __TOKENS: Iterator, >( arena: &'ast Arena<'ast>, - mut __lookahead: Option, + mut __lookahead: Option<(usize,Tok,usize)>, __tokens: &mut __TOKENS, __sym0: &mut Option, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> + ) -> Result<(Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> { - let mut __result: (Option, __Nonterminal<'ast, >); + let mut __result: (Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some(__tok @ Tok::Times(..)) => { - let mut __sym1 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state9(arena, __lookahead, __tokens, __sym1)); - } - Some(__tok @ Tok::LParen(..)) => { - let mut __sym1 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state13(arena, __lookahead, __tokens, __sym1)); - } - Some(Tok::Num(__tok0)) => { - let mut __sym1 = &mut Some((__tok0)); + Some((_, __tok @ Tok::Times(..), _)) => { + let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); __result = try!(__state14(arena, __lookahead, __tokens, __sym1)); } + Some((_, __tok @ Tok::LParen(..), _)) => { + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state11(arena, __lookahead, __tokens, __sym1)); + } + Some((_, Tok::Num(__tok0), _)) => { + let mut __sym1 = &mut Some((__tok0)); + let __lookahead = __tokens.next(); + __result = try!(__state16(arena, __lookahead, __tokens, __sym1)); + } _ => { return Err(__lookahead); } @@ -2689,16 +2826,16 @@ mod __parse__Expr { match __nt { __Nonterminal::Term(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state12(arena, __lookahead, __tokens, __sym1)); + __result = try!(__state15(arena, __lookahead, __tokens, __sym1)); + } + __Nonterminal::Factor(__nt) => { + let __sym1 = &mut Some(__nt); + __result = try!(__state13(arena, __lookahead, __tokens, __sym1)); } __Nonterminal::Expr(__nt) => { let __sym1 = &mut Some(__nt); __result = try!(__state47(arena, __lookahead, __tokens, __sym0, __sym1)); } - __Nonterminal::Factor(__nt) => { - let __sym1 = &mut Some(__nt); - __result = try!(__state10(arena, __lookahead, __tokens, __sym1)); - } _ => { return Ok((__lookahead, __nt)); } @@ -2707,186 +2844,49 @@ mod __parse__Expr { return Ok(__result); } - // State 38 - // Expr = Factor (*) [")"] - // Expr = Factor (*) ["+"] - // Expr = Factor (*) [","] - // Expr = Factor (*) ["-"] - // Factor = Factor (*) "*" Term [")"] - // Factor = Factor (*) "*" Term ["*"] - // Factor = Factor (*) "*" Term ["+"] - // Factor = Factor (*) "*" Term [","] - // Factor = Factor (*) "*" Term ["-"] - // Factor = Factor (*) "*" Term ["/"] - // Factor = Factor (*) "/" Term [")"] - // Factor = Factor (*) "/" Term ["*"] - // Factor = Factor (*) "/" Term ["+"] - // Factor = Factor (*) "/" Term [","] - // Factor = Factor (*) "/" Term ["-"] - // Factor = Factor (*) "/" Term ["/"] - // - // "/" -> Shift(S48) - // "," -> Reduce(Expr = Factor => ActionFn(3);) - // "*" -> Shift(S49) - // "+" -> Reduce(Expr = Factor => ActionFn(3);) - // "-" -> Reduce(Expr = Factor => ActionFn(3);) - // ")" -> Reduce(Expr = Factor => ActionFn(3);) - // - pub fn __state38< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - mut __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> - { - let mut __result: (Option, __Nonterminal<'ast, >); - match __lookahead { - Some(__tok @ Tok::Div(..)) => { - let mut __sym1 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state48(arena, __lookahead, __tokens, __sym0, __sym1)); - } - Some(__tok @ Tok::Times(..)) => { - let mut __sym1 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state49(arena, __lookahead, __tokens, __sym0, __sym1)); - } - Some(Tok::Comma(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action3(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Expr(__nt))); - } - Some(Tok::Plus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action3(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Expr(__nt))); - } - Some(Tok::Minus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action3(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Expr(__nt))); - } - Some(Tok::RParen(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action3(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Expr(__nt))); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 39 - // Factor = Term (*) [")"] - // Factor = Term (*) ["*"] - // Factor = Term (*) ["+"] - // Factor = Term (*) [","] - // Factor = Term (*) ["-"] - // Factor = Term (*) ["/"] - // - // "/" -> Reduce(Factor = Term => ActionFn(7);) - // "," -> Reduce(Factor = Term => ActionFn(7);) - // "-" -> Reduce(Factor = Term => ActionFn(7);) - // "+" -> Reduce(Factor = Term => ActionFn(7);) - // ")" -> Reduce(Factor = Term => ActionFn(7);) - // "*" -> Reduce(Factor = Term => ActionFn(7);) - // - pub fn __state39< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - mut __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> - { - let mut __result: (Option, __Nonterminal<'ast, >); - match __lookahead { - Some(Tok::Div(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Comma(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Minus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Plus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::RParen(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Times(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action7(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - // State 40 // ( ",")* = ( ",")* ( ",") (*) ["("] // ( ",")* = ( ",")* ( ",") (*) [")"] // ( ",")* = ( ",")* ( ",") (*) ["*"] // ( ",")* = ( ",")* ( ",") (*) ["Num"] // - // "(" -> Reduce(( ",")* = ( ",")*, ( ",") => ActionFn(14);) - // "*" -> Reduce(( ",")* = ( ",")*, ( ",") => ActionFn(14);) - // ")" -> Reduce(( ",")* = ( ",")*, ( ",") => ActionFn(14);) - // "Num" -> Reduce(( ",")* = ( ",")*, ( ",") => ActionFn(14);) + // "(" -> Reduce(( ",")* = ( ",")*, ( ",") => Call(ActionFn(14));) + // "*" -> Reduce(( ",")* = ( ",")*, ( ",") => Call(ActionFn(14));) + // ")" -> Reduce(( ",")* = ( ",")*, ( ",") => Call(ActionFn(14));) + // "Num" -> Reduce(( ",")* = ( ",")*, ( ",") => Call(ActionFn(14));) // pub fn __state40< 'ast, - __TOKENS: Iterator, + __TOKENS: Iterator, >( arena: &'ast Arena<'ast>, - mut __lookahead: Option, + mut __lookahead: Option<(usize,Tok,usize)>, __tokens: &mut __TOKENS, __sym0: &mut Option<::std::vec::Vec<&'ast Node<'ast>>>, __sym1: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> + ) -> Result<(Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> { - let mut __result: (Option, __Nonterminal<'ast, >); + let mut __result: (Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some(Tok::LParen(..)) => { + Some((_, Tok::LParen(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __nt = super::__actions::__action14(arena, __sym0, __sym1); return Ok((__lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt))); } - Some(Tok::Times(..)) => { + Some((_, Tok::Times(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __nt = super::__actions::__action14(arena, __sym0, __sym1); return Ok((__lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt))); } - Some(Tok::RParen(..)) => { + Some((_, Tok::RParen(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __nt = super::__actions::__action14(arena, __sym0, __sym1); return Ok((__lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt))); } - Some(Tok::Num(_)) => { + Some((_, Tok::Num(_), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __nt = super::__actions::__action14(arena, __sym0, __sym1); @@ -2906,24 +2906,24 @@ mod __parse__Expr { // Factor = "*" (*) "(" Comma ")" ["-"] // Factor = "*" (*) "(" Comma ")" ["/"] // - // "(" -> Shift(S50) + // "(" -> Shift(S48) // pub fn __state41< 'ast, - __TOKENS: Iterator, + __TOKENS: Iterator, >( arena: &'ast Arena<'ast>, - mut __lookahead: Option, + mut __lookahead: Option<(usize,Tok,usize)>, __tokens: &mut __TOKENS, __sym0: &mut Option, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> + ) -> Result<(Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> { - let mut __result: (Option, __Nonterminal<'ast, >); + let mut __result: (Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some(__tok @ Tok::LParen(..)) => { - let mut __sym1 = &mut Some(__tok); + Some((_, __tok @ Tok::LParen(..), _)) => { + let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state50(arena, __lookahead, __tokens, __sym0, __sym1)); + __result = try!(__state48(arena, __lookahead, __tokens, __sym0, __sym1)); } _ => { return Err(__lookahead); @@ -2933,36 +2933,6 @@ mod __parse__Expr { } // State 42 - // Comma = ( ",")* Expr? (*) [")"] - // - // ")" -> Reduce(Comma = ( ",")*, Expr? => ActionFn(10);) - // - pub fn __state42< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - mut __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option<::std::vec::Vec<&'ast Node<'ast>>>, - __sym1: &mut Option<::std::option::Option<&'ast Node<'ast>>>, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> - { - let mut __result: (Option, __Nonterminal<'ast, >); - match __lookahead { - Some(Tok::RParen(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __nt = super::__actions::__action10(arena, __sym0, __sym1); - return Ok((__lookahead, __Nonterminal::Comma_3cExpr_3e(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 43 // ( ",") = Expr (*) "," ["("] // ( ",") = Expr (*) "," [")"] // ( ",") = Expr (*) "," ["*"] @@ -2977,39 +2947,39 @@ mod __parse__Expr { // Expr = Expr (*) "-" Factor ["-"] // Expr? = Expr (*) [")"] // - // "-" -> Shift(S52) - // "," -> Shift(S53) - // ")" -> Reduce(Expr? = Expr => ActionFn(11);) + // "-" -> Shift(S50) + // "," -> Shift(S49) + // ")" -> Reduce(Expr? = Expr => Call(ActionFn(11));) // "+" -> Shift(S51) // - pub fn __state43< + pub fn __state42< 'ast, - __TOKENS: Iterator, + __TOKENS: Iterator, >( arena: &'ast Arena<'ast>, - mut __lookahead: Option, + mut __lookahead: Option<(usize,Tok,usize)>, __tokens: &mut __TOKENS, __sym0: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> + ) -> Result<(Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> { - let mut __result: (Option, __Nonterminal<'ast, >); + let mut __result: (Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some(__tok @ Tok::Minus(..)) => { - let mut __sym1 = &mut Some(__tok); + Some((_, __tok @ Tok::Minus(..), _)) => { + let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state52(arena, __lookahead, __tokens, __sym0, __sym1)); + __result = try!(__state50(arena, __lookahead, __tokens, __sym0, __sym1)); } - Some(__tok @ Tok::Comma(..)) => { - let mut __sym1 = &mut Some(__tok); + Some((_, __tok @ Tok::Comma(..), _)) => { + let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state53(arena, __lookahead, __tokens, __sym0, __sym1)); + __result = try!(__state49(arena, __lookahead, __tokens, __sym0, __sym1)); } - Some(__tok @ Tok::Plus(..)) => { - let mut __sym1 = &mut Some(__tok); + Some((_, __tok @ Tok::Plus(..), _)) => { + let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); __result = try!(__state51(arena, __lookahead, __tokens, __sym0, __sym1)); } - Some(Tok::RParen(..)) => { + Some((_, Tok::RParen(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __nt = super::__actions::__action11(arena, __sym0); return Ok((__lookahead, __Nonterminal::Expr_3f(__nt))); @@ -3021,62 +2991,103 @@ mod __parse__Expr { return Ok(__result); } - // State 44 - // Term = "Num" (*) [")"] - // Term = "Num" (*) ["*"] - // Term = "Num" (*) ["+"] - // Term = "Num" (*) [","] - // Term = "Num" (*) ["-"] - // Term = "Num" (*) ["/"] + // State 43 + // Expr = Factor (*) [")"] + // Expr = Factor (*) ["+"] + // Expr = Factor (*) [","] + // Expr = Factor (*) ["-"] + // Factor = Factor (*) "*" Term [")"] + // Factor = Factor (*) "*" Term ["*"] + // Factor = Factor (*) "*" Term ["+"] + // Factor = Factor (*) "*" Term [","] + // Factor = Factor (*) "*" Term ["-"] + // Factor = Factor (*) "*" Term ["/"] + // Factor = Factor (*) "/" Term [")"] + // Factor = Factor (*) "/" Term ["*"] + // Factor = Factor (*) "/" Term ["+"] + // Factor = Factor (*) "/" Term [","] + // Factor = Factor (*) "/" Term ["-"] + // Factor = Factor (*) "/" Term ["/"] // - // "," -> Reduce(Term = "Num" => ActionFn(8);) - // "-" -> Reduce(Term = "Num" => ActionFn(8);) - // "*" -> Reduce(Term = "Num" => ActionFn(8);) - // ")" -> Reduce(Term = "Num" => ActionFn(8);) - // "+" -> Reduce(Term = "Num" => ActionFn(8);) - // "/" -> Reduce(Term = "Num" => ActionFn(8);) + // ")" -> Reduce(Expr = Factor => Call(ActionFn(3));) + // "," -> Reduce(Expr = Factor => Call(ActionFn(3));) + // "-" -> Reduce(Expr = Factor => Call(ActionFn(3));) + // "*" -> Shift(S53) + // "/" -> Shift(S52) + // "+" -> Reduce(Expr = Factor => Call(ActionFn(3));) + // + pub fn __state43< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + mut __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + ) -> Result<(Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, __tok @ Tok::Times(..), _)) => { + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state53(arena, __lookahead, __tokens, __sym0, __sym1)); + } + Some((_, __tok @ Tok::Div(..), _)) => { + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state52(arena, __lookahead, __tokens, __sym0, __sym1)); + } + Some((_, Tok::RParen(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action3(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Expr(__nt))); + } + Some((_, Tok::Comma(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action3(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Expr(__nt))); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action3(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Expr(__nt))); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action3(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Expr(__nt))); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + + // State 44 + // Comma = ( ",")* Expr? (*) [")"] + // + // ")" -> Reduce(Comma = ( ",")*, Expr? => Call(ActionFn(10));) // pub fn __state44< 'ast, - __TOKENS: Iterator, + __TOKENS: Iterator, >( arena: &'ast Arena<'ast>, - mut __lookahead: Option, + mut __lookahead: Option<(usize,Tok,usize)>, __tokens: &mut __TOKENS, - __sym0: &mut Option, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> + __sym0: &mut Option<::std::vec::Vec<&'ast Node<'ast>>>, + __sym1: &mut Option<::std::option::Option<&'ast Node<'ast>>>, + ) -> Result<(Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> { - let mut __result: (Option, __Nonterminal<'ast, >); + let mut __result: (Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some(Tok::Comma(..)) => { + Some((_, Tok::RParen(..), _)) => { let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action8(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Term(__nt))); - } - Some(Tok::Minus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action8(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Term(__nt))); - } - Some(Tok::Times(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action8(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Term(__nt))); - } - Some(Tok::RParen(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action8(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Term(__nt))); - } - Some(Tok::Plus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action8(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Term(__nt))); - } - Some(Tok::Div(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action8(arena, __sym0); - return Ok((__lookahead, __Nonterminal::Term(__nt))); + let __sym1 = __sym1.take().unwrap(); + let __nt = super::__actions::__action10(arena, __sym0, __sym1); + return Ok((__lookahead, __Nonterminal::Comma_3cExpr_3e(__nt))); } _ => { return Err(__lookahead); @@ -3085,72 +3096,61 @@ mod __parse__Expr { } // State 45 - // Factor = "*" "(" Comma ")" (*) [EOF] - // Factor = "*" "(" Comma ")" (*) ["*"] - // Factor = "*" "(" Comma ")" (*) ["+"] - // Factor = "*" "(" Comma ")" (*) ["-"] - // Factor = "*" "(" Comma ")" (*) ["/"] + // Term = "Num" (*) [")"] + // Term = "Num" (*) ["*"] + // Term = "Num" (*) ["+"] + // Term = "Num" (*) [","] + // Term = "Num" (*) ["-"] + // Term = "Num" (*) ["/"] // - // "*" -> Reduce(Factor = "*", "(", Comma, ")" => ActionFn(6);) - // "/" -> Reduce(Factor = "*", "(", Comma, ")" => ActionFn(6);) - // "-" -> Reduce(Factor = "*", "(", Comma, ")" => ActionFn(6);) - // EOF -> Reduce(Factor = "*", "(", Comma, ")" => ActionFn(6);) - // "+" -> Reduce(Factor = "*", "(", Comma, ")" => ActionFn(6);) + // "*" -> 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 __state45< 'ast, - __TOKENS: Iterator, + __TOKENS: Iterator, >( arena: &'ast Arena<'ast>, - mut __lookahead: Option, + mut __lookahead: Option<(usize,Tok,usize)>, __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option, - __sym2: &mut Option>>, - __sym3: &mut Option, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> + __sym0: &mut Option, + ) -> Result<(Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> { - let mut __result: (Option, __Nonterminal<'ast, >); + let mut __result: (Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some(Tok::Times(..)) => { + 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((__lookahead, __Nonterminal::Factor(__nt))); + let __nt = super::__actions::__action8(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Term(__nt))); } - Some(Tok::Div(..)) => { + Some((_, Tok::Plus(..), _)) => { let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __sym3 = __sym3.take().unwrap(); - let __nt = super::__actions::__action6(arena, __sym0, __sym1, __sym2, __sym3); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); + let __nt = super::__actions::__action8(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Term(__nt))); } - Some(Tok::Minus(..)) => { + 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((__lookahead, __Nonterminal::Factor(__nt))); + let __nt = super::__actions::__action8(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Term(__nt))); } - None => { + 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((__lookahead, __Nonterminal::Factor(__nt))); + let __nt = super::__actions::__action8(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Term(__nt))); } - Some(Tok::Plus(..)) => { + Some((_, Tok::Minus(..), _)) => { let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __sym3 = __sym3.take().unwrap(); - let __nt = super::__actions::__action6(arena, __sym0, __sym1, __sym2, __sym3); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); + let __nt = super::__actions::__action8(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Term(__nt))); + } + Some((_, Tok::Div(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action8(arena, __sym0); + return Ok((__lookahead, __Nonterminal::Term(__nt))); } _ => { return Err(__lookahead); @@ -3165,28 +3165,28 @@ mod __parse__Expr { // Factor = "*" "(" Comma ")" (*) ["-"] // Factor = "*" "(" Comma ")" (*) ["/"] // - // "-" -> Reduce(Factor = "*", "(", Comma, ")" => ActionFn(6);) - // "*" -> Reduce(Factor = "*", "(", Comma, ")" => ActionFn(6);) - // "+" -> Reduce(Factor = "*", "(", Comma, ")" => ActionFn(6);) - // ")" -> Reduce(Factor = "*", "(", Comma, ")" => ActionFn(6);) - // "/" -> Reduce(Factor = "*", "(", Comma, ")" => ActionFn(6);) + // "*" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) + // "-" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) + // "/" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) + // ")" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) + // "+" -> Reduce(Factor = "*", "(", Comma, ")" => Call(ActionFn(6));) // pub fn __state46< 'ast, - __TOKENS: Iterator, + __TOKENS: Iterator, >( arena: &'ast Arena<'ast>, - mut __lookahead: Option, + mut __lookahead: Option<(usize,Tok,usize)>, __tokens: &mut __TOKENS, __sym0: &mut Option, __sym1: &mut Option, __sym2: &mut Option>>, __sym3: &mut Option, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> + ) -> Result<(Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> { - let mut __result: (Option, __Nonterminal<'ast, >); + let mut __result: (Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some(Tok::Minus(..)) => { + Some((_, Tok::Times(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); @@ -3194,7 +3194,7 @@ mod __parse__Expr { let __nt = super::__actions::__action6(arena, __sym0, __sym1, __sym2, __sym3); return Ok((__lookahead, __Nonterminal::Factor(__nt))); } - Some(Tok::Times(..)) => { + Some((_, Tok::Minus(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); @@ -3202,7 +3202,7 @@ mod __parse__Expr { let __nt = super::__actions::__action6(arena, __sym0, __sym1, __sym2, __sym3); return Ok((__lookahead, __Nonterminal::Factor(__nt))); } - Some(Tok::Plus(..)) => { + Some((_, Tok::Div(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); @@ -3210,7 +3210,7 @@ mod __parse__Expr { let __nt = super::__actions::__action6(arena, __sym0, __sym1, __sym2, __sym3); return Ok((__lookahead, __Nonterminal::Factor(__nt))); } - Some(Tok::RParen(..)) => { + Some((_, Tok::RParen(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); @@ -3218,7 +3218,7 @@ mod __parse__Expr { let __nt = super::__actions::__action6(arena, __sym0, __sym1, __sym2, __sym3); return Ok((__lookahead, __Nonterminal::Factor(__nt))); } - Some(Tok::Div(..)) => { + Some((_, Tok::Plus(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); @@ -3246,37 +3246,37 @@ mod __parse__Expr { // Term = "(" Expr (*) ")" ["-"] // Term = "(" Expr (*) ")" ["/"] // + // "-" -> Shift(S25) + // "+" -> Shift(S23) // ")" -> Shift(S54) - // "-" -> Shift(S23) - // "+" -> Shift(S25) // pub fn __state47< 'ast, - __TOKENS: Iterator, + __TOKENS: Iterator, >( arena: &'ast Arena<'ast>, - mut __lookahead: Option, + mut __lookahead: Option<(usize,Tok,usize)>, __tokens: &mut __TOKENS, __sym0: &mut Option, __sym1: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> + ) -> Result<(Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> { - let mut __result: (Option, __Nonterminal<'ast, >); + let mut __result: (Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some(__tok @ Tok::RParen(..)) => { - let mut __sym2 = &mut Some(__tok); + Some((_, __tok @ Tok::Minus(..), _)) => { + let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state54(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); + __result = try!(__state25(arena, __lookahead, __tokens, __sym1, __sym2)); } - Some(__tok @ Tok::Minus(..)) => { - let mut __sym2 = &mut Some(__tok); + Some((_, __tok @ Tok::Plus(..), _)) => { + let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); __result = try!(__state23(arena, __lookahead, __tokens, __sym1, __sym2)); } - Some(__tok @ Tok::Plus(..)) => { - let mut __sym2 = &mut Some(__tok); + Some((_, __tok @ Tok::RParen(..), _)) => { + let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state25(arena, __lookahead, __tokens, __sym1, __sym2)); + __result = try!(__state54(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); } _ => { return Err(__lookahead); @@ -3286,138 +3286,6 @@ mod __parse__Expr { } // State 48 - // Factor = Factor "/" (*) Term [")"] - // Factor = Factor "/" (*) Term ["*"] - // Factor = Factor "/" (*) Term ["+"] - // Factor = Factor "/" (*) Term [","] - // Factor = Factor "/" (*) Term ["-"] - // Factor = Factor "/" (*) Term ["/"] - // Term = (*) "(" Expr ")" [")"] - // Term = (*) "(" Expr ")" ["*"] - // Term = (*) "(" Expr ")" ["+"] - // Term = (*) "(" Expr ")" [","] - // Term = (*) "(" Expr ")" ["-"] - // Term = (*) "(" Expr ")" ["/"] - // Term = (*) "Num" [")"] - // Term = (*) "Num" ["*"] - // Term = (*) "Num" ["+"] - // Term = (*) "Num" [","] - // Term = (*) "Num" ["-"] - // Term = (*) "Num" ["/"] - // - // "Num" -> Shift(S44) - // "(" -> Shift(S37) - // - // Term -> S55 - pub fn __state48< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - mut __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> - { - let mut __result: (Option, __Nonterminal<'ast, >); - match __lookahead { - Some(Tok::Num(__tok0)) => { - let mut __sym2 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state44(arena, __lookahead, __tokens, __sym2)); - } - Some(__tok @ Tok::LParen(..)) => { - let mut __sym2 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state37(arena, __lookahead, __tokens, __sym2)); - } - _ => { - return Err(__lookahead); - } - } - while __sym1.is_some() { - let (__lookahead, __nt) = __result; - match __nt { - __Nonterminal::Term(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state55(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - _ => { - return Ok((__lookahead, __nt)); - } - } - } - return Ok(__result); - } - - // State 49 - // Factor = Factor "*" (*) Term [")"] - // Factor = Factor "*" (*) Term ["*"] - // Factor = Factor "*" (*) Term ["+"] - // Factor = Factor "*" (*) Term [","] - // Factor = Factor "*" (*) Term ["-"] - // Factor = Factor "*" (*) Term ["/"] - // Term = (*) "(" Expr ")" [")"] - // Term = (*) "(" Expr ")" ["*"] - // Term = (*) "(" Expr ")" ["+"] - // Term = (*) "(" Expr ")" [","] - // Term = (*) "(" Expr ")" ["-"] - // Term = (*) "(" Expr ")" ["/"] - // Term = (*) "Num" [")"] - // Term = (*) "Num" ["*"] - // Term = (*) "Num" ["+"] - // Term = (*) "Num" [","] - // Term = (*) "Num" ["-"] - // Term = (*) "Num" ["/"] - // - // "(" -> Shift(S37) - // "Num" -> Shift(S44) - // - // Term -> S56 - pub fn __state49< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - mut __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> - { - let mut __result: (Option, __Nonterminal<'ast, >); - match __lookahead { - Some(__tok @ Tok::LParen(..)) => { - let mut __sym2 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state37(arena, __lookahead, __tokens, __sym2)); - } - Some(Tok::Num(__tok0)) => { - let mut __sym2 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state44(arena, __lookahead, __tokens, __sym2)); - } - _ => { - return Err(__lookahead); - } - } - while __sym1.is_some() { - let (__lookahead, __nt) = __result; - match __nt { - __Nonterminal::Term(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state56(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } - _ => { - return Ok((__lookahead, __nt)); - } - } - } - return Ok(__result); - } - - // State 50 // ( ",")* = (*) ["("] // ( ",")* = (*) [")"] // ( ",")* = (*) ["*"] @@ -3434,39 +3302,39 @@ mod __parse__Expr { // Factor = "*" "(" (*) Comma ")" ["-"] // Factor = "*" "(" (*) Comma ")" ["/"] // - // "(" -> Reduce(( ",")* = => ActionFn(13);) - // "Num" -> Reduce(( ",")* = => ActionFn(13);) - // "*" -> Reduce(( ",")* = => ActionFn(13);) - // ")" -> Reduce(( ",")* = => ActionFn(13);) + // ")" -> Reduce(( ",")* = => Call(ActionFn(13));) + // "*" -> Reduce(( ",")* = => Call(ActionFn(13));) + // "Num" -> Reduce(( ",")* = => Call(ActionFn(13));) + // "(" -> Reduce(( ",")* = => Call(ActionFn(13));) // - // Comma -> S57 - // ( ",")* -> S29 - pub fn __state50< + // Comma -> S55 + // ( ",")* -> S30 + pub fn __state48< 'ast, - __TOKENS: Iterator, + __TOKENS: Iterator, >( arena: &'ast Arena<'ast>, - mut __lookahead: Option, + mut __lookahead: Option<(usize,Tok,usize)>, __tokens: &mut __TOKENS, __sym0: &mut Option, __sym1: &mut Option, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> + ) -> Result<(Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> { - let mut __result: (Option, __Nonterminal<'ast, >); + let mut __result: (Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some(Tok::LParen(..)) => { + Some((_, Tok::RParen(..), _)) => { let __nt = super::__actions::__action13(arena, ); __result = (__lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); } - Some(Tok::Num(_)) => { + Some((_, Tok::Times(..), _)) => { let __nt = super::__actions::__action13(arena, ); __result = (__lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); } - Some(Tok::Times(..)) => { + Some((_, Tok::Num(_), _)) => { let __nt = super::__actions::__action13(arena, ); __result = (__lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); } - Some(Tok::RParen(..)) => { + Some((_, Tok::LParen(..), _)) => { let __nt = super::__actions::__action13(arena, ); __result = (__lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt)); } @@ -3479,11 +3347,164 @@ mod __parse__Expr { match __nt { __Nonterminal::Comma_3cExpr_3e(__nt) => { let __sym2 = &mut Some(__nt); - __result = try!(__state57(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); + __result = try!(__state55(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); } __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29_2a(__nt) => { let __sym2 = &mut Some(__nt); - __result = try!(__state29(arena, __lookahead, __tokens, __sym2)); + __result = try!(__state30(arena, __lookahead, __tokens, __sym2)); + } + _ => { + return Ok((__lookahead, __nt)); + } + } + } + return Ok(__result); + } + + // State 49 + // ( ",") = Expr "," (*) ["("] + // ( ",") = Expr "," (*) [")"] + // ( ",") = Expr "," (*) ["*"] + // ( ",") = Expr "," (*) ["Num"] + // + // ")" -> Reduce(( ",") = Expr, "," => Call(ActionFn(15));) + // "(" -> Reduce(( ",") = Expr, "," => Call(ActionFn(15));) + // "*" -> Reduce(( ",") = Expr, "," => Call(ActionFn(15));) + // "Num" -> Reduce(( ",") = Expr, "," => Call(ActionFn(15));) + // + pub fn __state49< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + mut __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + __sym1: &mut Option, + ) -> Result<(Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (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::__action15(arena, __sym0, __sym1); + return Ok((__lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29(__nt))); + } + Some((_, Tok::LParen(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __nt = super::__actions::__action15(arena, __sym0, __sym1); + return Ok((__lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29(__nt))); + } + Some((_, Tok::Times(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __nt = super::__actions::__action15(arena, __sym0, __sym1); + return Ok((__lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29(__nt))); + } + Some((_, Tok::Num(_), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __nt = super::__actions::__action15(arena, __sym0, __sym1); + return Ok((__lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 50 + // Expr = Expr "-" (*) Factor [")"] + // Expr = Expr "-" (*) Factor ["+"] + // Expr = Expr "-" (*) Factor [","] + // Expr = Expr "-" (*) Factor ["-"] + // Factor = (*) Factor "*" Term [")"] + // Factor = (*) Factor "*" Term ["*"] + // Factor = (*) Factor "*" Term ["+"] + // Factor = (*) Factor "*" Term [","] + // Factor = (*) Factor "*" Term ["-"] + // Factor = (*) Factor "*" Term ["/"] + // Factor = (*) Factor "/" Term [")"] + // Factor = (*) Factor "/" Term ["*"] + // Factor = (*) Factor "/" Term ["+"] + // Factor = (*) Factor "/" Term [","] + // Factor = (*) Factor "/" Term ["-"] + // Factor = (*) Factor "/" Term ["/"] + // Factor = (*) Term [")"] + // Factor = (*) Term ["*"] + // Factor = (*) Term ["+"] + // Factor = (*) Term [","] + // Factor = (*) Term ["-"] + // Factor = (*) Term ["/"] + // Factor = (*) "*" "(" Comma ")" [")"] + // Factor = (*) "*" "(" Comma ")" ["*"] + // Factor = (*) "*" "(" Comma ")" ["+"] + // Factor = (*) "*" "(" Comma ")" [","] + // Factor = (*) "*" "(" Comma ")" ["-"] + // Factor = (*) "*" "(" Comma ")" ["/"] + // Term = (*) "(" Expr ")" [")"] + // Term = (*) "(" Expr ")" ["*"] + // Term = (*) "(" Expr ")" ["+"] + // Term = (*) "(" Expr ")" [","] + // Term = (*) "(" Expr ")" ["-"] + // Term = (*) "(" Expr ")" ["/"] + // Term = (*) "Num" [")"] + // Term = (*) "Num" ["*"] + // Term = (*) "Num" ["+"] + // Term = (*) "Num" [","] + // Term = (*) "Num" ["-"] + // Term = (*) "Num" ["/"] + // + // "Num" -> Shift(S45) + // "(" -> Shift(S39) + // "*" -> Shift(S41) + // + // Term -> S38 + // Factor -> S56 + pub fn __state50< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + mut __lookahead: Option<(usize,Tok,usize)>, + __tokens: &mut __TOKENS, + __sym0: &mut Option<&'ast Node<'ast>>, + __sym1: &mut Option, + ) -> Result<(Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, Tok::Num(__tok0), _)) => { + let mut __sym2 = &mut Some((__tok0)); + let __lookahead = __tokens.next(); + __result = try!(__state45(arena, __lookahead, __tokens, __sym2)); + } + Some((_, __tok @ Tok::LParen(..), _)) => { + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state39(arena, __lookahead, __tokens, __sym2)); + } + Some((_, __tok @ Tok::Times(..), _)) => { + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state41(arena, __lookahead, __tokens, __sym2)); + } + _ => { + return Err(__lookahead); + } + } + while __sym1.is_some() { + let (__lookahead, __nt) = __result; + match __nt { + __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state38(arena, __lookahead, __tokens, __sym2)); + } + __Nonterminal::Factor(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state56(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); } _ => { return Ok((__lookahead, __nt)); @@ -3535,40 +3556,40 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "Num" -> Shift(S44) - // "(" -> Shift(S37) + // "(" -> Shift(S39) // "*" -> Shift(S41) + // "Num" -> Shift(S45) // - // Term -> S39 - // Factor -> S58 + // Term -> S38 + // Factor -> S57 pub fn __state51< 'ast, - __TOKENS: Iterator, + __TOKENS: Iterator, >( arena: &'ast Arena<'ast>, - mut __lookahead: Option, + mut __lookahead: Option<(usize,Tok,usize)>, __tokens: &mut __TOKENS, __sym0: &mut Option<&'ast Node<'ast>>, __sym1: &mut Option, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> + ) -> Result<(Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> { - let mut __result: (Option, __Nonterminal<'ast, >); + let mut __result: (Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some(Tok::Num(__tok0)) => { - let mut __sym2 = &mut Some((__tok0)); + Some((_, __tok @ Tok::LParen(..), _)) => { + let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state44(arena, __lookahead, __tokens, __sym2)); + __result = try!(__state39(arena, __lookahead, __tokens, __sym2)); } - Some(__tok @ Tok::LParen(..)) => { - let mut __sym2 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state37(arena, __lookahead, __tokens, __sym2)); - } - Some(__tok @ Tok::Times(..)) => { - let mut __sym2 = &mut Some(__tok); + Some((_, __tok @ Tok::Times(..), _)) => { + let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); __result = try!(__state41(arena, __lookahead, __tokens, __sym2)); } + Some((_, Tok::Num(__tok0), _)) => { + let mut __sym2 = &mut Some((__tok0)); + let __lookahead = __tokens.next(); + __result = try!(__state45(arena, __lookahead, __tokens, __sym2)); + } _ => { return Err(__lookahead); } @@ -3578,11 +3599,11 @@ mod __parse__Expr { match __nt { __Nonterminal::Term(__nt) => { let __sym2 = &mut Some(__nt); - __result = try!(__state39(arena, __lookahead, __tokens, __sym2)); + __result = try!(__state38(arena, __lookahead, __tokens, __sym2)); } __Nonterminal::Factor(__nt) => { let __sym2 = &mut Some(__nt); - __result = try!(__state58(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); + __result = try!(__state57(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); } _ => { return Ok((__lookahead, __nt)); @@ -3593,34 +3614,12 @@ mod __parse__Expr { } // State 52 - // Expr = Expr "-" (*) Factor [")"] - // Expr = Expr "-" (*) Factor ["+"] - // Expr = Expr "-" (*) Factor [","] - // Expr = Expr "-" (*) Factor ["-"] - // Factor = (*) Factor "*" Term [")"] - // Factor = (*) Factor "*" Term ["*"] - // Factor = (*) Factor "*" Term ["+"] - // Factor = (*) Factor "*" Term [","] - // Factor = (*) Factor "*" Term ["-"] - // Factor = (*) Factor "*" Term ["/"] - // Factor = (*) Factor "/" Term [")"] - // Factor = (*) Factor "/" Term ["*"] - // Factor = (*) Factor "/" Term ["+"] - // Factor = (*) Factor "/" Term [","] - // Factor = (*) Factor "/" Term ["-"] - // Factor = (*) Factor "/" Term ["/"] - // Factor = (*) Term [")"] - // Factor = (*) Term ["*"] - // Factor = (*) Term ["+"] - // Factor = (*) Term [","] - // Factor = (*) Term ["-"] - // Factor = (*) Term ["/"] - // Factor = (*) "*" "(" Comma ")" [")"] - // Factor = (*) "*" "(" Comma ")" ["*"] - // Factor = (*) "*" "(" Comma ")" ["+"] - // Factor = (*) "*" "(" Comma ")" [","] - // Factor = (*) "*" "(" Comma ")" ["-"] - // Factor = (*) "*" "(" Comma ")" ["/"] + // Factor = Factor "/" (*) Term [")"] + // Factor = Factor "/" (*) Term ["*"] + // Factor = Factor "/" (*) Term ["+"] + // Factor = Factor "/" (*) Term [","] + // Factor = Factor "/" (*) Term ["-"] + // Factor = Factor "/" (*) Term ["/"] // Term = (*) "(" Expr ")" [")"] // Term = (*) "(" Expr ")" ["*"] // Term = (*) "(" Expr ")" ["+"] @@ -3634,39 +3633,32 @@ mod __parse__Expr { // Term = (*) "Num" ["-"] // Term = (*) "Num" ["/"] // - // "Num" -> Shift(S44) - // "*" -> Shift(S41) - // "(" -> Shift(S37) + // "(" -> Shift(S39) + // "Num" -> Shift(S45) // - // Factor -> S59 - // Term -> S39 + // Term -> S58 pub fn __state52< 'ast, - __TOKENS: Iterator, + __TOKENS: Iterator, >( arena: &'ast Arena<'ast>, - mut __lookahead: Option, + mut __lookahead: Option<(usize,Tok,usize)>, __tokens: &mut __TOKENS, __sym0: &mut Option<&'ast Node<'ast>>, __sym1: &mut Option, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> + ) -> Result<(Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> { - let mut __result: (Option, __Nonterminal<'ast, >); + let mut __result: (Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some(Tok::Num(__tok0)) => { + Some((_, __tok @ Tok::LParen(..), _)) => { + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state39(arena, __lookahead, __tokens, __sym2)); + } + Some((_, Tok::Num(__tok0), _)) => { let mut __sym2 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state44(arena, __lookahead, __tokens, __sym2)); - } - Some(__tok @ Tok::Times(..)) => { - let mut __sym2 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state41(arena, __lookahead, __tokens, __sym2)); - } - Some(__tok @ Tok::LParen(..)) => { - let mut __sym2 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state37(arena, __lookahead, __tokens, __sym2)); + __result = try!(__state45(arena, __lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); @@ -3675,13 +3667,9 @@ mod __parse__Expr { while __sym1.is_some() { let (__lookahead, __nt) = __result; match __nt { - __Nonterminal::Factor(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state59(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); - } __Nonterminal::Term(__nt) => { let __sym2 = &mut Some(__nt); - __result = try!(__state39(arena, __lookahead, __tokens, __sym2)); + __result = try!(__state58(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); } _ => { return Ok((__lookahead, __nt)); @@ -3692,57 +3680,69 @@ mod __parse__Expr { } // State 53 - // ( ",") = Expr "," (*) ["("] - // ( ",") = Expr "," (*) [")"] - // ( ",") = Expr "," (*) ["*"] - // ( ",") = Expr "," (*) ["Num"] + // 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" ["/"] // - // ")" -> Reduce(( ",") = Expr, "," => ActionFn(15);) - // "Num" -> Reduce(( ",") = Expr, "," => ActionFn(15);) - // "*" -> Reduce(( ",") = Expr, "," => ActionFn(15);) - // "(" -> Reduce(( ",") = Expr, "," => ActionFn(15);) + // "(" -> Shift(S39) + // "Num" -> Shift(S45) // + // Term -> S59 pub fn __state53< 'ast, - __TOKENS: Iterator, + __TOKENS: Iterator, >( arena: &'ast Arena<'ast>, - mut __lookahead: Option, + mut __lookahead: Option<(usize,Tok,usize)>, __tokens: &mut __TOKENS, __sym0: &mut Option<&'ast Node<'ast>>, __sym1: &mut Option, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> + ) -> Result<(Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> { - let mut __result: (Option, __Nonterminal<'ast, >); + let mut __result: (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::__action15(arena, __sym0, __sym1); - return Ok((__lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29(__nt))); + Some((_, __tok @ Tok::LParen(..), _)) => { + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state39(arena, __lookahead, __tokens, __sym2)); } - Some(Tok::Num(_)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __nt = super::__actions::__action15(arena, __sym0, __sym1); - return Ok((__lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29(__nt))); - } - Some(Tok::Times(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __nt = super::__actions::__action15(arena, __sym0, __sym1); - return Ok((__lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29(__nt))); - } - Some(Tok::LParen(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __nt = super::__actions::__action15(arena, __sym0, __sym1); - return Ok((__lookahead, __Nonterminal::_28_3cExpr_3e_20_22_2c_22_29(__nt))); + Some((_, Tok::Num(__tok0), _)) => { + let mut __sym2 = &mut Some((__tok0)); + let __lookahead = __tokens.next(); + __result = try!(__state45(arena, __lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); } } + while __sym1.is_some() { + let (__lookahead, __nt) = __result; + match __nt { + __Nonterminal::Term(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state59(arena, __lookahead, __tokens, __sym0, __sym1, __sym2)); + } + _ => { + return Ok((__lookahead, __nt)); + } + } + } + return Ok(__result); } // State 54 @@ -3753,63 +3753,63 @@ mod __parse__Expr { // Term = "(" Expr ")" (*) ["-"] // Term = "(" Expr ")" (*) ["/"] // - // ")" -> Reduce(Term = "(", Expr, ")" => ActionFn(9);) - // "/" -> Reduce(Term = "(", Expr, ")" => ActionFn(9);) - // "+" -> Reduce(Term = "(", Expr, ")" => ActionFn(9);) - // "," -> Reduce(Term = "(", Expr, ")" => ActionFn(9);) - // "-" -> Reduce(Term = "(", Expr, ")" => ActionFn(9);) - // "*" -> Reduce(Term = "(", Expr, ")" => ActionFn(9);) + // "," -> Reduce(Term = "(", Expr, ")" => 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 __state54< 'ast, - __TOKENS: Iterator, + __TOKENS: Iterator, >( arena: &'ast Arena<'ast>, - mut __lookahead: Option, + mut __lookahead: Option<(usize,Tok,usize)>, __tokens: &mut __TOKENS, __sym0: &mut Option, __sym1: &mut Option<&'ast Node<'ast>>, __sym2: &mut Option, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> + ) -> Result<(Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> { - let mut __result: (Option, __Nonterminal<'ast, >); + let mut __result: (Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some(Tok::RParen(..)) => { + Some((_, Tok::Comma(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); let __nt = super::__actions::__action9(arena, __sym0, __sym1, __sym2); return Ok((__lookahead, __Nonterminal::Term(__nt))); } - Some(Tok::Div(..)) => { + Some((_, Tok::Minus(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); let __nt = super::__actions::__action9(arena, __sym0, __sym1, __sym2); return Ok((__lookahead, __Nonterminal::Term(__nt))); } - Some(Tok::Plus(..)) => { + Some((_, Tok::Plus(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); let __nt = super::__actions::__action9(arena, __sym0, __sym1, __sym2); return Ok((__lookahead, __Nonterminal::Term(__nt))); } - Some(Tok::Comma(..)) => { + Some((_, Tok::Div(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); let __nt = super::__actions::__action9(arena, __sym0, __sym1, __sym2); return Ok((__lookahead, __Nonterminal::Term(__nt))); } - Some(Tok::Minus(..)) => { + Some((_, Tok::RParen(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); let __nt = super::__actions::__action9(arena, __sym0, __sym1, __sym2); return Ok((__lookahead, __Nonterminal::Term(__nt))); } - Some(Tok::Times(..)) => { + Some((_, Tok::Times(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); @@ -3823,160 +3823,6 @@ mod __parse__Expr { } // State 55 - // Factor = Factor "/" Term (*) [")"] - // Factor = Factor "/" Term (*) ["*"] - // Factor = Factor "/" Term (*) ["+"] - // Factor = Factor "/" Term (*) [","] - // Factor = Factor "/" Term (*) ["-"] - // Factor = Factor "/" Term (*) ["/"] - // - // "," -> Reduce(Factor = Factor, "/", Term => ActionFn(5);) - // "+" -> Reduce(Factor = Factor, "/", Term => ActionFn(5);) - // "-" -> Reduce(Factor = Factor, "/", Term => ActionFn(5);) - // "/" -> Reduce(Factor = Factor, "/", Term => ActionFn(5);) - // "*" -> Reduce(Factor = Factor, "/", Term => ActionFn(5);) - // ")" -> Reduce(Factor = Factor, "/", Term => ActionFn(5);) - // - pub fn __state55< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - mut __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, - __sym2: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> - { - let mut __result: (Option, __Nonterminal<'ast, >); - match __lookahead { - Some(Tok::Comma(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action5(arena, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Plus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action5(arena, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Minus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action5(arena, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Div(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action5(arena, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Times(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action5(arena, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::RParen(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action5(arena, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 56 - // Factor = Factor "*" Term (*) [")"] - // Factor = Factor "*" Term (*) ["*"] - // Factor = Factor "*" Term (*) ["+"] - // Factor = Factor "*" Term (*) [","] - // Factor = Factor "*" Term (*) ["-"] - // Factor = Factor "*" Term (*) ["/"] - // - // "*" -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) - // "-" -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) - // "," -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) - // "/" -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) - // "+" -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) - // ")" -> Reduce(Factor = Factor, "*", Term => ActionFn(4);) - // - pub fn __state56< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - mut __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, - __sym2: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> - { - let mut __result: (Option, __Nonterminal<'ast, >); - match __lookahead { - Some(Tok::Times(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Minus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Comma(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Div(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::Plus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - Some(Tok::RParen(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action4(arena, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Factor(__nt))); - } - _ => { - return Err(__lookahead); - } - } - } - - // State 57 // Factor = "*" "(" Comma (*) ")" [")"] // Factor = "*" "(" Comma (*) ")" ["*"] // Factor = "*" "(" Comma (*) ")" ["+"] @@ -3986,22 +3832,22 @@ mod __parse__Expr { // // ")" -> Shift(S60) // - pub fn __state57< + pub fn __state55< 'ast, - __TOKENS: Iterator, + __TOKENS: Iterator, >( arena: &'ast Arena<'ast>, - mut __lookahead: Option, + mut __lookahead: Option<(usize,Tok,usize)>, __tokens: &mut __TOKENS, __sym0: &mut Option, __sym1: &mut Option, __sym2: &mut Option>>, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> + ) -> Result<(Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> { - let mut __result: (Option, __Nonterminal<'ast, >); + let mut __result: (Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some(__tok @ Tok::RParen(..)) => { - let mut __sym3 = &mut Some(__tok); + Some((_, __tok @ Tok::RParen(..), _)) => { + let mut __sym3 = &mut Some((__tok)); let __lookahead = __tokens.next(); __result = try!(__state60(arena, __lookahead, __tokens, __sym0, __sym1, __sym2, __sym3)); } @@ -4012,91 +3858,7 @@ mod __parse__Expr { return Ok(__result); } - // State 58 - // Expr = Expr "+" Factor (*) [")"] - // Expr = Expr "+" Factor (*) ["+"] - // Expr = Expr "+" Factor (*) [","] - // Expr = Expr "+" Factor (*) ["-"] - // Factor = Factor (*) "*" Term [")"] - // Factor = Factor (*) "*" Term ["*"] - // Factor = Factor (*) "*" Term ["+"] - // Factor = Factor (*) "*" Term [","] - // Factor = Factor (*) "*" Term ["-"] - // Factor = Factor (*) "*" Term ["/"] - // Factor = Factor (*) "/" Term [")"] - // Factor = Factor (*) "/" Term ["*"] - // Factor = Factor (*) "/" Term ["+"] - // Factor = Factor (*) "/" Term [","] - // Factor = Factor (*) "/" Term ["-"] - // Factor = Factor (*) "/" Term ["/"] - // - // "," -> Reduce(Expr = Expr, "+", Factor => ActionFn(2);) - // ")" -> Reduce(Expr = Expr, "+", Factor => ActionFn(2);) - // "/" -> Shift(S48) - // "*" -> Shift(S49) - // "+" -> Reduce(Expr = Expr, "+", Factor => ActionFn(2);) - // "-" -> Reduce(Expr = Expr, "+", Factor => ActionFn(2);) - // - pub fn __state58< - 'ast, - __TOKENS: Iterator, - >( - arena: &'ast Arena<'ast>, - mut __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option<&'ast Node<'ast>>, - __sym1: &mut Option, - __sym2: &mut Option<&'ast Node<'ast>>, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> - { - let mut __result: (Option, __Nonterminal<'ast, >); - match __lookahead { - Some(__tok @ Tok::Div(..)) => { - let mut __sym3 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state48(arena, __lookahead, __tokens, __sym2, __sym3)); - } - Some(__tok @ Tok::Times(..)) => { - let mut __sym3 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state49(arena, __lookahead, __tokens, __sym2, __sym3)); - } - Some(Tok::Comma(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action2(arena, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Expr(__nt))); - } - Some(Tok::RParen(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action2(arena, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Expr(__nt))); - } - Some(Tok::Plus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action2(arena, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Expr(__nt))); - } - Some(Tok::Minus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action2(arena, __sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::Expr(__nt))); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 59 + // State 56 // Expr = Expr "-" Factor (*) [")"] // Expr = Expr "-" Factor (*) ["+"] // Expr = Expr "-" Factor (*) [","] @@ -4114,59 +3876,59 @@ mod __parse__Expr { // Factor = Factor (*) "/" Term ["-"] // Factor = Factor (*) "/" Term ["/"] // - // ")" -> Reduce(Expr = Expr, "-", Factor => ActionFn(1);) - // "+" -> Reduce(Expr = Expr, "-", Factor => ActionFn(1);) - // "*" -> Shift(S49) - // "/" -> Shift(S48) - // "," -> Reduce(Expr = Expr, "-", Factor => ActionFn(1);) - // "-" -> Reduce(Expr = Expr, "-", Factor => ActionFn(1);) + // "+" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // "/" -> Shift(S52) + // "-" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // ")" -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // "," -> Reduce(Expr = Expr, "-", Factor => Call(ActionFn(1));) + // "*" -> Shift(S53) // - pub fn __state59< + pub fn __state56< 'ast, - __TOKENS: Iterator, + __TOKENS: Iterator, >( arena: &'ast Arena<'ast>, - mut __lookahead: Option, + mut __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, __Nonterminal<'ast, >), Option> + ) -> Result<(Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> { - let mut __result: (Option, __Nonterminal<'ast, >); + let mut __result: (Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some(__tok @ Tok::Times(..)) => { - let mut __sym3 = &mut Some(__tok); + Some((_, __tok @ Tok::Div(..), _)) => { + let mut __sym3 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state49(arena, __lookahead, __tokens, __sym2, __sym3)); + __result = try!(__state52(arena, __lookahead, __tokens, __sym2, __sym3)); } - Some(__tok @ Tok::Div(..)) => { - let mut __sym3 = &mut Some(__tok); + Some((_, __tok @ Tok::Times(..), _)) => { + let mut __sym3 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state48(arena, __lookahead, __tokens, __sym2, __sym3)); + __result = try!(__state53(arena, __lookahead, __tokens, __sym2, __sym3)); } - Some(Tok::RParen(..)) => { + Some((_, Tok::Plus(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); let __nt = super::__actions::__action1(arena, __sym0, __sym1, __sym2); return Ok((__lookahead, __Nonterminal::Expr(__nt))); } - Some(Tok::Plus(..)) => { + Some((_, Tok::Minus(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); let __nt = super::__actions::__action1(arena, __sym0, __sym1, __sym2); return Ok((__lookahead, __Nonterminal::Expr(__nt))); } - Some(Tok::Comma(..)) => { + Some((_, Tok::RParen(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); let __nt = super::__actions::__action1(arena, __sym0, __sym1, __sym2); return Ok((__lookahead, __Nonterminal::Expr(__nt))); } - Some(Tok::Minus(..)) => { + Some((_, Tok::Comma(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); @@ -4180,6 +3942,244 @@ mod __parse__Expr { return Ok(__result); } + // State 57 + // Expr = Expr "+" Factor (*) [")"] + // Expr = Expr "+" Factor (*) ["+"] + // Expr = Expr "+" Factor (*) [","] + // Expr = Expr "+" Factor (*) ["-"] + // Factor = Factor (*) "*" Term [")"] + // Factor = Factor (*) "*" Term ["*"] + // Factor = Factor (*) "*" Term ["+"] + // Factor = Factor (*) "*" Term [","] + // Factor = Factor (*) "*" Term ["-"] + // Factor = Factor (*) "*" Term ["/"] + // Factor = Factor (*) "/" Term [")"] + // Factor = Factor (*) "/" Term ["*"] + // Factor = Factor (*) "/" Term ["+"] + // Factor = Factor (*) "/" Term [","] + // Factor = Factor (*) "/" Term ["-"] + // Factor = Factor (*) "/" Term ["/"] + // + // ")" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) + // "+" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) + // "-" -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) + // "*" -> Shift(S53) + // "," -> Reduce(Expr = Expr, "+", Factor => Call(ActionFn(2));) + // "/" -> Shift(S52) + // + pub fn __state57< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + mut __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<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); + match __lookahead { + Some((_, __tok @ Tok::Times(..), _)) => { + let mut __sym3 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state53(arena, __lookahead, __tokens, __sym2, __sym3)); + } + Some((_, __tok @ Tok::Div(..), _)) => { + let mut __sym3 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state52(arena, __lookahead, __tokens, __sym2, __sym3)); + } + Some((_, Tok::RParen(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action2(arena, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Expr(__nt))); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action2(arena, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Expr(__nt))); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action2(arena, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Expr(__nt))); + } + Some((_, Tok::Comma(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action2(arena, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Expr(__nt))); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + + // State 58 + // Factor = Factor "/" Term (*) [")"] + // Factor = Factor "/" Term (*) ["*"] + // Factor = Factor "/" Term (*) ["+"] + // Factor = Factor "/" Term (*) [","] + // Factor = Factor "/" Term (*) ["-"] + // Factor = Factor "/" Term (*) ["/"] + // + // "/" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // "+" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // "-" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // "," -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // ")" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // "*" -> Reduce(Factor = Factor, "/", Term => Call(ActionFn(5));) + // + pub fn __state58< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + mut __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<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (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((__lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action5(arena, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Minus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action5(arena, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Comma(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action5(arena, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::RParen(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action5(arena, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Times(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action5(arena, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + + // State 59 + // Factor = Factor "*" Term (*) [")"] + // Factor = Factor "*" Term (*) ["*"] + // Factor = Factor "*" Term (*) ["+"] + // Factor = Factor "*" Term (*) [","] + // Factor = Factor "*" Term (*) ["-"] + // Factor = Factor "*" Term (*) ["/"] + // + // "-" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // "," -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // "+" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // "/" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // ")" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // "*" -> Reduce(Factor = Factor, "*", Term => Call(ActionFn(4));) + // + pub fn __state59< + 'ast, + __TOKENS: Iterator, + >( + arena: &'ast Arena<'ast>, + mut __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<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> + { + let mut __result: (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((__lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Comma(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action4(arena, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Plus(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action4(arena, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Div(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action4(arena, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::RParen(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action4(arena, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + Some((_, Tok::Times(..), _)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action4(arena, __sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::Factor(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } + // State 60 // Factor = "*" "(" Comma ")" (*) [")"] // Factor = "*" "(" Comma ")" (*) ["*"] @@ -4188,29 +4188,29 @@ mod __parse__Expr { // Factor = "*" "(" Comma ")" (*) ["-"] // Factor = "*" "(" Comma ")" (*) ["/"] // - // "*" -> Reduce(Factor = "*", "(", Comma, ")" => ActionFn(6);) - // "+" -> Reduce(Factor = "*", "(", Comma, ")" => ActionFn(6);) - // "/" -> Reduce(Factor = "*", "(", Comma, ")" => ActionFn(6);) - // ")" -> Reduce(Factor = "*", "(", Comma, ")" => ActionFn(6);) - // "-" -> Reduce(Factor = "*", "(", Comma, ")" => ActionFn(6);) - // "," -> Reduce(Factor = "*", "(", Comma, ")" => ActionFn(6);) + // "-" -> Reduce(Factor = "*", "(", Comma, ")" => 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, - __TOKENS: Iterator, + __TOKENS: Iterator, >( arena: &'ast Arena<'ast>, - mut __lookahead: Option, + mut __lookahead: Option<(usize,Tok,usize)>, __tokens: &mut __TOKENS, __sym0: &mut Option, __sym1: &mut Option, __sym2: &mut Option>>, __sym3: &mut Option, - ) -> Result<(Option, __Nonterminal<'ast, >), Option> + ) -> Result<(Option<(usize,Tok,usize)>, __Nonterminal<'ast, >), Option<(usize,Tok,usize)>> { - let mut __result: (Option, __Nonterminal<'ast, >); + let mut __result: (Option<(usize,Tok,usize)>, __Nonterminal<'ast, >); match __lookahead { - Some(Tok::Times(..)) => { + Some((_, Tok::Minus(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); @@ -4218,7 +4218,7 @@ mod __parse__Expr { let __nt = super::__actions::__action6(arena, __sym0, __sym1, __sym2, __sym3); return Ok((__lookahead, __Nonterminal::Factor(__nt))); } - Some(Tok::Plus(..)) => { + Some((_, Tok::RParen(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); @@ -4226,7 +4226,7 @@ mod __parse__Expr { let __nt = super::__actions::__action6(arena, __sym0, __sym1, __sym2, __sym3); return Ok((__lookahead, __Nonterminal::Factor(__nt))); } - Some(Tok::Div(..)) => { + Some((_, Tok::Plus(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); @@ -4234,7 +4234,7 @@ mod __parse__Expr { let __nt = super::__actions::__action6(arena, __sym0, __sym1, __sym2, __sym3); return Ok((__lookahead, __Nonterminal::Factor(__nt))); } - Some(Tok::RParen(..)) => { + Some((_, Tok::Div(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); @@ -4242,7 +4242,7 @@ mod __parse__Expr { let __nt = super::__actions::__action6(arena, __sym0, __sym1, __sym2, __sym3); return Ok((__lookahead, __Nonterminal::Factor(__nt))); } - Some(Tok::Minus(..)) => { + Some((_, Tok::Times(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); @@ -4250,7 +4250,7 @@ mod __parse__Expr { let __nt = super::__actions::__action6(arena, __sym0, __sym1, __sym2, __sym3); return Ok((__lookahead, __Nonterminal::Factor(__nt))); } - Some(Tok::Comma(..)) => { + Some((_, Tok::Comma(..), _)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); diff --git a/lalrpop-test/src/main.rs b/lalrpop-test/src/main.rs index 3b07dad..241ea84 100644 --- a/lalrpop-test/src/main.rs +++ b/lalrpop-test/src/main.rs @@ -54,7 +54,7 @@ fn expr_arena_test1() { arena.alloc(Node::Value(22)), arena.alloc(Node::Value(3)))), arena.alloc(Node::Value(6)))); - util::test(|v| expr_arena::parse_Expr(&arena, v), "22 * 3 - 6", expected); + util::test_loc(|v| expr_arena::parse_Expr(&arena, v), "22 * 3 - 6", expected); } #[test] @@ -66,7 +66,7 @@ fn expr_arena_test2() { vec![arena.alloc(Node::Value(22)), arena.alloc(Node::Value(3)), arena.alloc(Node::Value(6))]));; - util::test(|v| expr_arena::parse_Expr(&arena, v), "*(22, 3, 6)", expected); - util::test(|v| expr_arena::parse_Expr(&arena, v), "*(22, 3, 6,)", expected); + util::test_loc(|v| expr_arena::parse_Expr(&arena, v), "*(22, 3, 6)", expected); + util::test_loc(|v| expr_arena::parse_Expr(&arena, v), "*(22, 3, 6,)", expected); } diff --git a/lalrpop-test/src/sub.rs b/lalrpop-test/src/sub.rs index 16a7ba8..e24225a 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), + ____S(i32), E(i32), T(i32), - ____S(i32), - S(i32), } // State 0 @@ -40,12 +40,12 @@ mod __parse__S { // T = (*) "Num" ["-"] // __S = (*) S [EOF] // - // "(" -> Shift(S5) // "Num" -> Shift(S4) + // "(" -> Shift(S5) // - // E -> S1 - // T -> S2 - // S -> S3 + // E -> S3 + // T -> S1 + // S -> S2 pub fn __state0< __TOKENS: Iterator, >( @@ -55,16 +55,16 @@ mod __parse__S { { let mut __result: (Option, __Nonterminal<>); match __lookahead { - Some(__tok @ Tok::LParen(..)) => { - let mut __sym0 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state5(__lookahead, __tokens, __sym0)); - } Some(Tok::Num(__tok0)) => { let mut __sym0 = &mut Some((__tok0)); let __lookahead = __tokens.next(); __result = try!(__state4(__lookahead, __tokens, __sym0)); } + Some(__tok @ Tok::LParen(..)) => { + let mut __sym0 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state5(__lookahead, __tokens, __sym0)); + } _ => { return Err(__lookahead); } @@ -74,15 +74,15 @@ mod __parse__S { match __nt { __Nonterminal::E(__nt) => { let __sym0 = &mut Some(__nt); - __result = try!(__state1(__lookahead, __tokens, __sym0)); + __result = try!(__state3(__lookahead, __tokens, __sym0)); } __Nonterminal::T(__nt) => { let __sym0 = &mut Some(__nt); - __result = try!(__state2(__lookahead, __tokens, __sym0)); + __result = try!(__state1(__lookahead, __tokens, __sym0)); } __Nonterminal::S(__nt) => { let __sym0 = &mut Some(__nt); - __result = try!(__state3(__lookahead, __tokens, __sym0)); + __result = try!(__state2(__lookahead, __tokens, __sym0)); } _ => { return Ok((__lookahead, __nt)); @@ -92,12 +92,11 @@ mod __parse__S { } // State 1 - // E = E (*) "-" T [EOF] - // E = E (*) "-" T ["-"] - // S = E (*) [EOF] + // E = T (*) [EOF] + // E = T (*) ["-"] // - // EOF -> Reduce(S = E => ActionFn(1);) - // "-" -> Shift(S6) + // EOF -> Reduce(E = T => Call(ActionFn(3));) + // "-" -> Reduce(E = T => Call(ActionFn(3));) // pub fn __state1< __TOKENS: Iterator, @@ -109,62 +108,28 @@ mod __parse__S { { let mut __result: (Option, __Nonterminal<>); match __lookahead { - Some(__tok @ Tok::Minus(..)) => { - let mut __sym1 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state6(__lookahead, __tokens, __sym0, __sym1)); - } None => { let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action1(__sym0); - return Ok((__lookahead, __Nonterminal::S(__nt))); + let __nt = super::__actions::__action3(__sym0); + return Ok((__lookahead, __Nonterminal::E(__nt))); } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - - // State 2 - // E = T (*) [EOF] - // E = T (*) ["-"] - // - // "-" -> Reduce(E = T => ActionFn(3);) - // EOF -> Reduce(E = T => ActionFn(3);) - // - pub fn __state2< - __TOKENS: Iterator, - >( - mut __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - ) -> Result<(Option, __Nonterminal<>), Option> - { - let mut __result: (Option, __Nonterminal<>); - match __lookahead { Some(Tok::Minus(..)) => { let __sym0 = __sym0.take().unwrap(); let __nt = super::__actions::__action3(__sym0); return Ok((__lookahead, __Nonterminal::E(__nt))); } - None => { - let __sym0 = __sym0.take().unwrap(); - let __nt = super::__actions::__action3(__sym0); - return Ok((__lookahead, __Nonterminal::E(__nt))); - } _ => { return Err(__lookahead); } } } - // State 3 + // State 2 // __S = S (*) [EOF] // - // EOF -> Reduce(__S = S => ActionFn(0);) + // EOF -> Reduce(__S = S => Call(ActionFn(0));) // - pub fn __state3< + pub fn __state2< __TOKENS: Iterator, >( mut __lookahead: Option, @@ -185,12 +150,47 @@ mod __parse__S { } } + // State 3 + // E = E (*) "-" T [EOF] + // E = E (*) "-" T ["-"] + // S = E (*) [EOF] + // + // EOF -> Reduce(S = E => Call(ActionFn(1));) + // "-" -> Shift(S6) + // + pub fn __state3< + __TOKENS: Iterator, + >( + mut __lookahead: Option, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + ) -> Result<(Option, __Nonterminal<>), Option> + { + let mut __result: (Option, __Nonterminal<>); + match __lookahead { + Some(__tok @ Tok::Minus(..)) => { + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state6(__lookahead, __tokens, __sym0, __sym1)); + } + None => { + let __sym0 = __sym0.take().unwrap(); + let __nt = super::__actions::__action1(__sym0); + return Ok((__lookahead, __Nonterminal::S(__nt))); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + // State 4 // T = "Num" (*) [EOF] // T = "Num" (*) ["-"] // - // "-" -> Reduce(T = "Num" => ActionFn(4);) - // EOF -> Reduce(T = "Num" => ActionFn(4);) + // EOF -> Reduce(T = "Num" => Call(ActionFn(4));) + // "-" -> Reduce(T = "Num" => Call(ActionFn(4));) // pub fn __state4< __TOKENS: Iterator, @@ -202,12 +202,12 @@ mod __parse__S { { let mut __result: (Option, __Nonterminal<>); match __lookahead { - Some(Tok::Minus(..)) => { + None => { let __sym0 = __sym0.take().unwrap(); let __nt = super::__actions::__action4(__sym0); return Ok((__lookahead, __Nonterminal::T(__nt))); } - None => { + Some(Tok::Minus(..)) => { let __sym0 = __sym0.take().unwrap(); let __nt = super::__actions::__action4(__sym0); return Ok((__lookahead, __Nonterminal::T(__nt))); @@ -233,8 +233,8 @@ mod __parse__S { // "(" -> Shift(S8) // "Num" -> Shift(S10) // - // T -> S7 - // E -> S9 + // T -> S9 + // E -> S7 pub fn __state5< __TOKENS: Iterator, >( @@ -246,7 +246,7 @@ mod __parse__S { let mut __result: (Option, __Nonterminal<>); match __lookahead { Some(__tok @ Tok::LParen(..)) => { - let mut __sym1 = &mut Some(__tok); + let mut __sym1 = &mut Some((__tok)); let __lookahead = __tokens.next(); __result = try!(__state8(__lookahead, __tokens, __sym1)); } @@ -264,11 +264,11 @@ mod __parse__S { match __nt { __Nonterminal::T(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state7(__lookahead, __tokens, __sym1)); + __result = try!(__state9(__lookahead, __tokens, __sym1)); } __Nonterminal::E(__nt) => { let __sym1 = &mut Some(__nt); - __result = try!(__state9(__lookahead, __tokens, __sym0, __sym1)); + __result = try!(__state7(__lookahead, __tokens, __sym0, __sym1)); } _ => { return Ok((__lookahead, __nt)); @@ -286,8 +286,8 @@ mod __parse__S { // T = (*) "Num" [EOF] // T = (*) "Num" ["-"] // - // "Num" -> Shift(S4) // "(" -> Shift(S5) + // "Num" -> Shift(S4) // // T -> S11 pub fn __state6< @@ -301,16 +301,16 @@ mod __parse__S { { let mut __result: (Option, __Nonterminal<>); match __lookahead { + Some(__tok @ Tok::LParen(..)) => { + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state5(__lookahead, __tokens, __sym2)); + } Some(Tok::Num(__tok0)) => { let mut __sym2 = &mut Some((__tok0)); let __lookahead = __tokens.next(); __result = try!(__state4(__lookahead, __tokens, __sym2)); } - Some(__tok @ Tok::LParen(..)) => { - let mut __sym2 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state5(__lookahead, __tokens, __sym2)); - } _ => { return Err(__lookahead); } @@ -331,13 +331,110 @@ mod __parse__S { } // State 7 + // E = E (*) "-" T [")"] + // E = E (*) "-" T ["-"] + // T = "(" E (*) ")" [EOF] + // T = "(" E (*) ")" ["-"] + // + // "-" -> Shift(S12) + // ")" -> Shift(S13) + // + pub fn __state7< + __TOKENS: Iterator, + >( + mut __lookahead: Option, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + __sym1: &mut Option, + ) -> Result<(Option, __Nonterminal<>), Option> + { + let mut __result: (Option, __Nonterminal<>); + match __lookahead { + Some(__tok @ Tok::Minus(..)) => { + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state12(__lookahead, __tokens, __sym1, __sym2)); + } + Some(__tok @ Tok::RParen(..)) => { + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state13(__lookahead, __tokens, __sym0, __sym1, __sym2)); + } + _ => { + return Err(__lookahead); + } + } + return Ok(__result); + } + + // State 8 + // E = (*) E "-" T [")"] + // E = (*) E "-" T ["-"] + // E = (*) T [")"] + // E = (*) T ["-"] + // T = (*) "(" E ")" [")"] + // T = (*) "(" E ")" ["-"] + // T = "(" (*) E ")" [")"] + // T = "(" (*) E ")" ["-"] + // T = (*) "Num" [")"] + // T = (*) "Num" ["-"] + // + // "(" -> Shift(S8) + // "Num" -> Shift(S10) + // + // T -> S9 + // E -> S14 + pub fn __state8< + __TOKENS: Iterator, + >( + mut __lookahead: Option, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + ) -> Result<(Option, __Nonterminal<>), Option> + { + let mut __result: (Option, __Nonterminal<>); + match __lookahead { + Some(__tok @ Tok::LParen(..)) => { + let mut __sym1 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state8(__lookahead, __tokens, __sym1)); + } + Some(Tok::Num(__tok0)) => { + let mut __sym1 = &mut Some((__tok0)); + let __lookahead = __tokens.next(); + __result = try!(__state10(__lookahead, __tokens, __sym1)); + } + _ => { + return Err(__lookahead); + } + } + while __sym0.is_some() { + let (__lookahead, __nt) = __result; + match __nt { + __Nonterminal::T(__nt) => { + let __sym1 = &mut Some(__nt); + __result = try!(__state9(__lookahead, __tokens, __sym1)); + } + __Nonterminal::E(__nt) => { + let __sym1 = &mut Some(__nt); + __result = try!(__state14(__lookahead, __tokens, __sym0, __sym1)); + } + _ => { + return Ok((__lookahead, __nt)); + } + } + } + return Ok(__result); + } + + // State 9 // E = T (*) [")"] // E = T (*) ["-"] // - // ")" -> Reduce(E = T => ActionFn(3);) - // "-" -> Reduce(E = T => ActionFn(3);) + // ")" -> Reduce(E = T => Call(ActionFn(3));) + // "-" -> Reduce(E = T => Call(ActionFn(3));) // - pub fn __state7< + pub fn __state9< __TOKENS: Iterator, >( mut __lookahead: Option, @@ -363,109 +460,12 @@ mod __parse__S { } } - // State 8 - // E = (*) E "-" T [")"] - // E = (*) E "-" T ["-"] - // E = (*) T [")"] - // E = (*) T ["-"] - // T = (*) "(" E ")" [")"] - // T = (*) "(" E ")" ["-"] - // T = "(" (*) E ")" [")"] - // T = "(" (*) E ")" ["-"] - // T = (*) "Num" [")"] - // T = (*) "Num" ["-"] - // - // "Num" -> Shift(S10) - // "(" -> Shift(S8) - // - // E -> S12 - // T -> S7 - pub fn __state8< - __TOKENS: Iterator, - >( - mut __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - ) -> Result<(Option, __Nonterminal<>), Option> - { - let mut __result: (Option, __Nonterminal<>); - match __lookahead { - Some(Tok::Num(__tok0)) => { - let mut __sym1 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state10(__lookahead, __tokens, __sym1)); - } - Some(__tok @ Tok::LParen(..)) => { - let mut __sym1 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state8(__lookahead, __tokens, __sym1)); - } - _ => { - return Err(__lookahead); - } - } - while __sym0.is_some() { - let (__lookahead, __nt) = __result; - match __nt { - __Nonterminal::E(__nt) => { - let __sym1 = &mut Some(__nt); - __result = try!(__state12(__lookahead, __tokens, __sym0, __sym1)); - } - __Nonterminal::T(__nt) => { - let __sym1 = &mut Some(__nt); - __result = try!(__state7(__lookahead, __tokens, __sym1)); - } - _ => { - return Ok((__lookahead, __nt)); - } - } - } - return Ok(__result); - } - - // State 9 - // E = E (*) "-" T [")"] - // E = E (*) "-" T ["-"] - // T = "(" E (*) ")" [EOF] - // T = "(" E (*) ")" ["-"] - // - // "-" -> Shift(S14) - // ")" -> Shift(S13) - // - pub fn __state9< - __TOKENS: Iterator, - >( - mut __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option, - ) -> Result<(Option, __Nonterminal<>), Option> - { - let mut __result: (Option, __Nonterminal<>); - match __lookahead { - Some(__tok @ Tok::Minus(..)) => { - let mut __sym2 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state14(__lookahead, __tokens, __sym1, __sym2)); - } - Some(__tok @ Tok::RParen(..)) => { - let mut __sym2 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state13(__lookahead, __tokens, __sym0, __sym1, __sym2)); - } - _ => { - return Err(__lookahead); - } - } - return Ok(__result); - } - // State 10 // T = "Num" (*) [")"] // T = "Num" (*) ["-"] // - // ")" -> Reduce(T = "Num" => ActionFn(4);) - // "-" -> Reduce(T = "Num" => ActionFn(4);) + // ")" -> Reduce(T = "Num" => Call(ActionFn(4));) + // "-" -> Reduce(T = "Num" => Call(ActionFn(4));) // pub fn __state10< __TOKENS: Iterator, @@ -497,8 +497,8 @@ mod __parse__S { // E = E "-" T (*) [EOF] // E = E "-" T (*) ["-"] // - // "-" -> Reduce(E = E, "-", T => ActionFn(2);) - // EOF -> Reduce(E = E, "-", T => ActionFn(2);) + // EOF -> Reduce(E = E, "-", T => Call(ActionFn(2));) + // "-" -> Reduce(E = E, "-", T => Call(ActionFn(2));) // pub fn __state11< __TOKENS: Iterator, @@ -512,14 +512,14 @@ mod __parse__S { { let mut __result: (Option, __Nonterminal<>); match __lookahead { - Some(Tok::Minus(..)) => { + None => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); let __nt = super::__actions::__action2(__sym0, __sym1, __sym2); return Ok((__lookahead, __Nonterminal::E(__nt))); } - None => { + Some(Tok::Minus(..)) => { let __sym0 = __sym0.take().unwrap(); let __sym1 = __sym1.take().unwrap(); let __sym2 = __sym2.take().unwrap(); @@ -533,39 +533,54 @@ mod __parse__S { } // State 12 - // E = E (*) "-" T [")"] - // E = E (*) "-" T ["-"] - // T = "(" E (*) ")" [")"] - // T = "(" E (*) ")" ["-"] + // E = E "-" (*) T [")"] + // E = E "-" (*) T ["-"] + // T = (*) "(" E ")" [")"] + // T = (*) "(" E ")" ["-"] + // T = (*) "Num" [")"] + // T = (*) "Num" ["-"] // - // ")" -> Shift(S15) - // "-" -> Shift(S14) + // "Num" -> Shift(S10) + // "(" -> Shift(S8) // + // T -> S15 pub fn __state12< __TOKENS: Iterator, >( mut __lookahead: Option, __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option, + __sym0: &mut Option, + __sym1: &mut Option, ) -> Result<(Option, __Nonterminal<>), Option> { let mut __result: (Option, __Nonterminal<>); match __lookahead { - Some(__tok @ Tok::RParen(..)) => { - let mut __sym2 = &mut Some(__tok); + Some(Tok::Num(__tok0)) => { + let mut __sym2 = &mut Some((__tok0)); let __lookahead = __tokens.next(); - __result = try!(__state15(__lookahead, __tokens, __sym0, __sym1, __sym2)); + __result = try!(__state10(__lookahead, __tokens, __sym2)); } - Some(__tok @ Tok::Minus(..)) => { - let mut __sym2 = &mut Some(__tok); + Some(__tok @ Tok::LParen(..)) => { + let mut __sym2 = &mut Some((__tok)); let __lookahead = __tokens.next(); - __result = try!(__state14(__lookahead, __tokens, __sym1, __sym2)); + __result = try!(__state8(__lookahead, __tokens, __sym2)); } _ => { return Err(__lookahead); } } + while __sym1.is_some() { + let (__lookahead, __nt) = __result; + match __nt { + __Nonterminal::T(__nt) => { + let __sym2 = &mut Some(__nt); + __result = try!(__state15(__lookahead, __tokens, __sym0, __sym1, __sym2)); + } + _ => { + return Ok((__lookahead, __nt)); + } + } + } return Ok(__result); } @@ -573,8 +588,8 @@ mod __parse__S { // T = "(" E ")" (*) [EOF] // T = "(" E ")" (*) ["-"] // - // "-" -> Reduce(T = "(", E, ")" => ActionFn(5);) - // EOF -> Reduce(T = "(", E, ")" => ActionFn(5);) + // "-" -> Reduce(T = "(", E, ")" => Call(ActionFn(5));) + // EOF -> Reduce(T = "(", E, ")" => Call(ActionFn(5));) // pub fn __state13< __TOKENS: Iterator, @@ -609,104 +624,50 @@ mod __parse__S { } // State 14 - // E = E "-" (*) T [")"] - // E = E "-" (*) T ["-"] - // T = (*) "(" E ")" [")"] - // T = (*) "(" E ")" ["-"] - // T = (*) "Num" [")"] - // T = (*) "Num" ["-"] + // E = E (*) "-" T [")"] + // E = E (*) "-" T ["-"] + // T = "(" E (*) ")" [")"] + // T = "(" E (*) ")" ["-"] // - // "Num" -> Shift(S10) - // "(" -> Shift(S8) + // "-" -> Shift(S12) + // ")" -> Shift(S16) // - // T -> S16 pub fn __state14< __TOKENS: Iterator, - >( - mut __lookahead: Option, - __tokens: &mut __TOKENS, - __sym0: &mut Option, - __sym1: &mut Option, - ) -> Result<(Option, __Nonterminal<>), Option> - { - let mut __result: (Option, __Nonterminal<>); - match __lookahead { - Some(Tok::Num(__tok0)) => { - let mut __sym2 = &mut Some((__tok0)); - let __lookahead = __tokens.next(); - __result = try!(__state10(__lookahead, __tokens, __sym2)); - } - Some(__tok @ Tok::LParen(..)) => { - let mut __sym2 = &mut Some(__tok); - let __lookahead = __tokens.next(); - __result = try!(__state8(__lookahead, __tokens, __sym2)); - } - _ => { - return Err(__lookahead); - } - } - while __sym1.is_some() { - let (__lookahead, __nt) = __result; - match __nt { - __Nonterminal::T(__nt) => { - let __sym2 = &mut Some(__nt); - __result = try!(__state16(__lookahead, __tokens, __sym0, __sym1, __sym2)); - } - _ => { - return Ok((__lookahead, __nt)); - } - } - } - return Ok(__result); - } - - // State 15 - // T = "(" E ")" (*) [")"] - // T = "(" E ")" (*) ["-"] - // - // ")" -> Reduce(T = "(", E, ")" => ActionFn(5);) - // "-" -> Reduce(T = "(", E, ")" => ActionFn(5);) - // - pub fn __state15< - __TOKENS: Iterator, >( mut __lookahead: Option, __tokens: &mut __TOKENS, __sym0: &mut Option, __sym1: &mut Option, - __sym2: &mut Option, ) -> Result<(Option, __Nonterminal<>), Option> { let mut __result: (Option, __Nonterminal<>); match __lookahead { - Some(Tok::RParen(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action5(__sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::T(__nt))); + Some(__tok @ Tok::Minus(..)) => { + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state12(__lookahead, __tokens, __sym1, __sym2)); } - Some(Tok::Minus(..)) => { - let __sym0 = __sym0.take().unwrap(); - let __sym1 = __sym1.take().unwrap(); - let __sym2 = __sym2.take().unwrap(); - let __nt = super::__actions::__action5(__sym0, __sym1, __sym2); - return Ok((__lookahead, __Nonterminal::T(__nt))); + Some(__tok @ Tok::RParen(..)) => { + let mut __sym2 = &mut Some((__tok)); + let __lookahead = __tokens.next(); + __result = try!(__state16(__lookahead, __tokens, __sym0, __sym1, __sym2)); } _ => { return Err(__lookahead); } } + return Ok(__result); } - // State 16 + // State 15 // E = E "-" T (*) [")"] // E = E "-" T (*) ["-"] // - // "-" -> Reduce(E = E, "-", T => ActionFn(2);) - // ")" -> Reduce(E = E, "-", T => ActionFn(2);) + // "-" -> Reduce(E = E, "-", T => Call(ActionFn(2));) + // ")" -> Reduce(E = E, "-", T => Call(ActionFn(2));) // - pub fn __state16< + pub fn __state15< __TOKENS: Iterator, >( mut __lookahead: Option, @@ -737,6 +698,45 @@ mod __parse__S { } } } + + // State 16 + // T = "(" E ")" (*) [")"] + // T = "(" E ")" (*) ["-"] + // + // "-" -> Reduce(T = "(", E, ")" => Call(ActionFn(5));) + // ")" -> Reduce(T = "(", E, ")" => Call(ActionFn(5));) + // + pub fn __state16< + __TOKENS: Iterator, + >( + mut __lookahead: Option, + __tokens: &mut __TOKENS, + __sym0: &mut Option, + __sym1: &mut Option, + __sym2: &mut Option, + ) -> Result<(Option, __Nonterminal<>), Option> + { + let mut __result: (Option, __Nonterminal<>); + match __lookahead { + Some(Tok::Minus(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action5(__sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::T(__nt))); + } + Some(Tok::RParen(..)) => { + let __sym0 = __sym0.take().unwrap(); + let __sym1 = __sym1.take().unwrap(); + let __sym2 = __sym2.take().unwrap(); + let __nt = super::__actions::__action5(__sym0, __sym1, __sym2); + return Ok((__lookahead, __Nonterminal::T(__nt))); + } + _ => { + return Err(__lookahead); + } + } + } } mod __actions { diff --git a/lalrpop-test/src/util/mod.rs b/lalrpop-test/src/util/mod.rs index 2e0cd09..3c4380e 100644 --- a/lalrpop-test/src/util/mod.rs +++ b/lalrpop-test/src/util/mod.rs @@ -14,6 +14,28 @@ pub fn test(parse_fn: F, // create tokens let tokens = tok::tokenize(input); + // filter to tokens + let tokens = tokens.into_iter().map(|(_, tok, _)| tok).collect(); + + // parse + let (lookahead, r) = parse_fn(tokens).unwrap(); + + // expect input to be completely consumed + assert!(lookahead.is_none(), "input not completely consumed"); + + // expect output to be correct + assert!(r == expected, "parsing {:?}, got {:#?}, expected {:#?}", input, r, expected); +} + +pub fn test_loc(parse_fn: F, + input: &str, + expected: R) + where F: FnOnce(Vec<(usize, Tok, usize)>) -> Result<(Option<(usize, Tok, usize)>,R), + Option<(usize, Tok, usize)>> +{ + // create tokens + let tokens = tok::tokenize(input); + // parse let (lookahead, r) = parse_fn(tokens).unwrap(); diff --git a/lalrpop-test/src/util/tok.rs b/lalrpop-test/src/util/tok.rs index 679385a..be1bfd8 100644 --- a/lalrpop-test/src/util/tok.rs +++ b/lalrpop-test/src/util/tok.rs @@ -13,25 +13,26 @@ pub enum Tok { } // simplest and stupidest possible tokenizer -pub fn tokenize(s: &str) -> Vec { +pub fn tokenize(s: &str) -> Vec<(usize, Tok, usize)> { let mut tokens = vec![]; - let mut chars = s.chars(); + let mut chars = s.char_indices(); let mut lookahead = chars.next(); - while let Some(c) = lookahead { + while let Some((pos, c)) = lookahead { // skip whitespace characters if !c.is_whitespace() { match c { - '(' => tokens.push(Tok::LParen), - ')' => tokens.push(Tok::RParen), - '-' => tokens.push(Tok::Minus), - '+' => tokens.push(Tok::Plus), - '*' => tokens.push(Tok::Times), - ',' => tokens.push(Tok::Comma), - '/' => tokens.push(Tok::Div), + '(' => tokens.push((pos, Tok::LParen, pos+1)), + ')' => tokens.push((pos, Tok::RParen, pos+1)), + '-' => tokens.push((pos, Tok::Minus, pos+1)), + '+' => tokens.push((pos, Tok::Plus, pos+1)), + '*' => tokens.push((pos, Tok::Times, pos+1)), + ',' => tokens.push((pos, Tok::Comma, pos+1)), + '/' => tokens.push((pos, Tok::Div, pos+1)), _ if c.is_digit(10) => { let (tmp, next) = take_while(c, &mut chars, |c| c.is_digit(10)); lookahead = next; - tokens.push(Tok::Num(i32::from_str(&tmp).unwrap())); + let end = lookahead.map(|(pos, _)| pos).unwrap_or(s.len()); + tokens.push((pos, Tok::Num(i32::from_str(&tmp).unwrap()), end)); continue; } _ => { @@ -46,16 +47,16 @@ pub fn tokenize(s: &str) -> Vec { tokens } -fn take_while(c0: char, chars: &mut C, f: F) -> (String, Option) - where C: Iterator, F: Fn(char) -> bool +fn take_while(c0: char, chars: &mut C, f: F) -> (String, Option<(usize, char)>) + where C: Iterator, F: Fn(char) -> bool { let mut buf = String::new(); buf.push(c0); - while let Some(c) = chars.next() { + while let Some((pos, c)) = chars.next() { if !f(c) { - return (buf, Some(c)); + return (buf, Some((pos, c))); } buf.push(c); diff --git a/lalrpop/src/grammar/repr.rs b/lalrpop/src/grammar/repr.rs index fd4e6ec..1f36fb6 100644 --- a/lalrpop/src/grammar/repr.rs +++ b/lalrpop/src/grammar/repr.rs @@ -72,7 +72,8 @@ pub enum Symbol { #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] pub enum ProductionAction { - Call(ActionFn) + // execute code provided by the user + Call(ActionFn), } #[derive(Clone, PartialEq, Eq)] @@ -133,6 +134,10 @@ impl Types { &self.terminal_enum_type } + pub fn opt_terminal_loc_type(&self) -> Option<&TypeRepr> { + self.terminal_loc_type.as_ref() + } + pub fn terminal_type(&self, id: TerminalString) -> &TypeRepr { self.terminal_types.get(&id).unwrap_or(&self.default_terminal_type) } diff --git a/lalrpop/src/lr1/ascent.rs b/lalrpop/src/lr1/ascent.rs index a179db9..5bf1b43 100644 --- a/lalrpop/src/lr1/ascent.rs +++ b/lalrpop/src/lr1/ascent.rs @@ -104,15 +104,15 @@ impl<'ascent,'grammar,W:Write> RecursiveAscent<'ascent,'grammar,W> { } fn write_start_fn(&mut self) -> io::Result<()> { - let terminal_type = self.types.terminal_enum_type(); + let item_type = self.iterator_item_type(); rust!(self.out, "#[allow(non_snake_case)]"); try!(self.out.write_pub_fn_header( self.grammar, format!("parse_{}", self.user_start_symbol), - vec![format!("{}TOKENS: IntoIterator", self.prefix, terminal_type)], + vec![format!("{}TOKENS: IntoIterator", self.prefix, item_type)], vec![format!("{}tokens: {}TOKENS", self.prefix, self.prefix)], format!("Result<(Option<{}>, {}), Option<{}>>", - terminal_type, self.types.nonterminal_type(self.start_symbol), terminal_type), + item_type, self.types.nonterminal_type(self.start_symbol), item_type), vec![])); rust!(self.out, "{{"); rust!(self.out, "let mut {}tokens = {}tokens.into_iter();", self.prefix, self.prefix); @@ -134,7 +134,7 @@ impl<'ascent,'grammar,W:Write> RecursiveAscent<'ascent,'grammar,W> { fn write_state_fn(&mut self, this_index: StateIndex) -> io::Result<()> { let this_state = &self.states[this_index.0]; let this_prefix = self.state_prefixes[this_index.0]; - let terminal_type = self.types.terminal_enum_type(); + let item_type = self.iterator_item_type(); // Leave a comment explaining what this state is. rust!(self.out, "// State {}", this_index.0); @@ -154,7 +154,7 @@ impl<'ascent,'grammar,W:Write> RecursiveAscent<'ascent,'grammar,W> { let mut fallthrough = false; let base_args = - vec![format!("mut {}lookahead: Option<{}>", self.prefix, terminal_type), + vec![format!("mut {}lookahead: Option<{}>", self.prefix, item_type), format!("{}tokens: &mut {}TOKENS", self.prefix, self.prefix)]; let sym_args: Vec<_> = (0..this_prefix.len()) @@ -165,17 +165,17 @@ impl<'ascent,'grammar,W:Write> RecursiveAscent<'ascent,'grammar,W> { try!(self.out.write_pub_fn_header( self.grammar, format!("{}state{}", self.prefix, this_index.0), - vec![format!("{}TOKENS: Iterator", self.prefix, terminal_type)], + vec![format!("{}TOKENS: Iterator", self.prefix, item_type)], base_args.into_iter().chain(sym_args).collect(), format!("Result<(Option<{}>, {}Nonterminal<{}>), Option<{}>>", - terminal_type, self.prefix, + item_type, self.prefix, self.grammar.user_type_parameter_refs(), - terminal_type), + item_type), vec![])); rust!(self.out, "{{"); rust!(self.out, "let mut {}result: (Option<{}>, {}Nonterminal<{}>);", - self.prefix, terminal_type, self.prefix, self.grammar.user_type_parameter_refs()); + self.prefix, item_type, self.prefix, self.grammar.user_type_parameter_refs()); rust!(self.out, "match {}lookahead {{", self.prefix); @@ -343,7 +343,13 @@ impl<'ascent,'grammar,W:Write> RecursiveAscent<'ascent,'grammar,W> { /// Emit a pattern that matches `id` but doesn't extract any data. fn match_terminal(&mut self, id: TerminalString) -> io::Result<()> { let pattern = self.grammar.pattern(id) - .map(&mut |_| "_"); + .map(&mut |_| "_"); + + let mut pattern = format!("{}", pattern); + if self.types.opt_terminal_loc_type().is_some() { + pattern = format!("(_, {}, _)", pattern); + } + rust!(self.out, "Some({}) => {{", pattern); Ok(()) } @@ -358,17 +364,38 @@ impl<'ascent,'grammar,W:Write> RecursiveAscent<'ascent,'grammar,W> { pattern_names.last().cloned().unwrap() }); + let mut pattern = format!("{}", pattern); if pattern_names.is_empty() { - rust!(self.out, "Some({}tok @ {}) => {{", self.prefix, pattern); - rust!(self.out, "let mut {} = &mut Some({}tok);", - let_name, self.prefix); - } else { - rust!(self.out, "Some({}) => {{", pattern); - rust!(self.out, "let mut {} = &mut Some(({}));", - let_name, pattern_names.connect(", ")); + pattern_names.push(format!("{}tok", self.prefix)); + pattern = format!("{}tok @ {}", self.prefix, pattern); } + if self.types.opt_terminal_loc_type().is_some() { + pattern = format!("(_, {}, _)", pattern); + } + + rust!(self.out, "Some({}) => {{", pattern); + rust!(self.out, "let mut {} = &mut Some(({}));", + let_name, pattern_names.connect(", ")); Ok(()) } + + /// Returns the type of things we are iterating over. This will + /// depend on whether the user specified a location type `L` + /// or just an enum type `E`: + /// + /// - `(L,E,L)` if a location type is specified, + /// - `E` otherwise. + fn iterator_item_type(&mut self) -> String { + let enum_type = self.types.terminal_enum_type(); + match self.types.opt_terminal_loc_type() { + Some(loc_type) => { + format!("({},{},{})", loc_type, enum_type, loc_type) + } + None => { + format!("{}", enum_type) + } + } + } }