rewriting Ex 1-23 with finite state machine, adding single quote support to the other Ex 1-23 solution