mpw errors

This commit is contained in:
Kelvin Sherlock 2016-07-27 14:04:57 -04:00
parent 1a98acb756
commit 47af010ba5
2 changed files with 31 additions and 8 deletions

30
error.h
View File

@ -14,13 +14,13 @@ public:
constexpr int status() const noexcept { return _status; } constexpr int status() const noexcept { return _status; }
private: private:
int _status; int _status;
}; };
class execution_of_input_terminated : public mpw_error { class execution_of_input_terminated : public mpw_error {
public: public:
execution_of_input_terminated(int status = -9) : execution_of_input_terminated(int status = -9) :
mpw_error(status, "MPW Shell - Execution of input Terminated.") mpw_error(status, "MPW Shell - Execution of input Terminated.")
{} {}
}; };
@ -39,6 +39,32 @@ public:
{} {}
}; };
class estring_error: public mpw_error {
public:
estring_error(int status = -3) :
mpw_error(status, "MPW Shell - `s must occur in pairs.")
{}
};
class vstring_error: public mpw_error {
public:
vstring_error(int status = -3) :
mpw_error(status, "MPW Shell - {s must occur in pairs.")
{}
};
class sstring_error: public mpw_error {
public:
sstring_error(int status = -3) :
mpw_error(status, "MPW Shell - 's must occur in pairs.")
{}
};
class dstring_error: public mpw_error {
public:
dstring_error(int status = -3) :
mpw_error(status, "MPW Shell - \"s must occur in pairs.")
{}
};
#endif #endif

View File

@ -3,6 +3,7 @@
#include <stdio.h> #include <stdio.h>
#include "mpw-shell.h" #include "mpw-shell.h"
#include "error.h"
%%{ %%{
machine tokenizer; machine tokenizer;
@ -29,9 +30,7 @@
sstring = sstring =
['] schar** ['] ['] schar** [']
${ quoted = true; } ${ quoted = true; }
$err{ $err{ throw sstring_error(); }
throw std::runtime_error("### MPW Shell - 's must occur in pairs.");
}
; ;
escape_seq = escape_seq =
@ -49,9 +48,7 @@
dstring = dstring =
["] dchar** ["] ["] dchar** ["]
${ quoted = true; } ${ quoted = true; }
$err{ $err{ throw dstring_error(); }
throw std::runtime_error("### MPW Shell - \"s must occur in pairs.");
}
; ;