Refactor error reporting

This commit introduces ErrorReporter, a utility class which consolidates
all of the error logging functionality into a common set of functions.
It also replaces all direct interactions with an ErrorList with calls to
an ErrorReporter.

This commit resolves issue #2209
This commit is contained in:
Rhett Aultman
2017-05-30 07:28:31 -07:00
parent 0066a08aa8
commit 89b60ffbd4
47 changed files with 770 additions and 707 deletions
+5 -4
View File
@@ -45,16 +45,16 @@ namespace test
namespace
{
bool parse(string const& _source, ErrorList& errors)
bool parse(string const& _source, ErrorReporter& errorReporter)
{
try
{
auto scanner = make_shared<Scanner>(CharStream(_source));
auto parserResult = assembly::Parser(errors, true).parse(scanner);
auto parserResult = assembly::Parser(errorReporter, true).parse(scanner);
if (parserResult)
{
assembly::AsmAnalysisInfo analysisInfo;
return (assembly::AsmAnalyzer(analysisInfo, errors, true)).analyze(*parserResult);
return (assembly::AsmAnalyzer(analysisInfo, errorReporter, true)).analyze(*parserResult);
}
}
catch (FatalError const&)
@@ -67,7 +67,8 @@ bool parse(string const& _source, ErrorList& errors)
boost::optional<Error> parseAndReturnFirstError(string const& _source, bool _allowWarnings = true)
{
ErrorList errors;
if (!parse(_source, errors))
ErrorReporter errorReporter(errors);
if (!parse(_source, errorReporter))
{
BOOST_REQUIRE_EQUAL(errors.size(), 1);
return *errors.front();