/** ** \file parse/tweast.hh ** \brief Declaration of parse::Tweast. */ #pragma once #include #include #include #include #include #include #include namespace parse { /// \brief TWEAST stands for ``Text With Embedded Abstract Syntax Trees''. /// /// Aggregate string to parse and tables of metavariables. class Tweast : public MetavarMap , public MetavarMap , public MetavarMap , public MetavarMap , public MetavarMap { public: Tweast(); Tweast(const std::string& str); /// \brief Stream manipulator. /// /// Append Tiger expressions to the string to parse. template Tweast& operator<<(const T& t); /// Metavariables manipulator. template T* take(unsigned s); /// Move the contents of all aggregated Tweast metavariables into /// the current Tweast. void flatten(); /// Get the current input string. std::string input_get() const; /// Print the table std::ostream& dump(std::ostream& ostr) const; protected: // Insert base class members in the current scope. using MetavarMap::append_; using MetavarMap::append_; using MetavarMap::append_; using MetavarMap::append_; using MetavarMap::append_; /// Fake append (default case, i.e. when \a data is not a metavariable). template T& append_(unsigned&, T& data) const; template void move_metavars_(Tweast& tweast, std::string& input); protected: /// The next identifier suffix to create. static unsigned count_; /// The string to parse. std::stringstream input_; }; /// Display the content of the tweast. std::ostream& operator<<(std::ostream& ostr, const Tweast& in); } // namespace parse #include