moving state from generator to parser