Library

PDT · Pushdown transduction

What is left after cancelling ()

Cancel every matched pair of parentheses and print what remains. It always has the form )…)(…( — some closers nothing opened, then some openers nothing closed. Unmatched closers are printed as they arrive; openers wait on the stack and are printed at the end only if nothing cancelled them.

readflushdone
The machine as drawn — 3 states, 6 transitions.

The author’s examples, run

( → accept · () → accept · )(( → accept · ((() → accept((( → accept · ((()))())(()(())((( → accept · ))))((((