Refactor line-ending grammar rules.