// $ANTLR start "add" // antlr_temp_dir\\MathExpr.g:83:1: add : mult ( ( ADD | SUB ) mult )* ; public MathExprParser.add_return add() // throws RecognitionException [1] { MathExprParser.add_return retval = new MathExprParser.add_return(); retval.Start = input.LT(1); object root_0 = null; IToken set10 = null; MathExprParser.mult_return mult9 = default(MathExprParser.mult_return); MathExprParser.mult_return mult11 = default(MathExprParser.mult_return); object set10_tree=null; try { // antlr_temp_dir\\MathExpr.g:83:4: ( mult ( ( ADD | SUB ) mult )* ) // antlr_temp_dir\\MathExpr.g:83:7: mult ( ( ADD | SUB ) mult )* { root_0 = (object)adaptor.GetNilNode(); PushFollow(FOLLOW_mult_in_add424); mult9 = mult(); state.followingStackPointer--; adaptor.AddChild(root_0, mult9.Tree); // antlr_temp_dir\\MathExpr.g:83:13: ( ( ADD | SUB ) mult )* do { int alt3 = 2; int LA3_0 = input.LA(1); if ( ((LA3_0 >= ADD && LA3_0 <= SUB)) ) { alt3 = 1; } switch (alt3) { case 1 : // antlr_temp_dir\\MathExpr.g:83:15: ( ADD | SUB ) mult { set10=(IToken)input.LT(1); set10 = (IToken)input.LT(1); if ( (input.LA(1) >= ADD && input.LA(1) <= SUB) ) { input.Consume(); root_0 = (object)adaptor.BecomeRoot((object)adaptor.Create(set10), root_0); state.errorRecovery = false; } else { MismatchedSetException mse = new MismatchedSetException(null,input); throw mse; } PushFollow(FOLLOW_mult_in_add440); mult11 = mult(); state.followingStackPointer--; adaptor.AddChild(root_0, mult11.Tree); } break; default: goto loop3; } } while (true); loop3: ; // Stops C# compiler whining that label 'loop3' has no statements } retval.Stop = input.LT(-1); retval.Tree = (object)adaptor.RulePostProcessing(root_0); adaptor.SetTokenBoundaries(retval.Tree, (IToken) retval.Start, (IToken) retval.Stop); } catch (RecognitionException re) { ReportError(re); Recover(input,re); // Conversion of the second argument necessary, but harmless retval.Tree = (object)adaptor.ErrorNode(input, (IToken) retval.Start, input.LT(-1), re); } finally { } return retval; }
// $ANTLR start "add" // MathExpr.g:102:1: add : mult ( ( ADD | SUB | BIT_OR ) mult )* ; public MathExprParser.add_return add() // throws RecognitionException [1] { MathExprParser.add_return retval = new MathExprParser.add_return(); retval.Start = input.LT(1); int add_StartIndex = input.Index(); AstNode root_0 = null; IToken set24 = null; MathExprParser.mult_return mult23 = default(MathExprParser.mult_return); MathExprParser.mult_return mult25 = default(MathExprParser.mult_return); AstNode set24_tree=null; try { if ( (state.backtracking > 0) && AlreadyParsedRule(input, 7) ) { return retval; } // MathExpr.g:102:4: ( mult ( ( ADD | SUB | BIT_OR ) mult )* ) // MathExpr.g:102:8: mult ( ( ADD | SUB | BIT_OR ) mult )* { root_0 = (AstNode)adaptor.GetNilNode(); PushFollow(FOLLOW_mult_in_add1030); mult23 = mult(); state.followingStackPointer--; if (state.failed) return retval; if ( state.backtracking == 0 ) adaptor.AddChild(root_0, mult23.Tree); // MathExpr.g:102:14: ( ( ADD | SUB | BIT_OR ) mult )* do { int alt6 = 2; int LA6_0 = input.LA(1); if ( ((LA6_0 >= ADD && LA6_0 <= SUB) || LA6_0 == BIT_OR) ) { alt6 = 1; } switch (alt6) { case 1 : // MathExpr.g:102:16: ( ADD | SUB | BIT_OR ) mult { set24=(IToken)input.LT(1); set24 = (IToken)input.LT(1); if ( (input.LA(1) >= ADD && input.LA(1) <= SUB) || input.LA(1) == BIT_OR ) { input.Consume(); if ( state.backtracking == 0 ) root_0 = (AstNode)adaptor.BecomeRoot((AstNode)adaptor.Create(set24), root_0); state.errorRecovery = false;state.failed = false; } else { if ( state.backtracking > 0 ) {state.failed = true; return retval;} MismatchedSetException mse = new MismatchedSetException(null,input); throw mse; } PushFollow(FOLLOW_mult_in_add1050); mult25 = mult(); state.followingStackPointer--; if (state.failed) return retval; if ( state.backtracking == 0 ) adaptor.AddChild(root_0, mult25.Tree); } break; default: goto loop6; } } while (true); loop6: ; // Stops C# compiler whining that label 'loop6' has no statements } retval.Stop = input.LT(-1); if ( (state.backtracking==0) ) { retval.Tree = (AstNode)adaptor.RulePostProcessing(root_0); adaptor.SetTokenBoundaries(retval.Tree, (IToken) retval.Start, (IToken) retval.Stop);} } catch (RecognitionException re) { ReportError(re); Recover(input,re); // Conversion of the second argument necessary, but harmless retval.Tree = (AstNode)adaptor.ErrorNode(input, (IToken) retval.Start, input.LT(-1), re); } finally { if ( state.backtracking > 0 ) { Memoize(input, 7, add_StartIndex); } } return retval; }