상속: Antlr.Runtime.ParserRuleReturnScope
예제 #1
0
    // $ANTLR start "matrixelem"
    // spinach.g:104:1: matrixelem returns [MatrixElement ret] : (el1= variable '[' el2= int_literal ']' '[' el3= int_literal ']' ) ;
    public spinachParser.matrixelem_return matrixelem() // throws RecognitionException [1]
    {   
        spinachParser.matrixelem_return retval = new spinachParser.matrixelem_return();
        retval.Start = input.LT(1);

        object root_0 = null;

        IToken char_literal43 = null;
        IToken char_literal44 = null;
        IToken char_literal45 = null;
        IToken char_literal46 = null;
        spinachParser.variable_return el1 = null;

        spinachParser.int_literal_return el2 = null;

        spinachParser.int_literal_return el3 = null;


        object char_literal43_tree=null;
        object char_literal44_tree=null;
        object char_literal45_tree=null;
        object char_literal46_tree=null;


         retval.ret = new MatrixElement();
         
        try 
    	{
            // spinach.g:108:2: ( (el1= variable '[' el2= int_literal ']' '[' el3= int_literal ']' ) )
            // spinach.g:108:3: (el1= variable '[' el2= int_literal ']' '[' el3= int_literal ']' )
            {
            	root_0 = (object)adaptor.GetNilNode();

            	// spinach.g:108:3: (el1= variable '[' el2= int_literal ']' '[' el3= int_literal ']' )
            	// spinach.g:108:4: el1= variable '[' el2= int_literal ']' '[' el3= int_literal ']'
            	{
            		PushFollow(FOLLOW_variable_in_matrixelem628);
            		el1 = variable();
            		state.followingStackPointer--;

            		adaptor.AddChild(root_0, el1.Tree);
            		retval.ret.setVar(((el1 != null) ? el1.ret : null));
            		char_literal43=(IToken)Match(input,29,FOLLOW_29_in_matrixelem631); 
            			char_literal43_tree = (object)adaptor.Create(char_literal43);
            			adaptor.AddChild(root_0, char_literal43_tree);

            		PushFollow(FOLLOW_int_literal_in_matrixelem634);
            		el2 = int_literal();
            		state.followingStackPointer--;

            		adaptor.AddChild(root_0, el2.Tree);
            		retval.ret.setRow(((el2 != null) ? el2.ret : null));
            		char_literal44=(IToken)Match(input,30,FOLLOW_30_in_matrixelem636); 
            			char_literal44_tree = (object)adaptor.Create(char_literal44);
            			adaptor.AddChild(root_0, char_literal44_tree);

            		char_literal45=(IToken)Match(input,29,FOLLOW_29_in_matrixelem639); 
            			char_literal45_tree = (object)adaptor.Create(char_literal45);
            			adaptor.AddChild(root_0, char_literal45_tree);

            		PushFollow(FOLLOW_int_literal_in_matrixelem642);
            		el3 = int_literal();
            		state.followingStackPointer--;

            		adaptor.AddChild(root_0, el3.Tree);
            		retval.ret.setColumn(((el3 != null) ? el3.ret : null));
            		char_literal46=(IToken)Match(input,30,FOLLOW_30_in_matrixelem644); 
            			char_literal46_tree = (object)adaptor.Create(char_literal46);
            			adaptor.AddChild(root_0, char_literal46_tree);


            	}


            }

            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 "matrixelem"
    // C:\\Documents and Settings\\Administrator\\Desktop\\Spinach\\InterpreterFrontEnd\\spinach.g:124:1: matrixelem returns [MatrixElement ret] : (el1= variable '[' (el2= int_literal | el4= variable ) ']' '[' (el3= int_literal | el5= variable ) ']' ) ;
    public spinachParser.matrixelem_return matrixelem() // throws RecognitionException [1]
    {   
        spinachParser.matrixelem_return retval = new spinachParser.matrixelem_return();
        retval.Start = input.LT(1);

        object root_0 = null;

        IToken char_literal56 = null;
        IToken char_literal57 = null;
        IToken char_literal58 = null;
        IToken char_literal59 = null;
        spinachParser.variable_return el1 = null;

        spinachParser.int_literal_return el2 = null;

        spinachParser.variable_return el4 = null;

        spinachParser.int_literal_return el3 = null;

        spinachParser.variable_return el5 = null;


        object char_literal56_tree=null;
        object char_literal57_tree=null;
        object char_literal58_tree=null;
        object char_literal59_tree=null;


         retval.ret = new MatrixElement();
         
        try 
    	{
            // C:\\Documents and Settings\\Administrator\\Desktop\\Spinach\\InterpreterFrontEnd\\spinach.g:128:2: ( (el1= variable '[' (el2= int_literal | el4= variable ) ']' '[' (el3= int_literal | el5= variable ) ']' ) )
            // C:\\Documents and Settings\\Administrator\\Desktop\\Spinach\\InterpreterFrontEnd\\spinach.g:128:3: (el1= variable '[' (el2= int_literal | el4= variable ) ']' '[' (el3= int_literal | el5= variable ) ']' )
            {
            	root_0 = (object)adaptor.GetNilNode();

            	// C:\\Documents and Settings\\Administrator\\Desktop\\Spinach\\InterpreterFrontEnd\\spinach.g:128:3: (el1= variable '[' (el2= int_literal | el4= variable ) ']' '[' (el3= int_literal | el5= variable ) ']' )
            	// C:\\Documents and Settings\\Administrator\\Desktop\\Spinach\\InterpreterFrontEnd\\spinach.g:128:4: el1= variable '[' (el2= int_literal | el4= variable ) ']' '[' (el3= int_literal | el5= variable ) ']'
            	{
            		PushFollow(FOLLOW_variable_in_matrixelem706);
            		el1 = variable();
            		state.followingStackPointer--;

            		adaptor.AddChild(root_0, el1.Tree);
            		retval.ret.setVar(((el1 != null) ? el1.ret : null));
            		char_literal56=(IToken)Match(input,29,FOLLOW_29_in_matrixelem712); 
            			char_literal56_tree = (object)adaptor.Create(char_literal56);
            			adaptor.AddChild(root_0, char_literal56_tree);

            		// C:\\Documents and Settings\\Administrator\\Desktop\\Spinach\\InterpreterFrontEnd\\spinach.g:129:6: (el2= int_literal | el4= variable )
            		int alt15 = 2;
            		int LA15_0 = input.LA(1);

            		if ( (LA15_0 == INT_LITERAL) )
            		{
            		    alt15 = 1;
            		}
            		else if ( (LA15_0 == VARIABLE) )
            		{
            		    alt15 = 2;
            		}
            		else 
            		{
            		    NoViableAltException nvae_d15s0 =
            		        new NoViableAltException("", 15, 0, input);

            		    throw nvae_d15s0;
            		}
            		switch (alt15) 
            		{
            		    case 1 :
            		        // C:\\Documents and Settings\\Administrator\\Desktop\\Spinach\\InterpreterFrontEnd\\spinach.g:129:7: el2= int_literal
            		        {
            		        	PushFollow(FOLLOW_int_literal_in_matrixelem716);
            		        	el2 = int_literal();
            		        	state.followingStackPointer--;

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

            		        }
            		        break;
            		    case 2 :
            		        // C:\\Documents and Settings\\Administrator\\Desktop\\Spinach\\InterpreterFrontEnd\\spinach.g:129:53: el4= variable
            		        {
            		        	PushFollow(FOLLOW_variable_in_matrixelem721);
            		        	el4 = variable();
            		        	state.followingStackPointer--;

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

            		        }
            		        break;

            		}

            		char_literal57=(IToken)Match(input,30,FOLLOW_30_in_matrixelem724); 
            			char_literal57_tree = (object)adaptor.Create(char_literal57);
            			adaptor.AddChild(root_0, char_literal57_tree);

            		char_literal58=(IToken)Match(input,29,FOLLOW_29_in_matrixelem727); 
            			char_literal58_tree = (object)adaptor.Create(char_literal58);
            			adaptor.AddChild(root_0, char_literal58_tree);

            		// C:\\Documents and Settings\\Administrator\\Desktop\\Spinach\\InterpreterFrontEnd\\spinach.g:130:5: (el3= int_literal | el5= variable )
            		int alt16 = 2;
            		int LA16_0 = input.LA(1);

            		if ( (LA16_0 == INT_LITERAL) )
            		{
            		    alt16 = 1;
            		}
            		else if ( (LA16_0 == VARIABLE) )
            		{
            		    alt16 = 2;
            		}
            		else 
            		{
            		    NoViableAltException nvae_d16s0 =
            		        new NoViableAltException("", 16, 0, input);

            		    throw nvae_d16s0;
            		}
            		switch (alt16) 
            		{
            		    case 1 :
            		        // C:\\Documents and Settings\\Administrator\\Desktop\\Spinach\\InterpreterFrontEnd\\spinach.g:130:6: el3= int_literal
            		        {
            		        	PushFollow(FOLLOW_int_literal_in_matrixelem731);
            		        	el3 = int_literal();
            		        	state.followingStackPointer--;

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

            		        }
            		        break;
            		    case 2 :
            		        // C:\\Documents and Settings\\Administrator\\Desktop\\Spinach\\InterpreterFrontEnd\\spinach.g:130:55: el5= variable
            		        {
            		        	PushFollow(FOLLOW_variable_in_matrixelem736);
            		        	el5 = variable();
            		        	state.followingStackPointer--;

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

            		        }
            		        break;

            		}

            		char_literal59=(IToken)Match(input,30,FOLLOW_30_in_matrixelem739); 
            			char_literal59_tree = (object)adaptor.Create(char_literal59);
            			adaptor.AddChild(root_0, char_literal59_tree);


            	}


            }

            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 "matrixelem"
    // C:\\Users\\KULDEEP GANDHI\\Desktop\\pinac\\Spinach\\InterpreterFrontEnd\\spinach.g:112:1: matrixelem returns [MatrixElement ret] : (el1= variable '[' (el2= int_literal | el4= variable ) ']' '[' (el3= int_literal | el5= variable ) ']' ) ;
    public spinachParser.matrixelem_return matrixelem() // throws RecognitionException [1]
    {   
        spinachParser.matrixelem_return retval = new spinachParser.matrixelem_return();
        retval.Start = input.LT(1);

        object root_0 = null;

        IToken char_literal50 = null;
        IToken char_literal51 = null;
        IToken char_literal52 = null;
        IToken char_literal53 = null;
        spinachParser.variable_return el1 = null;

        spinachParser.int_literal_return el2 = null;

        spinachParser.variable_return el4 = null;

        spinachParser.int_literal_return el3 = null;

        spinachParser.variable_return el5 = null;


        object char_literal50_tree=null;
        object char_literal51_tree=null;
        object char_literal52_tree=null;
        object char_literal53_tree=null;


         retval.ret = new MatrixElement();
         
        try 
    	{
            // C:\\Users\\KULDEEP GANDHI\\Desktop\\pinac\\Spinach\\InterpreterFrontEnd\\spinach.g:116:2: ( (el1= variable '[' (el2= int_literal | el4= variable ) ']' '[' (el3= int_literal | el5= variable ) ']' ) )
            // C:\\Users\\KULDEEP GANDHI\\Desktop\\pinac\\Spinach\\InterpreterFrontEnd\\spinach.g:116:3: (el1= variable '[' (el2= int_literal | el4= variable ) ']' '[' (el3= int_literal | el5= variable ) ']' )
            {
            	root_0 = (object)adaptor.GetNilNode();

            	// C:\\Users\\KULDEEP GANDHI\\Desktop\\pinac\\Spinach\\InterpreterFrontEnd\\spinach.g:116:3: (el1= variable '[' (el2= int_literal | el4= variable ) ']' '[' (el3= int_literal | el5= variable ) ']' )
            	// C:\\Users\\KULDEEP GANDHI\\Desktop\\pinac\\Spinach\\InterpreterFrontEnd\\spinach.g:116:4: el1= variable '[' (el2= int_literal | el4= variable ) ']' '[' (el3= int_literal | el5= variable ) ']'
            	{
            		PushFollow(FOLLOW_variable_in_matrixelem642);
            		el1 = variable();
            		state.followingStackPointer--;

            		adaptor.AddChild(root_0, el1.Tree);
            		retval.ret.setVar(((el1 != null) ? el1.ret : null));
            		char_literal50=(IToken)Match(input,29,FOLLOW_29_in_matrixelem648); 
            			char_literal50_tree = (object)adaptor.Create(char_literal50);
            			adaptor.AddChild(root_0, char_literal50_tree);

            		// C:\\Users\\KULDEEP GANDHI\\Desktop\\pinac\\Spinach\\InterpreterFrontEnd\\spinach.g:117:6: (el2= int_literal | el4= variable )
            		int alt14 = 2;
            		int LA14_0 = input.LA(1);

            		if ( (LA14_0 == INT_LITERAL) )
            		{
            		    alt14 = 1;
            		}
            		else if ( (LA14_0 == VARIABLE) )
            		{
            		    alt14 = 2;
            		}
            		else 
            		{
            		    NoViableAltException nvae_d14s0 =
            		        new NoViableAltException("", 14, 0, input);

            		    throw nvae_d14s0;
            		}
            		switch (alt14) 
            		{
            		    case 1 :
            		        // C:\\Users\\KULDEEP GANDHI\\Desktop\\pinac\\Spinach\\InterpreterFrontEnd\\spinach.g:117:7: el2= int_literal
            		        {
            		        	PushFollow(FOLLOW_int_literal_in_matrixelem652);
            		        	el2 = int_literal();
            		        	state.followingStackPointer--;

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

            		        }
            		        break;
            		    case 2 :
            		        // C:\\Users\\KULDEEP GANDHI\\Desktop\\pinac\\Spinach\\InterpreterFrontEnd\\spinach.g:117:53: el4= variable
            		        {
            		        	PushFollow(FOLLOW_variable_in_matrixelem657);
            		        	el4 = variable();
            		        	state.followingStackPointer--;

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

            		        }
            		        break;

            		}

            		char_literal51=(IToken)Match(input,30,FOLLOW_30_in_matrixelem660); 
            			char_literal51_tree = (object)adaptor.Create(char_literal51);
            			adaptor.AddChild(root_0, char_literal51_tree);

            		char_literal52=(IToken)Match(input,29,FOLLOW_29_in_matrixelem663); 
            			char_literal52_tree = (object)adaptor.Create(char_literal52);
            			adaptor.AddChild(root_0, char_literal52_tree);

            		// C:\\Users\\KULDEEP GANDHI\\Desktop\\pinac\\Spinach\\InterpreterFrontEnd\\spinach.g:118:5: (el3= int_literal | el5= variable )
            		int alt15 = 2;
            		int LA15_0 = input.LA(1);

            		if ( (LA15_0 == INT_LITERAL) )
            		{
            		    alt15 = 1;
            		}
            		else if ( (LA15_0 == VARIABLE) )
            		{
            		    alt15 = 2;
            		}
            		else 
            		{
            		    NoViableAltException nvae_d15s0 =
            		        new NoViableAltException("", 15, 0, input);

            		    throw nvae_d15s0;
            		}
            		switch (alt15) 
            		{
            		    case 1 :
            		        // C:\\Users\\KULDEEP GANDHI\\Desktop\\pinac\\Spinach\\InterpreterFrontEnd\\spinach.g:118:6: el3= int_literal
            		        {
            		        	PushFollow(FOLLOW_int_literal_in_matrixelem667);
            		        	el3 = int_literal();
            		        	state.followingStackPointer--;

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

            		        }
            		        break;
            		    case 2 :
            		        // C:\\Users\\KULDEEP GANDHI\\Desktop\\pinac\\Spinach\\InterpreterFrontEnd\\spinach.g:118:55: el5= variable
            		        {
            		        	PushFollow(FOLLOW_variable_in_matrixelem672);
            		        	el5 = variable();
            		        	state.followingStackPointer--;

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

            		        }
            		        break;

            		}

            		char_literal53=(IToken)Match(input,30,FOLLOW_30_in_matrixelem675); 
            			char_literal53_tree = (object)adaptor.Create(char_literal53);
            			adaptor.AddChild(root_0, char_literal53_tree);


            	}


            }

            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;
    }