grammar rewrite