Port grammar changes to AST rewrite rules and tree grammar (closes #60)