Наследование: Antlr.Runtime.ParserRuleReturnScope
Пример #1
0
    // $ANTLR start "subtractive_exp"
    // C:\\Documents and Settings\\Administrator\\Desktop\\Spinach\\InterpreterFrontEnd\\spinach.g:186:1: subtractive_exp returns [SubtractionElement ret] : (e11= additive_expression ( '-' e12= subtractive_exp )* ) ;
    public spinachParser.subtractive_exp_return subtractive_exp() // throws RecognitionException [1]
    {   
        spinachParser.subtractive_exp_return retval = new spinachParser.subtractive_exp_return();
        retval.Start = input.LT(1);

        object root_0 = null;

        IToken char_literal76 = null;
        spinachParser.additive_expression_return e11 = null;

        spinachParser.subtractive_exp_return e12 = null;


        object char_literal76_tree=null;


        	retval.ret = new SubtractionElement();

        try 
    	{
            // C:\\Documents and Settings\\Administrator\\Desktop\\Spinach\\InterpreterFrontEnd\\spinach.g:190:1: ( (e11= additive_expression ( '-' e12= subtractive_exp )* ) )
            // C:\\Documents and Settings\\Administrator\\Desktop\\Spinach\\InterpreterFrontEnd\\spinach.g:190:6: (e11= additive_expression ( '-' e12= subtractive_exp )* )
            {
            	root_0 = (object)adaptor.GetNilNode();

            	// C:\\Documents and Settings\\Administrator\\Desktop\\Spinach\\InterpreterFrontEnd\\spinach.g:190:6: (e11= additive_expression ( '-' e12= subtractive_exp )* )
            	// C:\\Documents and Settings\\Administrator\\Desktop\\Spinach\\InterpreterFrontEnd\\spinach.g:190:7: e11= additive_expression ( '-' e12= subtractive_exp )*
            	{
            		PushFollow(FOLLOW_additive_expression_in_subtractive_exp1094);
            		e11 = additive_expression();
            		state.followingStackPointer--;

            		adaptor.AddChild(root_0, e11.Tree);
            		retval.ret.setLhs(((e11 != null) ? e11.ret : null));
            		// C:\\Documents and Settings\\Administrator\\Desktop\\Spinach\\InterpreterFrontEnd\\spinach.g:190:64: ( '-' e12= subtractive_exp )*
            		do 
            		{
            		    int alt24 = 2;
            		    int LA24_0 = input.LA(1);

            		    if ( (LA24_0 == 33) )
            		    {
            		        alt24 = 1;
            		    }


            		    switch (alt24) 
            			{
            				case 1 :
            				    // C:\\Documents and Settings\\Administrator\\Desktop\\Spinach\\InterpreterFrontEnd\\spinach.g:190:65: '-' e12= subtractive_exp
            				    {
            				    	char_literal76=(IToken)Match(input,33,FOLLOW_33_in_subtractive_exp1099); 
            				    		char_literal76_tree = (object)adaptor.Create(char_literal76);
            				    		adaptor.AddChild(root_0, char_literal76_tree);

            				    	PushFollow(FOLLOW_subtractive_exp_in_subtractive_exp1105);
            				    	e12 = subtractive_exp();
            				    	state.followingStackPointer--;

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

            				    }
            				    break;

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

            		loop24:
            			;	// Stops C# compiler whining that label 'loop24' 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 "subtractive_exp"
    // C:\\Users\\Jegan\\Documents\\MSCE\\FALL 09\\SoftwareStudio\\SPINACH-Srinivasan\\ConsoleApplication1\\ConsoleApplication1\\spinach.g:164:1: subtractive_exp returns [SubtractionElement ret] : (e11= additive_expression ( '-' e12= additive_expression )* ) ;
    public spinachParser.subtractive_exp_return subtractive_exp() // throws RecognitionException [1]
    {   
        spinachParser.subtractive_exp_return retval = new spinachParser.subtractive_exp_return();
        retval.Start = input.LT(1);

        object root_0 = null;

        IToken char_literal62 = null;
        spinachParser.additive_expression_return e11 = null;

        spinachParser.additive_expression_return e12 = null;


        object char_literal62_tree=null;


        	retval.ret = new SubtractionElement();

        try 
    	{
            // C:\\Users\\Jegan\\Documents\\MSCE\\FALL 09\\SoftwareStudio\\SPINACH-Srinivasan\\ConsoleApplication1\\ConsoleApplication1\\spinach.g:168:1: ( (e11= additive_expression ( '-' e12= additive_expression )* ) )
            // C:\\Users\\Jegan\\Documents\\MSCE\\FALL 09\\SoftwareStudio\\SPINACH-Srinivasan\\ConsoleApplication1\\ConsoleApplication1\\spinach.g:168:6: (e11= additive_expression ( '-' e12= additive_expression )* )
            {
            	root_0 = (object)adaptor.GetNilNode();

            	// C:\\Users\\Jegan\\Documents\\MSCE\\FALL 09\\SoftwareStudio\\SPINACH-Srinivasan\\ConsoleApplication1\\ConsoleApplication1\\spinach.g:168:6: (e11= additive_expression ( '-' e12= additive_expression )* )
            	// C:\\Users\\Jegan\\Documents\\MSCE\\FALL 09\\SoftwareStudio\\SPINACH-Srinivasan\\ConsoleApplication1\\ConsoleApplication1\\spinach.g:168:7: e11= additive_expression ( '-' e12= additive_expression )*
            	{
            		PushFollow(FOLLOW_additive_expression_in_subtractive_exp1010);
            		e11 = additive_expression();
            		state.followingStackPointer--;

            		adaptor.AddChild(root_0, e11.Tree);
            		retval.ret.setLhs(((e11 != null) ? e11.ret : null));
            		// C:\\Users\\Jegan\\Documents\\MSCE\\FALL 09\\SoftwareStudio\\SPINACH-Srinivasan\\ConsoleApplication1\\ConsoleApplication1\\spinach.g:168:64: ( '-' e12= additive_expression )*
            		do 
            		{
            		    int alt19 = 2;
            		    int LA19_0 = input.LA(1);

            		    if ( (LA19_0 == 33) )
            		    {
            		        alt19 = 1;
            		    }


            		    switch (alt19) 
            			{
            				case 1 :
            				    // C:\\Users\\Jegan\\Documents\\MSCE\\FALL 09\\SoftwareStudio\\SPINACH-Srinivasan\\ConsoleApplication1\\ConsoleApplication1\\spinach.g:168:65: '-' e12= additive_expression
            				    {
            				    	char_literal62=(IToken)Match(input,33,FOLLOW_33_in_subtractive_exp1015); 
            				    		char_literal62_tree = (object)adaptor.Create(char_literal62);
            				    		adaptor.AddChild(root_0, char_literal62_tree);

            				    	PushFollow(FOLLOW_additive_expression_in_subtractive_exp1021);
            				    	e12 = additive_expression();
            				    	state.followingStackPointer--;

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

            				    }
            				    break;

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

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