Exemple #1
0
 public void ParseIt(string strForParsing)
 {
     scOp = new OperatorStack();
     eqResult = new ExecutionQueue();
     string strSrc = strForParsing;
     scOp.Clear();
     int pos = 0;
     bool isFirstOperator = true;
     EnmOperators opCurrent;
     while(pos < strSrc.Length)
     {
         if((opCurrent = IsOperator(strSrc, isFirstOperator, ref pos)) != EnmOperators.Nop)
         {
             if(opCurrent != EnmOperators.Blank)
             {
                 OperatorStackManager(opCurrent);
                 if(opCurrent == EnmOperators.RightPar)
                     isFirstOperator = false;
                 else
                     isFirstOperator = true;
             }
             continue;
         }
         eqResult.Enqueue(GetOperand(strSrc, ref pos));
         isFirstOperator = false;
     }
     while(scOp.Count>0)
     {
         eqResult.Enqueue(new ExecutionItem(scOp.Pop()));
     }
 }
Exemple #2
0
        public void ParseIt(string strForParsing)
        {
            scOp     = new OperatorStack();
            eqResult = new ExecutionQueue();
            string strSrc = strForParsing;

            scOp.Clear();
            int          pos             = 0;
            bool         isFirstOperator = true;
            EnmOperators opCurrent;

            while (pos < strSrc.Length)
            {
                if ((opCurrent = IsOperator(strSrc, isFirstOperator, ref pos)) != EnmOperators.Nop)
                {
                    if (opCurrent != EnmOperators.Blank)
                    {
                        OperatorStackManager(opCurrent);
                        if (opCurrent == EnmOperators.RightPar)
                        {
                            isFirstOperator = false;
                        }
                        else
                        {
                            isFirstOperator = true;
                        }
                    }
                    continue;
                }
                eqResult.Enqueue(GetOperand(strSrc, ref pos));
                isFirstOperator = false;
            }
            while (scOp.Count > 0)
            {
                eqResult.Enqueue(new ExecutionItem(scOp.Pop()));
            }
        }