Ejemplo n.º 1
0
    public void lstmt()     //throws RecognitionException, TokenStreamException
    {
        returnAST = null;
        ASTPair currentAST = new ASTPair();
        AST     lstmt_AST  = null;

        try {              // for error handling
            if ((tokenSet_3_.member(LA(1))) && (tokenSet_5_.member(LA(2))))
            {
                stmt();
                astFactory.addASTChild(ref currentAST, returnAST);
                lstmt_AST       = (AST)currentAST.root;
                lstmt_AST       = (AST)astFactory.make(astFactory.create(STMT, "STMT"), lstmt_AST);
                currentAST.root = lstmt_AST;
                if ((null != lstmt_AST) && (null != lstmt_AST.getFirstChild()))
                {
                    currentAST.child = lstmt_AST.getFirstChild();
                }
                else
                {
                    currentAST.child = lstmt_AST;
                }
                currentAST.advanceChildToEnd();
                lstmt_AST = currentAST.root;
            }
            else if ((LA(1) == ID) && (LA(2) == COLON))
            {
                AST tmp14_AST = null;
                tmp14_AST = astFactory.create(LT(1));
                astFactory.addASTChild(ref currentAST, tmp14_AST);
                match(ID);
                match(COLON);
                stmt();
                astFactory.addASTChild(ref currentAST, returnAST);
                lstmt_AST       = (AST)currentAST.root;
                lstmt_AST       = (AST)astFactory.make(astFactory.create(LSTMT, "LSTMT"), lstmt_AST);
                currentAST.root = lstmt_AST;
                if ((null != lstmt_AST) && (null != lstmt_AST.getFirstChild()))
                {
                    currentAST.child = lstmt_AST.getFirstChild();
                }
                else
                {
                    currentAST.child = lstmt_AST;
                }
                currentAST.advanceChildToEnd();
                lstmt_AST = currentAST.root;
            }
            else
            {
                throw new NoViableAltException(LT(1), getFilename());
            }
        }
        catch (RecognitionException ex)
        {
            reportError(ex);
            recover(ex, tokenSet_6_);
        }
        returnAST = lstmt_AST;
    }
Ejemplo n.º 2
0
		/*Copy an ASTPair.  Don't call it clone() because we want type-safety */
		public ASTPair copy()
		{
			ASTPair tmp = new ASTPair();
			tmp.root = root;
			tmp.child = child;
			return tmp;
		}
Ejemplo n.º 3
0
 /// <summary>
 /// Add a child to the current AST
 /// </summary>
 /// <param name="currentAST">The AST to add a child to</param>
 /// <param name="child">The child AST to be added</param>
 public virtual void  addASTChild(ASTPair currentAST, AST child)
 {
     if (child != null)
     {
         if (currentAST.root == null)
         {
             // Make new child the current root
             currentAST.root = child;
         }
         else
         {
             if (currentAST.child == null)
             {
                 // Add new child to current root
                 currentAST.root.setFirstChild(child);
             }
             else
             {
                 currentAST.child.setNextSibling(child);
             }
         }
         // Make new child the current child
         currentAST.child = child;
         currentAST.advanceChildToEnd();
     }
 }
Ejemplo n.º 4
0
        /*Copy an ASTPair.  Don't call it clone() because we want type-safety */
        public virtual ASTPair copy()
        {
            ASTPair tmp = new ASTPair();

            tmp.root  = root;
            tmp.child = child;
            return(tmp);
        }
Ejemplo n.º 5
0
		static public void PutInstance(ASTPair p)
		{
			if (p != null)
			{
				p.reset();
				instancePool_.Enqueue(p);
			}
		}
Ejemplo n.º 6
0
        /*Copy an ASTPair.  Don't call it clone() because we want type-safety */
        public virtual ASTPair copy()
        {
            ASTPair tmp = ASTPair.GetInstance();

            tmp.root  = root;
            tmp.child = child;
            return(tmp);
        }
Ejemplo n.º 7
0
 static public void PutInstance(ASTPair p)
 {
     if (p != null)
     {
         p.reset();
         instancePool_.Enqueue(p);
     }
 }
Ejemplo n.º 8
0
    public void decider()     //throws RecognitionException, TokenStreamException
    {
        returnAST = null;
        ASTPair currentAST  = new ASTPair();
        AST     decider_AST = null;

        try {              // for error handling
            {
                switch (LA(1))
                {
                case QMARK:
                {
                    AST tmp60_AST = null;
                    tmp60_AST = astFactory.create(LT(1));
                    astFactory.addASTChild(ref currentAST, tmp60_AST);
                    match(QMARK);
                    break;
                }

                case ID:
                case LPAREN:
                case EMARK:
                case CONST:
                {
                    expr();
                    astFactory.addASTChild(ref currentAST, returnAST);
                    break;
                }

                default:
                {
                    throw new NoViableAltException(LT(1), getFilename());
                }
                }
            }
            decider_AST     = (AST)currentAST.root;
            decider_AST     = (AST)astFactory.make(astFactory.create(DECIDER, "DECIDER"), decider_AST);
            currentAST.root = decider_AST;
            if ((null != decider_AST) && (null != decider_AST.getFirstChild()))
            {
                currentAST.child = decider_AST.getFirstChild();
            }
            else
            {
                currentAST.child = decider_AST;
            }
            currentAST.advanceChildToEnd();
            decider_AST = currentAST.root;
        }
        catch (RecognitionException ex)
        {
            reportError(ex);
            recover(ex, tokenSet_10_);
        }
        returnAST = decider_AST;
    }
Ejemplo n.º 9
0
    public void sseq()     //throws RecognitionException, TokenStreamException
    {
        returnAST = null;
        ASTPair currentAST = new ASTPair();
        AST     sseq_AST   = null;

        try {             // for error handling
            {             // ( ... )+
                int _cnt18 = 0;
                for (;;)
                {
                    if ((tokenSet_3_.member(LA(1))))
                    {
                        lstmt();
                        astFactory.addASTChild(ref currentAST, returnAST);
                    }
                    else
                    {
                        if (_cnt18 >= 1)
                        {
                            goto _loop18_breakloop;
                        }
                        else
                        {
                            throw new NoViableAltException(LT(1), getFilename());;
                        }
                    }

                    _cnt18++;
                }
                _loop18_breakloop :;
            }                // ( ... )+
            sseq_AST        = (AST)currentAST.root;
            sseq_AST        = (AST)astFactory.make(astFactory.create(SSEQ, "SSEQ"), sseq_AST);
            currentAST.root = sseq_AST;
            if ((null != sseq_AST) && (null != sseq_AST.getFirstChild()))
            {
                currentAST.child = sseq_AST.getFirstChild();
            }
            else
            {
                currentAST.child = sseq_AST;
            }
            currentAST.advanceChildToEnd();
            sseq_AST = currentAST.root;
        }
        catch (RecognitionException ex)
        {
            reportError(ex);
            recover(ex, tokenSet_4_);
        }
        returnAST = sseq_AST;
    }
Ejemplo n.º 10
0
 /// <summary>
 /// Make an AST the root of current AST.
 /// </summary>
 /// <param name="currentAST"></param>
 /// <param name="root"></param>
 public virtual void  makeASTRoot(ASTPair currentAST, AST root)
 {
     if (root != null)
     {
         // Add the current root as a child of new root
         root.addChild(currentAST.root);
         // The new current child is the last sibling of the old root
         currentAST.child = currentAST.root;
         currentAST.advanceChildToEnd();
         // Set the new root
         currentAST.root = root;
     }
 }
Ejemplo n.º 11
0
    public void prog()     //throws RecognitionException, TokenStreamException
    {
        returnAST = null;
        ASTPair currentAST = new ASTPair();
        AST     prog_AST   = null;

        try {              // for error handling
            {              // ( ... )*
                for (;;)
                {
                    if ((LA(1) == LITERAL_decl))
                    {
                        decl();
                        astFactory.addASTChild(ref currentAST, returnAST);
                    }
                    else
                    {
                        goto _loop3_breakloop;
                    }
                }
                _loop3_breakloop :;
            }                // ( ... )*
            {                // ( ... )*
                for (;;)
                {
                    if ((LA(1) == ID))
                    {
                        proc();
                        astFactory.addASTChild(ref currentAST, returnAST);
                    }
                    else
                    {
                        goto _loop5_breakloop;
                    }
                }
                _loop5_breakloop :;
            }                // ( ... )*
            prog_AST = currentAST.root;
        }
        catch (RecognitionException ex)
        {
            reportError(ex);
            recover(ex, tokenSet_0_);
        }
        returnAST = prog_AST;
    }
Ejemplo n.º 12
0
    public void decl()     //throws RecognitionException, TokenStreamException
    {
        returnAST = null;
        ASTPair currentAST = new ASTPair();
        AST     decl_AST   = null;

        try {              // for error handling
            AST tmp1_AST = null;
            tmp1_AST = astFactory.create(LT(1));
            astFactory.makeASTRoot(ref currentAST, tmp1_AST);
            match(LITERAL_decl);
            {
                AST tmp2_AST = null;
                tmp2_AST = astFactory.create(LT(1));
                astFactory.addASTChild(ref currentAST, tmp2_AST);
                match(ID);
                {                    // ( ... )*
                    for (;;)
                    {
                        if ((LA(1) == COMMA))
                        {
                            match(COMMA);
                            AST tmp4_AST = null;
                            tmp4_AST = astFactory.create(LT(1));
                            astFactory.addASTChild(ref currentAST, tmp4_AST);
                            match(ID);
                        }
                        else
                        {
                            goto _loop9_breakloop;
                        }
                    }
                    _loop9_breakloop :;
                }                    // ( ... )*
            }
            match(SEMI);
            decl_AST = currentAST.root;
        }
        catch (RecognitionException ex)
        {
            reportError(ex);
            recover(ex, tokenSet_1_);
        }
        returnAST = decl_AST;
    }
Ejemplo n.º 13
0
    public void atom()     //throws RecognitionException, TokenStreamException
    {
        returnAST = null;
        ASTPair currentAST = new ASTPair();
        AST     atom_AST   = null;

        try {              // for error handling
            AST tmp6_AST = null;
            tmp6_AST = astFactory.create(LT(1));
            astFactory.addASTChild(ref currentAST, tmp6_AST);
            match(INT);
            atom_AST = currentAST.root;
        }
        catch (RecognitionException ex)
        {
            reportError(ex);
            recover(ex, tokenSet_2_);
        }
        returnAST = atom_AST;
    }
Ejemplo n.º 14
0
	public void expr() //throws RecognitionException, TokenStreamException
{

		returnAST = null;
		ASTPair currentAST = new ASTPair();
		AST expr_AST = null;

		try {      // for error handling
			mexpr();
			astFactory.addASTChild(ref currentAST, returnAST);
			{    // ( ... )*
				for (;;)
				{
					if ((LA(1)==PLUS))
					{
						AST tmp3_AST = null;
						tmp3_AST = astFactory.create(LT(1));
						astFactory.makeASTRoot(ref currentAST, tmp3_AST);
						match(PLUS);
						mexpr();
						astFactory.addASTChild(ref currentAST, returnAST);
					}
					else
					{
						goto _loop3_breakloop;
					}

				}
_loop3_breakloop:				;
			}    // ( ... )*
			match(SEMI);
			expr_AST = currentAST.root;
		}
		catch (RecognitionException ex)
		{
			reportError(ex);
			recover(ex,tokenSet_0_);
		}
		returnAST = expr_AST;
	}
Ejemplo n.º 15
0
    public void expr()     //throws RecognitionException, TokenStreamException
    {
        returnAST = null;
        ASTPair currentAST = new ASTPair();
        AST     expr_AST   = null;

        try {              // for error handling
            mexpr();
            astFactory.addASTChild(ref currentAST, returnAST);
            {                // ( ... )*
                for (;;)
                {
                    if ((LA(1) == PLUS))
                    {
                        AST tmp3_AST = null;
                        tmp3_AST = astFactory.create(LT(1));
                        astFactory.makeASTRoot(ref currentAST, tmp3_AST);
                        match(PLUS);
                        mexpr();
                        astFactory.addASTChild(ref currentAST, returnAST);
                    }
                    else
                    {
                        goto _loop3_breakloop;
                    }
                }
                _loop3_breakloop :;
            }                // ( ... )*
            match(SEMI);
            expr_AST = currentAST.root;
        }
        catch (RecognitionException ex)
        {
            reportError(ex);
            recover(ex, tokenSet_0_);
        }
        returnAST = expr_AST;
    }
Ejemplo n.º 16
0
    public void stmt()     //throws RecognitionException, TokenStreamException
    {
        returnAST = null;
        ASTPair currentAST = new ASTPair();
        AST     stmt_AST   = null;

        try {              // for error handling
            switch (LA(1))
            {
            case LITERAL_skip:
            {
                AST tmp16_AST = null;
                tmp16_AST = astFactory.create(LT(1));
                astFactory.addASTChild(ref currentAST, tmp16_AST);
                match(LITERAL_skip);
                match(SEMI);
                stmt_AST = currentAST.root;
                break;
            }

            case LITERAL_print:
            {
                AST tmp18_AST = null;
                tmp18_AST = astFactory.create(LT(1));
                astFactory.makeASTRoot(ref currentAST, tmp18_AST);
                match(LITERAL_print);
                match(LPAREN);
                {
                    expr();
                    astFactory.addASTChild(ref currentAST, returnAST);
                    {                        // ( ... )*
                        for (;;)
                        {
                            if ((LA(1) == COMMA))
                            {
                                match(COMMA);
                                expr();
                                astFactory.addASTChild(ref currentAST, returnAST);
                            }
                            else
                            {
                                goto _loop23_breakloop;
                            }
                        }
                        _loop23_breakloop :;
                    }                        // ( ... )*
                }
                match(RPAREN);
                match(SEMI);
                stmt_AST = currentAST.root;
                break;
            }

            case LITERAL_goto:
            {
                AST tmp23_AST = null;
                tmp23_AST = astFactory.create(LT(1));
                astFactory.makeASTRoot(ref currentAST, tmp23_AST);
                match(LITERAL_goto);
                AST tmp24_AST = null;
                tmp24_AST = astFactory.create(LT(1));
                astFactory.addASTChild(ref currentAST, tmp24_AST);
                match(ID);
                match(SEMI);
                stmt_AST = currentAST.root;
                break;
            }

            case LITERAL_return:
            {
                AST tmp26_AST = null;
                tmp26_AST = astFactory.create(LT(1));
                astFactory.makeASTRoot(ref currentAST, tmp26_AST);
                match(LITERAL_return);
                match(SEMI);
                stmt_AST = currentAST.root;
                break;
            }

            case LITERAL_if:
            {
                AST tmp28_AST = null;
                tmp28_AST = astFactory.create(LT(1));
                astFactory.makeASTRoot(ref currentAST, tmp28_AST);
                match(LITERAL_if);
                match(LPAREN);
                decider();
                astFactory.addASTChild(ref currentAST, returnAST);
                match(RPAREN);
                match(LITERAL_then);
                sseq();
                astFactory.addASTChild(ref currentAST, returnAST);
                match(LITERAL_else);
                sseq();
                astFactory.addASTChild(ref currentAST, returnAST);
                match(LITERAL_fi);
                stmt_AST = currentAST.root;
                break;
            }

            case LITERAL_while:
            {
                AST tmp34_AST = null;
                tmp34_AST = astFactory.create(LT(1));
                astFactory.makeASTRoot(ref currentAST, tmp34_AST);
                match(LITERAL_while);
                match(LPAREN);
                decider();
                astFactory.addASTChild(ref currentAST, returnAST);
                match(RPAREN);
                match(LITERAL_do);
                sseq();
                astFactory.addASTChild(ref currentAST, returnAST);
                match(LITERAL_od);
                stmt_AST = currentAST.root;
                break;
            }

            case LITERAL_assert:
            {
                AST tmp39_AST = null;
                tmp39_AST = astFactory.create(LT(1));
                astFactory.makeASTRoot(ref currentAST, tmp39_AST);
                match(LITERAL_assert);
                match(LPAREN);
                decider();
                astFactory.addASTChild(ref currentAST, returnAST);
                match(RPAREN);
                match(SEMI);
                stmt_AST = currentAST.root;
                break;
            }

            default:
                if ((LA(1) == ID) && (LA(2) == COMMA || LA(2) == ASSIGN))
                {
                    {
                        AST tmp43_AST = null;
                        tmp43_AST = astFactory.create(LT(1));
                        astFactory.addASTChild(ref currentAST, tmp43_AST);
                        match(ID);
                        {                            // ( ... )*
                            for (;;)
                            {
                                if ((LA(1) == COMMA))
                                {
                                    match(COMMA);
                                    AST tmp45_AST = null;
                                    tmp45_AST = astFactory.create(LT(1));
                                    astFactory.addASTChild(ref currentAST, tmp45_AST);
                                    match(ID);
                                }
                                else
                                {
                                    goto _loop26_breakloop;
                                }
                            }
                            _loop26_breakloop :;
                        }                            // ( ... )*
                    }
                    AST tmp46_AST = null;
                    tmp46_AST = astFactory.create(LT(1));
                    astFactory.addASTChild(ref currentAST, tmp46_AST);
                    match(ASSIGN);
                    {
                        expr();
                        astFactory.addASTChild(ref currentAST, returnAST);
                        {                            // ( ... )*
                            for (;;)
                            {
                                if ((LA(1) == COMMA))
                                {
                                    match(COMMA);
                                    expr();
                                    astFactory.addASTChild(ref currentAST, returnAST);
                                }
                                else
                                {
                                    goto _loop29_breakloop;
                                }
                            }
                            _loop29_breakloop :;
                        }                            // ( ... )*
                    }
                    match(SEMI);
                    stmt_AST        = (AST)currentAST.root;
                    stmt_AST        = (AST)astFactory.make(astFactory.create(ASSIGNMENT, "ASSIGNMENT"), stmt_AST);
                    currentAST.root = stmt_AST;
                    if ((null != stmt_AST) && (null != stmt_AST.getFirstChild()))
                    {
                        currentAST.child = stmt_AST.getFirstChild();
                    }
                    else
                    {
                        currentAST.child = stmt_AST;
                    }
                    currentAST.advanceChildToEnd();
                    stmt_AST = currentAST.root;
                }
                else if ((LA(1) == ID) && (LA(2) == LPAREN))
                {
                    AST tmp49_AST = null;
                    tmp49_AST = astFactory.create(LT(1));
                    astFactory.makeASTRoot(ref currentAST, tmp49_AST);
                    match(ID);
                    match(LPAREN);
                    {
                        switch (LA(1))
                        {
                        case ID:
                        case LPAREN:
                        case EMARK:
                        case CONST:
                        {
                            expr();
                            astFactory.addASTChild(ref currentAST, returnAST);
                            {                                // ( ... )*
                                for (;;)
                                {
                                    if ((LA(1) == COMMA))
                                    {
                                        match(COMMA);
                                        expr();
                                        astFactory.addASTChild(ref currentAST, returnAST);
                                    }
                                    else
                                    {
                                        goto _loop32_breakloop;
                                    }
                                }
                                _loop32_breakloop :;
                            }                                // ( ... )*
                            break;
                        }

                        case RPAREN:
                        {
                            break;
                        }

                        default:
                        {
                            throw new NoViableAltException(LT(1), getFilename());
                        }
                        }
                    }
                    match(RPAREN);
                    match(SEMI);
                    stmt_AST        = (AST)currentAST.root;
                    stmt_AST        = (AST)astFactory.make(astFactory.create(PROCCALL, "PROCCALL"), stmt_AST);
                    currentAST.root = stmt_AST;
                    if ((null != stmt_AST) && (null != stmt_AST.getFirstChild()))
                    {
                        currentAST.child = stmt_AST.getFirstChild();
                    }
                    else
                    {
                        currentAST.child = stmt_AST;
                    }
                    currentAST.advanceChildToEnd();
                    stmt_AST = currentAST.root;
                }
                else
                {
                    throw new NoViableAltException(LT(1), getFilename());
                }
                break;
            }
        }
        catch (RecognitionException ex)
        {
            reportError(ex);
            recover(ex, tokenSet_6_);
        }
        returnAST = stmt_AST;
    }
Ejemplo n.º 17
0
	public void atom() //throws RecognitionException, TokenStreamException
{

		returnAST = null;
		ASTPair currentAST = new ASTPair();
		AST atom_AST = null;

		try {      // for error handling
			AST tmp6_AST = null;
			tmp6_AST = astFactory.create(LT(1));
			astFactory.addASTChild(ref currentAST, tmp6_AST);
			match(INT);
			atom_AST = currentAST.root;
		}
		catch (RecognitionException ex)
		{
			reportError(ex);
			recover(ex,tokenSet_2_);
		}
		returnAST = atom_AST;
	}
Ejemplo n.º 18
0
    public void proc()     //throws RecognitionException, TokenStreamException
    {
        returnAST = null;
        ASTPair currentAST = new ASTPair();
        AST     proc_AST   = null;

        try {              // for error handling
            AST tmp6_AST = null;
            tmp6_AST = astFactory.create(LT(1));
            astFactory.makeASTRoot(ref currentAST, tmp6_AST);
            match(ID);
            match(LPAREN);
            {
                switch (LA(1))
                {
                case ID:
                {
                    AST tmp8_AST = null;
                    tmp8_AST = astFactory.create(LT(1));
                    astFactory.addASTChild(ref currentAST, tmp8_AST);
                    match(ID);
                    {                        // ( ... )*
                        for (;;)
                        {
                            if ((LA(1) == COMMA))
                            {
                                match(COMMA);
                                AST tmp10_AST = null;
                                tmp10_AST = astFactory.create(LT(1));
                                astFactory.addASTChild(ref currentAST, tmp10_AST);
                                match(ID);
                            }
                            else
                            {
                                goto _loop13_breakloop;
                            }
                        }
                        _loop13_breakloop :;
                    }                        // ( ... )*
                    break;
                }

                case RPAREN:
                {
                    break;
                }

                default:
                {
                    throw new NoViableAltException(LT(1), getFilename());
                }
                }
            }
            match(RPAREN);
            match(LITERAL_begin);
            {                // ( ... )*
                for (;;)
                {
                    if ((LA(1) == LITERAL_decl))
                    {
                        decl();
                        astFactory.addASTChild(ref currentAST, returnAST);
                    }
                    else
                    {
                        goto _loop15_breakloop;
                    }
                }
                _loop15_breakloop :;
            }                // ( ... )*
            sseq();
            astFactory.addASTChild(ref currentAST, returnAST);
            match(LITERAL_end);
            proc_AST        = (AST)currentAST.root;
            proc_AST        = (AST)astFactory.make(astFactory.create(PROC, "PROC"), proc_AST);
            currentAST.root = proc_AST;
            if ((null != proc_AST) && (null != proc_AST.getFirstChild()))
            {
                currentAST.child = proc_AST.getFirstChild();
            }
            else
            {
                currentAST.child = proc_AST;
            }
            currentAST.advanceChildToEnd();
            proc_AST = currentAST.root;
        }
        catch (RecognitionException ex)
        {
            reportError(ex);
            recover(ex, tokenSet_2_);
        }
        returnAST = proc_AST;
    }
Ejemplo n.º 19
0
 /// <summary>
 /// Make an AST the root of current AST.
 /// </summary>
 /// <param name="currentAST"></param>
 /// <param name="root"></param>
 public virtual void makeASTRoot(ASTPair currentAST, AST root)
 {
     if (root != null)
     {
         // Add the current root as a child of new root
         root.addChild(currentAST.root);
         // The new current child is the last sibling of the old root
         currentAST.child = currentAST.root;
         currentAST.advanceChildToEnd();
         // Set the new root
         currentAST.root = root;
     }
 }
Ejemplo n.º 20
0
 /// <summary>
 /// Add a child to the current AST
 /// </summary>
 /// <param name="currentAST">The AST to add a child to</param>
 /// <param name="child">The child AST to be added</param>
 public virtual void addASTChild(ASTPair currentAST, AST child)
 {
     if (child != null)
     {
         if (currentAST.root == null)
         {
             // Make new child the current root
             currentAST.root = child;
         }
         else
         {
             if (currentAST.child == null)
             {
                 // Add new child to current root
                 currentAST.root.setFirstChild(child);
             }
             else
             {
                 currentAST.child.setNextSibling(child);
             }
         }
         // Make new child the current child
         currentAST.child = child;
         currentAST.advanceChildToEnd();
     }
 }
Ejemplo n.º 21
0
    public void expr()     //throws RecognitionException, TokenStreamException
    {
        returnAST = null;
        ASTPair currentAST = new ASTPair();
        AST     expr_AST   = null;

        try {              // for error handling
            {
                switch (LA(1))
                {
                case EMARK:
                {
                    AST tmp54_AST = null;
                    tmp54_AST = astFactory.create(LT(1));
                    astFactory.addASTChild(ref currentAST, tmp54_AST);
                    match(EMARK);
                    expr();
                    astFactory.addASTChild(ref currentAST, returnAST);
                    break;
                }

                case LPAREN:
                {
                    match(LPAREN);
                    expr();
                    astFactory.addASTChild(ref currentAST, returnAST);
                    match(RPAREN);
                    break;
                }

                case ID:
                {
                    AST tmp57_AST = null;
                    tmp57_AST = astFactory.create(LT(1));
                    astFactory.addASTChild(ref currentAST, tmp57_AST);
                    match(ID);
                    break;
                }

                case CONST:
                {
                    AST tmp58_AST = null;
                    tmp58_AST = astFactory.create(LT(1));
                    astFactory.addASTChild(ref currentAST, tmp58_AST);
                    match(CONST);
                    break;
                }

                default:
                {
                    throw new NoViableAltException(LT(1), getFilename());
                }
                }
            }
            {
                if ((LA(1) == BINOP) && (tokenSet_7_.member(LA(2))))
                {
                    AST tmp59_AST = null;
                    tmp59_AST = astFactory.create(LT(1));
                    astFactory.addASTChild(ref currentAST, tmp59_AST);
                    match(BINOP);
                    expr();
                    astFactory.addASTChild(ref currentAST, returnAST);
                }
                else if ((tokenSet_8_.member(LA(1))) && (tokenSet_9_.member(LA(2))))
                {
                }
                else
                {
                    throw new NoViableAltException(LT(1), getFilename());
                }
            }
            expr_AST        = (AST)currentAST.root;
            expr_AST        = (AST)astFactory.make(astFactory.create(EXPR, "EXPR"), expr_AST);
            currentAST.root = expr_AST;
            if ((null != expr_AST) && (null != expr_AST.getFirstChild()))
            {
                currentAST.child = expr_AST.getFirstChild();
            }
            else
            {
                currentAST.child = expr_AST;
            }
            currentAST.advanceChildToEnd();
            expr_AST = currentAST.root;
        }
        catch (RecognitionException ex)
        {
            reportError(ex);
            recover(ex, tokenSet_8_);
        }
        returnAST = expr_AST;
    }