From 061f9ad04131febcc66975fd3d95b332789da52f Mon Sep 17 00:00:00 2001 From: crupest Date: Tue, 21 Dec 2021 15:13:55 +0800 Subject: ... --- include/cru/parse/ParsingTreeNode.hpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 include/cru/parse/ParsingTreeNode.hpp (limited to 'include/cru/parse') diff --git a/include/cru/parse/ParsingTreeNode.hpp b/include/cru/parse/ParsingTreeNode.hpp new file mode 100644 index 00000000..d1c3d058 --- /dev/null +++ b/include/cru/parse/ParsingTreeNode.hpp @@ -0,0 +1,33 @@ +#pragma once +#include "Grammar.hpp" + +#include + +namespace cru::parse { +class ParsingTreeNode { + public: + ParsingTreeNode(Symbol* symbol, Production* production); + + CRU_DELETE_COPY(ParsingTreeNode) + CRU_DELETE_MOVE(ParsingTreeNode) + + // In destructor, it will delete all children. + ~ParsingTreeNode(); + + public: + Symbol* GetSymbol() const { return symbol_; } + Production* GetProduction() const { return production_; } + Grammar* GetGrammar() const; + + const std::vector& GetChildren() const { return children_; } + + void AddChild(ParsingTreeNode* child); + void AddChild(ParsingTreeNode* child, Index index); + void RemoveChild(Index index); + + private: + Symbol* symbol_; + Production* production_; + std::vector children_; +}; +} // namespace cru::parse -- cgit v1.2.3