Rewriting grammar