grammar refactor