aboutsummaryrefslogtreecommitdiff
path: root/include/cru/parse/ParsingTreeNode.h
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2022-02-08 16:53:51 +0800
committercrupest <crupest@outlook.com>2022-02-08 16:53:51 +0800
commit74bb9cd27242b9320f99ff4d2b50c3051576cc14 (patch)
tree744bac5799c593d1d6f81e7b09581bea626f2cde /include/cru/parse/ParsingTreeNode.h
parentb90c398de829d1ba5329651d75bae82f5e4085fe (diff)
downloadcru-74bb9cd27242b9320f99ff4d2b50c3051576cc14.tar.gz
cru-74bb9cd27242b9320f99ff4d2b50c3051576cc14.tar.bz2
cru-74bb9cd27242b9320f99ff4d2b50c3051576cc14.zip
...
Diffstat (limited to 'include/cru/parse/ParsingTreeNode.h')
-rw-r--r--include/cru/parse/ParsingTreeNode.h33
1 files changed, 33 insertions, 0 deletions
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 <vector>
+
+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<ParsingTreeNode*>& 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<ParsingTreeNode*> children_;
+};
+} // namespace cru::parse