Completely rewrite grammar and AST