diff --git a/spec/compiler/generate_parsers.cpp b/spec/compiler/generate_parsers.cpp index 85d23564..f3fbfa86 100644 --- a/spec/compiler/generate_parsers.cpp +++ b/spec/compiler/generate_parsers.cpp @@ -6,7 +6,7 @@ START_TEST -describe("code_generation", []() { +describe("code generation", []() { string test_parser_dir = src_dir() + "/spec/fixtures/parsers"; it("works for the arithmetic grammar", [&]() { diff --git a/spec/compiler/spec_helper.cpp b/spec/compiler/spec_helper.cpp index 30343ecc..858c9b18 100644 --- a/spec/compiler/spec_helper.cpp +++ b/spec/compiler/spec_helper.cpp @@ -1,37 +1,5 @@ #include "spec_helper.h" -namespace tree_sitter { - namespace lr { - template - std::ostream & stream_map_of_sets(std::ostream &stream, const unordered_map> &map) { - stream << string("{"); - bool started = false; - for (auto pair : map) { - if (started) stream << string(", "); - stream << pair.first; - stream << string(" => ["); - bool started_set = false; - for (TValue action : pair.second) { - if (started_set) stream << ", "; - stream << action; - started_set = true; - } - stream << string("]}"); - started = true; - } - return stream; - } - - std::ostream& operator<<(std::ostream &stream, const unordered_map> &map) { - return stream_map_of_sets(stream, map); - } - - std::ostream& operator<<(std::ostream &stream, const unordered_map> &map) { - return stream_map_of_sets(stream, map); - } - } -} - string src_dir() { return string(getenv("TREESITTER_SRC_DIR")); } \ No newline at end of file diff --git a/spec/compiler/spec_helper.h b/spec/compiler/spec_helper.h index ea244f14..7c59a241 100644 --- a/spec/compiler/spec_helper.h +++ b/spec/compiler/spec_helper.h @@ -18,6 +18,34 @@ using namespace bandit; #define START_TEST go_bandit([]() { #define END_TEST }); +namespace std { + template + inline std::ostream& operator<<(std::ostream &stream, const unordered_set &set) { + stream << string("#"; + } + + template + inline std::ostream& operator<<(std::ostream &stream, const unordered_map &map) { + stream << string("# "); + stream << pair.second; + started = true; + } + return stream << ">"; + } +} + namespace snowhouse { template struct EqualsPointerConstraint : Expression> @@ -37,7 +65,7 @@ namespace snowhouse { { static std::string ToString(const EqualsPointerConstraint& constraint) { std::ostringstream builder; - builder << "equal to pointer " << snowhouse::Stringize(constraint.expected); + builder << "pointer to " << snowhouse::Stringize(constraint.expected); return builder.str(); } }; @@ -46,13 +74,7 @@ namespace snowhouse { inline EqualsPointerConstraint EqualsPointer(const ExpectedType& expected) { return EqualsPointerConstraint(expected); } -} - -namespace tree_sitter { - namespace lr { - std::ostream& operator<<(std::ostream &stream, const unordered_map> &map); - std::ostream& operator<<(std::ostream &stream, const unordered_map> &map); - } + } string src_dir();