text_reader.fsm: split the FSM into groups

The text reader FSM is complex. To make it easier to manage, this
change supports grouping the states and transitions into named
sections.