added warning mode to script compiler error handler

pull/22/head
Marc Zinnschlag 11 years ago
parent 1deb0a7cdf
commit 8bcdf54570

@ -5,7 +5,7 @@ namespace Compiler
{
// constructor
ErrorHandler::ErrorHandler() : mWarnings (0), mErrors (0) {}
ErrorHandler::ErrorHandler() : mWarnings (0), mErrors (0), mWarningsMode (1) {}
// destructor
@ -36,8 +36,13 @@ namespace Compiler
void ErrorHandler::warning (const std::string& message, const TokenLoc& loc)
{
++mWarnings;
report (message, loc, WarningMessage);
if (mWarningsMode==1)
{
++mWarnings;
report (message, loc, WarningMessage);
}
else if (mWarningsMode==2)
error (message, loc);
}
// Generate an error message.
@ -62,4 +67,9 @@ namespace Compiler
{
mErrors = mWarnings = 0;
}
void ErrorHandler::setWarningsMode (int mode)
{
mWarningsMode = mode;
}
}

@ -16,6 +16,7 @@ namespace Compiler
{
int mWarnings;
int mErrors;
int mWarningsMode;
protected:
@ -60,8 +61,11 @@ namespace Compiler
void endOfFile();
///< Generate an error message for an unexpected EOF.
virtual void reset();
virtual void reset();
///< Remove all previous error/warning events
void setWarningsMode (int mode);
///< // 0 ignore, 1 rate as warning, 2 rate as error
};
}

Loading…
Cancel
Save