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())); } }
private void OperatorStackManager(EnmOperators op) { if (scOp.Count == 0) { scOp.Push(op); return; } ; if (op == EnmOperators.LeftPar) { scOp.Push(op); return; } ; if (op == EnmOperators.RightPar) { while (scOp.Count > 0) { EnmOperators opStack = scOp.Pop(); if (opStack != EnmOperators.LeftPar) { eqResult.Enqueue(new ExecutionItem(opStack)); } else { return; } } ; return; } ; while (scOp.Count > 0) { EnmOperators opStack = scOp.Peek(); if (GetPrivelege(op) <= GetPrivelege(opStack)) { eqResult.Enqueue(new ExecutionItem(scOp.Pop())); } else { break; } } scOp.Push(op); }
public new ExecutionQueue Clone() { ExecutionQueue retEQ = new ExecutionQueue(); IEnumerator ieNum = this.GetEnumerator(); while(ieNum.MoveNext()) retEQ.Enqueue((ExecutionItem)ieNum.Current); return retEQ; }
public new ExecutionQueue Clone() { ExecutionQueue retEQ = new ExecutionQueue(); IEnumerator ieNum = this.GetEnumerator(); while (ieNum.MoveNext()) { retEQ.Enqueue((ExecutionItem)ieNum.Current); } return(retEQ); }
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())); } }