Skip to content

Commit

Permalink
fix: add a lookup function to symbol table
Browse files Browse the repository at this point in the history
  • Loading branch information
sillydan1 committed Dec 9, 2022
1 parent b1bf12a commit 797cdee
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/symbol_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ namespace expr {
struct symbol_table_t : public underlying_symbol_table_t {
auto operator+=(const symbol_table_t &) -> symbol_table_t&;
auto operator*=(const symbol_table_t &) -> symbol_table_t&;
auto get(const std::string& key) const -> const symbol_value_t&;
auto get(const std::string& key) -> symbol_value_t&;
auto put(const symbol_table_t &) -> symbol_table_t&;
auto overwrite_elements(const symbol_table_t &) -> symbol_table_t&;
auto is_overlapping(const symbol_table_t& other) -> bool;
Expand Down
8 changes: 8 additions & 0 deletions src/symbol_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ namespace expr {
return put(other);
}

auto symbol_table_t::get(const std::string& key) -> symbol_value_t& {
return this->operator[](key);
}

auto symbol_table_t::get(const std::string& key) const -> const symbol_value_t& {
return this->at(key);
}

auto symbol_table_t::put(const symbol_table_t &other) -> symbol_table_t & {
for (auto &e: other)
this->insert_or_assign(e.first, e.second);
Expand Down

0 comments on commit 797cdee

Please sign in to comment.