From 47af010ba5b8f1e2147247eb00c0af8f5564b859 Mon Sep 17 00:00:00 2001 From: Kelvin Sherlock Date: Wed, 27 Jul 2016 14:04:57 -0400 Subject: [PATCH] mpw errors --- error.h | 30 ++++++++++++++++++++++++++++-- mpw-shell-token.rl | 9 +++------ 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/error.h b/error.h index 712b204..325bc13 100644 --- a/error.h +++ b/error.h @@ -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 \ No newline at end of file diff --git a/mpw-shell-token.rl b/mpw-shell-token.rl index 6919991..fc34a57 100644 --- a/mpw-shell-token.rl +++ b/mpw-shell-token.rl @@ -3,6 +3,7 @@ #include #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(); } ;