// $ANTLR start "result" // antlr_temp_dir\\MathExpr.g:93:1: result : program -> ^( PROGRAM program ) ; public MathExprParser.result_return result() // throws RecognitionException [1] { MathExprParser.result_return retval = new MathExprParser.result_return(); retval.Start = input.LT(1); object root_0 = null; MathExprParser.program_return program19 = default(MathExprParser.program_return); RewriteRuleSubtreeStream stream_program = new RewriteRuleSubtreeStream(adaptor,"rule program"); try { // antlr_temp_dir\\MathExpr.g:93:7: ( program -> ^( PROGRAM program ) ) // antlr_temp_dir\\MathExpr.g:93:9: program { PushFollow(FOLLOW_program_in_result492); program19 = program(); state.followingStackPointer--; stream_program.Add(program19.Tree); // AST REWRITE // elements: program // token labels: // rule labels: retval // token list labels: // rule list labels: // wildcard labels: retval.Tree = root_0; RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval!=null ? retval.Tree : null); root_0 = (object)adaptor.GetNilNode(); // 93:17: -> ^( PROGRAM program ) { // antlr_temp_dir\\MathExpr.g:93:20: ^( PROGRAM program ) { object root_1 = (object)adaptor.GetNilNode(); root_1 = (object)adaptor.BecomeRoot((object)adaptor.Create(PROGRAM, "PROGRAM"), root_1); adaptor.AddChild(root_1, stream_program.NextTree()); adaptor.AddChild(root_0, root_1); } } retval.Tree = root_0;retval.Tree = root_0; } 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 "result" // MathExpr.g:150:1: result : program -> ^( PROGRAM program ) ; public MathExprParser.result_return result() // throws RecognitionException [1] { MathExprParser.result_return retval = new MathExprParser.result_return(); retval.Start = input.LT(1); int result_StartIndex = input.Index(); AstNode root_0 = null; MathExprParser.program_return program108 = default(MathExprParser.program_return); RewriteRuleSubtreeStream stream_program = new RewriteRuleSubtreeStream(adaptor,"rule program"); try { if ( (state.backtracking > 0) && AlreadyParsedRule(input, 25) ) { return retval; } // MathExpr.g:150:7: ( program -> ^( PROGRAM program ) ) // MathExpr.g:150:9: program { PushFollow(FOLLOW_program_in_result1579); program108 = program(); state.followingStackPointer--; if (state.failed) return retval; if ( (state.backtracking==0) ) stream_program.Add(program108.Tree); // AST REWRITE // elements: program // token labels: // rule labels: retval // token list labels: // rule list labels: // wildcard labels: if ( (state.backtracking==0) ) { retval.Tree = root_0; RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval!=null ? retval.Tree : null); root_0 = (AstNode)adaptor.GetNilNode(); // 150:17: -> ^( PROGRAM program ) { // MathExpr.g:150:20: ^( PROGRAM program ) { AstNode root_1 = (AstNode)adaptor.GetNilNode(); root_1 = (AstNode)adaptor.BecomeRoot((AstNode)adaptor.Create(PROGRAM, "PROGRAM"), root_1); adaptor.AddChild(root_1, stream_program.NextTree()); adaptor.AddChild(root_0, root_1); } } retval.Tree = root_0;retval.Tree = root_0;} } 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, 25, result_StartIndex); } } return retval; }