2
1
+
3
*
[0][1][2][3][4]
top ↓
(empty)
operands
Operand stack
▸1stack = []2for token in tokens:3 if token is a number:4 stack.push(number(token))5 else: // operator6 right = stack.pop()7 left = stack.pop()8 stack.push(left OP right)9return stack.top() // the only element
state
- stack[]
- actionstart