while (more input) {
next = nextToken()
if (next is operand)
push(next)
else apply next to top two operands and push the result
}
answer is on top of the stack
while (more input) {
next = nextToken()
if (next is operand)
emit next
else {
while (!stack.isEmpty() && (precedence(top()) >= precedence(next))) {
emit(pop());
} // while
push(next)
} // else
}
while !stack.isEmpty()
emit(pop())