From 74bb9cd27242b9320f99ff4d2b50c3051576cc14 Mon Sep 17 00:00:00 2001 From: crupest Date: Tue, 8 Feb 2022 16:53:51 +0800 Subject: ... --- include/cru/parse/ParsingTreeNode.h | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 include/cru/parse/ParsingTreeNode.h (limited to 'include/cru/parse/ParsingTreeNode.h') diff --git a/include/cru/parse/ParsingTreeNode.h b/include/cru/parse/ParsingTreeNode.h new file mode 100644 index 00000000..05b1006c --- /dev/null +++ b/include/cru/parse/ParsingTreeNode.h @@ -0,0 +1,33 @@ +#pragma once +#include "Grammar.h" + +#include + +namespace cru::parse { +class CRU_PARSE_API 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