Inheritance: Antlr.Runtime.ParserRuleReturnScope
示例#1
0
    // $ANTLR start "multiplicative_expression"
    // spinach.g:139:1: multiplicative_expression returns [MultiplicationElement ret] : (e11= var_int_or_double_literal | e12= bracket_exp | el3= matrixelem | el4= vectorelem ) ( '*' (e15= var_int_or_double_literal | e16= bracket_exp | el7= vectorelem | el8= matrixelem ) )* ;
    public spinachParser.multiplicative_expression_return multiplicative_expression() // throws RecognitionException [1]
    {   
        spinachParser.multiplicative_expression_return retval = new spinachParser.multiplicative_expression_return();
        retval.Start = input.LT(1);

        object root_0 = null;

        IToken char_literal58 = null;
        spinachParser.var_int_or_double_literal_return e11 = null;

        spinachParser.bracket_exp_return e12 = null;

        spinachParser.matrixelem_return el3 = null;

        spinachParser.vectorelem_return el4 = null;

        spinachParser.var_int_or_double_literal_return e15 = null;

        spinachParser.bracket_exp_return e16 = null;

        spinachParser.vectorelem_return el7 = null;

        spinachParser.matrixelem_return el8 = null;


        object char_literal58_tree=null;


        	retval.ret = new MultiplicationElement();

        try 
    	{
            // spinach.g:143:2: ( (e11= var_int_or_double_literal | e12= bracket_exp | el3= matrixelem | el4= vectorelem ) ( '*' (e15= var_int_or_double_literal | e16= bracket_exp | el7= vectorelem | el8= matrixelem ) )* )
            // spinach.g:143:4: (e11= var_int_or_double_literal | e12= bracket_exp | el3= matrixelem | el4= vectorelem ) ( '*' (e15= var_int_or_double_literal | e16= bracket_exp | el7= vectorelem | el8= matrixelem ) )*
            {
            	root_0 = (object)adaptor.GetNilNode();

            	// spinach.g:143:4: (e11= var_int_or_double_literal | e12= bracket_exp | el3= matrixelem | el4= vectorelem )
            	int alt16 = 4;
            	switch ( input.LA(1) ) 
            	{
            	case VARIABLE:
            		{
            	    int LA16_1 = input.LA(2);

            	    if ( (LA16_1 == 29) )
            	    {
            	        int LA16_4 = input.LA(3);

            	        if ( (LA16_4 == INT_LITERAL) )
            	        {
            	            int LA16_5 = input.LA(4);

            	            if ( (LA16_5 == 30) )
            	            {
            	                int LA16_6 = input.LA(5);

            	                if ( (LA16_6 == 29) )
            	                {
            	                    alt16 = 3;
            	                }
            	                else if ( (LA16_6 == END_OF_STATEMENT || LA16_6 == RIGHTBRACE || (LA16_6 >= PLUS && LA16_6 <= MULTIPLY) || LA16_6 == 33) )
            	                {
            	                    alt16 = 4;
            	                }
            	                else 
            	                {
            	                    NoViableAltException nvae_d16s6 =
            	                        new NoViableAltException("", 16, 6, input);

            	                    throw nvae_d16s6;
            	                }
            	            }
            	            else 
            	            {
            	                NoViableAltException nvae_d16s5 =
            	                    new NoViableAltException("", 16, 5, input);

            	                throw nvae_d16s5;
            	            }
            	        }
            	        else 
            	        {
            	            NoViableAltException nvae_d16s4 =
            	                new NoViableAltException("", 16, 4, input);

            	            throw nvae_d16s4;
            	        }
            	    }
            	    else if ( (LA16_1 == END_OF_STATEMENT || LA16_1 == RIGHTBRACE || (LA16_1 >= PLUS && LA16_1 <= MULTIPLY) || LA16_1 == 33) )
            	    {
            	        alt16 = 1;
            	    }
            	    else 
            	    {
            	        NoViableAltException nvae_d16s1 =
            	            new NoViableAltException("", 16, 1, input);

            	        throw nvae_d16s1;
            	    }
            	    }
            	    break;
            	case INT_LITERAL:
            	case DOUBLE_LITERAL:
            		{
            	    alt16 = 1;
            	    }
            	    break;
            	case LEFTBRACE:
            		{
            	    alt16 = 2;
            	    }
            	    break;
            		default:
            		    NoViableAltException nvae_d16s0 =
            		        new NoViableAltException("", 16, 0, input);

            		    throw nvae_d16s0;
            	}

            	switch (alt16) 
            	{
            	    case 1 :
            	        // spinach.g:143:5: e11= var_int_or_double_literal
            	        {
            	        	PushFollow(FOLLOW_var_int_or_double_literal_in_multiplicative_expression849);
            	        	e11 = var_int_or_double_literal();
            	        	state.followingStackPointer--;

            	        	adaptor.AddChild(root_0, e11.Tree);
            	        	retval.ret.setLhs(((e11 != null) ? e11.ret : null));

            	        }
            	        break;
            	    case 2 :
            	        // spinach.g:144:7: e12= bracket_exp
            	        {
            	        	PushFollow(FOLLOW_bracket_exp_in_multiplicative_expression861);
            	        	e12 = bracket_exp();
            	        	state.followingStackPointer--;

            	        	adaptor.AddChild(root_0, e12.Tree);
            	        	retval.ret.setLhs(((e12 != null) ? e12.ret : null));

            	        }
            	        break;
            	    case 3 :
            	        // spinach.g:145:7: el3= matrixelem
            	        {
            	        	PushFollow(FOLLOW_matrixelem_in_multiplicative_expression874);
            	        	el3 = matrixelem();
            	        	state.followingStackPointer--;

            	        	adaptor.AddChild(root_0, el3.Tree);
            	        	retval.ret.setLhs(((el3 != null) ? el3.ret : null));

            	        }
            	        break;
            	    case 4 :
            	        // spinach.g:146:7: el4= vectorelem
            	        {
            	        	PushFollow(FOLLOW_vectorelem_in_multiplicative_expression887);
            	        	el4 = vectorelem();
            	        	state.followingStackPointer--;

            	        	adaptor.AddChild(root_0, el4.Tree);
            	        	retval.ret.setLhs(((el4 != null) ? el4.ret : null));

            	        }
            	        break;

            	}

            	// spinach.g:147:5: ( '*' (e15= var_int_or_double_literal | e16= bracket_exp | el7= vectorelem | el8= matrixelem ) )*
            	do 
            	{
            	    int alt18 = 2;
            	    int LA18_0 = input.LA(1);

            	    if ( (LA18_0 == MULTIPLY) )
            	    {
            	        alt18 = 1;
            	    }


            	    switch (alt18) 
            		{
            			case 1 :
            			    // spinach.g:147:6: '*' (e15= var_int_or_double_literal | e16= bracket_exp | el7= vectorelem | el8= matrixelem )
            			    {
            			    	char_literal58=(IToken)Match(input,MULTIPLY,FOLLOW_MULTIPLY_in_multiplicative_expression896); 
            			    		char_literal58_tree = (object)adaptor.Create(char_literal58);
            			    		adaptor.AddChild(root_0, char_literal58_tree);

            			    	// spinach.g:147:9: (e15= var_int_or_double_literal | e16= bracket_exp | el7= vectorelem | el8= matrixelem )
            			    	int alt17 = 4;
            			    	switch ( input.LA(1) ) 
            			    	{
            			    	case VARIABLE:
            			    		{
            			    	    int LA17_1 = input.LA(2);

            			    	    if ( (LA17_1 == 29) )
            			    	    {
            			    	        int LA17_4 = input.LA(3);

            			    	        if ( (LA17_4 == INT_LITERAL) )
            			    	        {
            			    	            int LA17_5 = input.LA(4);

            			    	            if ( (LA17_5 == 30) )
            			    	            {
            			    	                int LA17_6 = input.LA(5);

            			    	                if ( (LA17_6 == 29) )
            			    	                {
            			    	                    alt17 = 4;
            			    	                }
            			    	                else if ( (LA17_6 == END_OF_STATEMENT || LA17_6 == RIGHTBRACE || (LA17_6 >= PLUS && LA17_6 <= MULTIPLY) || LA17_6 == 33) )
            			    	                {
            			    	                    alt17 = 3;
            			    	                }
            			    	                else 
            			    	                {
            			    	                    NoViableAltException nvae_d17s6 =
            			    	                        new NoViableAltException("", 17, 6, input);

            			    	                    throw nvae_d17s6;
            			    	                }
            			    	            }
            			    	            else 
            			    	            {
            			    	                NoViableAltException nvae_d17s5 =
            			    	                    new NoViableAltException("", 17, 5, input);

            			    	                throw nvae_d17s5;
            			    	            }
            			    	        }
            			    	        else 
            			    	        {
            			    	            NoViableAltException nvae_d17s4 =
            			    	                new NoViableAltException("", 17, 4, input);

            			    	            throw nvae_d17s4;
            			    	        }
            			    	    }
            			    	    else if ( (LA17_1 == END_OF_STATEMENT || LA17_1 == RIGHTBRACE || (LA17_1 >= PLUS && LA17_1 <= MULTIPLY) || LA17_1 == 33) )
            			    	    {
            			    	        alt17 = 1;
            			    	    }
            			    	    else 
            			    	    {
            			    	        NoViableAltException nvae_d17s1 =
            			    	            new NoViableAltException("", 17, 1, input);

            			    	        throw nvae_d17s1;
            			    	    }
            			    	    }
            			    	    break;
            			    	case INT_LITERAL:
            			    	case DOUBLE_LITERAL:
            			    		{
            			    	    alt17 = 1;
            			    	    }
            			    	    break;
            			    	case LEFTBRACE:
            			    		{
            			    	    alt17 = 2;
            			    	    }
            			    	    break;
            			    		default:
            			    		    NoViableAltException nvae_d17s0 =
            			    		        new NoViableAltException("", 17, 0, input);

            			    		    throw nvae_d17s0;
            			    	}

            			    	switch (alt17) 
            			    	{
            			    	    case 1 :
            			    	        // spinach.g:147:11: e15= var_int_or_double_literal
            			    	        {
            			    	        	PushFollow(FOLLOW_var_int_or_double_literal_in_multiplicative_expression902);
            			    	        	e15 = var_int_or_double_literal();
            			    	        	state.followingStackPointer--;

            			    	        	adaptor.AddChild(root_0, e15.Tree);
            			    	        	retval.ret.setRhs(((e15 != null) ? e15.ret : null));

            			    	        }
            			    	        break;
            			    	    case 2 :
            			    	        // spinach.g:148:7: e16= bracket_exp
            			    	        {
            			    	        	PushFollow(FOLLOW_bracket_exp_in_multiplicative_expression915);
            			    	        	e16 = bracket_exp();
            			    	        	state.followingStackPointer--;

            			    	        	adaptor.AddChild(root_0, e16.Tree);
            			    	        	retval.ret.setRhs(((e16 != null) ? e16.ret : null));

            			    	        }
            			    	        break;
            			    	    case 3 :
            			    	        // spinach.g:149:7: el7= vectorelem
            			    	        {
            			    	        	PushFollow(FOLLOW_vectorelem_in_multiplicative_expression928);
            			    	        	el7 = vectorelem();
            			    	        	state.followingStackPointer--;

            			    	        	adaptor.AddChild(root_0, el7.Tree);
            			    	        	retval.ret.setLhs(((el7 != null) ? el7.ret : null));

            			    	        }
            			    	        break;
            			    	    case 4 :
            			    	        // spinach.g:150:7: el8= matrixelem
            			    	        {
            			    	        	PushFollow(FOLLOW_matrixelem_in_multiplicative_expression941);
            			    	        	el8 = matrixelem();
            			    	        	state.followingStackPointer--;

            			    	        	adaptor.AddChild(root_0, el8.Tree);
            			    	        	retval.ret.setLhs(((el8 != null) ? el8.ret : null));

            			    	        }
            			    	        break;

            			    	}


            			    }
            			    break;

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

            	loop18:
            		;	// Stops C# compiler whining that label 'loop18' 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
    // $ANTLR start "multiplicative_expression"
    // C:\\Documents and Settings\\Administrator\\Desktop\\Spinach\\InterpreterFrontEnd\\spinach.g:161:1: multiplicative_expression returns [MultiplicationElement ret] : (e11= var_int_or_double_literal | e12= bracket_exp | el3= matrixelem | el4= vectorelem ) ( '*' el5= multiplicative_expression )* ;
    public spinachParser.multiplicative_expression_return multiplicative_expression() // throws RecognitionException [1]
    {   
        spinachParser.multiplicative_expression_return retval = new spinachParser.multiplicative_expression_return();
        retval.Start = input.LT(1);

        object root_0 = null;

        IToken char_literal72 = null;
        spinachParser.var_int_or_double_literal_return e11 = null;

        spinachParser.bracket_exp_return e12 = null;

        spinachParser.matrixelem_return el3 = null;

        spinachParser.vectorelem_return el4 = null;

        spinachParser.multiplicative_expression_return el5 = null;


        object char_literal72_tree=null;


        	retval.ret = new MultiplicationElement();

        try 
    	{
            // C:\\Documents and Settings\\Administrator\\Desktop\\Spinach\\InterpreterFrontEnd\\spinach.g:165:2: ( (e11= var_int_or_double_literal | e12= bracket_exp | el3= matrixelem | el4= vectorelem ) ( '*' el5= multiplicative_expression )* )
            // C:\\Documents and Settings\\Administrator\\Desktop\\Spinach\\InterpreterFrontEnd\\spinach.g:165:4: (e11= var_int_or_double_literal | e12= bracket_exp | el3= matrixelem | el4= vectorelem ) ( '*' el5= multiplicative_expression )*
            {
            	root_0 = (object)adaptor.GetNilNode();

            	// C:\\Documents and Settings\\Administrator\\Desktop\\Spinach\\InterpreterFrontEnd\\spinach.g:165:4: (e11= var_int_or_double_literal | e12= bracket_exp | el3= matrixelem | el4= vectorelem )
            	int alt22 = 4;
            	alt22 = dfa22.Predict(input);
            	switch (alt22) 
            	{
            	    case 1 :
            	        // C:\\Documents and Settings\\Administrator\\Desktop\\Spinach\\InterpreterFrontEnd\\spinach.g:165:5: e11= var_int_or_double_literal
            	        {
            	        	PushFollow(FOLLOW_var_int_or_double_literal_in_multiplicative_expression959);
            	        	e11 = var_int_or_double_literal();
            	        	state.followingStackPointer--;

            	        	adaptor.AddChild(root_0, e11.Tree);
            	        	retval.ret.setLhs(((e11 != null) ? e11.ret : null));

            	        }
            	        break;
            	    case 2 :
            	        // C:\\Documents and Settings\\Administrator\\Desktop\\Spinach\\InterpreterFrontEnd\\spinach.g:166:7: e12= bracket_exp
            	        {
            	        	PushFollow(FOLLOW_bracket_exp_in_multiplicative_expression971);
            	        	e12 = bracket_exp();
            	        	state.followingStackPointer--;

            	        	adaptor.AddChild(root_0, e12.Tree);
            	        	retval.ret.setLhs(((e12 != null) ? e12.ret : null));

            	        }
            	        break;
            	    case 3 :
            	        // C:\\Documents and Settings\\Administrator\\Desktop\\Spinach\\InterpreterFrontEnd\\spinach.g:167:7: el3= matrixelem
            	        {
            	        	PushFollow(FOLLOW_matrixelem_in_multiplicative_expression984);
            	        	el3 = matrixelem();
            	        	state.followingStackPointer--;

            	        	adaptor.AddChild(root_0, el3.Tree);
            	        	retval.ret.setLhs(((el3 != null) ? el3.ret : null));

            	        }
            	        break;
            	    case 4 :
            	        // C:\\Documents and Settings\\Administrator\\Desktop\\Spinach\\InterpreterFrontEnd\\spinach.g:168:7: el4= vectorelem
            	        {
            	        	PushFollow(FOLLOW_vectorelem_in_multiplicative_expression997);
            	        	el4 = vectorelem();
            	        	state.followingStackPointer--;

            	        	adaptor.AddChild(root_0, el4.Tree);
            	        	retval.ret.setLhs(((el4 != null) ? el4.ret : null));

            	        }
            	        break;

            	}

            	// C:\\Documents and Settings\\Administrator\\Desktop\\Spinach\\InterpreterFrontEnd\\spinach.g:169:5: ( '*' el5= multiplicative_expression )*
            	do 
            	{
            	    int alt23 = 2;
            	    int LA23_0 = input.LA(1);

            	    if ( (LA23_0 == MULTIPLY) )
            	    {
            	        alt23 = 1;
            	    }


            	    switch (alt23) 
            		{
            			case 1 :
            			    // C:\\Documents and Settings\\Administrator\\Desktop\\Spinach\\InterpreterFrontEnd\\spinach.g:169:6: '*' el5= multiplicative_expression
            			    {
            			    	char_literal72=(IToken)Match(input,MULTIPLY,FOLLOW_MULTIPLY_in_multiplicative_expression1006); 
            			    		char_literal72_tree = (object)adaptor.Create(char_literal72);
            			    		adaptor.AddChild(root_0, char_literal72_tree);

            			    	PushFollow(FOLLOW_multiplicative_expression_in_multiplicative_expression1016);
            			    	el5 = multiplicative_expression();
            			    	state.followingStackPointer--;

            			    	adaptor.AddChild(root_0, el5.Tree);
            			    	retval.ret.setRhs(el5.ret);

            			    }
            			    break;

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

            	loop23:
            		;	// Stops C# compiler whining that label 'loop23' 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;
    }
示例#3
0
    // $ANTLR start "multiplicative_expression"
    // spinach.g:160:1: multiplicative_expression returns [MultiplicationElement ret] : (e11= var_int_or_double_literal | e12= bracket_exp ) ( '*' el5= multiplicative_expression )* ;
    public spinachParser.multiplicative_expression_return multiplicative_expression() // throws RecognitionException [1]
    {   
        spinachParser.multiplicative_expression_return retval = new spinachParser.multiplicative_expression_return();
        retval.Start = input.LT(1);

        object root_0 = null;

        IToken char_literal74 = null;
        spinachParser.var_int_or_double_literal_return e11 = null;

        spinachParser.bracket_exp_return e12 = null;

        spinachParser.multiplicative_expression_return el5 = null;


        object char_literal74_tree=null;


        	retval.ret = new MultiplicationElement();

        try 
    	{
            // spinach.g:164:2: ( (e11= var_int_or_double_literal | e12= bracket_exp ) ( '*' el5= multiplicative_expression )* )
            // spinach.g:164:4: (e11= var_int_or_double_literal | e12= bracket_exp ) ( '*' el5= multiplicative_expression )*
            {
            	root_0 = (object)adaptor.GetNilNode();

            	// spinach.g:164:4: (e11= var_int_or_double_literal | e12= bracket_exp )
            	int alt21 = 2;
            	int LA21_0 = input.LA(1);

            	if ( ((LA21_0 >= VARIABLE && LA21_0 <= DOUBLE_LITERAL)) )
            	{
            	    alt21 = 1;
            	}
            	else if ( (LA21_0 == LEFTBRACE) )
            	{
            	    alt21 = 2;
            	}
            	else 
            	{
            	    NoViableAltException nvae_d21s0 =
            	        new NoViableAltException("", 21, 0, input);

            	    throw nvae_d21s0;
            	}
            	switch (alt21) 
            	{
            	    case 1 :
            	        // spinach.g:164:5: e11= var_int_or_double_literal
            	        {
            	        	PushFollow(FOLLOW_var_int_or_double_literal_in_multiplicative_expression945);
            	        	e11 = var_int_or_double_literal();
            	        	state.followingStackPointer--;

            	        	adaptor.AddChild(root_0, e11.Tree);
            	        	retval.ret.setLhs(((e11 != null) ? e11.ret : null));

            	        }
            	        break;
            	    case 2 :
            	        // spinach.g:165:7: e12= bracket_exp
            	        {
            	        	PushFollow(FOLLOW_bracket_exp_in_multiplicative_expression957);
            	        	e12 = bracket_exp();
            	        	state.followingStackPointer--;

            	        	adaptor.AddChild(root_0, e12.Tree);
            	        	retval.ret.setLhs(((e12 != null) ? e12.ret : null));

            	        }
            	        break;

            	}

            	// spinach.g:167:5: ( '*' el5= multiplicative_expression )*
            	do 
            	{
            	    int alt22 = 2;
            	    int LA22_0 = input.LA(1);

            	    if ( (LA22_0 == MULTIPLY) )
            	    {
            	        alt22 = 1;
            	    }


            	    switch (alt22) 
            		{
            			case 1 :
            			    // spinach.g:167:6: '*' el5= multiplicative_expression
            			    {
            			    	char_literal74=(IToken)Match(input,MULTIPLY,FOLLOW_MULTIPLY_in_multiplicative_expression971); 
            			    		char_literal74_tree = (object)adaptor.Create(char_literal74);
            			    		adaptor.AddChild(root_0, char_literal74_tree);

            			    	PushFollow(FOLLOW_multiplicative_expression_in_multiplicative_expression981);
            			    	el5 = multiplicative_expression();
            			    	state.followingStackPointer--;

            			    	adaptor.AddChild(root_0, el5.Tree);
            			    	retval.ret.setRhs(el5.ret);

            			    }
            			    break;

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

            	loop22:
            		;	// Stops C# compiler whining that label 'loop22' 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;
    }