@@ -59,7 +59,20 @@ bool TestGrammar(std::string input)
5959{
6060 auto parser = LuaParser::LoadFromBuffer (std::move (input));
6161 parser->BuildAstWithComment ();
62- return parser->GetErrors ().empty ();
62+ bool result = parser->GetErrors ().empty ();
63+
64+ if (!result)
65+ {
66+ for (auto & error : parser->GetErrors ())
67+ std::cout << format (" error: {}, from [{},{}] to [{},{}]" , error.ErrorMessage ,
68+ parser->GetLine (error.ErrorRange .StartOffset ),
69+ parser->GetColumn (error.ErrorRange .StartOffset ),
70+ parser->GetLine (error.ErrorRange .EndOffset ),
71+ parser->GetColumn (error.ErrorRange .EndOffset )
72+ ) << std::endl;
73+ }
74+
75+ return result;
6376}
6477
6578void CollectLuaFile (std::filesystem::path directoryPath, std::vector<std::string>& paths, std::filesystem::path& root)
@@ -138,10 +151,10 @@ int main(int argc, char* argv[])
138151 bool passed = TestFormatted (waitFormattingText, formattedText, options);
139152
140153 success &= passed;
141- std::cout << format (" test format {} ... {}" , path, passed) << std::endl;
154+ std::cout << format (" test format {} ... {}" , path, passed ? " true " : " false " ) << std::endl;
142155 }
143156 }
144- else if (target == " CheckGrammar" )
157+ else if (target == " CheckGrammar" )
145158 {
146159 for (auto & path : luaFiles)
147160 {
@@ -151,7 +164,7 @@ int main(int argc, char* argv[])
151164 bool passed = TestGrammar (text);
152165
153166 success &= passed;
154- std::cout << format (" test check grammar {} ... {}" , path, passed) << std::endl;
167+ std::cout << format (" test check grammar {} ... {}" , path, passed? " true " : " false " ) << std::endl;
155168 }
156169 }
157170
0 commit comments