time to refactor the grammar