--- /dev/null
+// Roast+ License
+/*
+*/
+#ifndef __SFJP_ROAST__lexical__exception_HPP__
+#define __SFJP_ROAST__lexical__exception_HPP__
+
+namespace roast
+{
+ namespace lexical
+ {
+ class lexical_exception : public ::std::string
+ {
+ public:
+ lexical_exception(const char* msg) : ::std::string(msg) {}
+ };
+
+ namespace rule
+ {
+ class lexical_rule_exception : public lexical_exception
+ {
+ public:
+ lexical_rule_exception(const char* msg) : lexical_exception(msg) {}
+ };
+
+ class illegal_terminated : public lexical_exception
+ {
+ public:
+ illegal_terminated() : lexical_exception("illegal terminated.") {}
+ };
+
+ class end_of_iterator_exception : public lexical_exception
+ {
+ public:
+ end_of_iterator_exception(const char* msg="End of iterator") : lexical_exception(msg) {}
+ };
+ typedef end_of_iterator_exception iterator_term_exception, eoi_exception;
+
+ //////////////////////////////////////////////////////////////////////////////
+
+ template <typename T, typename _OnTrueProc>
+ class on_true;
+
+ template <typename T, typename _OnFalseProc>
+ class on_false;
+
+ template <typename _Exception>
+ class _false_ret_to_exception_proc
+ {
+ public:
+ template <typename _It, typename _Param>
+ bool operator ()(_It&, _Param&)
+ {
+ throw _Exception();
+ return true;
+ }
+ };
+
+ template <typename T, typename _Exception = illegal_terminated>
+ class false_ret_to_exception : public on_false< T, _false_ret_to_exception_proc<_Exception> > {};
+
+ ///
+ template <int _EvtCode> class send_normal_event;
+ template <int _EvtCode> class send_error_event;
+
+ class Exception_is_send_normal_event;
+ class Exception_is_send_error_event;
+
+ template <typename T, int _EvtCode>
+ class false_ret_to_exception<T,send_normal_event<_EvtCode> > : public _true_analyze {
+ Exception_is_send_normal_event _; };
+ template <typename T, int _EvtCode>
+ class false_ret_to_exception<T,send_error_event<_EvtCode> > : public _true_analyze{
+ Exception_is_send_normal_event _; };
+
+ //////////
+
+ template <typename T, typename _CatchException>
+ class exception_to_false : public T
+ {
+ public:
+ template <typename _It, typename _Param>
+ bool analyze(_It &it, _Param& param)
+ {
+ try
+ {
+ T t;
+ return t.analyze(it, param);
+ }
+ catch(_CatchException &)
+ {
+ return false;
+ }
+ }
+ };
+
+ template <typename T, typename _CatchException, typename _NewException>
+ class exception_to_exception : public T
+ {
+ public:
+ template <typename _It, typename _Param>
+ bool analyze(_It &it, _Param& param)
+ {
+ try
+ {
+ T t;
+ return t.analyze(it, param);
+ }
+ catch(_CatchException &)
+ {
+ throw _NewException();
+ }
+ }
+ };
+ }
+
+ //////////////////////////////////////////////////
+ }
+}
+
+#endif//__SFJP_ROAST__lexical__exception_HPP__
#include "roast/memory/sized_ptr.hpp"
#include "roast/type_traits/is_derived.hpp" // for length_of
+#include "roast/lexical/exception.hpp"
#include <string>
namespace roast
{
namespace lexical
{
- class lexical_exception : public ::std::string
- {
- public:
- lexical_exception(const char* msg) : ::std::string(msg) {}
- };
-
namespace rule
{
- class lexical_rule_exception : public ::std::string
- {
- public:
- lexical_rule_exception(const char* msg) : ::std::string(msg) {}
- };
-
- class end_of_iterator_exception : public ::std::string
- {
- public:
- end_of_iterator_exception(const char* msg="End of iterator") : ::std::string(msg) {}
- };
- typedef end_of_iterator_exception iterator_term_exception, eoi_exception;
-
//////////////////////////////////////////////////////////////////////////////////
struct lengthable {};
}
};
- //////////
-
- class illegal_terminated : public lexical_exception
- {
- public:
- illegal_terminated() : lexical_exception("illegal terminated.") {}
- };
-
- template <typename _Exception>
- class _false_ret_to_exception_proc
- {
- public:
- template <typename _It, typename _Param>
- bool operator ()(_It&, _Param&)
- {
- throw _Exception();
- return true;
- }
- };
-
- template <typename T, typename _Exception = illegal_terminated>
- class false_ret_to_exception : public on_false< T, _false_ret_to_exception_proc<_Exception> > {};
-
- ///
- template <int _EvtCode> class send_normal_event;
- template <int _EvtCode> class send_error_event;
-
- class Exception_is_send_normal_event;
- class Exception_is_send_error_event;
-
- template <typename T, int _EvtCode>
- class false_ret_to_exception<T,send_normal_event<_EvtCode> > : public _true_analyze {
- Exception_is_send_normal_event _; };
- template <typename T, int _EvtCode>
- class false_ret_to_exception<T,send_error_event<_EvtCode> > : public _true_analyze{
- Exception_is_send_normal_event _; };
-
- //////////
-
- template <typename T, typename _CatchException>
- class exception_to_false : public T
- {
- public:
- template <typename _It, typename _Param>
- bool analyze(_It &it, _Param& param)
- {
- try
- {
- T t;
- return t.analyze(it, param);
- }
- catch(_CatchException &)
- {
- return false;
- }
- }
- };
-
- template <typename T, typename _CatchException, typename _NewException>
- class exception_to_exception : public T
- {
- public:
- template <typename _It, typename _Param>
- bool analyze(_It &it, _Param& param)
- {
- try
- {
- T t;
- return t.analyze(it, param);
- }
- catch(_CatchException &)
- {
- throw _NewException();
- }
- }
- };
-
////////////////////////////////////////////////////////////////
template <int N>