FSM demo implementation that parses string of a regular format. Intentionally suboptimal.