Factor out fsm/ast mapping