parse text: save the correct state on terminals

On a terminal node, the old state was saved instead of the new
state. This results in an incorrect classification if followed
by non-terminal states.