Evaluation Stack

The evaluation stack is used to keep track of intermediate stages and precedence of operations when evaluating a formula expression. The expression is evaluated from beginning to end, and operands are pushed onto the stack as they are encountered. When function tokens are encountered, the required number of operands is popped from the stack and the result of the operation is pushed back onto the stack. Control tokens are not pushed onto the stack. Evaluation begins with an empty stack, and when the evaluation is finished, there is exactly one token left on the stack. The remaining token is the result of the evaluation.