public void TestGetPriority01() { MemberOp memberOP = new MemberOp(); //Test Procedure Call OperatorPriority priority = memberOP.Priority; //Post Condition Check }
private List <Element> EvalPriorityOperators(List <Element> elements, OperatorPriority priority) { List <Element> new_elements = new List <Element>(); // seek for operators with high priority int len = elements.Count; for (int i = 0; i < len - 1; i++) { Element e = elements[i]; if (e.ElementType == ElementType.Operator) { Operator op = (Operator)e; if (op.Priority == priority) // operator with high priority, like * and / { Operand operand1 = (Operand)elements[i - 1]; Operand operand2 = (Operand)elements[i + 1]; for (int j = 0; j < i - 1; j++) { new_elements.Add(elements[j]); } new_elements.Add(new Operand(op.Eval(operand1.Eval(), operand2.Eval()))); for (int j = i + 2; j < len; j++) { new_elements.Add(elements[j]); } return(EvalPriorityOperators(new_elements, priority)); } } } return(elements); }
public Operator(OperatorType type) : base(ElementType.Operator) { _type = type; if (type == OperatorType.Powers || type == OperatorType.Percentage) { _priority = OperatorPriority.High; } else if (type == OperatorType.Multiply || type == OperatorType.Divide || type == OperatorType.Remainder) { _priority = OperatorPriority.Medium; } else { _priority = OperatorPriority.Low; } }
public Operator(string Operator, OperatorPriority Priority) { this.name = Operator; this.priority = Priority; }