예제 #1
0
    // $ANTLR start "unaryExpression"
    // E:\\SGL\\sgl4c#\\NewSGLGramma\\SGL.g:334:1: unaryExpression : Identifier ( '++' -> ^( VARINC Identifier ) | '--' -> ^( VARDEC Identifier ) ) ;
    public SGLParser.unaryExpression_return unaryExpression() // throws RecognitionException [1]
    {   
        SGLParser.unaryExpression_return retval = new SGLParser.unaryExpression_return();
        retval.Start = input.LT(1);
        int unaryExpression_StartIndex = input.Index();
        object root_0 = null;

        IToken Identifier107 = null;
        IToken string_literal108 = null;
        IToken string_literal109 = null;

        object Identifier107_tree=null;
        object string_literal108_tree=null;
        object string_literal109_tree=null;
        RewriteRuleTokenStream stream_79 = new RewriteRuleTokenStream(adaptor,"token 79");
        RewriteRuleTokenStream stream_80 = new RewriteRuleTokenStream(adaptor,"token 80");
        RewriteRuleTokenStream stream_Identifier = new RewriteRuleTokenStream(adaptor,"token Identifier");

        try 
    	{
    	    if ( (state.backtracking > 0) && AlreadyParsedRule(input, 29) ) 
    	    {
    	    	return retval; 
    	    }
            // E:\\SGL\\sgl4c#\\NewSGLGramma\\SGL.g:335:5: ( Identifier ( '++' -> ^( VARINC Identifier ) | '--' -> ^( VARDEC Identifier ) ) )
            // E:\\SGL\\sgl4c#\\NewSGLGramma\\SGL.g:335:9: Identifier ( '++' -> ^( VARINC Identifier ) | '--' -> ^( VARDEC Identifier ) )
            {
            	Identifier107=(IToken)Match(input,Identifier,FOLLOW_Identifier_in_unaryExpression1269); if (state.failed) return retval; 
            	if ( (state.backtracking==0) ) stream_Identifier.Add(Identifier107);

            	// E:\\SGL\\sgl4c#\\NewSGLGramma\\SGL.g:335:20: ( '++' -> ^( VARINC Identifier ) | '--' -> ^( VARDEC Identifier ) )
            	int alt33 = 2;
            	int LA33_0 = input.LA(1);

            	if ( (LA33_0 == 79) )
            	{
            	    alt33 = 1;
            	}
            	else if ( (LA33_0 == 80) )
            	{
            	    alt33 = 2;
            	}
            	else 
            	{
            	    if ( state.backtracking > 0 ) {state.failed = true; return retval;}
            	    NoViableAltException nvae_d33s0 =
            	        new NoViableAltException("", 33, 0, input);

            	    throw nvae_d33s0;
            	}
            	switch (alt33) 
            	{
            	    case 1 :
            	        // E:\\SGL\\sgl4c#\\NewSGLGramma\\SGL.g:335:21: '++'
            	        {
            	        	string_literal108=(IToken)Match(input,79,FOLLOW_79_in_unaryExpression1272); if (state.failed) return retval; 
            	        	if ( (state.backtracking==0) ) stream_79.Add(string_literal108);



            	        	// AST REWRITE
            	        	// elements:          Identifier
            	        	// 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();
            	        	// 335:26: -> ^( VARINC Identifier )
            	        	{
            	        	    // E:\\SGL\\sgl4c#\\NewSGLGramma\\SGL.g:335:29: ^( VARINC Identifier )
            	        	    {
            	        	    object root_1 = (object)adaptor.GetNilNode();
            	        	    root_1 = (object)adaptor.BecomeRoot((object)adaptor.Create(VARINC, "VARINC"), root_1);

            	        	    adaptor.AddChild(root_1, stream_Identifier.NextNode());

            	        	    adaptor.AddChild(root_0, root_1);
            	        	    }

            	        	}

            	        	retval.Tree = root_0;retval.Tree = root_0;}
            	        }
            	        break;
            	    case 2 :
            	        // E:\\SGL\\sgl4c#\\NewSGLGramma\\SGL.g:336:4: '--'
            	        {
            	        	string_literal109=(IToken)Match(input,80,FOLLOW_80_in_unaryExpression1285); if (state.failed) return retval; 
            	        	if ( (state.backtracking==0) ) stream_80.Add(string_literal109);



            	        	// AST REWRITE
            	        	// elements:          Identifier
            	        	// 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();
            	        	// 336:9: -> ^( VARDEC Identifier )
            	        	{
            	        	    // E:\\SGL\\sgl4c#\\NewSGLGramma\\SGL.g:336:12: ^( VARDEC Identifier )
            	        	    {
            	        	    object root_1 = (object)adaptor.GetNilNode();
            	        	    root_1 = (object)adaptor.BecomeRoot((object)adaptor.Create(VARDEC, "VARDEC"), root_1);

            	        	    adaptor.AddChild(root_1, stream_Identifier.NextNode());

            	        	    adaptor.AddChild(root_0, root_1);
            	        	    }

            	        	}

            	        	retval.Tree = root_0;retval.Tree = root_0;}
            	        }
            	        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, 29, unaryExpression_StartIndex); 
            }
        }
        return retval;
    }
예제 #2
0
파일: SGLParser.cs 프로젝트: peppy/sgl4cs
    // $ANTLR start "unaryExpression"
    // C:\\Users\\Dominik Halfkann\\Documents\\Visual Studio 2010\\Projects\\SGLParserTester\\SGL\\AntlrParser\\SGL.g:349:1: unaryExpression : ( '++' unaryExpression | '--' unaryExpression | unaryExpressionNotPlusMinus );
    public SGLParser.unaryExpression_return unaryExpression() // throws RecognitionException [1]
    {   
        SGLParser.unaryExpression_return retval = new SGLParser.unaryExpression_return();
        retval.Start = input.LT(1);

        object root_0 = null;

        IToken string_literal121 = null;
        IToken string_literal123 = null;
        SGLParser.unaryExpression_return unaryExpression122 = default(SGLParser.unaryExpression_return);

        SGLParser.unaryExpression_return unaryExpression124 = default(SGLParser.unaryExpression_return);

        SGLParser.unaryExpressionNotPlusMinus_return unaryExpressionNotPlusMinus125 = default(SGLParser.unaryExpressionNotPlusMinus_return);


        object string_literal121_tree=null;
        object string_literal123_tree=null;

        try 
    	{
            // C:\\Users\\Dominik Halfkann\\Documents\\Visual Studio 2010\\Projects\\SGLParserTester\\SGL\\AntlrParser\\SGL.g:350:5: ( '++' unaryExpression | '--' unaryExpression | unaryExpressionNotPlusMinus )
            int alt31 = 3;
            switch ( input.LA(1) ) 
            {
            case 82:
            	{
                alt31 = 1;
                }
                break;
            case 83:
            	{
                alt31 = 2;
                }
                break;
            case Identifier:
            	{
                alt31 = 3;
                }
                break;
            	default:
            	    NoViableAltException nvae_d31s0 =
            	        new NoViableAltException("", 31, 0, input);

            	    throw nvae_d31s0;
            }

            switch (alt31) 
            {
                case 1 :
                    // C:\\Users\\Dominik Halfkann\\Documents\\Visual Studio 2010\\Projects\\SGLParserTester\\SGL\\AntlrParser\\SGL.g:350:7: '++' unaryExpression
                    {
                    	root_0 = (object)adaptor.GetNilNode();

                    	string_literal121=(IToken)Match(input,82,FOLLOW_82_in_unaryExpression1424); 
                    		string_literal121_tree = (object)adaptor.Create(string_literal121);
                    		adaptor.AddChild(root_0, string_literal121_tree);

                    	PushFollow(FOLLOW_unaryExpression_in_unaryExpression1426);
                    	unaryExpression122 = unaryExpression();
                    	state.followingStackPointer--;

                    	adaptor.AddChild(root_0, unaryExpression122.Tree);

                    }
                    break;
                case 2 :
                    // C:\\Users\\Dominik Halfkann\\Documents\\Visual Studio 2010\\Projects\\SGLParserTester\\SGL\\AntlrParser\\SGL.g:351:9: '--' unaryExpression
                    {
                    	root_0 = (object)adaptor.GetNilNode();

                    	string_literal123=(IToken)Match(input,83,FOLLOW_83_in_unaryExpression1436); 
                    		string_literal123_tree = (object)adaptor.Create(string_literal123);
                    		adaptor.AddChild(root_0, string_literal123_tree);

                    	PushFollow(FOLLOW_unaryExpression_in_unaryExpression1438);
                    	unaryExpression124 = unaryExpression();
                    	state.followingStackPointer--;

                    	adaptor.AddChild(root_0, unaryExpression124.Tree);

                    }
                    break;
                case 3 :
                    // C:\\Users\\Dominik Halfkann\\Documents\\Visual Studio 2010\\Projects\\SGLParserTester\\SGL\\AntlrParser\\SGL.g:352:9: unaryExpressionNotPlusMinus
                    {
                    	root_0 = (object)adaptor.GetNilNode();

                    	PushFollow(FOLLOW_unaryExpressionNotPlusMinus_in_unaryExpression1448);
                    	unaryExpressionNotPlusMinus125 = unaryExpressionNotPlusMinus();
                    	state.followingStackPointer--;

                    	adaptor.AddChild(root_0, unaryExpressionNotPlusMinus125.Tree);

                    }
                    break;

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

            	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;
    }
예제 #3
0
    // $ANTLR start "unaryExpression"
    // D:\\sgl4c#\\NewSGLGramma\\SGL.g:321:1: unaryExpression : variable ( '++' -> ^( VARINC variable ) | '--' -> ^( VARDEC variable ) ) ;
    public SGLParser.unaryExpression_return unaryExpression() // throws RecognitionException [1]
    {   
        SGLParser.unaryExpression_return retval = new SGLParser.unaryExpression_return();
        retval.Start = input.LT(1);
        int unaryExpression_StartIndex = input.Index();
        object root_0 = null;

        IToken string_literal111 = null;
        IToken string_literal112 = null;
        SGLParser.variable_return variable110 = default(SGLParser.variable_return);


        object string_literal111_tree=null;
        object string_literal112_tree=null;
        RewriteRuleTokenStream stream_80 = new RewriteRuleTokenStream(adaptor,"token 80");
        RewriteRuleTokenStream stream_81 = new RewriteRuleTokenStream(adaptor,"token 81");
        RewriteRuleSubtreeStream stream_variable = new RewriteRuleSubtreeStream(adaptor,"rule variable");
        try 
    	{
    	    if ( (state.backtracking > 0) && AlreadyParsedRule(input, 30) ) 
    	    {
    	    	return retval; 
    	    }
            // D:\\sgl4c#\\NewSGLGramma\\SGL.g:322:5: ( variable ( '++' -> ^( VARINC variable ) | '--' -> ^( VARDEC variable ) ) )
            // D:\\sgl4c#\\NewSGLGramma\\SGL.g:322:9: variable ( '++' -> ^( VARINC variable ) | '--' -> ^( VARDEC variable ) )
            {
            	PushFollow(FOLLOW_variable_in_unaryExpression1242);
            	variable110 = variable();
            	state.followingStackPointer--;
            	if (state.failed) return retval;
            	if ( (state.backtracking==0) ) stream_variable.Add(variable110.Tree);
            	// D:\\sgl4c#\\NewSGLGramma\\SGL.g:322:18: ( '++' -> ^( VARINC variable ) | '--' -> ^( VARDEC variable ) )
            	int alt33 = 2;
            	int LA33_0 = input.LA(1);

            	if ( (LA33_0 == 80) )
            	{
            	    alt33 = 1;
            	}
            	else if ( (LA33_0 == 81) )
            	{
            	    alt33 = 2;
            	}
            	else 
            	{
            	    if ( state.backtracking > 0 ) {state.failed = true; return retval;}
            	    NoViableAltException nvae_d33s0 =
            	        new NoViableAltException("", 33, 0, input);

            	    throw nvae_d33s0;
            	}
            	switch (alt33) 
            	{
            	    case 1 :
            	        // D:\\sgl4c#\\NewSGLGramma\\SGL.g:322:19: '++'
            	        {
            	        	string_literal111=(IToken)Match(input,80,FOLLOW_80_in_unaryExpression1245); if (state.failed) return retval; 
            	        	if ( (state.backtracking==0) ) stream_80.Add(string_literal111);



            	        	// AST REWRITE
            	        	// elements:          variable
            	        	// 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();
            	        	// 322:24: -> ^( VARINC variable )
            	        	{
            	        	    // D:\\sgl4c#\\NewSGLGramma\\SGL.g:322:27: ^( VARINC variable )
            	        	    {
            	        	    object root_1 = (object)adaptor.GetNilNode();
            	        	    root_1 = (object)adaptor.BecomeRoot((object)adaptor.Create(VARINC, "VARINC"), root_1);

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

            	        	    adaptor.AddChild(root_0, root_1);
            	        	    }

            	        	}

            	        	retval.Tree = root_0;retval.Tree = root_0;}
            	        }
            	        break;
            	    case 2 :
            	        // D:\\sgl4c#\\NewSGLGramma\\SGL.g:323:4: '--'
            	        {
            	        	string_literal112=(IToken)Match(input,81,FOLLOW_81_in_unaryExpression1258); if (state.failed) return retval; 
            	        	if ( (state.backtracking==0) ) stream_81.Add(string_literal112);



            	        	// AST REWRITE
            	        	// elements:          variable
            	        	// 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();
            	        	// 323:9: -> ^( VARDEC variable )
            	        	{
            	        	    // D:\\sgl4c#\\NewSGLGramma\\SGL.g:323:12: ^( VARDEC variable )
            	        	    {
            	        	    object root_1 = (object)adaptor.GetNilNode();
            	        	    root_1 = (object)adaptor.BecomeRoot((object)adaptor.Create(VARDEC, "VARDEC"), root_1);

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

            	        	    adaptor.AddChild(root_0, root_1);
            	        	    }

            	        	}

            	        	retval.Tree = root_0;retval.Tree = root_0;}
            	        }
            	        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, 30, unaryExpression_StartIndex); 
            }
        }
        return retval;
    }