#pragma once #include "ast_node.hpp" namespace ast { struct Expr : public AstVisitable { }; template struct VisitableExpr : public Crtp, public Expr { using uptr = std::unique_ptr; virtual void accept(AstVisitor& visitor) { visitor.visit(this->derived()); } }; template struct LeafExpr : public VisitableExpr { LeafExpr(T value) : value(value) {} T value; }; template struct BinaryExpr : public VisitableExpr { BinaryExpr(Expr* left, Expr* right) : left(left), right(right) {} Expr* left; Expr* right; }; }