|
|
|
@ -1,5 +1,9 @@
|
|
|
|
|
#include "streamerrorhandler.hpp"
|
|
|
|
|
|
|
|
|
|
#include <sstream>
|
|
|
|
|
|
|
|
|
|
#include <components/debug/debuglog.hpp>
|
|
|
|
|
|
|
|
|
|
#include "tokenloc.hpp"
|
|
|
|
|
|
|
|
|
|
namespace Compiler
|
|
|
|
@ -9,32 +13,47 @@ namespace Compiler
|
|
|
|
|
void StreamErrorHandler::report (const std::string& message, const TokenLoc& loc,
|
|
|
|
|
Type type)
|
|
|
|
|
{
|
|
|
|
|
Debug::Level logLevel = Debug::Info; // Usually script warnings are not too important
|
|
|
|
|
if (type == ErrorMessage)
|
|
|
|
|
logLevel = Debug::Error;
|
|
|
|
|
|
|
|
|
|
std::stringstream text;
|
|
|
|
|
|
|
|
|
|
if (type==ErrorMessage)
|
|
|
|
|
mStream << "error ";
|
|
|
|
|
text << "Error: ";
|
|
|
|
|
else
|
|
|
|
|
mStream << "warning ";
|
|
|
|
|
text << "Warning: ";
|
|
|
|
|
|
|
|
|
|
if (!mContext.empty())
|
|
|
|
|
mStream << mContext << " ";
|
|
|
|
|
text << mContext << " ";
|
|
|
|
|
|
|
|
|
|
text << "line " << loc.mLine+1 << ", column " << loc.mColumn+1
|
|
|
|
|
<< " (" << loc.mLiteral << "): " << message;
|
|
|
|
|
|
|
|
|
|
mStream
|
|
|
|
|
<< "line " << loc.mLine+1 << ", column " << loc.mColumn+1
|
|
|
|
|
<< " (" << loc.mLiteral << ")" << std::endl
|
|
|
|
|
<< " " << message << std::endl;
|
|
|
|
|
Log(logLevel) << text.str();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Report a file related error
|
|
|
|
|
|
|
|
|
|
void StreamErrorHandler::report (const std::string& message, Type type)
|
|
|
|
|
{
|
|
|
|
|
Debug::Level logLevel = Debug::Info;
|
|
|
|
|
if (type==ErrorMessage)
|
|
|
|
|
mStream << "error ";
|
|
|
|
|
logLevel = Debug::Error;
|
|
|
|
|
|
|
|
|
|
std::stringstream text;
|
|
|
|
|
|
|
|
|
|
if (type==ErrorMessage)
|
|
|
|
|
text << "Error: ";
|
|
|
|
|
else
|
|
|
|
|
mStream << "warning ";
|
|
|
|
|
text << "Warning: ";
|
|
|
|
|
|
|
|
|
|
if (!mContext.empty())
|
|
|
|
|
text << mContext << " ";
|
|
|
|
|
|
|
|
|
|
text << "file: " << message << std::endl;
|
|
|
|
|
|
|
|
|
|
mStream
|
|
|
|
|
<< "file:" << std::endl
|
|
|
|
|
<< " " << message << std::endl;
|
|
|
|
|
Log(logLevel) << text.str();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void StreamErrorHandler::setContext(const std::string &context)
|
|
|
|
@ -42,5 +61,5 @@ namespace Compiler
|
|
|
|
|
mContext = context;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StreamErrorHandler::StreamErrorHandler (std::ostream& ErrorStream) : mStream (ErrorStream) {}
|
|
|
|
|
StreamErrorHandler::StreamErrorHandler() {}
|
|
|
|
|
}
|
|
|
|
|