aboutsummaryrefslogtreecommitdiff
path: root/include/cru/parse/ParsingTreeNode.hpp
blob: d1c3d058cf9561c933586919eba02d6fc015541b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#pragma once
#include "Grammar.hpp"

#include <vector>

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<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