From 967be9e750221ab2ab783f95df79bb26d290a45e Mon Sep 17 00:00:00 2001 From: Martial Simon Date: Mon, 15 Sep 2025 01:07:58 +0200 Subject: add: added projects --- tiger-compiler/src/overload/over-table.hh | 63 +++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 tiger-compiler/src/overload/over-table.hh (limited to 'tiger-compiler/src/overload/over-table.hh') diff --git a/tiger-compiler/src/overload/over-table.hh b/tiger-compiler/src/overload/over-table.hh new file mode 100644 index 0000000..04ddb34 --- /dev/null +++ b/tiger-compiler/src/overload/over-table.hh @@ -0,0 +1,63 @@ +/** + ** \file overload/over-table.hh + ** \brief Checking/translating an OverTiger program in a Tiger program. + */ + +#pragma once + +#include +#include + +namespace overload +{ + template class OverTable + { + public: + using map_type = std::multimap; + using iterator = typename map_type::iterator; + using const_iterator = typename map_type::const_iterator; + using oversymtab_type = std::vector; + using range_type = std::pair; + + /// Create a new over table. + OverTable(); + + /// \name Symbol handling + /// \{ + /// Put \a key in the map and add the value to the associated container. + void put(misc::symbol key, T& value); + + /// Return the range associated to the key. + /// + /// If the key is not found, the beginning and the end of the range are + /// equal. + range_type get(misc::symbol key); + /// \} + + /// \name Scopes. + /// \{ + /// \brief Open a new scope. + /// + /// All further type related declarations will be limited to this scope. + void scope_begin(); + + /// \brief Close the last scope. + /// + /// Forget everything (i.e. every type related informations) since the + /// latest scope_begin(). + void scope_end(); + /// \} + + /// Print the table + std::ostream& dump(std::ostream& ostr) const; + + protected: + oversymtab_type oversymtab_; + }; + + template + std::ostream& operator<<(std::ostream& ostr, const OverTable& tbl); + +} // namespace overload + +#include -- cgit v1.2.3