mirror of
https://codeberg.org/ProgramSnail/lang.git
synced 2025-12-12 09:58:44 +00:00
name tree mostly finished
This commit is contained in:
parent
263b58a17c
commit
fc114ff959
14 changed files with 116 additions and 38 deletions
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue