Exemple #1
0
    // $ANTLR start "tryStatement"
    // AS3_ex.g3:1858:1: tryStatement : T= TRY blockStatement ( ( catchClause )+ finallyClause | ( catchClause )+ | finallyClause ) ;
    public AS3_exParser.tryStatement_return tryStatement() // throws RecognitionException [1]
    {   
        AS3_exParser.tryStatement_return retval = new AS3_exParser.tryStatement_return();
        retval.Start = input.LT(1);
        int tryStatement_StartIndex = input.Index();
        object root_0 = null;

        IToken T = null;
        AS3_exParser.blockStatement_return blockStatement162 = null;

        AS3_exParser.catchClause_return catchClause163 = null;

        AS3_exParser.finallyClause_return finallyClause164 = null;

        AS3_exParser.catchClause_return catchClause165 = null;

        AS3_exParser.finallyClause_return finallyClause166 = null;


        object T_tree=null;

        try 
    	{
    	    if ( (state.backtracking > 0) && AlreadyParsedRule(input, 64) ) 
    	    {
    	    	return retval; 
    	    }
            // AS3_ex.g3:1859:5: (T= TRY blockStatement ( ( catchClause )+ finallyClause | ( catchClause )+ | finallyClause ) )
            // AS3_ex.g3:1859:7: T= TRY blockStatement ( ( catchClause )+ finallyClause | ( catchClause )+ | finallyClause )
            {
            	root_0 = (object)adaptor.GetNilNode();

            	if ( state.backtracking == 0 ) 
            	{
            	  InsertStatementCR();
            	}
            	T=(IToken)Match(input,TRY,FOLLOW_TRY_in_tryStatement8275); if (state.failed) return retval;
            	if ( state.backtracking == 0 )
            	{T_tree = (object)adaptor.Create(T);
            		adaptor.AddChild(root_0, T_tree);
            	}
            	if ( state.backtracking == 0 ) 
            	{
            	  Emit((CommonToken)T);
            	}
            	if ( state.backtracking == 0 ) 
            	{
            	  PushIndent(false);
            	}
            	PushFollow(FOLLOW_blockStatement_in_tryStatement8281);
            	blockStatement162 = blockStatement();
            	state.followingStackPointer--;
            	if (state.failed) return retval;
            	if ( state.backtracking == 0 ) adaptor.AddChild(root_0, blockStatement162.Tree);
            	if ( state.backtracking == 0 ) 
            	{
            	  PopIndent();
            	}
            	// AS3_ex.g3:1860:9: ( ( catchClause )+ finallyClause | ( catchClause )+ | finallyClause )
            	int alt84 = 3;
            	int LA84_0 = input.LA(1);

            	if ( (LA84_0 == CATCH) )
            	{
            	    int LA84_1 = input.LA(2);

            	    if ( (synpred195_AS3_ex()) )
            	    {
            	        alt84 = 1;
            	    }
            	    else if ( (synpred197_AS3_ex()) )
            	    {
            	        alt84 = 2;
            	    }
            	    else 
            	    {
            	        if ( state.backtracking > 0 ) {state.failed = true; return retval;}
            	        NoViableAltException nvae_d84s1 =
            	            new NoViableAltException("", 84, 1, input);

            	        throw nvae_d84s1;
            	    }
            	}
            	else if ( (LA84_0 == FINALLY) )
            	{
            	    alt84 = 3;
            	}
            	else 
            	{
            	    if ( state.backtracking > 0 ) {state.failed = true; return retval;}
            	    NoViableAltException nvae_d84s0 =
            	        new NoViableAltException("", 84, 0, input);

            	    throw nvae_d84s0;
            	}
            	switch (alt84) 
            	{
            	    case 1 :
            	        // AS3_ex.g3:1860:11: ( catchClause )+ finallyClause
            	        {
            	        	// AS3_ex.g3:1860:11: ( catchClause )+
            	        	int cnt82 = 0;
            	        	do 
            	        	{
            	        	    int alt82 = 2;
            	        	    int LA82_0 = input.LA(1);

            	        	    if ( (LA82_0 == CATCH) )
            	        	    {
            	        	        alt82 = 1;
            	        	    }


            	        	    switch (alt82) 
            	        		{
            	        			case 1 :
            	        			    // AS3_ex.g3:0:0: catchClause
            	        			    {
            	        			    	PushFollow(FOLLOW_catchClause_in_tryStatement8295);
            	        			    	catchClause163 = catchClause();
            	        			    	state.followingStackPointer--;
            	        			    	if (state.failed) return retval;
            	        			    	if ( state.backtracking == 0 ) adaptor.AddChild(root_0, catchClause163.Tree);

            	        			    }
            	        			    break;

            	        			default:
            	        			    if ( cnt82 >= 1 ) goto loop82;
            	        			    if ( state.backtracking > 0 ) {state.failed = true; return retval;}
            	        		            EarlyExitException eee =
            	        		                new EarlyExitException(82, input);
            	        		            throw eee;
            	        	    }
            	        	    cnt82++;
            	        	} while (true);

            	        	loop82:
            	        		;	// Stops C# compiler whinging that label 'loop82' has no statements

            	        	PushFollow(FOLLOW_finallyClause_in_tryStatement8298);
            	        	finallyClause164 = finallyClause();
            	        	state.followingStackPointer--;
            	        	if (state.failed) return retval;
            	        	if ( state.backtracking == 0 ) adaptor.AddChild(root_0, finallyClause164.Tree);

            	        }
            	        break;
            	    case 2 :
            	        // AS3_ex.g3:1861:11: ( catchClause )+
            	        {
            	        	// AS3_ex.g3:1861:11: ( catchClause )+
            	        	int cnt83 = 0;
            	        	do 
            	        	{
            	        	    int alt83 = 2;
            	        	    int LA83_0 = input.LA(1);

            	        	    if ( (LA83_0 == CATCH) )
            	        	    {
            	        	        int LA83_2 = input.LA(2);

            	        	        if ( (LA83_2 == LPAREN) )
            	        	        {
            	        	            alt83 = 1;
            	        	        }


            	        	    }


            	        	    switch (alt83) 
            	        		{
            	        			case 1 :
            	        			    // AS3_ex.g3:0:0: catchClause
            	        			    {
            	        			    	PushFollow(FOLLOW_catchClause_in_tryStatement8310);
            	        			    	catchClause165 = catchClause();
            	        			    	state.followingStackPointer--;
            	        			    	if (state.failed) return retval;
            	        			    	if ( state.backtracking == 0 ) adaptor.AddChild(root_0, catchClause165.Tree);

            	        			    }
            	        			    break;

            	        			default:
            	        			    if ( cnt83 >= 1 ) goto loop83;
            	        			    if ( state.backtracking > 0 ) {state.failed = true; return retval;}
            	        		            EarlyExitException eee =
            	        		                new EarlyExitException(83, input);
            	        		            throw eee;
            	        	    }
            	        	    cnt83++;
            	        	} while (true);

            	        	loop83:
            	        		;	// Stops C# compiler whinging that label 'loop83' has no statements


            	        }
            	        break;
            	    case 3 :
            	        // AS3_ex.g3:1862:11: finallyClause
            	        {
            	        	PushFollow(FOLLOW_finallyClause_in_tryStatement8323);
            	        	finallyClause166 = finallyClause();
            	        	state.followingStackPointer--;
            	        	if (state.failed) return retval;
            	        	if ( state.backtracking == 0 ) adaptor.AddChild(root_0, finallyClause166.Tree);

            	        }
            	        break;

            	}


            }

            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, 64, tryStatement_StartIndex); 
            }
        }
        return retval;
    }
    // $ANTLR start "tryStatement"
    // AS3_ex.g3:2392:1: tryStatement : T= TRY blockStatement ( ( catchClause )+ finallyClause | ( catchClause )+ | finallyClause ) ;
    public AS3_exParser.tryStatement_return tryStatement() // throws RecognitionException [1]
    {   
        AS3_exParser.tryStatement_return retval = new AS3_exParser.tryStatement_return();
        retval.Start = input.LT(1);
        int tryStatement_StartIndex = input.Index();
        object root_0 = null;

        IToken T = null;
        AS3_exParser.blockStatement_return blockStatement173 = null;

        AS3_exParser.catchClause_return catchClause174 = null;

        AS3_exParser.finallyClause_return finallyClause175 = null;

        AS3_exParser.catchClause_return catchClause176 = null;

        AS3_exParser.finallyClause_return finallyClause177 = null;


        object T_tree=null;

        try 
        {
            if ( (state.backtracking > 0) && AlreadyParsedRule(input, 64) ) 
            {
                return retval; 
            }
            // AS3_ex.g3:2393:5: (T= TRY blockStatement ( ( catchClause )+ finallyClause | ( catchClause )+ | finallyClause ) )
            // AS3_ex.g3:2394:5: T= TRY blockStatement ( ( catchClause )+ finallyClause | ( catchClause )+ | finallyClause )
            {
                root_0 = (object)adaptor.GetNilNode();

                if ( state.backtracking == 0 ) 
                {
                  mPrinter.markDeclEqualsContextChange();
                }
                if ( state.backtracking == 0 ) 
                {
                  insertStatementCR();
                }
                T=(IToken)Match(input,TRY,FOLLOW_TRY_in_tryStatement8833); if (state.failed) return retval;
                if ( state.backtracking == 0 )
                {T_tree = (object)adaptor.Create(T);
                    adaptor.AddChild(root_0, T_tree);
                }
                if ( state.backtracking == 0 ) 
                {
                  emit(T);
                }
                if ( state.backtracking == 0 ) 
                {
                  pushIndent(false);mCodeBlockStack.Add(ASPrettyPrinter.BraceContext_try_code);
                }
                PushFollow(FOLLOW_blockStatement_in_tryStatement8839);
                blockStatement173 = blockStatement();
                state.followingStackPointer--;
                if (state.failed) return retval;
                if ( state.backtracking == 0 ) adaptor.AddChild(root_0, blockStatement173.Tree);
                if ( state.backtracking == 0 ) 
                {
                  popIndent();popBlockStack();
                }
                // AS3_ex.g3:2396:9: ( ( catchClause )+ finallyClause | ( catchClause )+ | finallyClause )
                int alt91 = 3;
                int LA91_0 = input.LA(1);

                if ( (LA91_0 == CATCH) )
                {
                    int LA91_1 = input.LA(2);

                    if ( (synpred205_AS3_ex()) )
                    {
                        alt91 = 1;
                    }
                    else if ( (synpred207_AS3_ex()) )
                    {
                        alt91 = 2;
                    }
                    else 
                    {
                        if ( state.backtracking > 0 ) {state.failed = true; return retval;}
                        NoViableAltException nvae_d91s1 =
                            new NoViableAltException("", 91, 1, input);

                        throw nvae_d91s1;
                    }
                }
                else if ( (LA91_0 == FINALLY) )
                {
                    alt91 = 3;
                }
                else 
                {
                    if ( state.backtracking > 0 ) {state.failed = true; return retval;}
                    NoViableAltException nvae_d91s0 =
                        new NoViableAltException("", 91, 0, input);

                    throw nvae_d91s0;
                }
                switch (alt91) 
                {
                    case 1 :
                        // AS3_ex.g3:2396:11: ( catchClause )+ finallyClause
                        {
                            // AS3_ex.g3:2396:11: ( catchClause )+
                            int cnt89 = 0;
                            do 
                            {
                                int alt89 = 2;
                                int LA89_0 = input.LA(1);

                                if ( (LA89_0 == CATCH) )
                                {
                                    alt89 = 1;
                                }


                                switch (alt89) 
                                {
                                    case 1 :
                                        // AS3_ex.g3:0:0: catchClause
                                        {
                                            PushFollow(FOLLOW_catchClause_in_tryStatement8853);
                                            catchClause174 = catchClause();
                                            state.followingStackPointer--;
                                            if (state.failed) return retval;
                                            if ( state.backtracking == 0 ) adaptor.AddChild(root_0, catchClause174.Tree);

                                        }
                                        break;

                                    default:
                                        if ( cnt89 >= 1 ) goto loop89;
                                        if ( state.backtracking > 0 ) {state.failed = true; return retval;}
                                            EarlyExitException eee =
                                                new EarlyExitException(89, input);
                                            throw eee;
                                }
                                cnt89++;
                            } while (true);

                            loop89:
                                ;   // Stops C# compiler whinging that label 'loop89' has no statements

                            PushFollow(FOLLOW_finallyClause_in_tryStatement8856);
                            finallyClause175 = finallyClause();
                            state.followingStackPointer--;
                            if (state.failed) return retval;
                            if ( state.backtracking == 0 ) adaptor.AddChild(root_0, finallyClause175.Tree);

                        }
                        break;
                    case 2 :
                        // AS3_ex.g3:2397:11: ( catchClause )+
                        {
                            // AS3_ex.g3:2397:11: ( catchClause )+
                            int cnt90 = 0;
                            do 
                            {
                                int alt90 = 2;
                                int LA90_0 = input.LA(1);

                                if ( (LA90_0 == CATCH) )
                                {
                                    int LA90_2 = input.LA(2);

                                    if ( (LA90_2 == LPAREN) )
                                    {
                                        alt90 = 1;
                                    }


                                }


                                switch (alt90) 
                                {
                                    case 1 :
                                        // AS3_ex.g3:0:0: catchClause
                                        {
                                            PushFollow(FOLLOW_catchClause_in_tryStatement8868);
                                            catchClause176 = catchClause();
                                            state.followingStackPointer--;
                                            if (state.failed) return retval;
                                            if ( state.backtracking == 0 ) adaptor.AddChild(root_0, catchClause176.Tree);

                                        }
                                        break;

                                    default:
                                        if ( cnt90 >= 1 ) goto loop90;
                                        if ( state.backtracking > 0 ) {state.failed = true; return retval;}
                                            EarlyExitException eee =
                                                new EarlyExitException(90, input);
                                            throw eee;
                                }
                                cnt90++;
                            } while (true);

                            loop90:
                                ;   // Stops C# compiler whinging that label 'loop90' has no statements


                        }
                        break;
                    case 3 :
                        // AS3_ex.g3:2398:11: finallyClause
                        {
                            PushFollow(FOLLOW_finallyClause_in_tryStatement8881);
                            finallyClause177 = finallyClause();
                            state.followingStackPointer--;
                            if (state.failed) return retval;
                            if ( state.backtracking == 0 ) adaptor.AddChild(root_0, finallyClause177.Tree);

                        }
                        break;

                }


            }

            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, 64, tryStatement_StartIndex); 
            }
        }
        return retval;
    }