示例#1
0
    // $ANTLR start "formalParameterList"
    // AS3_ex.g3:1701:1: formalParameterList : L= LPAREN ( ( variableDeclaration (C= COMMA variableDeclaration )* (C= COMMA formalEllipsisParameter )? ) | formalEllipsisParameter )? R= RPAREN ;
    public AS3_exParser.formalParameterList_return formalParameterList() // throws RecognitionException [1]
    {   
        AS3_exParser.formalParameterList_return retval = new AS3_exParser.formalParameterList_return();
        retval.Start = input.LT(1);
        int formalParameterList_StartIndex = input.Index();
        object root_0 = null;

        IToken L = null;
        IToken C = null;
        IToken R = null;
        AS3_exParser.variableDeclaration_return variableDeclaration122 = null;

        AS3_exParser.variableDeclaration_return variableDeclaration123 = null;

        AS3_exParser.formalEllipsisParameter_return formalEllipsisParameter124 = null;

        AS3_exParser.formalEllipsisParameter_return formalEllipsisParameter125 = null;


        object L_tree=null;
        object C_tree=null;
        object R_tree=null;


        	WrapOptions options=mPrinter.GetMethodDeclWrapOptions();
        	bool pushedFormat=false;
        	bool pushedIndent=false;

        try 
    	{
    	    if ( (state.backtracking > 0) && AlreadyParsedRule(input, 53) ) 
    	    {
    	    	return retval; 
    	    }
            // AS3_ex.g3:1708:5: (L= LPAREN ( ( variableDeclaration (C= COMMA variableDeclaration )* (C= COMMA formalEllipsisParameter )? ) | formalEllipsisParameter )? R= RPAREN )
            // AS3_ex.g3:1709:3: L= LPAREN ( ( variableDeclaration (C= COMMA variableDeclaration )* (C= COMMA formalEllipsisParameter )? ) | formalEllipsisParameter )? R= RPAREN
            {
            	root_0 = (object)adaptor.GetNilNode();

            	if ( state.backtracking == 0 ) 
            	{

            	  			pushedFormat=PushFormatType(options, false);
            	  			mPrinter.SetInParameterDecl(true);
            	  		
            	}
            	L=(IToken)Match(input,LPAREN,FOLLOW_LPAREN_in_formalParameterList7180); 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 ) 
            	{
            	  Emit((CommonToken)L);InsertWS(mPrinter.GetAdvancedSpacesInsideParens());
            	}
            	// AS3_ex.g3:1714:9: ( ( variableDeclaration (C= COMMA variableDeclaration )* (C= COMMA formalEllipsisParameter )? ) | formalEllipsisParameter )?
            	int alt73 = 3;
            	int LA73_0 = input.LA(1);

            	if ( (LA73_0 == NATIVE || LA73_0 == TO || (LA73_0 >= EACH && LA73_0 <= NAMESPACE) || (LA73_0 >= DYNAMIC && LA73_0 <= STATIC) || LA73_0 == IDENTIFIER) )
            	{
            	    alt73 = 1;
            	}
            	else if ( (LA73_0 == ELLIPSIS) )
            	{
            	    alt73 = 2;
            	}
            	switch (alt73) 
            	{
            	    case 1 :
            	        // AS3_ex.g3:1714:11: ( variableDeclaration (C= COMMA variableDeclaration )* (C= COMMA formalEllipsisParameter )? )
            	        {
            	        	// AS3_ex.g3:1714:11: ( variableDeclaration (C= COMMA variableDeclaration )* (C= COMMA formalEllipsisParameter )? )
            	        	// AS3_ex.g3:1714:13: variableDeclaration (C= COMMA variableDeclaration )* (C= COMMA formalEllipsisParameter )?
            	        	{
            	        		if ( state.backtracking == 0 ) 
            	        		{
            	        		  pushedIndent=PushLazyParmIndent(pushedIndent, options.IndentStyle);
            	        		}
            	        		PushFollow(FOLLOW_variableDeclaration_in_formalParameterList7199);
            	        		variableDeclaration122 = variableDeclaration();
            	        		state.followingStackPointer--;
            	        		if (state.failed) return retval;
            	        		if ( state.backtracking == 0 ) adaptor.AddChild(root_0, variableDeclaration122.Tree);
            	        		// AS3_ex.g3:1715:13: (C= COMMA variableDeclaration )*
            	        		do 
            	        		{
            	        		    int alt71 = 2;
            	        		    int LA71_0 = input.LA(1);

            	        		    if ( (LA71_0 == COMMA) )
            	        		    {
            	        		        int LA71_1 = input.LA(2);

            	        		        if ( (LA71_1 == NATIVE || LA71_1 == TO || (LA71_1 >= EACH && LA71_1 <= NAMESPACE) || (LA71_1 >= DYNAMIC && LA71_1 <= STATIC) || LA71_1 == IDENTIFIER) )
            	        		        {
            	        		            alt71 = 1;
            	        		        }


            	        		    }


            	        		    switch (alt71) 
            	        			{
            	        				case 1 :
            	        				    // AS3_ex.g3:1716:16: C= COMMA variableDeclaration
            	        				    {
            	        				    	C=(IToken)Match(input,COMMA,FOLLOW_COMMA_in_formalParameterList7234); if (state.failed) return retval;
            	        				    	if ( state.backtracking == 0 )
            	        				    	{C_tree = (object)adaptor.Create(C);
            	        				    		adaptor.AddChild(root_0, C_tree);
            	        				    	}
            	        				    	if ( state.backtracking == 0 ) 
            	        				    	{
            	        				    	  pushedIndent=EmitCommaWithSpacingAndCRs(options, (CommonToken) C, pushedIndent);
            	        				    	}
            	        				    	PushFollow(FOLLOW_variableDeclaration_in_formalParameterList7269);
            	        				    	variableDeclaration123 = variableDeclaration();
            	        				    	state.followingStackPointer--;
            	        				    	if (state.failed) return retval;
            	        				    	if ( state.backtracking == 0 ) adaptor.AddChild(root_0, variableDeclaration123.Tree);

            	        				    }
            	        				    break;

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

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

            	        		// AS3_ex.g3:1720:13: (C= COMMA formalEllipsisParameter )?
            	        		int alt72 = 2;
            	        		int LA72_0 = input.LA(1);

            	        		if ( (LA72_0 == COMMA) )
            	        		{
            	        		    alt72 = 1;
            	        		}
            	        		switch (alt72) 
            	        		{
            	        		    case 1 :
            	        		        // AS3_ex.g3:1720:15: C= COMMA formalEllipsisParameter
            	        		        {
            	        		        	if ( state.backtracking == 0 ) 
            	        		        	{
            	        		        	  InsertWS(mPrinter.GetSpacesBeforeComma());
            	        		        	}
            	        		        	C=(IToken)Match(input,COMMA,FOLLOW_COMMA_in_formalParameterList7306); if (state.failed) return retval;
            	        		        	if ( state.backtracking == 0 )
            	        		        	{C_tree = (object)adaptor.Create(C);
            	        		        		adaptor.AddChild(root_0, C_tree);
            	        		        	}
            	        		        	if ( state.backtracking == 0 ) 
            	        		        	{
            	        		        	  Emit((CommonToken)C);
            	        		        	}
            	        		        	if ( state.backtracking == 0 ) 
            	        		        	{
            	        		        	  InsertWS(mPrinter.GetSpacesAfterComma());
            	        		        	}
            	        		        	PushFollow(FOLLOW_formalEllipsisParameter_in_formalParameterList7312);
            	        		        	formalEllipsisParameter124 = formalEllipsisParameter();
            	        		        	state.followingStackPointer--;
            	        		        	if (state.failed) return retval;
            	        		        	if ( state.backtracking == 0 ) adaptor.AddChild(root_0, formalEllipsisParameter124.Tree);

            	        		        }
            	        		        break;

            	        		}


            	        	}


            	        }
            	        break;
            	    case 2 :
            	        // AS3_ex.g3:1722:14: formalEllipsisParameter
            	        {
            	        	if ( state.backtracking == 0 ) 
            	        	{
            	        	  pushedIndent=PushLazyParmIndent(pushedIndent, options.IndentStyle);
            	        	}
            	        	PushFollow(FOLLOW_formalEllipsisParameter_in_formalParameterList7344);
            	        	formalEllipsisParameter125 = formalEllipsisParameter();
            	        	state.followingStackPointer--;
            	        	if (state.failed) return retval;
            	        	if ( state.backtracking == 0 ) adaptor.AddChild(root_0, formalEllipsisParameter125.Tree);

            	        }
            	        break;

            	}

            	R=(IToken)Match(input,RPAREN,FOLLOW_RPAREN_in_formalParameterList7368); 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 ) 
            	{
            	  InsertWS(mPrinter.GetAdvancedSpacesInsideParens());Emit((CommonToken)R);
            	}
            	if ( state.backtracking == 0 ) 
            	{

            	          	 mPrinter.SetInParameterDecl(false);
            	  	        if (pushedIndent)
            	      	    	PopIndent();
            	      	    if (pushedFormat)
            	      	    	mPrinter.PopFormatMode();
            	          
            	}

            }

            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, 53, formalParameterList_StartIndex); 
            }
        }
        return retval;
    }
示例#2
0
    // $ANTLR start "formalParameterList"
    // AS3_ex.g3:2165:1: formalParameterList : L= LPAREN ( ( variableDeclaration (C= COMMA variableDeclaration )* (C= COMMA formalEllipsisParameter )? ) | formalEllipsisParameter )? R= RPAREN ;
    public AS3_exParser.formalParameterList_return formalParameterList() // throws RecognitionException [1]
    {   
        AS3_exParser.formalParameterList_return retval = new AS3_exParser.formalParameterList_return();
        retval.Start = input.LT(1);
        int formalParameterList_StartIndex = input.Index();
        object root_0 = null;

        IToken L = null;
        IToken C = null;
        IToken R = null;
        AS3_exParser.variableDeclaration_return variableDeclaration133 = null;

        AS3_exParser.variableDeclaration_return variableDeclaration134 = null;

        AS3_exParser.formalEllipsisParameter_return formalEllipsisParameter135 = null;

        AS3_exParser.formalEllipsisParameter_return formalEllipsisParameter136 = null;


        object L_tree=null;
        object C_tree=null;
        object R_tree=null;


            WrapOptions options=mPrinter.getMethodDeclWrapOptions();
            bool pushedFormat=false;
            bool pushedIndent=false;
            bool pushedWrapInfo=false;
            int firstParm=0;

        try 
        {
            if ( (state.backtracking > 0) && AlreadyParsedRule(input, 53) ) 
            {
                return retval; 
            }
            // AS3_ex.g3:2174:5: (L= LPAREN ( ( variableDeclaration (C= COMMA variableDeclaration )* (C= COMMA formalEllipsisParameter )? ) | formalEllipsisParameter )? R= RPAREN )
            // AS3_ex.g3:2175:3: L= LPAREN ( ( variableDeclaration (C= COMMA variableDeclaration )* (C= COMMA formalEllipsisParameter )? ) | formalEllipsisParameter )? R= RPAREN
            {
                root_0 = (object)adaptor.GetNilNode();

                if ( state.backtracking == 0 ) 
                {

                            mInFunctionParameterDecl=true;
                            pushedFormat=pushFormatType(options, true);
                            mPrinter.setInParameterDecl(true);
                            pushedWrapInfo=pushWrapInfo(options, true);
                        
                }
                L=(IToken)Match(input,LPAREN,FOLLOW_LPAREN_in_formalParameterList7653); 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 ) 
                {
                  insertWS(mPrinter.getSpacesBeforeFormalParameters());
                }
                if ( state.backtracking == 0 ) 
                {
                  emit(L);insertWS(mPrinter.getAdvancedSpacesInsideParensInParameterLists());
                }
                // AS3_ex.g3:2182:9: ( ( variableDeclaration (C= COMMA variableDeclaration )* (C= COMMA formalEllipsisParameter )? ) | formalEllipsisParameter )?
                int alt79 = 3;
                int LA79_0 = input.LA(1);

                if ( (LA79_0 == NATIVE || LA79_0 == TO || (LA79_0 >= EACH && LA79_0 <= NAMESPACE) || (LA79_0 >= DYNAMIC && LA79_0 <= STATIC) || LA79_0 == IDENTIFIER) )
                {
                    alt79 = 1;
                }
                else if ( (LA79_0 == ELLIPSIS) )
                {
                    alt79 = 2;
                }
                switch (alt79) 
                {
                    case 1 :
                        // AS3_ex.g3:2182:11: ( variableDeclaration (C= COMMA variableDeclaration )* (C= COMMA formalEllipsisParameter )? )
                        {
                            // AS3_ex.g3:2182:11: ( variableDeclaration (C= COMMA variableDeclaration )* (C= COMMA formalEllipsisParameter )? )
                            // AS3_ex.g3:2182:13: variableDeclaration (C= COMMA variableDeclaration )* (C= COMMA formalEllipsisParameter )?
                            {
                                if ( state.backtracking == 0 ) 
                                {
                                  pushedIndent=pushLazyParmIndent(pushedIndent, options.getIndentStyle());
                                }
                                if ( state.backtracking == 0 ) 
                                {
                                  mPrinter.captureNextTextPosition();
                                }
                                PushFollow(FOLLOW_variableDeclaration_in_formalParameterList7674);
                                variableDeclaration133 = variableDeclaration();
                                state.followingStackPointer--;
                                if (state.failed) return retval;
                                if ( state.backtracking == 0 ) adaptor.AddChild(root_0, variableDeclaration133.Tree);
                                if ( state.backtracking == 0 ) 
                                {
                                  firstParm=mPrinter.getLastCapturePosition();
                                }
                                // AS3_ex.g3:2183:13: (C= COMMA variableDeclaration )*
                                do 
                                {
                                    int alt77 = 2;
                                    int LA77_0 = input.LA(1);

                                    if ( (LA77_0 == COMMA) )
                                    {
                                        int LA77_1 = input.LA(2);

                                        if ( (LA77_1 == NATIVE || LA77_1 == TO || (LA77_1 >= EACH && LA77_1 <= NAMESPACE) || (LA77_1 >= DYNAMIC && LA77_1 <= STATIC) || LA77_1 == IDENTIFIER) )
                                        {
                                            alt77 = 1;
                                        }


                                    }


                                    switch (alt77) 
                                    {
                                        case 1 :
                                            // AS3_ex.g3:2184:16: C= COMMA variableDeclaration
                                            {
                                                C=(IToken)Match(input,COMMA,FOLLOW_COMMA_in_formalParameterList7711); if (state.failed) return retval;
                                                if ( state.backtracking == 0 )
                                                {C_tree = (object)adaptor.Create(C);
                                                    adaptor.AddChild(root_0, C_tree);
                                                }
                                                if ( state.backtracking == 0 ) 
                                                {
                                                  pushedIndent=emitCommaWithSpacingAndCRs(options, C, pushedIndent, firstParm, ASPrettyPrinter.Break_SubType_Parameters);
                                                }
                                                PushFollow(FOLLOW_variableDeclaration_in_formalParameterList7746);
                                                variableDeclaration134 = variableDeclaration();
                                                state.followingStackPointer--;
                                                if (state.failed) return retval;
                                                if ( state.backtracking == 0 ) adaptor.AddChild(root_0, variableDeclaration134.Tree);

                                            }
                                            break;

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

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

                                // AS3_ex.g3:2188:13: (C= COMMA formalEllipsisParameter )?
                                int alt78 = 2;
                                int LA78_0 = input.LA(1);

                                if ( (LA78_0 == COMMA) )
                                {
                                    alt78 = 1;
                                }
                                switch (alt78) 
                                {
                                    case 1 :
                                        // AS3_ex.g3:2188:15: C= COMMA formalEllipsisParameter
                                        {
                                            C=(IToken)Match(input,COMMA,FOLLOW_COMMA_in_formalParameterList7781); if (state.failed) return retval;
                                            if ( state.backtracking == 0 )
                                            {C_tree = (object)adaptor.Create(C);
                                                adaptor.AddChild(root_0, C_tree);
                                            }
                                            if ( state.backtracking == 0 ) 
                                            {
                                              pushedIndent=emitCommaWithSpacingAndCRs(options, C, pushedIndent, firstParm, ASPrettyPrinter.Break_SubType_Parameters);
                                            }
                                            PushFollow(FOLLOW_formalEllipsisParameter_in_formalParameterList7786);
                                            formalEllipsisParameter135 = formalEllipsisParameter();
                                            state.followingStackPointer--;
                                            if (state.failed) return retval;
                                            if ( state.backtracking == 0 ) adaptor.AddChild(root_0, formalEllipsisParameter135.Tree);

                                        }
                                        break;

                                }


                            }


                        }
                        break;
                    case 2 :
                        // AS3_ex.g3:2190:14: formalEllipsisParameter
                        {
                            if ( state.backtracking == 0 ) 
                            {
                              pushedIndent=pushLazyParmIndent(pushedIndent, options.getIndentStyle());
                            }
                            PushFollow(FOLLOW_formalEllipsisParameter_in_formalParameterList7818);
                            formalEllipsisParameter136 = formalEllipsisParameter();
                            state.followingStackPointer--;
                            if (state.failed) return retval;
                            if ( state.backtracking == 0 ) adaptor.AddChild(root_0, formalEllipsisParameter136.Tree);

                        }
                        break;

                }

                R=(IToken)Match(input,RPAREN,FOLLOW_RPAREN_in_formalParameterList7836); 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 ) 
                {
                  insertWS(mPrinter.getAdvancedSpacesInsideParensInParameterLists());emit(R);
                }
                if ( state.backtracking == 0 ) 
                {

                             mPrinter.setInParameterDecl(false);
                            if (pushedWrapInfo)
                                mPrinter.popWrapContext();
                            if (pushedIndent)
                                popIndent();
                            if (pushedFormat)
                            {
                                mPrinter.popFormatMode();
                            }
                            mInFunctionParameterDecl=false;
                          
                }

            }

            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, 53, formalParameterList_StartIndex); 
            }
        }
        return retval;
    }