Example #1
0
    // $ANTLR start "whileStatement"
    // AS3_ex.g3:2015:1: whileStatement : W= WHILE parExpression statement ;
    public AS3_exParser.whileStatement_return whileStatement() // throws RecognitionException [1]
    {   
        AS3_exParser.whileStatement_return retval = new AS3_exParser.whileStatement_return();
        retval.Start = input.LT(1);
        int whileStatement_StartIndex = input.Index();
        object root_0 = null;

        IToken W = null;
        AS3_exParser.parExpression_return parExpression204 = null;

        AS3_exParser.statement_return statement205 = null;


        object W_tree=null;

        try 
    	{
    	    if ( (state.backtracking > 0) && AlreadyParsedRule(input, 84) ) 
    	    {
    	    	return retval; 
    	    }
            // AS3_ex.g3:2016:5: (W= WHILE parExpression statement )
            // AS3_ex.g3:2016:9: W= WHILE parExpression statement
            {
            	root_0 = (object)adaptor.GetNilNode();

            	W=(IToken)Match(input,WHILE,FOLLOW_WHILE_in_whileStatement9242); if (state.failed) return retval;
            	if ( state.backtracking == 0 )
            	{W_tree = (object)adaptor.Create(W);
            		adaptor.AddChild(root_0, W_tree);
            	}
            	if ( state.backtracking == 0 ) 
            	{
            	  Emit((CommonToken)W);InsertWS(mPrinter.GetSpacesBetweenControlKeywordsAndParens());
            	}
            	if ( state.backtracking == 0 ) 
            	{
            	  PushExpressionIndent();
            	}
            	PushFollow(FOLLOW_parExpression_in_whileStatement9247);
            	parExpression204 = parExpression();
            	state.followingStackPointer--;
            	if (state.failed) return retval;
            	if ( state.backtracking == 0 ) adaptor.AddChild(root_0, parExpression204.Tree);
            	if ( state.backtracking == 0 ) 
            	{
            	  PopIndent();
            	}
            	if ( state.backtracking == 0 ) 
            	{
            	  PushIndent(false);
            	}
            	PushFollow(FOLLOW_statement_in_whileStatement9253);
            	statement205 = statement();
            	state.followingStackPointer--;
            	if (state.failed) return retval;
            	if ( state.backtracking == 0 ) adaptor.AddChild(root_0, statement205.Tree);
            	if ( state.backtracking == 0 ) 
            	{
            	  PopIndent();
            	}

            }

            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, 84, whileStatement_StartIndex); 
            }
        }
        return retval;
    }
Example #2
0
    // $ANTLR start "whileStatement"
    // AS3_ex.g3:2673:1: whileStatement : W= WHILE parExpression statement ;
    public AS3_exParser.whileStatement_return whileStatement() // throws RecognitionException [1]
    {   
        AS3_exParser.whileStatement_return retval = new AS3_exParser.whileStatement_return();
        retval.Start = input.LT(1);
        int whileStatement_StartIndex = input.Index();
        object root_0 = null;

        IToken W = null;
        AS3_exParser.parExpression_return parExpression215 = null;

        AS3_exParser.statement_return statement216 = null;


        object W_tree=null;


            int statementStartInOutput=(-1);
            int statementEndInOutput=(-1);
            int statementCount=0;
            IToken endToken=null;

        try 
        {
            if ( (state.backtracking > 0) && AlreadyParsedRule(input, 84) ) 
            {
                return retval; 
            }
            // AS3_ex.g3:2681:5: (W= WHILE parExpression statement )
            // AS3_ex.g3:2682:8: W= WHILE parExpression statement
            {
                root_0 = (object)adaptor.GetNilNode();

                if ( state.backtracking == 0 ) 
                {
                  mPrinter.markDeclEqualsContextChange();
                }
                W=(IToken)Match(input,WHILE,FOLLOW_WHILE_in_whileStatement10151); if (state.failed) return retval;
                if ( state.backtracking == 0 )
                {W_tree = (object)adaptor.Create(W);
                    adaptor.AddChild(root_0, W_tree);
                }
                if ( state.backtracking == 0 ) 
                {
                  emit(W);statementStartInOutput=mPrinter.getCurrentOutputLength();insertWS(mPrinter.getSpacesBetweenControlKeywordsAndParens());
                }
                if ( state.backtracking == 0 ) 
                {
                  pushExpressionIndent();
                }
                PushFollow(FOLLOW_parExpression_in_whileStatement10156);
                parExpression215 = parExpression();
                state.followingStackPointer--;
                if (state.failed) return retval;
                if ( state.backtracking == 0 ) adaptor.AddChild(root_0, parExpression215.Tree);
                if ( state.backtracking == 0 ) 
                {
                  endToken=input.LT(-1);statementEndInOutput=mPrinter.getCurrentOutputLength();popIndent();
                }
                if ( state.backtracking == 0 ) 
                {
                  pushIndent(false);
                }
                if ( state.backtracking == 0 ) 
                {
                  mPrinter.addOpenBrace(input, ASPrettyPrinter.BraceAdd_Loop);
                         mPrinter.captureStatementStart(W, statementStartInOutput);
                         mPrinter.captureStatementEnd(endToken, statementEndInOutput);
                         statementCount=mStatementCount;
                        
                }
                PushFollow(FOLLOW_statement_in_whileStatement10176);
                statement216 = statement();
                state.followingStackPointer--;
                if (state.failed) return retval;
                if ( state.backtracking == 0 ) adaptor.AddChild(root_0, statement216.Tree);
                if ( state.backtracking == 0 ) 
                {
                  mPrinter.addCloseBrace(input.LT(1), ASPrettyPrinter.BraceAdd_Loop, mStatementCount-statementCount);
                }
                if ( state.backtracking == 0 ) 
                {
                  popIndent();
                }

            }

            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, 84, whileStatement_StartIndex); 
            }
        }
        return retval;
    }