コード例 #1
0
ファイル: SGLParser.cs プロジェクト: peppy/sgl4cs
    // $ANTLR start "additiveExpression"
    // C:\\Users\\Dominik Halfkann\\Documents\\Visual Studio 2010\\Projects\\SGLParserTester\\SGL\\AntlrParser\\SGL.g:339:1: additiveExpression : multiplicativeExpression ( ( '+' | '-' ) multiplicativeExpression )* ;
    public SGLParser.additiveExpression_return additiveExpression() // throws RecognitionException [1]
    {   
        SGLParser.additiveExpression_return retval = new SGLParser.additiveExpression_return();
        retval.Start = input.LT(1);

        object root_0 = null;

        IToken char_literal113 = null;
        IToken char_literal114 = null;
        SGLParser.multiplicativeExpression_return multiplicativeExpression112 = default(SGLParser.multiplicativeExpression_return);

        SGLParser.multiplicativeExpression_return multiplicativeExpression115 = default(SGLParser.multiplicativeExpression_return);


        object char_literal113_tree=null;
        object char_literal114_tree=null;

        try 
    	{
            // C:\\Users\\Dominik Halfkann\\Documents\\Visual Studio 2010\\Projects\\SGLParserTester\\SGL\\AntlrParser\\SGL.g:340:5: ( multiplicativeExpression ( ( '+' | '-' ) multiplicativeExpression )* )
            // C:\\Users\\Dominik Halfkann\\Documents\\Visual Studio 2010\\Projects\\SGLParserTester\\SGL\\AntlrParser\\SGL.g:340:9: multiplicativeExpression ( ( '+' | '-' ) multiplicativeExpression )*
            {
            	root_0 = (object)adaptor.GetNilNode();

            	PushFollow(FOLLOW_multiplicativeExpression_in_additiveExpression1338);
            	multiplicativeExpression112 = multiplicativeExpression();
            	state.followingStackPointer--;

            	adaptor.AddChild(root_0, multiplicativeExpression112.Tree);
            	// C:\\Users\\Dominik Halfkann\\Documents\\Visual Studio 2010\\Projects\\SGLParserTester\\SGL\\AntlrParser\\SGL.g:340:34: ( ( '+' | '-' ) multiplicativeExpression )*
            	do 
            	{
            	    int alt28 = 2;
            	    int LA28_0 = input.LA(1);

            	    if ( ((LA28_0 >= 77 && LA28_0 <= 78)) )
            	    {
            	        alt28 = 1;
            	    }


            	    switch (alt28) 
            		{
            			case 1 :
            			    // C:\\Users\\Dominik Halfkann\\Documents\\Visual Studio 2010\\Projects\\SGLParserTester\\SGL\\AntlrParser\\SGL.g:340:35: ( '+' | '-' ) multiplicativeExpression
            			    {
            			    	// C:\\Users\\Dominik Halfkann\\Documents\\Visual Studio 2010\\Projects\\SGLParserTester\\SGL\\AntlrParser\\SGL.g:340:35: ( '+' | '-' )
            			    	int alt27 = 2;
            			    	int LA27_0 = input.LA(1);

            			    	if ( (LA27_0 == 77) )
            			    	{
            			    	    alt27 = 1;
            			    	}
            			    	else if ( (LA27_0 == 78) )
            			    	{
            			    	    alt27 = 2;
            			    	}
            			    	else 
            			    	{
            			    	    NoViableAltException nvae_d27s0 =
            			    	        new NoViableAltException("", 27, 0, input);

            			    	    throw nvae_d27s0;
            			    	}
            			    	switch (alt27) 
            			    	{
            			    	    case 1 :
            			    	        // C:\\Users\\Dominik Halfkann\\Documents\\Visual Studio 2010\\Projects\\SGLParserTester\\SGL\\AntlrParser\\SGL.g:340:36: '+'
            			    	        {
            			    	        	char_literal113=(IToken)Match(input,77,FOLLOW_77_in_additiveExpression1342); 
            			    	        		char_literal113_tree = (object)adaptor.Create(char_literal113);
            			    	        		root_0 = (object)adaptor.BecomeRoot(char_literal113_tree, root_0);


            			    	        }
            			    	        break;
            			    	    case 2 :
            			    	        // C:\\Users\\Dominik Halfkann\\Documents\\Visual Studio 2010\\Projects\\SGLParserTester\\SGL\\AntlrParser\\SGL.g:340:41: '-'
            			    	        {
            			    	        	char_literal114=(IToken)Match(input,78,FOLLOW_78_in_additiveExpression1345); 
            			    	        		char_literal114_tree = (object)adaptor.Create(char_literal114);
            			    	        		root_0 = (object)adaptor.BecomeRoot(char_literal114_tree, root_0);


            			    	        }
            			    	        break;

            			    	}

            			    	PushFollow(FOLLOW_multiplicativeExpression_in_additiveExpression1349);
            			    	multiplicativeExpression115 = multiplicativeExpression();
            			    	state.followingStackPointer--;

            			    	adaptor.AddChild(root_0, multiplicativeExpression115.Tree);

            			    }
            			    break;

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

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


            }

            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;
    }
コード例 #2
0
ファイル: SGLParser.cs プロジェクト: brianex/osu-sgl
    // $ANTLR start "additiveExpression"
    // E:\\SGL\\sgl4c#\\NewSGLGramma\\SGL.g:312:1: additiveExpression : multiplicativeExpression ( ( '+' | '-' ) multiplicativeExpression )* ;
    public SGLParser.additiveExpression_return additiveExpression() // throws RecognitionException [1]
    {   
        SGLParser.additiveExpression_return retval = new SGLParser.additiveExpression_return();
        retval.Start = input.LT(1);
        int additiveExpression_StartIndex = input.Index();
        object root_0 = null;

        IToken char_literal90 = null;
        IToken char_literal91 = null;
        SGLParser.multiplicativeExpression_return multiplicativeExpression89 = default(SGLParser.multiplicativeExpression_return);

        SGLParser.multiplicativeExpression_return multiplicativeExpression92 = default(SGLParser.multiplicativeExpression_return);


        object char_literal90_tree=null;
        object char_literal91_tree=null;

        try 
    	{
    	    if ( (state.backtracking > 0) && AlreadyParsedRule(input, 25) ) 
    	    {
    	    	return retval; 
    	    }
            // E:\\SGL\\sgl4c#\\NewSGLGramma\\SGL.g:313:5: ( multiplicativeExpression ( ( '+' | '-' ) multiplicativeExpression )* )
            // E:\\SGL\\sgl4c#\\NewSGLGramma\\SGL.g:313:9: multiplicativeExpression ( ( '+' | '-' ) multiplicativeExpression )*
            {
            	root_0 = (object)adaptor.GetNilNode();

            	PushFollow(FOLLOW_multiplicativeExpression_in_additiveExpression1113);
            	multiplicativeExpression89 = multiplicativeExpression();
            	state.followingStackPointer--;
            	if (state.failed) return retval;
            	if ( state.backtracking == 0 ) adaptor.AddChild(root_0, multiplicativeExpression89.Tree);
            	// E:\\SGL\\sgl4c#\\NewSGLGramma\\SGL.g:313:34: ( ( '+' | '-' ) multiplicativeExpression )*
            	do 
            	{
            	    int alt28 = 2;
            	    int LA28_0 = input.LA(1);

            	    if ( ((LA28_0 >= 72 && LA28_0 <= 73)) )
            	    {
            	        alt28 = 1;
            	    }


            	    switch (alt28) 
            		{
            			case 1 :
            			    // E:\\SGL\\sgl4c#\\NewSGLGramma\\SGL.g:313:35: ( '+' | '-' ) multiplicativeExpression
            			    {
            			    	// E:\\SGL\\sgl4c#\\NewSGLGramma\\SGL.g:313:35: ( '+' | '-' )
            			    	int alt27 = 2;
            			    	int LA27_0 = input.LA(1);

            			    	if ( (LA27_0 == 72) )
            			    	{
            			    	    alt27 = 1;
            			    	}
            			    	else if ( (LA27_0 == 73) )
            			    	{
            			    	    alt27 = 2;
            			    	}
            			    	else 
            			    	{
            			    	    if ( state.backtracking > 0 ) {state.failed = true; return retval;}
            			    	    NoViableAltException nvae_d27s0 =
            			    	        new NoViableAltException("", 27, 0, input);

            			    	    throw nvae_d27s0;
            			    	}
            			    	switch (alt27) 
            			    	{
            			    	    case 1 :
            			    	        // E:\\SGL\\sgl4c#\\NewSGLGramma\\SGL.g:313:36: '+'
            			    	        {
            			    	        	char_literal90=(IToken)Match(input,72,FOLLOW_72_in_additiveExpression1117); if (state.failed) return retval;
            			    	        	if ( state.backtracking == 0 )
            			    	        	{char_literal90_tree = (object)adaptor.Create(char_literal90);
            			    	        		root_0 = (object)adaptor.BecomeRoot(char_literal90_tree, root_0);
            			    	        	}

            			    	        }
            			    	        break;
            			    	    case 2 :
            			    	        // E:\\SGL\\sgl4c#\\NewSGLGramma\\SGL.g:313:41: '-'
            			    	        {
            			    	        	char_literal91=(IToken)Match(input,73,FOLLOW_73_in_additiveExpression1120); if (state.failed) return retval;
            			    	        	if ( state.backtracking == 0 )
            			    	        	{char_literal91_tree = (object)adaptor.Create(char_literal91);
            			    	        		root_0 = (object)adaptor.BecomeRoot(char_literal91_tree, root_0);
            			    	        	}

            			    	        }
            			    	        break;

            			    	}

            			    	PushFollow(FOLLOW_multiplicativeExpression_in_additiveExpression1124);
            			    	multiplicativeExpression92 = multiplicativeExpression();
            			    	state.followingStackPointer--;
            			    	if (state.failed) return retval;
            			    	if ( state.backtracking == 0 ) adaptor.AddChild(root_0, multiplicativeExpression92.Tree);

            			    }
            			    break;

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

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


            }

            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, 25, additiveExpression_StartIndex); 
            }
        }
        return retval;
    }