blob: 23bbf8037a1a468543e1a00474778e2f47bd1b13 (
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
|
#include "cru/parse/ParsingTreeNode.hpp"
namespace cru::parse {
ParsingTreeNode::ParsingTreeNode(Symbol* symbol, Production* production)
: symbol_(symbol), production_(production) {}
ParsingTreeNode::~ParsingTreeNode() {
for (auto child : children_) {
delete child;
}
}
Grammar* ParsingTreeNode::GetGrammar() const { return symbol_->GetGrammar(); }
void ParsingTreeNode::AddChild(ParsingTreeNode* child) {
children_.push_back(child);
}
void ParsingTreeNode::AddChild(ParsingTreeNode* child, Index index) {
children_.insert(children_.begin() + index, child);
}
void ParsingTreeNode::RemoveChild(Index index) {
delete children_[index];
children_.erase(children_.begin() + index);
}
} // namespace cru::parse
|