#include namespace LXC::AST { // Enum to track which node it was created as // enum class NodeType { // General nodes // Identifier, FunctionCall, IntLiteral, Operation, // Variable nodes // Var_Declare, Var_Assign, Var_Access, // Control flow nodes // IfBranch, ReturnVal }; // Base class of all AST nodes // class Node { public: // Virtual deconstructor for safe-polymorphism // virtual ~Node() = default; // Allows external access to find what the type is // NodeType Type() const { return m_Type; } protected: // Stops the base type being created // Node(NodeType _type) : m_Type(_type) {} // Stores the type for polymorphism // const NodeType m_Type; }; // Nodes that can return values inherit from this instead // class NodeValue : public Node { protected: NodeValue(NodeType _type) : Node(_type) {} }; // Returns a pointer to the actual type of the node // template requires std::is_base_of_v inline T* As(const Node& base) { return dynamic_cast(base); } }