Rewriting grammar

practice