name tree mostly finished

This commit is contained in:
ProgramSnail 2023-07-28 19:42:09 +03:00
parent 263b58a17c
commit fc114ff959
14 changed files with 116 additions and 38 deletions

View file

@ -17,6 +17,20 @@ bool NameTree::insert(const std::string &path, nodes::Statement &&statement) {
return true;
}
bool NameTree::insert(const std::string &path,
const nodes::Statement &statement) {
auto name_ids = slice_path_to_name_ids(path);
size_t node_id = add_node(get_root(), name_ids);
if (nodes_[node_id].get_statement().has_value()) {
return false;
}
nodes_[node_id].set_statement(statement);
return true;
}
std::optional<nodes::Statement *> NameTree::find(const std::string &path) {
auto name_ids = slice_path_to_existing_name_ids(path);