Exemple #1
0
    // $ANTLR end "main"


    // $ANTLR start "block"
    // E:\\SGL\\sgl4c#\\NewSGLGramma\\SGLTreeWalker.g:136:1: block returns [AbstractNode node] : ^( BLOCK ( statement )* ) ;
    public AbstractNode block() // throws RecognitionException [1]
    {   
        AbstractNode node = default(AbstractNode);

        AbstractNode statement2 = default(AbstractNode);


         
          Scope scope = new Scope(currentScope); 
          currentScope = scope;
          BlockNode bn = new BlockNode(currentScope); 
          node = bn;  

        try 
    	{
            // E:\\SGL\\sgl4c#\\NewSGLGramma\\SGLTreeWalker.g:146:2: ( ^( BLOCK ( statement )* ) )
            // E:\\SGL\\sgl4c#\\NewSGLGramma\\SGLTreeWalker.g:146:4: ^( BLOCK ( statement )* )
            {
            	Match(input,BLOCK,FOLLOW_BLOCK_in_block104); 

            	if ( input.LA(1) == Token.DOWN )
            	{
            	    Match(input, Token.DOWN, null); 
            	    // E:\\SGL\\sgl4c#\\NewSGLGramma\\SGLTreeWalker.g:147:10: ( statement )*
            	    do 
            	    {
            	        int alt1 = 2;
            	        int LA1_0 = input.LA(1);

            	        if ( ((LA1_0 >= DEF && LA1_0 <= ASSIGN) || (LA1_0 >= VARINC && LA1_0 <= VARDEC) || (LA1_0 >= FUNC_CALL && LA1_0 <= IF) || (LA1_0 >= 84 && LA1_0 <= 85)) )
            	        {
            	            alt1 = 1;
            	        }


            	        switch (alt1) 
            	    	{
            	    		case 1 :
            	    		    // E:\\SGL\\sgl4c#\\NewSGLGramma\\SGLTreeWalker.g:147:11: statement
            	    		    {
            	    		    	PushFollow(FOLLOW_statement_in_block119);
            	    		    	statement2 = statement();
            	    		    	state.followingStackPointer--;

            	    		    	bn.AddStatement(statement2);

            	    		    }
            	    		    break;

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

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


            	    Match(input, Token.UP, null); 
            	}

            }

             
              currentScope = currentScope.Parent; 

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return node;
    }
Exemple #2
0
    // $ANTLR end "ifStatement"


    // $ANTLR start "forLoop"
    // E:\\SGL\\sgl4c#\\NewSGLGramma\\SGLTreeWalker.g:205:1: forLoop returns [AbstractNode node] : ^( 'for' ^( FORDEC (dec= statement )* ) ^( FORCOND (cond= expression )? ) ^( FORITER (iter= statement )? ) block ) ;
    public AbstractNode forLoop() // throws RecognitionException [1]
    {   
        AbstractNode node = default(AbstractNode);

        AbstractNode dec = default(AbstractNode);

        AbstractNode cond = default(AbstractNode);

        AbstractNode iter = default(AbstractNode);

        AbstractNode block27 = default(AbstractNode);



          // We have to use 2 Blocks for the for-Node to work correctly
          // Create new block for the beginning of the for-Loop
          Scope scope = new Scope(currentScope); 
          currentScope = scope;
          BlockNode bn = new BlockNode(currentScope); 
          
          //Create the For-Node and add it to the block
          ForNode forNode = new ForNode();
          bn.AddStatement(forNode);
          
          // Return the block node
          node = bn;

        try 
    	{
            // E:\\SGL\\sgl4c#\\NewSGLGramma\\SGLTreeWalker.g:223:2: ( ^( 'for' ^( FORDEC (dec= statement )* ) ^( FORCOND (cond= expression )? ) ^( FORITER (iter= statement )? ) block ) )
            // E:\\SGL\\sgl4c#\\NewSGLGramma\\SGLTreeWalker.g:223:4: ^( 'for' ^( FORDEC (dec= statement )* ) ^( FORCOND (cond= expression )? ) ^( FORITER (iter= statement )? ) block )
            {
            	Match(input,85,FOLLOW_85_in_forLoop517); 

            	Match(input, Token.DOWN, null); 
            	Match(input,FORDEC,FOLLOW_FORDEC_in_forLoop520); 

            	if ( input.LA(1) == Token.DOWN )
            	{
            	    Match(input, Token.DOWN, null); 
            	    // E:\\SGL\\sgl4c#\\NewSGLGramma\\SGLTreeWalker.g:223:21: (dec= statement )*
            	    do 
            	    {
            	        int alt9 = 2;
            	        int LA9_0 = input.LA(1);

            	        if ( ((LA9_0 >= DEF && LA9_0 <= ASSIGN) || (LA9_0 >= VARINC && LA9_0 <= VARDEC) || (LA9_0 >= FUNC_CALL && LA9_0 <= IF) || (LA9_0 >= 84 && LA9_0 <= 85)) )
            	        {
            	            alt9 = 1;
            	        }


            	        switch (alt9) 
            	    	{
            	    		case 1 :
            	    		    // E:\\SGL\\sgl4c#\\NewSGLGramma\\SGLTreeWalker.g:223:22: dec= statement
            	    		    {
            	    		    	PushFollow(FOLLOW_statement_in_forLoop525);
            	    		    	dec = statement();
            	    		    	state.followingStackPointer--;

            	    		    	 forNode.Init = dec; 

            	    		    }
            	    		    break;

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

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


            	    Match(input, Token.UP, null); 
            	}
            	Match(input,FORCOND,FOLLOW_FORCOND_in_forLoop534); 

            	if ( input.LA(1) == Token.DOWN )
            	{
            	    Match(input, Token.DOWN, null); 
            	    // E:\\SGL\\sgl4c#\\NewSGLGramma\\SGLTreeWalker.g:223:80: (cond= expression )?
            	    int alt10 = 2;
            	    int LA10_0 = input.LA(1);

            	    if ( ((LA10_0 >= STRING && LA10_0 <= VARDEC) || LA10_0 == LOOKUP || LA10_0 == CLASS || (LA10_0 >= IntAtom && LA10_0 <= LoopTriggerAtom) || LA10_0 == Null || LA10_0 == 62 || (LA10_0 >= 64 && LA10_0 <= 77)) )
            	    {
            	        alt10 = 1;
            	    }
            	    switch (alt10) 
            	    {
            	        case 1 :
            	            // E:\\SGL\\sgl4c#\\NewSGLGramma\\SGLTreeWalker.g:223:81: cond= expression
            	            {
            	            	PushFollow(FOLLOW_expression_in_forLoop539);
            	            	cond = expression();
            	            	state.followingStackPointer--;

            	            	 forNode.Condition = cond; 

            	            }
            	            break;

            	    }


            	    Match(input, Token.UP, null); 
            	}
            	Match(input,FORITER,FOLLOW_FORITER_in_forLoop547); 

            	if ( input.LA(1) == Token.DOWN )
            	{
            	    Match(input, Token.DOWN, null); 
            	    // E:\\SGL\\sgl4c#\\NewSGLGramma\\SGLTreeWalker.g:223:146: (iter= statement )?
            	    int alt11 = 2;
            	    int LA11_0 = input.LA(1);

            	    if ( ((LA11_0 >= DEF && LA11_0 <= ASSIGN) || (LA11_0 >= VARINC && LA11_0 <= VARDEC) || (LA11_0 >= FUNC_CALL && LA11_0 <= IF) || (LA11_0 >= 84 && LA11_0 <= 85)) )
            	    {
            	        alt11 = 1;
            	    }
            	    switch (alt11) 
            	    {
            	        case 1 :
            	            // E:\\SGL\\sgl4c#\\NewSGLGramma\\SGLTreeWalker.g:223:147: iter= statement
            	            {
            	            	PushFollow(FOLLOW_statement_in_forLoop552);
            	            	iter = statement();
            	            	state.followingStackPointer--;

            	            	 forNode.Iteration = iter; 

            	            }
            	            break;

            	    }


            	    Match(input, Token.UP, null); 
            	}
            	PushFollow(FOLLOW_block_in_forLoop559);
            	block27 = block();
            	state.followingStackPointer--;


            	Match(input, Token.UP, null); 
            	 forNode.Block = block27; 

            }

             
              currentScope = currentScope.Parent; 

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return node;
    }