Encode parser as finite state machine