Commit d6eb96ba authored by Francis Dupont's avatar Francis Dupont
Browse files

[master] Merged trac4203 (no exit())

parents aed3cf4a 3d663ac3
...@@ -50,3 +50,9 @@ EvalContext::error (const std::string& what) ...@@ -50,3 +50,9 @@ EvalContext::error (const std::string& what)
{ {
isc_throw(EvalParseError, what); isc_throw(EvalParseError, what);
} }
void
EvalContext::fatal (const std::string& what)
{
isc_throw(Unexpected, what);
}
...@@ -81,6 +81,11 @@ public: ...@@ -81,6 +81,11 @@ public:
/// cases when the EvalParser is not able to handle the packet. /// cases when the EvalParser is not able to handle the packet.
void error(const std::string& what); void error(const std::string& what);
/// @brief Fatal error handler
///
/// This is for should not happen but fatal errors
static void fatal(const std::string& what);
private: private:
/// @brief Flag determining scanner debugging. /// @brief Flag determining scanner debugging.
bool trace_scanning_; bool trace_scanning_;
......
...@@ -31,6 +31,9 @@ ...@@ -31,6 +31,9 @@
// The location of the current token. The lexer will keep updating it. This // The location of the current token. The lexer will keep updating it. This
// variable will be useful for logging errors. // variable will be useful for logging errors.
static isc::eval::location loc; static isc::eval::location loc;
// To avoid the call to exit... oops!
#define YY_FATAL_ERROR(msg) isc::eval::EvalContext::fatal(msg)
%} %}
/* noyywrap disables automatic rewinding for the next file to parse. Since we /* noyywrap disables automatic rewinding for the next file to parse. Since we
...@@ -147,8 +150,8 @@ EvalContext::scanStringBegin() ...@@ -147,8 +150,8 @@ EvalContext::scanStringBegin()
YY_BUFFER_STATE buffer; YY_BUFFER_STATE buffer;
buffer = yy_scan_bytes(string_.c_str(), string_.size()); buffer = yy_scan_bytes(string_.c_str(), string_.size());
if (!buffer) { if (!buffer) {
error("cannot scan string"); fatal("cannot scan string");
exit(EXIT_FAILURE); // fatal() throws an exception so this can't be reached
} }
} }
...@@ -157,3 +160,10 @@ EvalContext::scanStringEnd() ...@@ -157,3 +160,10 @@ EvalContext::scanStringEnd()
{ {
yy_delete_buffer(YY_CURRENT_BUFFER); yy_delete_buffer(YY_CURRENT_BUFFER);
} }
namespace {
/// To avoid unused function error
class Dummy {
void dummy() { yy_fatal_error("Fix me: how to disable its definition?"); }
};
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment