Reword AstVisitor to use visitor pattern