2014-10-30 01:56:49 +00:00
|
|
|
#include "Diagnostic.h"
|
|
|
|
|
|
|
|
Diagnostic::Diagnostic()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
Diagnostic::Diagnostic(Severity sev, std::string msg, yy::location loc)
|
2019-08-18 11:21:00 +00:00
|
|
|
: severity(sev), message(msg), location(loc)
|
2014-10-30 01:56:49 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::ostream &operator<<(std::ostream &out, const Diagnostic &d)
|
|
|
|
{
|
2019-08-18 11:21:00 +00:00
|
|
|
//return out << d.location << ": " << d.message;
|
|
|
|
const yy::location& loc = d.location;
|
|
|
|
if (loc.begin.filename)
|
|
|
|
out << *loc.begin.filename << ':';
|
|
|
|
out << loc.begin.line << ':' << loc.begin.column;
|
|
|
|
out << ": ";
|
|
|
|
if(d.severity >= Diagnostic::error)
|
|
|
|
out << "error";
|
|
|
|
else
|
|
|
|
out << "warning";
|
|
|
|
out << ": " << d.message;
|
|
|
|
return out;
|
2014-10-30 01:56:49 +00:00
|
|
|
}
|