/// <summary> /// Recursively pop operators and operands /// </summary> /// <param name="operands"></param> /// <param name="operators"></param> private void Pop(Stack operands, Stack operators) { operators.Pop(); AndOrElement andOrChild = MyLeftChild as AndOrElement; if (andOrChild == null) { operands.Pop(); } else { andOrChild.Pop(operands, operators); } andOrChild = MyRightChild as AndOrElement; if (andOrChild == null) { operands.Pop(); } else { andOrChild.Pop(operands, operators); } }
private void PopRightChild(Stack operands, Stack operators) { AndOrElement andOrChild = MyRightChild as AndOrElement; // What kind of child do we have? if ((andOrChild != null)) { // Another and/or expression so recurse andOrChild.Pop(operands, operators); } else { // A terminal so pop it off the operands stack operands.Pop(); } }