// $ANTLR start "functionBody" // AS3_ex.g3:1739:1: functionBody : L= LCURLY ( statement | functionDeclaration )* R= RCURLY ; public AS3_exParser.functionBody_return functionBody() // throws RecognitionException [1] { AS3_exParser.functionBody_return retval = new AS3_exParser.functionBody_return(); retval.Start = input.LT(1); int functionBody_StartIndex = input.Index(); object root_0 = null; IToken L = null; IToken R = null; AS3_exParser.statement_return statement127 = null; AS3_exParser.functionDeclaration_return functionDeclaration128 = null; object L_tree=null; object R_tree=null; try { if ( (state.backtracking > 0) && AlreadyParsedRule(input, 55) ) { return retval; } // AS3_ex.g3:1740:5: (L= LCURLY ( statement | functionDeclaration )* R= RCURLY ) // AS3_ex.g3:1740:9: L= LCURLY ( statement | functionDeclaration )* R= RCURLY { root_0 = (object)adaptor.GetNilNode(); L=(IToken)Match(input,LCURLY,FOLLOW_LCURLY_in_functionBody7444); if (state.failed) return retval; if ( state.backtracking == 0 ) {L_tree = (object)adaptor.Create(L); adaptor.AddChild(root_0, L_tree); } if ( state.backtracking == 0 ) { LeftCurlyNewlineHandler(false); Emit((CommonToken)L);PushIndent(true); } // AS3_ex.g3:1745:7: ( statement | functionDeclaration )* do { int alt74 = 3; alt74 = dfa74.Predict(input); switch (alt74) { case 1 : // AS3_ex.g3:1745:8: statement { PushFollow(FOLLOW_statement_in_functionBody7462); statement127 = statement(); state.followingStackPointer--; if (state.failed) return retval; if ( state.backtracking == 0 ) adaptor.AddChild(root_0, statement127.Tree); } break; case 2 : // AS3_ex.g3:1745:18: functionDeclaration { PushFollow(FOLLOW_functionDeclaration_in_functionBody7464); functionDeclaration128 = functionDeclaration(); state.followingStackPointer--; if (state.failed) return retval; if ( state.backtracking == 0 ) adaptor.AddChild(root_0, functionDeclaration128.Tree); } break; default: goto loop74; } } while (true); loop74: ; // Stops C# compiler whining that label 'loop74' has no statements if ( state.backtracking == 0 ) { PopIndent(); } R=(IToken)Match(input,RCURLY,FOLLOW_RCURLY_in_functionBody7478); if (state.failed) return retval; if ( state.backtracking == 0 ) {R_tree = (object)adaptor.Create(R); adaptor.AddChild(root_0, R_tree); } if ( state.backtracking == 0 ) { InsertCR(false);Emit((CommonToken)R); } } retval.Stop = input.LT(-1); if ( state.backtracking==0 ) { 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 { if ( state.backtracking > 0 ) { Memoize(input, 55, functionBody_StartIndex); } } return retval; }
// $ANTLR start "functionBody" // AS3_ex.g3:2212:1: functionBody : L= LCURLY ( ( statement | functionDeclaration ) )* R= RCURLY ; public AS3_exParser.functionBody_return functionBody() // throws RecognitionException [1] { AS3_exParser.functionBody_return retval = new AS3_exParser.functionBody_return(); retval.Start = input.LT(1); int functionBody_StartIndex = input.Index(); object root_0 = null; IToken L = null; IToken R = null; AS3_exParser.statement_return statement138 = null; AS3_exParser.functionDeclaration_return functionDeclaration139 = null; object L_tree=null; object R_tree=null; bool containsStatements=false; try { if ( (state.backtracking > 0) && AlreadyParsedRule(input, 55) ) { return retval; } // AS3_ex.g3:2217:5: (L= LCURLY ( ( statement | functionDeclaration ) )* R= RCURLY ) // AS3_ex.g3:2217:9: L= LCURLY ( ( statement | functionDeclaration ) )* R= RCURLY { root_0 = (object)adaptor.GetNilNode(); L=(IToken)Match(input,LCURLY,FOLLOW_LCURLY_in_functionBody7917); if (state.failed) return retval; if ( state.backtracking == 0 ) {L_tree = (object)adaptor.Create(L); adaptor.AddChild(root_0, L_tree); } if ( state.backtracking == 0 ) { mCodeBlockStack.Add(mIsFunctionDecl ? ASPrettyPrinter.BraceContext_functionDecl_code : ASPrettyPrinter.BraceContext_functionExpression_code); leftCurlyNewlineHandler(false); emit(L);pushIndent(true); {mPrinter.addDeclEqualsBlock();} mCodeBlockStack.Add(ASPrettyPrinter.BraceContext_block_code); insertLines(mPrinter.getBlankLinesToStartFunctions(), false); } // AS3_ex.g3:2226:7: ( ( statement | functionDeclaration ) )* do { int alt81 = 2; int LA81_0 = input.LA(1); if ( ((LA81_0 >= AS && LA81_0 <= LCURLY) || LA81_0 == LPAREN || LA81_0 == LBRACK || LA81_0 == LT || (LA81_0 >= PLUS && LA81_0 <= STAR) || (LA81_0 >= INC && LA81_0 <= DEC) || (LA81_0 >= NOT && LA81_0 <= INV) || (LA81_0 >= XML_AT && LA81_0 <= XML_LS_STD) || (LA81_0 >= SINGLE_QUOTE_LITERAL && LA81_0 <= DOUBLE_QUOTE_LITERAL) || LA81_0 == REGULAR_EXPR_LITERAL || LA81_0 == HEX_NUMBER_LITERAL || LA81_0 == DEC_NUMBER_LITERAL || LA81_0 == IDENTIFIER || (LA81_0 >= XML_COMMENT && LA81_0 <= XML_PI)) ) { alt81 = 1; } switch (alt81) { case 1 : // AS3_ex.g3:2226:8: ( statement | functionDeclaration ) { // AS3_ex.g3:2226:8: ( statement | functionDeclaration ) int alt80 = 2; alt80 = dfa80.Predict(input); switch (alt80) { case 1 : // AS3_ex.g3:2226:9: statement { PushFollow(FOLLOW_statement_in_functionBody7936); statement138 = statement(); state.followingStackPointer--; if (state.failed) return retval; if ( state.backtracking == 0 ) adaptor.AddChild(root_0, statement138.Tree); } break; case 2 : // AS3_ex.g3:2226:21: functionDeclaration { PushFollow(FOLLOW_functionDeclaration_in_functionBody7940); functionDeclaration139 = functionDeclaration(); state.followingStackPointer--; if (state.failed) return retval; if ( state.backtracking == 0 ) adaptor.AddChild(root_0, functionDeclaration139.Tree); } break; } if ( state.backtracking == 0 ) { containsStatements=true; } } break; default: goto loop81; } } while (true); loop81: ; // Stops C# compiler whining that label 'loop81' has no statements if ( state.backtracking == 0 ) { popIndent(); } if ( state.backtracking == 0 ) { if (containsStatements) insertLines(mPrinter.getBlankLinesToEndFunctions(), false); else mPrinter.clearAddedWhitespace(); } if ( state.backtracking == 0 ) { mPrinter.popDeclEqualsBlock(); } R=(IToken)Match(input,RCURLY,FOLLOW_RCURLY_in_functionBody7973); if (state.failed) return retval; if ( state.backtracking == 0 ) {R_tree = (object)adaptor.Create(R); adaptor.AddChild(root_0, R_tree); } if ( state.backtracking == 0 ) { insertCR(false);emit(R);popBlockStack();popBlockStack(); } } retval.Stop = input.LT(-1); if ( state.backtracking==0 ) { 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 { if ( state.backtracking > 0 ) { Memoize(input, 55, functionBody_StartIndex); } } return retval; }