#ifndef tree_sitter_stream_methods_h #define tree_sitter_stream_methods_h #include #include #include #include #include #include #include "compiler/prepared_grammar.h" using std::cout; namespace std { template inline std::ostream& operator<<(std::ostream &stream, const std::vector &vector) { stream << std::string("(vector: "); bool started = false; for (auto item : vector) { if (started) stream << std::string(", "); stream << item; started = true; } return stream << ")"; } template inline std::ostream& operator<<(std::ostream &stream, const std::set &set) { stream << std::string("(set: "); bool started = false; for (auto item : set) { if (started) stream << std::string(", "); stream << item; started = true; } return stream << ")"; } template inline std::ostream& operator<<(std::ostream &stream, const std::unordered_set &set) { stream << std::string("(set: "); bool started = false; for (auto item : set) { if (started) stream << std::string(", "); stream << item; started = true; } return stream << ")"; } template inline std::ostream& operator<<(std::ostream &stream, const std::map &map) { stream << std::string("(map: "); bool started = false; for (auto pair : map) { if (started) stream << std::string(", "); stream << pair.first; stream << std::string(" => "); stream << pair.second; started = true; } return stream << ")"; } template inline std::ostream& operator<<(std::ostream &stream, const std::unordered_map &map) { stream << std::string("(map: "); bool started = false; for (auto pair : map) { if (started) stream << std::string(", "); stream << pair.first; stream << std::string(" => "); stream << pair.second; started = true; } return stream << ")"; } template inline std::ostream& operator<<(std::ostream &stream, const std::pair &pair) { return stream << "{" << pair.first << ", " << pair.second << "}"; } } // namespace std namespace tree_sitter { using std::ostream; using std::string; using std::to_string; inline ostream &operator<<(ostream &stream, const RuleEntry &entry) { return stream << string("{") << entry.name << string(", ") << entry.rule << string(", ") << to_string(entry.type) << string("}"); } } #endif