workaround for incorrect argument order for PositionCell instruction

deque
Marc Zinnschlag 11 years ago
parent af54bb9623
commit 6a745c014f

@ -3,11 +3,8 @@
namespace Compiler
{
// constructor
ErrorHandler::ErrorHandler() : mWarnings (0), mErrors (0), mWarningsMode (1) {}
// destructor
ErrorHandler::ErrorHandler()
: mWarnings (0), mErrors (0), mWarningsMode (1), mDowngradeErrors (false) {}
ErrorHandler::~ErrorHandler() {}
@ -49,6 +46,12 @@ namespace Compiler
void ErrorHandler::error (const std::string& message, const TokenLoc& loc)
{
if (mDowngradeErrors)
{
warning (message, loc);
return;
}
++mErrors;
report (message, loc, ErrorMessage);
}
@ -72,4 +75,21 @@ namespace Compiler
{
mWarningsMode = mode;
}
void ErrorHandler::downgradeErrors (bool downgrade)
{
mDowngradeErrors = downgrade;
}
ErrorDowngrade::ErrorDowngrade (ErrorHandler& handler) : mHandler (handler)
{
mHandler.downgradeErrors (true);
}
ErrorDowngrade::~ErrorDowngrade()
{
mHandler.downgradeErrors (false);
}
}

@ -17,6 +17,7 @@ namespace Compiler
int mWarnings;
int mErrors;
int mWarningsMode;
bool mDowngradeErrors;
protected:
@ -66,6 +67,26 @@ namespace Compiler
void setWarningsMode (int mode);
///< // 0 ignore, 1 rate as warning, 2 rate as error
/// Treat errors as warnings.
void downgradeErrors (bool downgrade);
};
class ErrorDowngrade
{
ErrorHandler& mHandler;
/// not implemented
ErrorDowngrade (const ErrorDowngrade&);
/// not implemented
ErrorDowngrade& operator= (const ErrorDowngrade&);
public:
ErrorDowngrade (ErrorHandler& handler);
~ErrorDowngrade();
};
}

@ -11,6 +11,7 @@
#include "generator.hpp"
#include "extensions.hpp"
#include "declarationparser.hpp"
#include "exception.hpp"
namespace Compiler
{
@ -292,9 +293,31 @@ namespace Compiler
mExplicit.clear();
}
int optionals = mExprParser.parseArguments (argumentType, scanner, mCode);
int optionals = 0;
try
{
ErrorDowngrade errorDowngrade (getErrorHandler());
std::vector<Interpreter::Type_Code> code;
optionals = mExprParser.parseArguments (argumentType, scanner, code);
mCode.insert (mCode.begin(), code.begin(), code.end());
extensions->generateInstructionCode (keyword, mCode, mLiterals,
mExplicit, optionals);
}
catch (const SourceException& exception)
{
// Ignore argument exceptions for positioncell.
/// \todo add option to disable this
if (Misc::StringUtils::lowerCase (loc.mLiteral)=="positioncell")
{
SkipParser skip (getErrorHandler(), getContext());
scanner.scan (skip);
return false;
}
throw;
}
extensions->generateInstructionCode (keyword, mCode, mLiterals, mExplicit, optionals);
mState = EndState;
return true;
}

Loading…
Cancel
Save