Rewriting grammar and compiler