Exemplo n.º 1
0
    // $ANTLR start "forStatementInitialiserPart"
    // JavaScript.g:138:1: forStatementInitialiserPart : ( expression -> ^( EXPRESSIONSTATEMENT expression ) | 'var' ( LT )* variableDeclarationList );
    public JavaScriptParser.forStatementInitialiserPart_return forStatementInitialiserPart() // throws RecognitionException [1]
    {   
        JavaScriptParser.forStatementInitialiserPart_return retval = new JavaScriptParser.forStatementInitialiserPart_return();
        retval.Start = input.LT(1);

        object root_0 = null;

        IToken string_literal136 = null;
        IToken LT137 = null;
        JavaScriptParser.expression_return expression135 = default(JavaScriptParser.expression_return);

        JavaScriptParser.variableDeclarationList_return variableDeclarationList138 = default(JavaScriptParser.variableDeclarationList_return);


        object string_literal136_tree=null;
        object LT137_tree=null;
        RewriteRuleSubtreeStream stream_expression = new RewriteRuleSubtreeStream(adaptor,"rule expression");
        try 
    	{
            // JavaScript.g:139:2: ( expression -> ^( EXPRESSIONSTATEMENT expression ) | 'var' ( LT )* variableDeclarationList )
            int alt73 = 2;
            int LA73_0 = input.LA(1);

            if ( ((LA73_0 >= Identifier && LA73_0 <= RegexLiteral) || (LA73_0 >= 39 && LA73_0 <= 40) || LA73_0 == 42 || (LA73_0 >= 66 && LA73_0 <= 67) || (LA73_0 >= 99 && LA73_0 <= 100) || (LA73_0 >= 104 && LA73_0 <= 114)) )
            {
                alt73 = 1;
            }
            else if ( (LA73_0 == 45) )
            {
                alt73 = 2;
            }
            else 
            {
                if ( state.backtracking > 0 ) {state.failed = true; return retval;}
                NoViableAltException nvae_d73s0 =
                    new NoViableAltException("", 73, 0, input);

                throw nvae_d73s0;
            }
            switch (alt73) 
            {
                case 1 :
                    // JavaScript.g:139:4: expression
                    {
                    	PushFollow(FOLLOW_expression_in_forStatementInitialiserPart1113);
                    	expression135 = expression();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;
                    	if ( (state.backtracking==0) ) stream_expression.Add(expression135.Tree);


                    	// AST REWRITE
                    	// elements:          expression
                    	// token labels:      
                    	// rule labels:       retval
                    	// token list labels: 
                    	// rule list labels:  
                    	// wildcard labels: 
                    	if ( (state.backtracking==0) ) {
                    	retval.Tree = root_0;
                    	RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval!=null ? retval.Tree : null);

                    	root_0 = (object)adaptor.GetNilNode();
                    	// 139:16: -> ^( EXPRESSIONSTATEMENT expression )
                    	{
                    	    // JavaScript.g:139:19: ^( EXPRESSIONSTATEMENT expression )
                    	    {
                    	    object root_1 = (object)adaptor.GetNilNode();
                    	    root_1 = (object)adaptor.BecomeRoot(new ExpressionStatement(EXPRESSIONSTATEMENT), root_1);

                    	    adaptor.AddChild(root_1, stream_expression.NextTree());

                    	    adaptor.AddChild(root_0, root_1);
                    	    }

                    	}

                    	retval.Tree = root_0;retval.Tree = root_0;}
                    }
                    break;
                case 2 :
                    // JavaScript.g:140:4: 'var' ( LT )* variableDeclarationList
                    {
                    	root_0 = (object)adaptor.GetNilNode();

                    	string_literal136=(IToken)Match(input,45,FOLLOW_45_in_forStatementInitialiserPart1130); if (state.failed) return retval;
                    	if ( state.backtracking == 0 )
                    	{string_literal136_tree = new VarDeclStatement(string_literal136) ;
                    		root_0 = (object)adaptor.BecomeRoot(string_literal136_tree, root_0);
                    	}
                    	// JavaScript.g:140:31: ( LT )*
                    	do 
                    	{
                    	    int alt72 = 2;
                    	    int LA72_0 = input.LA(1);

                    	    if ( (LA72_0 == LT) )
                    	    {
                    	        alt72 = 1;
                    	    }


                    	    switch (alt72) 
                    		{
                    			case 1 :
                    			    // JavaScript.g:140:31: LT
                    			    {
                    			    	LT137=(IToken)Match(input,LT,FOLLOW_LT_in_forStatementInitialiserPart1136); if (state.failed) return retval;

                    			    }
                    			    break;

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

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

                    	PushFollow(FOLLOW_variableDeclarationList_in_forStatementInitialiserPart1140);
                    	variableDeclarationList138 = variableDeclarationList();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;
                    	if ( state.backtracking == 0 ) adaptor.AddChild(root_0, variableDeclarationList138.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 
    	{
        }
        return retval;
    }
Exemplo n.º 2
0
    // $ANTLR start "variableStatement"
    // JavaScript.g:82:1: variableStatement : 'var' ( LT )* variableDeclarationList statementEnd ;
    public JavaScriptParser.variableStatement_return variableStatement() // throws RecognitionException [1]
    {   
        JavaScriptParser.variableStatement_return retval = new JavaScriptParser.variableStatement_return();
        retval.Start = input.LT(1);

        object root_0 = null;

        IToken string_literal63 = null;
        IToken LT64 = null;
        JavaScriptParser.variableDeclarationList_return variableDeclarationList65 = default(JavaScriptParser.variableDeclarationList_return);

        JavaScriptParser.statementEnd_return statementEnd66 = default(JavaScriptParser.statementEnd_return);


        object string_literal63_tree=null;
        object LT64_tree=null;

        try 
    	{
            // JavaScript.g:83:2: ( 'var' ( LT )* variableDeclarationList statementEnd )
            // JavaScript.g:83:4: 'var' ( LT )* variableDeclarationList statementEnd
            {
            	root_0 = (object)adaptor.GetNilNode();

            	string_literal63=(IToken)Match(input,45,FOLLOW_45_in_variableStatement604); if (state.failed) return retval;
            	if ( state.backtracking == 0 )
            	{string_literal63_tree = new VarDeclStatement(string_literal63) ;
            		root_0 = (object)adaptor.BecomeRoot(string_literal63_tree, root_0);
            	}
            	// JavaScript.g:83:31: ( LT )*
            	do 
            	{
            	    int alt36 = 2;
            	    int LA36_0 = input.LA(1);

            	    if ( (LA36_0 == LT) )
            	    {
            	        alt36 = 1;
            	    }


            	    switch (alt36) 
            		{
            			case 1 :
            			    // JavaScript.g:83:31: LT
            			    {
            			    	LT64=(IToken)Match(input,LT,FOLLOW_LT_in_variableStatement610); if (state.failed) return retval;

            			    }
            			    break;

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

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

            	PushFollow(FOLLOW_variableDeclarationList_in_variableStatement614);
            	variableDeclarationList65 = variableDeclarationList();
            	state.followingStackPointer--;
            	if (state.failed) return retval;
            	if ( state.backtracking == 0 ) adaptor.AddChild(root_0, variableDeclarationList65.Tree);
            	PushFollow(FOLLOW_statementEnd_in_variableStatement616);
            	statementEnd66 = statementEnd();
            	state.followingStackPointer--;
            	if (state.failed) return retval;

            }

            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 
    	{
        }
        return retval;
    }