/** ** \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