Rewrite parse tree structures for new grammar