Exemple #1
0
    // $ANTLR start "switchStatement"
    // AS3_ex.g3:1893:1: switchStatement : S= SWITCH parExpression L= LCURLY ( switchBlockStatementGroup )* R= RCURLY ;
    public AS3_exParser.switchStatement_return switchStatement() // throws RecognitionException [1]
    {   
        AS3_exParser.switchStatement_return retval = new AS3_exParser.switchStatement_return();
        retval.Start = input.LT(1);
        int switchStatement_StartIndex = input.Index();
        object root_0 = null;

        IToken S = null;
        IToken L = null;
        IToken R = null;
        AS3_exParser.parExpression_return parExpression171 = null;

        AS3_exParser.switchBlockStatementGroup_return switchBlockStatementGroup172 = null;


        object S_tree=null;
        object L_tree=null;
        object R_tree=null;

        try 
    	{
    	    if ( (state.backtracking > 0) && AlreadyParsedRule(input, 68) ) 
    	    {
    	    	return retval; 
    	    }
            // AS3_ex.g3:1894:5: (S= SWITCH parExpression L= LCURLY ( switchBlockStatementGroup )* R= RCURLY )
            // AS3_ex.g3:1894:8: S= SWITCH parExpression L= LCURLY ( switchBlockStatementGroup )* R= RCURLY
            {
            	root_0 = (object)adaptor.GetNilNode();

            	if ( state.backtracking == 0 ) 
            	{
            	  InsertLines(mPrinter.GetBlankLinesBeforeControlStatement());
            	}
            	if ( state.backtracking == 0 ) 
            	{
            	  InsertStatementCR();
            	}
            	S=(IToken)Match(input,SWITCH,FOLLOW_SWITCH_in_switchStatement8493); if (state.failed) return retval;
            	if ( state.backtracking == 0 )
            	{S_tree = (object)adaptor.Create(S);
            		adaptor.AddChild(root_0, S_tree);
            	}
            	if ( state.backtracking == 0 ) 
            	{
            	  Emit((CommonToken)S);InsertWS(mPrinter.GetSpacesBetweenControlKeywordsAndParens());
            	}
            	if ( state.backtracking == 0 ) 
            	{
            	  PushExpressionIndent();
            	}
            	PushFollow(FOLLOW_parExpression_in_switchStatement8498);
            	parExpression171 = parExpression();
            	state.followingStackPointer--;
            	if (state.failed) return retval;
            	if ( state.backtracking == 0 ) adaptor.AddChild(root_0, parExpression171.Tree);
            	if ( state.backtracking == 0 ) 
            	{
            	  PopIndent();
            	}
            	L=(IToken)Match(input,LCURLY,FOLLOW_LCURLY_in_switchStatement8510); 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:1900:6: ( switchBlockStatementGroup )*
            	do 
            	{
            	    int alt85 = 2;
            	    int LA85_0 = input.LA(1);

            	    if ( (LA85_0 == CASE || LA85_0 == DEFAULT) )
            	    {
            	        alt85 = 1;
            	    }


            	    switch (alt85) 
            		{
            			case 1 :
            			    // AS3_ex.g3:0:0: switchBlockStatementGroup
            			    {
            			    	PushFollow(FOLLOW_switchBlockStatementGroup_in_switchStatement8526);
            			    	switchBlockStatementGroup172 = switchBlockStatementGroup();
            			    	state.followingStackPointer--;
            			    	if (state.failed) return retval;
            			    	if ( state.backtracking == 0 ) adaptor.AddChild(root_0, switchBlockStatementGroup172.Tree);

            			    }
            			    break;

            			default:
            			    goto loop85;
            	    }
            	} while (true);

            	loop85:
            		;	// Stops C# compiler whining that label 'loop85' has no statements

            	if ( state.backtracking == 0 ) 
            	{
            	  PopIndent();
            	}
            	R=(IToken)Match(input,RCURLY,FOLLOW_RCURLY_in_switchStatement8539); 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, 68, switchStatement_StartIndex); 
            }
        }
        return retval;
    }
    // $ANTLR start "switchStatement"
    // AS3_ex.g3:2429:1: switchStatement : S= SWITCH parExpression L= LCURLY ( switchBlockStatementGroup )* R= RCURLY ;
    public AS3_exParser.switchStatement_return switchStatement() // throws RecognitionException [1]
    {   
        AS3_exParser.switchStatement_return retval = new AS3_exParser.switchStatement_return();
        retval.Start = input.LT(1);
        int switchStatement_StartIndex = input.Index();
        object root_0 = null;

        IToken S = null;
        IToken L = null;
        IToken R = null;
        AS3_exParser.parExpression_return parExpression182 = null;

        AS3_exParser.switchBlockStatementGroup_return switchBlockStatementGroup183 = null;


        object S_tree=null;
        object L_tree=null;
        object R_tree=null;

        try 
        {
            if ( (state.backtracking > 0) && AlreadyParsedRule(input, 68) ) 
            {
                return retval; 
            }
            // AS3_ex.g3:2430:5: (S= SWITCH parExpression L= LCURLY ( switchBlockStatementGroup )* R= RCURLY )
            // AS3_ex.g3:2431:5: S= SWITCH parExpression L= LCURLY ( switchBlockStatementGroup )* R= RCURLY
            {
                root_0 = (object)adaptor.GetNilNode();

                if ( state.backtracking == 0 ) 
                {
                  mPrinter.markDeclEqualsContextChange();
                }
                if ( state.backtracking == 0 ) 
                {
                  insertLines(mPrinter.getBlankLinesBeforeControlStatement());
                }
                if ( state.backtracking == 0 ) 
                {
                  insertStatementCR();
                }
                S=(IToken)Match(input,SWITCH,FOLLOW_SWITCH_in_switchStatement9065); if (state.failed) return retval;
                if ( state.backtracking == 0 )
                {S_tree = (object)adaptor.Create(S);
                    adaptor.AddChild(root_0, S_tree);
                }
                if ( state.backtracking == 0 ) 
                {
                  emit(S);
                       pushIndent(false);
                       insertWS(mPrinter.getSpacesBetweenControlKeywordsAndParens());
                }
                if ( state.backtracking == 0 ) 
                {
                  pushExpressionIndent();
                }
                PushFollow(FOLLOW_parExpression_in_switchStatement9076);
                parExpression182 = parExpression();
                state.followingStackPointer--;
                if (state.failed) return retval;
                if ( state.backtracking == 0 ) adaptor.AddChild(root_0, parExpression182.Tree);
                if ( state.backtracking == 0 ) 
                {
                  popIndent();
                }
                L=(IToken)Match(input,LCURLY,FOLLOW_LCURLY_in_switchStatement9088); 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(ASPrettyPrinter.BraceContext_controlStatement_code);
                            leftCurlyNewlineHandler(false);
                            emit(L);
                            if (mPrinter.isIndentSwitchCases())
                                pushIndent(true);
                            else
                                mPrinter.pushRelativeIndent(ASPrettyPrinter.BRACE_INDENT, -1);
                            {mPrinter.addDeclEqualsBlock();}
                            mCodeBlockStack.Add(ASPrettyPrinter.BraceContext_block_code);
                        
                }
                // AS3_ex.g3:2449:6: ( switchBlockStatementGroup )*
                do 
                {
                    int alt92 = 2;
                    int LA92_0 = input.LA(1);

                    if ( (LA92_0 == CASE || LA92_0 == DEFAULT) )
                    {
                        alt92 = 1;
                    }


                    switch (alt92) 
                    {
                        case 1 :
                            // AS3_ex.g3:0:0: switchBlockStatementGroup
                            {
                                PushFollow(FOLLOW_switchBlockStatementGroup_in_switchStatement9104);
                                switchBlockStatementGroup183 = switchBlockStatementGroup();
                                state.followingStackPointer--;
                                if (state.failed) return retval;
                                if ( state.backtracking == 0 ) adaptor.AddChild(root_0, switchBlockStatementGroup183.Tree);

                            }
                            break;

                        default:
                            goto loop92;
                    }
                } while (true);

                loop92:
                    ;   // Stops C# compiler whining that label 'loop92' has no statements

                if ( state.backtracking == 0 ) 
                {
                  popIndent();
                }
                if ( state.backtracking == 0 ) 
                {
                  mPrinter.popDeclEqualsBlock();
                }
                R=(IToken)Match(input,RCURLY,FOLLOW_RCURLY_in_switchStatement9124); 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);popIndent();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, 68, switchStatement_StartIndex); 
            }
        }
        return retval;
    }