#ifndef roza_NODE_HPP #define roza_NODE_HPP #include "commons.hpp" #include "SrcLoc.hpp" #define NODE_TYPE(G) \ G(NODE_PROG), G(NODE_INSTR), G(NODE_EOI), \ G(NODE_INT), G(NODE_ADD), G(NODE_SUB), G(NODE_MUL), \ G(NODE_DIV), G(NODE_MOD), G(NODE_POW), G(NODE_OPAR), \ G(NODE_CPAR), G(NODE_UADD), G(NODE_USUB) namespace roza { MAKE_ENUM(NODE_TYPE, NodeType); class Node { public: explicit Node(NodeType type, std::string const& repr, SrcLoc loc); virtual ~Node(); NodeType type() const { return m_type; } std::string repr() const { return m_repr; } SrcLoc loc() const { return m_loc; } size_t size() const { return m_children.size(); } std::string string() const; void add_child(std::shared_ptr child); std::shared_ptr child(size_t index); Node const& child(size_t index) const; private: NodeType m_type; std::string m_repr; SrcLoc m_loc; std::vector> m_children; }; } #endif