"Defines an automata that computes polish expressions using a Stack" 'stack.st' r 'automata.st' r s <- Stack new t1 <- Transition new; setTrigger: '1234567890' t1 setAction: [ :d | s push: d asInteger - $0 asInteger ] t2 <- Transition new; setTrigger: '+' t2 setAction: [ :c | s push: ( s pop + s pop ) ] t3 <- Transition new; setTrigger: '-' t3 setAction: [ :c | s push: ( s pop - s pop ) ] t4 <- Transition new; setTrigger: '*' t4 setAction: [ :c | s push: ( s pop * s pop ) ] t5 <- Transition new; setTrigger: '/' t5 setAction: [ :c | s push: ( s pop / s pop ) ] t6 <- Transition new; setTrigger: '$' t6 setAction: [ :c | s pop print ] s1 <- State new; add: t1; add: t2; add: t3; add: t4; add: t5; add: t6 t1 nextState: s1 t2 nextState: s1 t3 nextState: s1 t4 nextState: s1 t5 nextState: s1 t6 nextState: s1 a <- Automata new; currentState: s1 a perform: '11+$' a perform: '123*+$' a perform: '12/12/*$'