private void pushOperationAccordingToAssociationAndPriority(Operation operation, OperationsStackItem itemToPush) { // Push an operation according to association and priority if (stack.Count > 0) { int j = stack.Count - 1; bool priorityExit = false; while ((j >= 0) && (!priorityExit)) { if (stack[j].Kind == OperationStackItemKind.Delimiter) { break; } // switch (stack[j].Kind) { case OperationStackItemKind.Operation: { if (operationsRegistry.GetAssociationByPriority(operation.Priority) == PriorityAssociation.LeftAssociated) { if (operationsRegistry.GetOperationByName(stack[j].OperationName).Priority > operation.Priority) { priorityExit = true; } } else { if (operationsRegistry.GetOperationByName(stack[j].OperationName).Priority >= operation.Priority) { priorityExit = true; } } if (!priorityExit) { res.Add(new CompiledExpressionItem(CompiledExpressionItemKind.Operation, stack[j].OperationName)); stack.RemoveAt(j); } break; } case OperationStackItemKind.PartialSignature: { priorityExit = true; break; } default: { throw new MathProcessorException("Unexpected item in stack."); } } j--; } } // stack.Add(itemToPush); }
private void pushOperationAccordingToAssociationAndPriority(Operation operation, OperationsStackItem itemToPush) { // Push an operation according to association and priority if (stack.Count > 0) { int j = stack.Count - 1; bool priorityExit = false; while ((j >= 0) && (!priorityExit)) { if (stack[j].Kind == OperationStackItemKind.Delimiter) { break; } // switch (stack[j].Kind) { case OperationStackItemKind.Operation: { if (operationsRegistry.GetAssociationByPriority(operation.Priority) == PriorityAssociation.LeftAssociated) { if (operationsRegistry.GetOperationByName(stack[j].OperationName).Priority > operation.Priority) priorityExit = true; } else { if (operationsRegistry.GetOperationByName(stack[j].OperationName).Priority >= operation.Priority) priorityExit = true; } if (!priorityExit) { res.Add(new CompiledExpressionItem(CompiledExpressionItemKind.Operation, stack[j].OperationName)); stack.RemoveAt(j); } break; } case OperationStackItemKind.PartialSignature: { priorityExit = true; break; } default: { throw new MathProcessorException("Unexpected item in stack."); } } j--; } } // stack.Add(itemToPush); }