#ifndef MEMGRAPH_CYPHER_AST_TREE_HPP #define MEMGRAPH_CYPHER_AST_TREE_HPP #include #include "ast_node.hpp" namespace ast { class Ast { public: Ast() {} AstVisitable::uptr root; void traverse(AstVisitor& visitor) { root->accept(visitor); } template T* create(Args&&... args) { auto node = new T(std::forward(args)...); items.push_back(std::unique_ptr(node)); return node; } private: // basically a gc vector that destroys all ast nodes once this object is // destroyed. parser generator is written in c and works only with raw // pointers so this is what makes it leak free after the parser finishes // parsing std::vector items; }; } #endif