Refactoring grammar rules