コード例 #1
0
        //	Create as much of the parse tree as possible.
        public override int CreateParseSubTree(ref CLexicalAnalyzer plexAnal, ref CSymbolTable pSymbolTable)
        {
            CParserBuilder builder = new CParserBuilder();
            CGrammarNode   pDecl   = null;

            //try
            {
                while (null != (pDecl = builder.CreateParser(ref plexAnal, STATEMENT_TYPE.STMT_DECL)))
                {
                    m_declList.Add((CDeclaration)pDecl);
                    pDecl.CreateParseSubTree(ref plexAnal, ref pSymbolTable);
                }
                return(1);
            }

            /*
             *          catch (CRIDEError* perr)
             *          {
             *                  pvecErrors.push_back(perr);
             *                  //just skip a few tokens and hope everything becomes alright.
             *                  plexAnal.MovePast(
             *                          RUL_SYMBOL,
             *                          RUL_SEMICOLON,
             *                          pSymbolTable);
             *          }
             *          catch (...)
             *          {
             *                  throw (C_UM_ERROR_UNKNOWNERROR);
             *          }
             *          return PARSE_FAIL;
             */
        }
コード例 #2
0
ファイル: Statement.cs プロジェクト: Wotingfengyu12/11
        //	Create as much of the parse tree as possible.
        public override int CreateParseSubTree(ref CLexicalAnalyzer plexAnal, ref CSymbolTable pSymbolTable)
        {
            CParserBuilder builder = new CParserBuilder();
            CGrammarNode   pStmt   = null;

            int i = 0;

            //try
            {
                while (true)
                {
                    i++;

                    if (i == 0xb)
                    {
                        ;
                    }

                    pStmt = builder.CreateParser(ref plexAnal, STATEMENT_TYPE.STMT_asic);
                    if (pStmt == null)
                    {
                        if (plexAnal.IsEndOfSource())
                        {
                            return(1);
                        }
                        else
                        {
                            CToken pToken = null;

                            if ((CLexicalAnalyzer.LEX_FAIL != plexAnal.GetNextToken(ref pToken, ref pSymbolTable)) && pToken != null)
                            {
                                if (pToken.GetSubType() == RUL_TOKEN_SUBTYPE.RUL_SEMICOLON)
                                {
                                    continue;
                                }
                                else
                                {
                                    plexAnal.UnGetToken();
                                }
                            }

                            return(0);
                        }
                    }
                    pStmt.SetScopeIndex(plexAnal.GetSymbolTableScopeIndex());         //SCR26200 Felix
                    m_stmtList.Add((CStatement)pStmt);
                    pStmt.CreateParseSubTree(ref plexAnal, ref pSymbolTable);
                }//end of while loop

                //return 1;
            }

            /*
             *          catch (...)
             *          {
             *                  return PARSE_FAIL;
             *          }
             */
        }
コード例 #3
0
        public CGrammarNode CreateParser(ref CLexicalAnalyzer plexAnal, STATEMENT_TYPE stmt_type)
        {
            CGrammarNode pNode  = null;
            CToken       pToken = null;

            if ((CLexicalAnalyzer.LEX_FAIL != (plexAnal.LookAheadToken(ref pToken))) && pToken != null)
            {
                if (((stmt_type == STATEMENT_TYPE.STMT_DECL) || (stmt_type == STATEMENT_TYPE.STMT_asic)) &&
                    ((pToken.GetType() == RUL_TOKEN_TYPE.RUL_SYMBOL) && (pToken.GetSubType() == RUL_TOKEN_SUBTYPE.RUL_SEMICOLON)))
                {
                    pNode = new CEmptyStatement();
                }
                else if (
                    ((stmt_type == STATEMENT_TYPE.STMT_DECL) || (stmt_type == STATEMENT_TYPE.STMT_asic)) &&
                    ((pToken.GetType() == RUL_TOKEN_TYPE.RUL_SYMBOL) && (pToken.GetSubType() == RUL_TOKEN_SUBTYPE.RUL_LPAREN))
                    )
                {
                    pNode = new CExpression();
                }
                else if (((stmt_type == STATEMENT_TYPE.STMT_DECL) || (stmt_type == STATEMENT_TYPE.STMT_asic)) && pToken.IsDeclaration())          //Declaration Statement
                {
                    pNode = new CDeclaration();
                }
                else if (((stmt_type == STATEMENT_TYPE.STMT_asic)) &&
                         (RUL_TOKEN_TYPE.RUL_KEYWORD == pToken.GetType()) &&
                         !pToken.IsIteration() &&
                         !pToken.IsFunctionToken())
                {
                    if (pToken.GetSubType() == RUL_TOKEN_SUBTYPE.RUL_IF)// IF Selection Statement
                    {
                        pNode = new CSelectionStatement();
                    }
                    else if (pToken.GetSubType() == RUL_TOKEN_SUBTYPE.RUL_SWITCH)//SWITCH Statement
                    {
                        pNode = new CSwitchStatement();
                    }
                    else if (RUL_TOKEN_TYPE.RUL_KEYWORD == pToken.GetType() &&
                             RUL_TOKEN_SUBTYPE.RUL_RULE_ENGINE == pToken.GetSubType())   //Rule Statement
                    {
                        pNode = new CRuleServiceStatement();
                    }
                    else if (RUL_TOKEN_TYPE.RUL_KEYWORD == pToken.GetType() &&
                             RUL_TOKEN_SUBTYPE.RUL_BREAK == pToken.GetSubType())     //break Statement
                    {
                        pNode = new CBreakStatement();
                    }
                    else if (RUL_TOKEN_TYPE.RUL_KEYWORD == pToken.GetType() &&
                             RUL_TOKEN_SUBTYPE.RUL_CONTINUE == pToken.GetSubType())      //continue Statement
                    {
                        pNode = new CContinueStatement();
                    }
                    else if (RUL_TOKEN_TYPE.RUL_KEYWORD == pToken.GetType() &&
                             RUL_TOKEN_SUBTYPE.RUL_RETURN == pToken.GetSubType())    //continue Statement
                    {
                        pNode = new CReturnStatement();
                    }
                }
                else if (((stmt_type == STATEMENT_TYPE.STMT_ITERATION) || (stmt_type == STATEMENT_TYPE.STMT_asic)) && pToken.IsIteration())                               //Iteration Statement
                {
                    if (pToken.IsWHILEStatement())
                    {
                        pNode = new CIterationStatement();
                    }
                    else if (pToken.IsDOStatement())
                    {
                        pNode = new CIterationDoWhileStatement();
                    }
                    else if (pToken.IsFORStatement())
                    {
                        pNode = new CIterationForStatement();
                    }
                }
                else if (((stmt_type == STATEMENT_TYPE.STMT_ASSIGNMENT) || (stmt_type == STATEMENT_TYPE.STMT_asic)) && (pToken.IsFunctionToken()))
                //Assignment Statement
                {
                    pNode = new CExpression();
                }
                else if (((stmt_type == STATEMENT_TYPE.STMT_ASSIGNMENT) || (stmt_type == STATEMENT_TYPE.STMT_asic)) &&
                         (pToken.IsVariable() || pToken.IsArrayVar() || pToken.IsDDItem() ||//Added By Anil August 4 2005
                          pToken.IsOMToken() || pToken.IsNumeric() ||
                          pToken.IsConstant() || pToken.IsFunctionToken() || pToken.IsOperator() ||
                          ((pToken.GetType() == RUL_TOKEN_TYPE.RUL_SYMBOL) && (pToken.GetSubType() == RUL_TOKEN_SUBTYPE.RUL_LPAREN))
                         ))
                //Assignment Statement
                {
                    CToken pNewToken = null;  //TSRPRASAD 09MAR2004 Fix the memory leaks	*/

                    bool bLineIsAssignment = false;
                    if (plexAnal.ScanLineForToken(RUL_TOKEN_TYPE.RUL_ARITHMETIC_OPERATOR, RUL_TOKEN_SUBTYPE.RUL_PLUS_ASSIGN, ref pNewToken))   //TSRPRASAD 09MAR2004 Fix the memory leaks	*/
                    {
                        bLineIsAssignment = true;
                    }
                    else if (plexAnal.ScanLineForToken(RUL_TOKEN_TYPE.RUL_ASSIGNMENT_OPERATOR, RUL_TOKEN_SUBTYPE.RUL_MINUS_ASSIGN, ref pNewToken))   //TSRPRASAD 09MAR2004 Fix the memory leaks	*/
                    {
                        bLineIsAssignment = true;
                    }
                    else if (plexAnal.ScanLineForToken(RUL_TOKEN_TYPE.RUL_ASSIGNMENT_OPERATOR, RUL_TOKEN_SUBTYPE.RUL_DIV_ASSIGN, ref pNewToken))     //TSRPRASAD 09MAR2004 Fix the memory leaks	*/
                    {
                        bLineIsAssignment = true;
                    }
                    else if (plexAnal.ScanLineForToken(RUL_TOKEN_TYPE.RUL_ASSIGNMENT_OPERATOR, RUL_TOKEN_SUBTYPE.RUL_MOD_ASSIGN, ref pNewToken))   //TSRPRASAD 09MAR2004 Fix the memory leaks	*/
                    {
                        bLineIsAssignment = true;
                    }

                    else if (plexAnal.ScanLineForToken(RUL_TOKEN_TYPE.RUL_ASSIGNMENT_OPERATOR, RUL_TOKEN_SUBTYPE.RUL_MUL_ASSIGN, ref pNewToken))    //TSRPRASAD 09MAR2004 Fix the memory leaks	*/
                    {
                        bLineIsAssignment = true;
                    }
                    else if (plexAnal.ScanLineForToken(RUL_TOKEN_TYPE.RUL_ASSIGNMENT_OPERATOR, RUL_TOKEN_SUBTYPE.RUL_BIT_AND_ASSIGN, ref pNewToken)) //TSRPRASAD 09MAR2004 Fix the memory leaks	*/
                    {
                        bLineIsAssignment = true;
                    }
                    else if (plexAnal.ScanLineForToken(RUL_TOKEN_TYPE.RUL_ASSIGNMENT_OPERATOR, RUL_TOKEN_SUBTYPE.RUL_BIT_OR_ASSIGN, ref pNewToken))  //TSRPRASAD 09MAR2004 Fix the memory leaks	*/
                    {
                        bLineIsAssignment = true;
                    }
                    else if (plexAnal.ScanLineForToken(RUL_TOKEN_TYPE.RUL_ASSIGNMENT_OPERATOR, RUL_TOKEN_SUBTYPE.RUL_BIT_XOR_ASSIGN, ref pNewToken)) //TSRPRASAD 09MAR2004 Fix the memory leaks	*/
                    {
                        bLineIsAssignment = true;
                    }
                    else if (plexAnal.ScanLineForToken(RUL_TOKEN_TYPE.RUL_ASSIGNMENT_OPERATOR, RUL_TOKEN_SUBTYPE.RUL_BIT_RSHIFT_ASSIGN, ref pNewToken))  //TSRPRASAD 09MAR2004 Fix the memory leaks	*/
                    {
                        bLineIsAssignment = true;
                    }
                    else if (plexAnal.ScanLineForToken(RUL_TOKEN_TYPE.RUL_ASSIGNMENT_OPERATOR, RUL_TOKEN_SUBTYPE.RUL_BIT_LSHIFT_ASSIGN, ref pNewToken)) //TSRPRASAD 09MAR2004 Fix the memory leaks	*/

                    {
                        bLineIsAssignment = true;
                    }
                    else if (plexAnal.ScanLineForToken(RUL_TOKEN_TYPE.RUL_ASSIGNMENT_OPERATOR, RUL_TOKEN_SUBTYPE.RUL_ASSIGN, ref pNewToken)) //TSRPRASAD 09MAR2004 Fix the memory leaks	*/

                    {
                        bLineIsAssignment = true;
                    }

                    if (bLineIsAssignment)
                    {
                        pNode = new CAssignmentStatement();
                    }
                    else
                    {
                        pNode = new CExpression();
                    }
                }
                else if (((stmt_type == STATEMENT_TYPE.STMT_ASSIGNMENT) || (stmt_type == STATEMENT_TYPE.STMT_asic)) && pToken.IsFunctionToken())                           //Assignment Statement
                {
                    pNode = new CAssignmentStatement();
                }
                else if (((stmt_type == STATEMENT_TYPE.STMT_COMPOUND) || (stmt_type == STATEMENT_TYPE.STMT_asic)) && pToken.IsCompound())                                //Compound Statement
                {
                    pNode = new CCompoundStatement();
                }
                else if (((stmt_type == STATEMENT_TYPE.STMT_SERVICE) || (stmt_type == STATEMENT_TYPE.STMT_asic) || (stmt_type == STATEMENT_TYPE.STMT_ASSIGNMENT_FOR)) &&
                         pToken.IsService())                               //Service Statement
                {
                    pNode = new CServiceStatement();
                }
                else if (((stmt_type == STATEMENT_TYPE.STMT_SELECTION)) && (RUL_TOKEN_TYPE.RUL_KEYWORD == pToken.GetType()))
                {
                    if ((pToken.GetSubType() == RUL_TOKEN_SUBTYPE.RUL_CASE) || (pToken.GetSubType() == RUL_TOKEN_SUBTYPE.RUL_DEFAULT))//CASE or DEFAULT Statement
                    {
                        pNode = new CCASEStatement();
                    }
                    else if (pToken.GetSubType() == RUL_TOKEN_SUBTYPE.RUL_ELSE)//ELSE Statement
                    {
                        pNode = new CELSEStatement();
                    }
                }
                else
                {
                    //error
                    //the natural control flow is allowed to take care of this
                    //erroneous condition.
                }
            }
            return(pNode);
        }
コード例 #4
0
ファイル: CASEStatement.cs プロジェクト: Wotingfengyu12/11
        //	Create as much of the parse tree as possible.
        public override int CreateParseSubTree(ref CLexicalAnalyzer plexAnal, ref CSymbolTable pSymbolTable)
        {
            //Eat a Statement...
            CToken pToken = null;
            //try
            {
                //Munch a <CASE>
                if ((CLexicalAnalyzer.LEX_FAIL == plexAnal.GetNextToken(ref pToken, ref pSymbolTable)) ||
                    pToken == null || (pToken.GetSubType() != RUL_TOKEN_SUBTYPE.RUL_CASE)
                    )
                {
                    if (pToken.GetSubType() != RUL_TOKEN_SUBTYPE.RUL_DEFAULT)
                    {
                        //throw (C_UM_ERROR_INTERNALERR);
                    }
                    else
                    {
                        m_bIsDefaultCase = true;
                    }
                }

                //Munch & Parse the expression.
                //we got to give the expression string to the expression parser.
                //
                if (m_bIsDefaultCase != true)
                {
                    CExpParser expParser = new CExpParser();
                    //try
                    {
                        m_pExpression = expParser.ParseExpression(ref plexAnal, ref pSymbolTable, STMT_EXPR_TYPE.EXPR_CASE);
                        if (m_pExpression == null)
                        {
                            //ADD_ERROR(C_IF_ERROR_MISSINGEXP);
                        }
                    }

                    /*
                     * catch (CRIDEError* perr)
                     * {
                     *      pvecErrors.push_back(perr);
                     *      plexAnal.SynchronizeTo(EXPRESSION, ref pSymbolTable);
                     * }
                     */
                }

                //Munch a <:>
                if ((CLexicalAnalyzer.LEX_FAIL == plexAnal.GetNextToken(ref pToken, ref pSymbolTable)) ||
                    pToken == null || (pToken.GetSubType() != RUL_TOKEN_SUBTYPE.RUL_COLON))
                {
                    //throw (C_UM_ERROR_INTERNALERR);
                }

                if ((CLexicalAnalyzer.LEX_FAIL != plexAnal.GetNextToken(ref pToken, ref pSymbolTable)) &&
                    pToken != null && (pToken.GetSubType() == RUL_TOKEN_SUBTYPE.RUL_CASE))
                {
                    plexAnal.UnGetToken();
                    m_pStatementList = null;
                    return(1);
                }
                plexAnal.UnGetToken();

                //Look for a statement
                m_pStatementList = new CStatementList();

                /*		if((CLexicalAnalyzer.LEX_FAIL == plexAnal.GetNextToken(ref pToken,pSymbolTable))
                || !pToken
                || (pToken.GetSubType() != RUL_LBRACK)
                ||                      )
                ||              {
                ||                      plexAnal.UnGetToken();
                ||              }
                ||              else
                ||              {
                ||                      bCompoundStatement = true;
                ||              }
                ||              DELETE_PTR(pToken);*/

                bool bCompoundStatement = false;
                int  iBrackCount        = 0;
                while (true)
                {
                    if (CLexicalAnalyzer.LEX_FAIL != plexAnal.GetNextToken(ref pToken, ref pSymbolTable))
                    {
                        if ((pToken.GetSubType() == RUL_TOKEN_SUBTYPE.RUL_LBRACK) && (bCompoundStatement))
                        {
                            bCompoundStatement = true;
                            iBrackCount++;
                        }
                        if ((pToken.GetSubType() == RUL_TOKEN_SUBTYPE.RUL_RBRACK) && (bCompoundStatement))
                        {
                            if (bCompoundStatement == true)
                            {
                                iBrackCount--;
                                if (iBrackCount == 0)
                                {
                                    bCompoundStatement = false;
                                }
                            }
                        }

                        if ((pToken.GetSubType() == RUL_TOKEN_SUBTYPE.RUL_CASE) || (pToken.GetSubType() == RUL_TOKEN_SUBTYPE.RUL_DEFAULT))
                        {
                            plexAnal.UnGetToken();
                            break;
                        }

                        plexAnal.UnGetToken();
                    }

                    CGrammarNode   pStmt   = null;
                    CParserBuilder builder = new CParserBuilder();

                    pStmt = builder.CreateParser(ref plexAnal, STATEMENT_TYPE.STMT_asic);
                    if (pStmt == null)
                    {
                        if (plexAnal.IsEndOfSource())
                        {
                            return(1);
                        }
                        else
                        {
                            return(0);
                        }
                    }
                    m_pStatementList.AddStatement((CStatement)pStmt);
                    int i32Ret = pStmt.CreateParseSubTree(ref plexAnal, ref pSymbolTable);
                    if (i32Ret == 0)
                    {
                        //ADD_ERROR(C_ES_ERROR_MISSINGSTMT);
                    }
                }
                return(1);
            }

            /*
             * catch (CRIDEError* perr)
             * {
             *      pvecErrors.push_back(perr);
             *      plexAnal.MovePast(
             *              RUL_SYMBOL,
             *              RUL_SEMICOLON,
             *              pSymbolTable);
             * }
             * catch (...)
             * {
             *      throw (C_UM_ERROR_UNKNOWNERROR);
             * }
             * return PARSE_FAIL;
             */
        }
コード例 #5
0
ファイル: SwitchStatement.cs プロジェクト: Wotingfengyu12/11
        //	Create as much of the parse tree as possible.
        public override int CreateParseSubTree(ref CLexicalAnalyzer plexAnal, ref CSymbolTable pSymbolTable)
        {
            CToken pToken = null;
            //try
            {
                //Munch a <SWITCH>
                if ((CLexicalAnalyzer.LEX_FAIL == plexAnal.GetNextToken(ref pToken, ref pSymbolTable)) ||
                    pToken == null || (pToken.GetSubType() != RUL_TOKEN_SUBTYPE.RUL_SWITCH))
                {
                    //throw (C_UM_ERROR_INTERNALERR);
                }

                //Munch a <(>
                if ((CLexicalAnalyzer.LEX_FAIL == plexAnal.GetNextToken(ref pToken, ref pSymbolTable)) ||
                    pToken == null || (pToken.GetSubType() != RUL_TOKEN_SUBTYPE.RUL_LPAREN))
                {
                    //ADD_ERROR(C_IF_ERROR_MISSINGLP);
                    plexAnal.UnGetToken();
                }

                //Munch & Parse the expression.
                //we got to give the expression string to the expression parser.
                //
                CParserBuilder builder2  = new CParserBuilder();
                CExpParser     expParser = new CExpParser();
                CGrammarNode   pNode     = null;

                pNode = builder2.CreateParser(ref plexAnal, STATEMENT_TYPE.STMT_asic);

                m_pExpression          = null;
                m_pExpressionStatement = null;
                if (null != pNode)
                {
                    expressionNodeType = pNode.GetNodeType();
                    if (expressionNodeType == GRAMMAR_NODE_TYPE.NODE_TYPE_ASSIGN)
                    {
                        expressionNodeType     = GRAMMAR_NODE_TYPE.NODE_TYPE_ASSIGN;
                        m_pExpressionStatement = (CAssignmentStatement)pNode;

                        m_pExpressionStatement.CreateParseSubTree(ref plexAnal, ref pSymbolTable, STATEMENT_TYPE.STMT_ASSIGNMENT_FOR);
                    }
                    else if (expressionNodeType == GRAMMAR_NODE_TYPE.NODE_TYPE_EXPRESSION)
                    {
                        expressionNodeType = GRAMMAR_NODE_TYPE.NODE_TYPE_EXPRESSION;
                        m_pExpression      = expParser.ParseExpression(ref plexAnal, ref pSymbolTable, STMT_EXPR_TYPE.EXPR_FOR);

                        if (m_pExpression == null)
                        {
                            //ADD_ERROR(C_WHILE_ERROR_MISSINGEXP);
                        }
                    }
                }
                else
                {
                    //ADD_ERROR(C_WHILE_ERROR_MISSINGSTMT);
                }

                //Munch a <)>
                if ((CLexicalAnalyzer.LEX_FAIL == plexAnal.GetNextToken(ref pToken, ref pSymbolTable)) ||
                    pToken == null || (pToken.GetSubType() != RUL_TOKEN_SUBTYPE.RUL_RPAREN))
                {
                    //ADD_ERROR(C_IF_ERROR_MISSINGRP);
                    plexAnal.UnGetToken();
                }

                //Munch a <{>
                if ((CLexicalAnalyzer.LEX_FAIL == plexAnal.GetNextToken(ref pToken, ref pSymbolTable)) ||
                    pToken == null || (pToken.GetSubType() != RUL_TOKEN_SUBTYPE.RUL_LBRACK))
                {
                    //ADD_ERROR(C_IF_ERROR_MISSINGRP);
                    plexAnal.UnGetToken();
                }

                //See if you can snatch a "case"
                CParserBuilder builder = new CParserBuilder();
                int            iNumberOfCaseStatements = 0;
                m_pCase[iNumberOfCaseStatements] = (CCASEStatement)builder.CreateParser(ref plexAnal, STATEMENT_TYPE.STMT_SELECTION);
                while (null != (m_pCase[iNumberOfCaseStatements]))
                {
                    m_pCase[iNumberOfCaseStatements].CreateParseSubTree(ref plexAnal, ref pSymbolTable);
                    if (m_pCase[iNumberOfCaseStatements].IsDefaultStatement())
                    {
                        m_bIsDefaultPresent = true;
                        m_pDefaultCase      = m_pCase[iNumberOfCaseStatements];
                    }
                    else
                    {
                        iNumberOfCaseStatements++;
                    }
                    m_pCase[iNumberOfCaseStatements] = (CCASEStatement)builder.CreateParser(ref plexAnal, STATEMENT_TYPE.STMT_SELECTION);
                }
                m_iNumberOfCasesPresent = iNumberOfCaseStatements;

                //Munch a <}>
                if ((CLexicalAnalyzer.LEX_FAIL == plexAnal.GetNextToken(ref pToken, ref pSymbolTable)) ||
                    pToken == null || (pToken.GetSubType() != RUL_TOKEN_SUBTYPE.RUL_RBRACK))
                {
                    //ADD_ERROR(C_IF_ERROR_MISSINGRP);
                    plexAnal.UnGetToken();
                }

                /* VMKP Commented on 140404,  For INOR device
                 *      Sensor selection method is crashing with this Fix */
                /*	if (pNode)	//TSRPRASAD 09MAR2004 Fix the memory leaks
                 *      {
                 *              delete pNode;
                 *              pNode = null;
                 *      }*/
                /* VMKP Commented on 140404 */

                return(1);
            }

            /*
             * catch (CRIDEError perr)
             * {
             *      pvecErrors.push_back(perr);
             *      plexAnal.MovePast(
             *              RUL_SYMBOL,
             *              RUL_SEMICOLON,
             *              pSymbolTable);
             * }
             * catch (...)
             * {
             *      throw (C_UM_ERROR_UNKNOWNERROR);
             * }
             * return PARSE_FAIL;
             */
        }
コード例 #6
0
ファイル: Statement.cs プロジェクト: Wotingfengyu12/11
 public bool AddStatement(CGrammarNode pStmt)
 {
     m_stmtList.Add((CStatement)pStmt);
     return(true);
 }
コード例 #7
0
        //	Create as much of the parse tree as possible.
        public override int CreateParseSubTree(ref CLexicalAnalyzer plexAnal, ref CSymbolTable pSymbolTable)
        {
            CToken pToken = null;
            //try
            {
                //Munch a <DO>
                if ((CLexicalAnalyzer.LEX_FAIL == plexAnal.GetNextToken(ref pToken, ref pSymbolTable)) ||
                    pToken == null || !pToken.IsDOStatement())
                {
                    //throw (C_UM_ERROR_INTERNALERR);
                }

                //Munch a Statement...
                CParserBuilder builder = new CParserBuilder();
                m_pStatement = (CStatement)builder.CreateParser(ref plexAnal, STATEMENT_TYPE.STMT_asic);
                if (null != (m_pStatement))
                {
                    m_pStatement.CreateParseSubTree(ref plexAnal, ref pSymbolTable);
                }
                else
                {
                    //ADD_ERROR(C_WHILE_ERROR_MISSINGSTMT);
                }

                //Munch a <WHILE>
                if ((CLexicalAnalyzer.LEX_FAIL == plexAnal.GetNextToken(ref pToken, ref pSymbolTable)) ||
                    pToken == null || !pToken.IsWHILEStatement())
                {
                    //throw (C_UM_ERROR_INTERNALERR);
                }

                //Munch a <(>
                if ((CLexicalAnalyzer.LEX_FAIL == plexAnal.GetNextToken(ref pToken, ref pSymbolTable)) ||
                    pToken == null || !(pToken.GetSubType() == RUL_TOKEN_SUBTYPE.RUL_LPAREN))
                {
                    //ADD_ERROR(C_WHILE_ERROR_MISSINGLP);
                    plexAnal.UnGetToken();
                }

                //Munch & Parse the expression.
                //we got to give the expression string to the expression parser.
                //
                CParserBuilder builder2  = new CParserBuilder();
                CExpParser     expParser = new CExpParser();
                CGrammarNode   pNode     = null;           //TSRPRASAD 09MAR2004 Fix the memory leaks	*/

                pNode = builder2.CreateParser(ref plexAnal, STATEMENT_TYPE.STMT_asic);

                m_pExpression          = null;
                m_pExpressionStatement = null;
                if (null != pNode)
                {
                    expressionNodeType = pNode.GetNodeType();
                    if (expressionNodeType == GRAMMAR_NODE_TYPE.NODE_TYPE_ASSIGN)
                    {
                        expressionNodeType     = GRAMMAR_NODE_TYPE.NODE_TYPE_ASSIGN;
                        m_pExpressionStatement = (CAssignmentStatement)pNode;

                        m_pExpressionStatement.CreateParseSubTree(ref plexAnal, ref pSymbolTable, STATEMENT_TYPE.STMT_ASSIGNMENT_FOR);
                    }
                    else if (expressionNodeType == GRAMMAR_NODE_TYPE.NODE_TYPE_EXPRESSION)
                    {
                        expressionNodeType = GRAMMAR_NODE_TYPE.NODE_TYPE_EXPRESSION;
                        m_pExpression      = expParser.ParseExpression(ref plexAnal, ref pSymbolTable, STMT_EXPR_TYPE.EXPR_FOR);

                        if (m_pExpression == null)
                        {
                            //ADD_ERROR(C_WHILE_ERROR_MISSINGEXP);
                        }
                    }
                }
                else
                {
                    //ADD_ERROR(C_WHILE_ERROR_MISSINGSTMT);
                }

                //Munch a <)>
                if ((CLexicalAnalyzer.LEX_FAIL == plexAnal.GetNextToken(ref pToken, ref pSymbolTable)) ||
                    pToken == null || !(pToken.GetSubType() == RUL_TOKEN_SUBTYPE.RUL_RPAREN))
                {
                    //ADD_ERROR(C_WHILE_ERROR_MISSINGRP);
                    plexAnal.UnGetToken();
                }

                //Munch a <;>
                if ((CLexicalAnalyzer.LEX_FAIL == plexAnal.GetNextToken(ref pToken, ref pSymbolTable)) ||
                    pToken == null || !(pToken.GetSubType() == RUL_TOKEN_SUBTYPE.RUL_SEMICOLON))
                {
                    //ADD_ERROR(C_WHILE_ERROR_MISSINGRP);
                    plexAnal.UnGetToken();
                }
                /*<START>TSRPRASAD 09MAR2004 Fix the memory leaks	*/
                /*<END>TSRPRASAD 09MAR2004 Fix the memory leaks	*/

                return(1);
            }

            /*
             * catch (CRIDEError* perr)
             * {
             *      pvecErrors.push_back(perr);
             *      plexAnal.MovePast(
             *              RUL_SYMBOL,
             *              RUL_SEMICOLON,
             *              pSymbolTable);
             * }
             * catch (...)
             * {
             *      throw (C_UM_ERROR_UNKNOWNERROR);
             * }
             * return PARSE_FAIL;
             */
        }