I strongly doubt the AST would be needed. You could probably do this in a trivial loop state machine. It can't even be called laziness: that regex took time to work out - far longer than a switch-based state machine would have taken to write in the first place.
Aside: out of curiosity it would have been interesting to see how a Thompson NFA[1] would have dealt with this.