Exemplo n.º 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 <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;
             */
        }