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; }
private:
int _status;
int _status;
};
class execution_of_input_terminated : public mpw_error {
public:
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

View File

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