Inheritance: Antlr.Runtime.ParserRuleReturnScope
Esempio n. 1
0
    // $ANTLR start "setExpr"
    // C:\\Development\\TT.Net\\TT\\Template.g:91:1: setExpr : ( ( 'SET' )? ID ASSIGN LITERAL -> ^( SET ID LITERAL ) | ( 'SET' )? ID ASSIGN NUMBER -> ^( SET ID NUMBER ) | ( 'SET' )? ID ASSIGN DECIMAL -> ^( SET ID DECIMAL ) );
    public TemplateParser.setExpr_return setExpr() // throws RecognitionException [1]
    {   
        TemplateParser.setExpr_return retval = new TemplateParser.setExpr_return();
        retval.Start = input.LT(1);

        CommonTree root_0 = null;

        IToken string_literal13 = null;
        IToken ID14 = null;
        IToken ASSIGN15 = null;
        IToken LITERAL16 = null;
        IToken string_literal17 = null;
        IToken ID18 = null;
        IToken ASSIGN19 = null;
        IToken NUMBER20 = null;
        IToken string_literal21 = null;
        IToken ID22 = null;
        IToken ASSIGN23 = null;
        IToken DECIMAL24 = null;

        CommonTree string_literal13_tree=null;
        CommonTree ID14_tree=null;
        CommonTree ASSIGN15_tree=null;
        CommonTree LITERAL16_tree=null;
        CommonTree string_literal17_tree=null;
        CommonTree ID18_tree=null;
        CommonTree ASSIGN19_tree=null;
        CommonTree NUMBER20_tree=null;
        CommonTree string_literal21_tree=null;
        CommonTree ID22_tree=null;
        CommonTree ASSIGN23_tree=null;
        CommonTree DECIMAL24_tree=null;
        RewriteRuleTokenStream stream_LITERAL = new RewriteRuleTokenStream(adaptor,"token LITERAL");
        RewriteRuleTokenStream stream_56 = new RewriteRuleTokenStream(adaptor,"token 56");
        RewriteRuleTokenStream stream_DECIMAL = new RewriteRuleTokenStream(adaptor,"token DECIMAL");
        RewriteRuleTokenStream stream_ID = new RewriteRuleTokenStream(adaptor,"token ID");
        RewriteRuleTokenStream stream_NUMBER = new RewriteRuleTokenStream(adaptor,"token NUMBER");
        RewriteRuleTokenStream stream_ASSIGN = new RewriteRuleTokenStream(adaptor,"token ASSIGN");

        try {
        	dbg.EnterRule(GrammarFileName, "setExpr");
        	if ( RuleLevel==0 ) {dbg.Commence();}
        	IncRuleLevel();
        	dbg.Location(91, 1);

        try 
    	{
            // C:\\Development\\TT.Net\\TT\\Template.g:92:2: ( ( 'SET' )? ID ASSIGN LITERAL -> ^( SET ID LITERAL ) | ( 'SET' )? ID ASSIGN NUMBER -> ^( SET ID NUMBER ) | ( 'SET' )? ID ASSIGN DECIMAL -> ^( SET ID DECIMAL ) )
            int alt10 = 3;
            try { dbg.EnterDecision(10);

            int LA10_0 = input.LA(1);

            if ( (LA10_0 == 56) )
            {
                int LA10_1 = input.LA(2);

                if ( (LA10_1 == ID) )
                {
                    int LA10_2 = input.LA(3);

                    if ( (LA10_2 == ASSIGN) )
                    {
                        switch ( input.LA(4) ) 
                        {
                        case LITERAL:
                        	{
                            alt10 = 1;
                            }
                            break;
                        case NUMBER:
                        	{
                            alt10 = 2;
                            }
                            break;
                        case DECIMAL:
                        	{
                            alt10 = 3;
                            }
                            break;
                        	default:
                        	    NoViableAltException nvae_d10s3 =
                        	        new NoViableAltException("", 10, 3, input);

                        	    dbg.RecognitionException(nvae_d10s3);
                        	    throw nvae_d10s3;
                        }

                    }
                    else 
                    {
                        NoViableAltException nvae_d10s2 =
                            new NoViableAltException("", 10, 2, input);

                        dbg.RecognitionException(nvae_d10s2);
                        throw nvae_d10s2;
                    }
                }
                else 
                {
                    NoViableAltException nvae_d10s1 =
                        new NoViableAltException("", 10, 1, input);

                    dbg.RecognitionException(nvae_d10s1);
                    throw nvae_d10s1;
                }
            }
            else if ( (LA10_0 == ID) )
            {
                int LA10_2 = input.LA(2);

                if ( (LA10_2 == ASSIGN) )
                {
                    switch ( input.LA(3) ) 
                    {
                    case LITERAL:
                    	{
                        alt10 = 1;
                        }
                        break;
                    case NUMBER:
                    	{
                        alt10 = 2;
                        }
                        break;
                    case DECIMAL:
                    	{
                        alt10 = 3;
                        }
                        break;
                    	default:
                    	    NoViableAltException nvae_d10s3 =
                    	        new NoViableAltException("", 10, 3, input);

                    	    dbg.RecognitionException(nvae_d10s3);
                    	    throw nvae_d10s3;
                    }

                }
                else 
                {
                    NoViableAltException nvae_d10s2 =
                        new NoViableAltException("", 10, 2, input);

                    dbg.RecognitionException(nvae_d10s2);
                    throw nvae_d10s2;
                }
            }
            else 
            {
                NoViableAltException nvae_d10s0 =
                    new NoViableAltException("", 10, 0, input);

                dbg.RecognitionException(nvae_d10s0);
                throw nvae_d10s0;
            }
            } finally { dbg.ExitDecision(10); }

            switch (alt10) 
            {
                case 1 :
                    dbg.EnterAlt(1);

                    // C:\\Development\\TT.Net\\TT\\Template.g:92:4: ( 'SET' )? ID ASSIGN LITERAL
                    {
                    	dbg.Location(92,4);
                    	// C:\\Development\\TT.Net\\TT\\Template.g:92:4: ( 'SET' )?
                    	int alt7 = 2;
                    	try { dbg.EnterSubRule(7);
                    	try { dbg.EnterDecision(7);

                    	int LA7_0 = input.LA(1);

                    	if ( (LA7_0 == 56) )
                    	{
                    	    alt7 = 1;
                    	}
                    	} finally { dbg.ExitDecision(7); }

                    	switch (alt7) 
                    	{
                    	    case 1 :
                    	        dbg.EnterAlt(1);

                    	        // C:\\Development\\TT.Net\\TT\\Template.g:92:4: 'SET'
                    	        {
                    	        	dbg.Location(92,4);
                    	        	string_literal13=(IToken)Match(input,56,FOLLOW_56_in_setExpr583);  
                    	        	stream_56.Add(string_literal13);


                    	        }
                    	        break;

                    	}
                    	} finally { dbg.ExitSubRule(7); }

                    	dbg.Location(92,11);
                    	ID14=(IToken)Match(input,ID,FOLLOW_ID_in_setExpr586);  
                    	stream_ID.Add(ID14);

                    	dbg.Location(92,14);
                    	ASSIGN15=(IToken)Match(input,ASSIGN,FOLLOW_ASSIGN_in_setExpr588);  
                    	stream_ASSIGN.Add(ASSIGN15);

                    	dbg.Location(92,21);
                    	LITERAL16=(IToken)Match(input,LITERAL,FOLLOW_LITERAL_in_setExpr590);  
                    	stream_LITERAL.Add(LITERAL16);



                    	// AST REWRITE
                    	// elements:          ID, LITERAL
                    	// token labels:      
                    	// rule labels:       retval
                    	// token list labels: 
                    	// rule list labels:  
                    	// wildcard labels: 
                    	retval.Tree = root_0;
                    	RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval!=null ? retval.Tree : null);

                    	root_0 = (CommonTree)adaptor.GetNilNode();
                    	// 92:29: -> ^( SET ID LITERAL )
                    	{
                    	    dbg.Location(92,32);
                    	    // C:\\Development\\TT.Net\\TT\\Template.g:92:32: ^( SET ID LITERAL )
                    	    {
                    	    CommonTree root_1 = (CommonTree)adaptor.GetNilNode();
                    	    dbg.Location(92,34);
                    	    root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(SET, "SET"), root_1);

                    	    dbg.Location(92,38);
                    	    adaptor.AddChild(root_1, stream_ID.NextNode());
                    	    dbg.Location(92,41);
                    	    adaptor.AddChild(root_1, stream_LITERAL.NextNode());

                    	    adaptor.AddChild(root_0, root_1);
                    	    }

                    	}

                    	retval.Tree = root_0;retval.Tree = root_0;
                    }
                    break;
                case 2 :
                    dbg.EnterAlt(2);

                    // C:\\Development\\TT.Net\\TT\\Template.g:93:4: ( 'SET' )? ID ASSIGN NUMBER
                    {
                    	dbg.Location(93,4);
                    	// C:\\Development\\TT.Net\\TT\\Template.g:93:4: ( 'SET' )?
                    	int alt8 = 2;
                    	try { dbg.EnterSubRule(8);
                    	try { dbg.EnterDecision(8);

                    	int LA8_0 = input.LA(1);

                    	if ( (LA8_0 == 56) )
                    	{
                    	    alt8 = 1;
                    	}
                    	} finally { dbg.ExitDecision(8); }

                    	switch (alt8) 
                    	{
                    	    case 1 :
                    	        dbg.EnterAlt(1);

                    	        // C:\\Development\\TT.Net\\TT\\Template.g:93:4: 'SET'
                    	        {
                    	        	dbg.Location(93,4);
                    	        	string_literal17=(IToken)Match(input,56,FOLLOW_56_in_setExpr605);  
                    	        	stream_56.Add(string_literal17);


                    	        }
                    	        break;

                    	}
                    	} finally { dbg.ExitSubRule(8); }

                    	dbg.Location(93,11);
                    	ID18=(IToken)Match(input,ID,FOLLOW_ID_in_setExpr608);  
                    	stream_ID.Add(ID18);

                    	dbg.Location(93,14);
                    	ASSIGN19=(IToken)Match(input,ASSIGN,FOLLOW_ASSIGN_in_setExpr610);  
                    	stream_ASSIGN.Add(ASSIGN19);

                    	dbg.Location(93,21);
                    	NUMBER20=(IToken)Match(input,NUMBER,FOLLOW_NUMBER_in_setExpr612);  
                    	stream_NUMBER.Add(NUMBER20);



                    	// AST REWRITE
                    	// elements:          NUMBER, ID
                    	// token labels:      
                    	// rule labels:       retval
                    	// token list labels: 
                    	// rule list labels:  
                    	// wildcard labels: 
                    	retval.Tree = root_0;
                    	RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval!=null ? retval.Tree : null);

                    	root_0 = (CommonTree)adaptor.GetNilNode();
                    	// 93:29: -> ^( SET ID NUMBER )
                    	{
                    	    dbg.Location(93,32);
                    	    // C:\\Development\\TT.Net\\TT\\Template.g:93:32: ^( SET ID NUMBER )
                    	    {
                    	    CommonTree root_1 = (CommonTree)adaptor.GetNilNode();
                    	    dbg.Location(93,34);
                    	    root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(SET, "SET"), root_1);

                    	    dbg.Location(93,38);
                    	    adaptor.AddChild(root_1, stream_ID.NextNode());
                    	    dbg.Location(93,41);
                    	    adaptor.AddChild(root_1, stream_NUMBER.NextNode());

                    	    adaptor.AddChild(root_0, root_1);
                    	    }

                    	}

                    	retval.Tree = root_0;retval.Tree = root_0;
                    }
                    break;
                case 3 :
                    dbg.EnterAlt(3);

                    // C:\\Development\\TT.Net\\TT\\Template.g:94:4: ( 'SET' )? ID ASSIGN DECIMAL
                    {
                    	dbg.Location(94,4);
                    	// C:\\Development\\TT.Net\\TT\\Template.g:94:4: ( 'SET' )?
                    	int alt9 = 2;
                    	try { dbg.EnterSubRule(9);
                    	try { dbg.EnterDecision(9);

                    	int LA9_0 = input.LA(1);

                    	if ( (LA9_0 == 56) )
                    	{
                    	    alt9 = 1;
                    	}
                    	} finally { dbg.ExitDecision(9); }

                    	switch (alt9) 
                    	{
                    	    case 1 :
                    	        dbg.EnterAlt(1);

                    	        // C:\\Development\\TT.Net\\TT\\Template.g:94:4: 'SET'
                    	        {
                    	        	dbg.Location(94,4);
                    	        	string_literal21=(IToken)Match(input,56,FOLLOW_56_in_setExpr628);  
                    	        	stream_56.Add(string_literal21);


                    	        }
                    	        break;

                    	}
                    	} finally { dbg.ExitSubRule(9); }

                    	dbg.Location(94,11);
                    	ID22=(IToken)Match(input,ID,FOLLOW_ID_in_setExpr631);  
                    	stream_ID.Add(ID22);

                    	dbg.Location(94,14);
                    	ASSIGN23=(IToken)Match(input,ASSIGN,FOLLOW_ASSIGN_in_setExpr633);  
                    	stream_ASSIGN.Add(ASSIGN23);

                    	dbg.Location(94,21);
                    	DECIMAL24=(IToken)Match(input,DECIMAL,FOLLOW_DECIMAL_in_setExpr635);  
                    	stream_DECIMAL.Add(DECIMAL24);



                    	// AST REWRITE
                    	// elements:          DECIMAL, ID
                    	// token labels:      
                    	// rule labels:       retval
                    	// token list labels: 
                    	// rule list labels:  
                    	// wildcard labels: 
                    	retval.Tree = root_0;
                    	RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval!=null ? retval.Tree : null);

                    	root_0 = (CommonTree)adaptor.GetNilNode();
                    	// 94:29: -> ^( SET ID DECIMAL )
                    	{
                    	    dbg.Location(94,32);
                    	    // C:\\Development\\TT.Net\\TT\\Template.g:94:32: ^( SET ID DECIMAL )
                    	    {
                    	    CommonTree root_1 = (CommonTree)adaptor.GetNilNode();
                    	    dbg.Location(94,34);
                    	    root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(SET, "SET"), root_1);

                    	    dbg.Location(94,38);
                    	    adaptor.AddChild(root_1, stream_ID.NextNode());
                    	    dbg.Location(94,41);
                    	    adaptor.AddChild(root_1, stream_DECIMAL.NextNode());

                    	    adaptor.AddChild(root_0, root_1);
                    	    }

                    	}

                    	retval.Tree = root_0;retval.Tree = root_0;
                    }
                    break;

            }
            retval.Stop = input.LT(-1);

            	retval.Tree = (CommonTree)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 = (CommonTree)adaptor.ErrorNode(input, (IToken) retval.Start, input.LT(-1), re);

        }
        finally 
    	{
        }
        dbg.Location(95, 2);

        }
        finally {
            dbg.ExitRule(GrammarFileName, "setExpr");
            DecRuleLevel();
            if ( RuleLevel==0 ) {dbg.Terminate();}
        }

        return retval;
    }
Esempio n. 2
0
    // $ANTLR start "setExpr"
    // TT\\Template.g:104:1: setExpr : ( 'SET' )? ( assignment )+ -> ( ^( SET assignment ) )+ ;
    public TemplateParser.setExpr_return setExpr() // throws RecognitionException [1]
    {   
        TemplateParser.setExpr_return retval = new TemplateParser.setExpr_return();
        retval.Start = input.LT(1);

        CommonTree root_0 = null;

        IToken string_literal34 = null;
        TemplateParser.assignment_return assignment35 = default(TemplateParser.assignment_return);


        CommonTree string_literal34_tree=null;
        RewriteRuleTokenStream stream_58 = new RewriteRuleTokenStream(adaptor,"token 58");
        RewriteRuleSubtreeStream stream_assignment = new RewriteRuleSubtreeStream(adaptor,"rule assignment");
        try 
    	{
            // TT\\Template.g:105:2: ( ( 'SET' )? ( assignment )+ -> ( ^( SET assignment ) )+ )
            // TT\\Template.g:105:4: ( 'SET' )? ( assignment )+
            {
            	// TT\\Template.g:105:4: ( 'SET' )?
            	int alt15 = 2;
            	int LA15_0 = input.LA(1);

            	if ( (LA15_0 == 58) )
            	{
            	    alt15 = 1;
            	}
            	switch (alt15) 
            	{
            	    case 1 :
            	        // TT\\Template.g:105:4: 'SET'
            	        {
            	        	string_literal34=(IToken)Match(input,58,FOLLOW_58_in_setExpr700);  
            	        	stream_58.Add(string_literal34);


            	        }
            	        break;

            	}

            	// TT\\Template.g:105:11: ( assignment )+
            	int cnt16 = 0;
            	do 
            	{
            	    int alt16 = 2;
            	    int LA16_0 = input.LA(1);

            	    if ( (LA16_0 == ID) )
            	    {
            	        alt16 = 1;
            	    }


            	    switch (alt16) 
            		{
            			case 1 :
            			    // TT\\Template.g:105:12: assignment
            			    {
            			    	PushFollow(FOLLOW_assignment_in_setExpr704);
            			    	assignment35 = assignment();
            			    	state.followingStackPointer--;

            			    	stream_assignment.Add(assignment35.Tree);

            			    }
            			    break;

            			default:
            			    if ( cnt16 >= 1 ) goto loop16;
            		            EarlyExitException eee16 =
            		                new EarlyExitException(16, input);
            		            throw eee16;
            	    }
            	    cnt16++;
            	} while (true);

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



            	// AST REWRITE
            	// elements:          assignment
            	// token labels:      
            	// rule labels:       retval
            	// token list labels: 
            	// rule list labels:  
            	// wildcard labels: 
            	retval.Tree = root_0;
            	RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval!=null ? retval.Tree : null);

            	root_0 = (CommonTree)adaptor.GetNilNode();
            	// 105:25: -> ( ^( SET assignment ) )+
            	{
            	    if ( !(stream_assignment.HasNext()) ) {
            	        throw new RewriteEarlyExitException();
            	    }
            	    while ( stream_assignment.HasNext() )
            	    {
            	        // TT\\Template.g:105:28: ^( SET assignment )
            	        {
            	        CommonTree root_1 = (CommonTree)adaptor.GetNilNode();
            	        root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(SET, "SET"), root_1);

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

            	        adaptor.AddChild(root_0, root_1);
            	        }

            	    }
            	    stream_assignment.Reset();

            	}

            	retval.Tree = root_0;retval.Tree = root_0;
            }

            retval.Stop = input.LT(-1);

            	retval.Tree = (CommonTree)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 = (CommonTree)adaptor.ErrorNode(input, (IToken) retval.Start, input.LT(-1), re);

        }
        finally 
    	{
        }
        return retval;
    }