예제 #1
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 <{>
                if ((CLexicalAnalyzer.LEX_FAIL == plexAnal.GetNextToken(ref pToken, ref pSymbolTable)) ||
                    pToken == null || (pToken.GetSubType() != RUL_TOKEN_SUBTYPE.RUL_LBRACK))
                {
                    if (pToken.GetSubType() != RUL_TOKEN_SUBTYPE.RUL_COLON)
                    {
                        //throw (C_UM_ERROR_INTERNALERR);
                    }
                }

                //Munch List of statments...
                //try
                {
                    m_pStmtList = new CStatementList();
                    m_pStmtList.CreateParseSubTree(ref plexAnal, ref pSymbolTable);
                }

                /*
                 * catch (CRIDEError* perr)
                 * {
                 *      pvecErrors.push_back(perr);
                 *      plexAnal.MoveTo(
                 *              RUL_SYMBOL,
                 *              RUL_RBRACK,
                 *              pSymbolTable);
                 * }
                 */
                //Munch a <}>
                if ((CLexicalAnalyzer.LEX_FAIL == plexAnal.GetNextToken(ref pToken, ref pSymbolTable)) ||
                    pToken == null || (pToken.GetSubType() != RUL_TOKEN_SUBTYPE.RUL_RBRACK))
                {
                    //ADD_ERROR(C_CS_ERROR_MISSINGRBRACK);
                    plexAnal.UnGetToken();
                }
                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;
             */
        }
예제 #2
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   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
        //	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 <return>
                if ((CLexicalAnalyzer.LEX_FAIL == plexAnal.GetNextToken(ref pToken, ref pSymbolTable)) ||
                    !pToken.IsRETURNStatement())
                {
                    //throw (C_UM_ERROR_INTERNALERR);
                }
                //Munch a <;>
                if ((CLexicalAnalyzer.LEX_FAIL == plexAnal.GetNextToken(ref pToken, ref pSymbolTable)) ||
                    pToken.GetSubType() == RUL_TOKEN_SUBTYPE.RUL_SEMICOLON)   //Anil Octobet 5 2005 for handling Method Calling Method
                {
                    //throw(C_UM_ERROR_INTERNALERR)//Commented by anil
                    //this is the case of Void return so no need to parse the futher satement
                    m_pExpression = null;//Anil Octobet 5 2005 for handling Method Calling Method
                    return(1);
                }
                plexAnal.UnGetToken();

                //Added Anil Octobet 5 2005 for handling Method Calling Method
                //Return statement may be a Expression So Do Parse those Expression and Push it on to m_pExpression
                CExpParser expParser = new CExpParser();
                //try
                {
                    m_pExpression = expParser.ParseExpression(ref plexAnal, ref pSymbolTable, STMT_EXPR_TYPE.EXPR_ASSIGN);

                    if (m_pExpression == null)
                    {
                        //throw (C_AP_ERROR_MISSINGEXP);
                    }
                }

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

            /*
             *          catch (CRIDEError* perr)
             *          {
             *                  pvecErrors.push_back(perr);
             *                  plexAnal.SynchronizeTo(EXPRESSION, pSymbolTable);
             *          }
             *          catch (...)
             *          {
             *                  throw (C_UM_ERROR_UNKNOWNERROR);
             *          }
             *          return PARSE_FAIL;
             */
        }
예제 #4
0
        //	Create as much of the parse tree as possible.
        public override int CreateParseSubTree(ref CLexicalAnalyzer plexAnal, ref CSymbolTable pSymbolTable)
        {
            CToken pToken = null;
            //try
            {
                CExpParser expParser;
                //Munch a <Var>
                if ((CLexicalAnalyzer.LEX_FAIL == plexAnal.GetNextToken(ref pToken, ref pSymbolTable)) || pToken == null)
                {
                    //throw (C_UM_ERROR_INTERNALERR);
                }
                if (pToken.IsArrayVar())
                {
                    plexAnal.UnGetToken();
                    expParser        = new CExpParser();
                    m_pArrayExp      = expParser.ParseExpression(ref plexAnal, ref pSymbolTable, STMT_EXPR_TYPE.EXPR_LVALUE);
                    m_bLvalueIsArray = true;
                    m_pVariable      = null;
                    m_pOMExp         = null;
                    m_pComplexDDExp  = null;//Added By Anil August 23 2005
                }
                //Added By Anil August 4 2005 --starts here
                //For Handlin the DD variable and Expressions
                else if (pToken.IsDDItem())
                {
                    plexAnal.UnGetToken();
                    expParser            = new CExpParser();
                    m_pComplexDDExp      = expParser.ParseExpression(ref plexAnal, ref pSymbolTable, STMT_EXPR_TYPE.EXPR_LVALUE);
                    m_bLvalueIsComplexDD = true;
                    m_pArrayExp          = null;
                    m_pVariable          = null;
                    m_pOMExp             = null;
                }
                //Added By Anil August 4 2005 --Ends here
                else if (pToken.IsVariable())
                {
                    m_pVariable     = pToken;
                    m_pArrayExp     = null;
                    m_pOMExp        = null;
                    m_pComplexDDExp = null;//Anil August 23 2005

                    //DELETE_PTR(pToken);
                    //todo walter
                }
                else if (pToken.IsOMToken())
                {
                    //do something...
                    plexAnal.UnGetToken();
                    m_pOMExp = new COMServiceExpression();
                    m_pOMExp.CreateParseSubTree(ref plexAnal, ref pSymbolTable);
                    m_pVariable     = null;
                    m_pArrayExp     = null;
                    m_pComplexDDExp = null;//Anil August 23 2005
                }
                else
                {
                    //throw (C_AP_ERROR_LVALUE);
                }

                //DELETE_PTR(pToken);  //todo walter
                pToken = null;
                //Munch a <=> or <*=>
                if ((CLexicalAnalyzer.LEX_FAIL == plexAnal.GetNextToken(ref pToken, ref pSymbolTable)) ||
                    pToken == null ||
                    !pToken.IsAssignOp())
                {
                    //throw (C_AP_ERROR_MISSINGEQ);
                }
                m_AssignType = pToken.GetSubType();

                //Munch & Parse the expression.
                //we got to give the expression string to the expression parser.
                expParser = new CExpParser();
                //try
                {
                    m_pExpression = expParser.ParseExpression(ref plexAnal, ref pSymbolTable, STMT_EXPR_TYPE.EXPR_ASSIGN);

                    if (m_pExpression == null)
                    {
                        //throw (C_AP_ERROR_MISSINGEXP);
                    }
                }

                /*
                 *              catch (CRIDEError* perr)
                 *              {
                 *                      pvecErrors.push_back(perr);
                 *                      plexAnal.SynchronizeTo(EXPRESSION, pSymbolTable);
                 *              }
                 */
                if ((CLexicalAnalyzer.LEX_FAIL == plexAnal.GetNextToken(ref pToken, ref pSymbolTable)) ||
                    pToken == null || (RUL_TOKEN_SUBTYPE.RUL_SEMICOLON != pToken.GetSubType()))
                {
                    //throw (C_AP_ERROR_MISSINGSC);
                }
                return(1);
            }

            /*
             *          catch (CRIDEError* perr)
             *          {
             *                  pvecErrors.push_back(perr);
             *                  plexAnal.SynchronizeTo(EXPRESSION, pSymbolTable);
             *          }
             *          catch (...)
             *          {
             *                  throw (C_UM_ERROR_UNKNOWNERROR);
             *          }
             *          return PARSE_FAIL;
             */
        }
예제 #5
0
        //	Create as much of the parse tree as possible.
        public override int CreateParseSubTree(ref CLexicalAnalyzer plexAnal, ref CSymbolTable pSymbolTable)
        {
            CToken pToken = null;
            {
                //Munch a <IF>
                if ((CLexicalAnalyzer.LEX_FAIL == plexAnal.GetNextToken(ref pToken, ref pSymbolTable)) ||
                    pToken == null || !pToken.IsIFStatement())
                {
                    //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.
                //
                CExpParser expParser = new CExpParser();
                //try
                {
                    m_pExpression = expParser.ParseExpression(ref plexAnal, ref pSymbolTable, STMT_EXPR_TYPE.EXPR_IF);
                    if (m_pExpression == null)
                    {
                        //ADD_ERROR(C_IF_ERROR_MISSINGEXP);
                    }
                }

                //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();
                }

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

                //See if you can snatch a "else"
                try
                {
                    m_pElse = (CELSEStatement)builder.CreateParser(ref plexAnal, STATEMENT_TYPE.STMT_SELECTION);
                    if (null != m_pElse)
                    {
                        m_pElse.CreateParseSubTree(ref plexAnal, ref pSymbolTable);
                    }
                }
                catch (Exception ex)
                {
                    string exinfo = ex.Message;
                    //return 0;
                }

                return(1);
            }
        }
예제 #6
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 <FOR>
                if ((CLexicalAnalyzer.LEX_FAIL == plexAnal.GetNextToken(ref pToken, ref pSymbolTable)) ||
                    pToken == null || !pToken.IsFORStatement())
                {
                    //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 a Initialization Statement...
                CParserBuilder builder = new CParserBuilder();
                m_pInitializationStatement = (CAssignmentStatement)builder.CreateParser(ref plexAnal, STATEMENT_TYPE.STMT_asic);
                if (null != (m_pInitializationStatement))
                {
                    m_pInitializationStatement.CreateParseSubTree(ref plexAnal, ref pSymbolTable);
                }
                else
                {
                    //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_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;

                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_asic);
                    }
                    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 if (expressionNodeType == GRAMMAR_NODE_TYPE.NODE_TYPE_INVALID)
                    {
                        pToken = null;

                        //try
                        {
                            if ((CLexicalAnalyzer.LEX_FAIL != (plexAnal.LookAheadToken(ref pToken))) && pToken != null)
                            {
                                if ((pToken.GetType() == RUL_TOKEN_TYPE.RUL_SYMBOL) && (pToken.GetSubType() == RUL_TOKEN_SUBTYPE.RUL_SEMICOLON))
                                {
                                    // This code is to handle for(;;) for Yokagawa EJX
                                    expressionNodeType = GRAMMAR_NODE_TYPE.NODE_TYPE_EXPRESSION;
                                    CToken pToken2 = new CToken("1");
                                    pToken2.SetType(RUL_TOKEN_TYPE.RUL_NUMERIC_CONSTANT);
                                    m_pExpression = new CPrimaryExpression(pToken2);
                                }
                            }
                        }

                        /*
                         *                      catch (...)
                         *                      {
                         *                      }
                         */
                    }
                }
                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_SEMICOLON))
                {
                    //ADD_ERROR(C_WHILE_ERROR_MISSINGLP);
                    plexAnal.UnGetToken();
                }

                //Munch a Increment Statement...
                pNode = builder2.CreateParser(ref plexAnal, STATEMENT_TYPE.STMT_asic);

                m_pIncrementExpression = null;
                m_pIncrementStatement  = null;
                if (null != pNode)
                {
                    incrementNodeType = pNode.GetNodeType();
                    if (incrementNodeType == GRAMMAR_NODE_TYPE.NODE_TYPE_ASSIGN)
                    {
                        incrementNodeType     = GRAMMAR_NODE_TYPE.NODE_TYPE_ASSIGN;
                        m_pIncrementStatement = (CAssignmentStatement)pNode;

                        m_pIncrementStatement.CreateParseSubTree(ref plexAnal, ref pSymbolTable, STATEMENT_TYPE.STMT_ASSIGNMENT_FOR);
                    }
                    else if (incrementNodeType == GRAMMAR_NODE_TYPE.NODE_TYPE_EXPRESSION)
                    {
                        incrementNodeType = GRAMMAR_NODE_TYPE.NODE_TYPE_EXPRESSION;
                        m_pIncrementExpression
                            = expParser.ParseExpression(ref plexAnal, ref pSymbolTable, STMT_EXPR_TYPE.EXPR_FOR);

                        if (m_pIncrementExpression == 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_MISSINGLP);
                    plexAnal.UnGetToken();
                }

                //Munch the statement
                CParserBuilder builder3 = 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);
                }

                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;
             */
        }
예제 #7
0
        //	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;
             */
        }
예제 #8
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 <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;
             */
        }
예제 #9
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 <RuleEngine>
                if ((CLexicalAnalyzer.LEX_FAIL == plexAnal.GetNextToken(ref pToken, ref pSymbolTable)) ||
                    pToken == null || (RUL_TOKEN_TYPE.RUL_KEYWORD != pToken.GetType()) ||
                    (RUL_TOKEN_SUBTYPE.RUL_RULE_ENGINE != pToken.GetSubType()))
                {
                    //throw (C_UM_ERROR_INTERNALERR);
                }

                //Munch a <::>
                if ((CLexicalAnalyzer.LEX_FAIL == plexAnal.GetNextToken(ref pToken, ref pSymbolTable)) ||
                    pToken == null || (RUL_TOKEN_TYPE.RUL_SYMBOL != pToken.GetType()) ||
                    RUL_TOKEN_SUBTYPE.RUL_SCOPE != pToken.GetSubType())
                {
                    //ADD_ERROR(C_RS_ERROR_MISSINGSCOPE);
                    plexAnal.UnGetToken();
                }

                //Munch a <Invoke>
                if ((CLexicalAnalyzer.LEX_FAIL == plexAnal.GetNextToken(ref pToken, ref pSymbolTable)) ||
                    pToken == null || (RUL_TOKEN_TYPE.RUL_KEYWORD != pToken.GetType()) ||
                    (RUL_TOKEN_SUBTYPE.RUL_INVOKE != pToken.GetSubType()))
                {
                    //ADD_ERROR(C_RS_ERROR_MISSINGINVOKE);
                    plexAnal.UnGetToken();
                }

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

                //Munch a <RuleName> -- this is a string
                if ((CLexicalAnalyzer.LEX_FAIL == plexAnal.GetNextToken(ref pToken, ref pSymbolTable)) ||
                    pToken == null || (RUL_TOKEN_SUBTYPE.RUL_STRING_CONSTANT != pToken.GetSubType() &&
                                       RUL_TOKEN_SUBTYPE.RUL_STRING_DECL != pToken.GetSubType()))
                {
                    //ADD_ERROR(C_RS_ERROR_MISSINGRNAME);
                    plexAnal.UnGetToken();
                }
                m_pRuleName = pToken;
                pToken      = null;

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

                if ((CLexicalAnalyzer.LEX_FAIL == plexAnal.GetNextToken(ref pToken, ref pSymbolTable)) ||
                    pToken == null || (RUL_TOKEN_SUBTYPE.RUL_SEMICOLON != pToken.GetSubType()))
                {
                    //ADD_ERROR(C_RS_ERROR_MISSINGSC);
                    plexAnal.UnGetToken();
                }
                return(1);
            }

            /*
             *          catch (CRIDEError* perr)
             *          {
             *                  pvecErrors.push_back(perr);
             *                  plexAnal.MovePast(
             *                          RUL_TOKEN_TYPE.RUL_SYMBOL,
             *                          RUL_TOKEN_TYPE.RUL_SEMICOLON,
             *                          pSymbolTable);
             *          }
             *          catch (...)
             *          {
             *                  //throw (C_UM_ERROR_UNKNOWNERROR);
             *          }
             *          return PARSE_FAIL;
             */
        }
예제 #10
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 <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;

                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_WHILE);//Vibhor 150305: Changed from 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 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);
                }
                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;
             */
        }