Fix LR0 state machine algorithm