Merge pull request #2752 from Assumeru/parsing-errors

Reset errorhandler context
pull/578/head
Bret Curtis 5 years ago committed by GitHub
commit 328c3617b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -171,7 +171,7 @@ namespace MWScript
{
Compiler::Locals locals;
mErrorHandler.setContext(name2 + "[local variables]");
const Compiler::ContextOverride override(mErrorHandler, name2 + "[local variables]");
std::istringstream stream (script->mScriptText);
Compiler::QuickFileParser parser (mErrorHandler, mCompilerContext, locals);

@ -62,4 +62,14 @@ namespace Compiler
}
StreamErrorHandler::StreamErrorHandler() {}
ContextOverride::ContextOverride(StreamErrorHandler& handler, const std::string& context) : mHandler(handler), mContext(handler.mContext)
{
mHandler.setContext(context);
}
ContextOverride::~ContextOverride()
{
mHandler.setContext(mContext);
}
}

@ -7,12 +7,14 @@
namespace Compiler
{
class ContextOverride;
/// \brief Error handler implementation: Write errors into logging stream
class StreamErrorHandler : public ErrorHandler
{
std::string mContext;
friend class ContextOverride;
// not implemented
StreamErrorHandler (const StreamErrorHandler&);
@ -33,6 +35,19 @@ namespace Compiler
StreamErrorHandler ();
///< constructor
};
class ContextOverride
{
StreamErrorHandler& mHandler;
const std::string mContext;
public:
ContextOverride (StreamErrorHandler& handler, const std::string& context);
ContextOverride (const ContextOverride&) = delete;
ContextOverride& operator= (const ContextOverride&) = delete;
~ContextOverride();
};
}
#endif

Loading…
Cancel
Save