Spawn the stack and the reading head. start -> ()| Handle a push. Continually push symbols until you run into another instruction. If you can't push any more symbols, and a push is pending, push a separator. )|push1 -> 1)|push )|push; -> ;)| Handle a drop. Continue erasing symbols until you encounter a separator. ;)|drop; -> |drop;) 1|drop -> |drop ;|drop;) -> ;)| Handle the last element being dropped. (|drop;) -> ()| Handle an empty drop. ()|drop; -> ()| Handle an addition. Seek to the separator that divides two runs of symbols. ;)|add; -> |+;) 1|+ -> |+1 When you reach it, eliminate it, then reset. ;|+ -> |> If there's only one number on the stack, reset. (|+ -> (|> Handle a subtraction. Seek to the separator that divides two runs of symbols. ;)|sub; -> |-;) 1|- -> |-1 When you encounter it, stop and consume one symbol from both sides of the separator. 1;|-1 -> ;|- If you run out of symbols on the left side of the separator, reset. (;|- -> (|> ;;|- ->|> If you run out of symbols on the right side of the separator, reset. ;|-;) -> ;)| If there's only one number on the stack, reset. (|- -> (|> Handle a reset. Seek back to the instruction stream. |>1 -> 1|> |>; -> ;|> |>) -> )| ::=:: start push 11; push 111; add; push 1; sub; push; add;