OSDN Git Service

lexical/exception.hpp への分離
authorMyun2 <myun2@nwhite.info>
Sat, 8 Jan 2011 19:07:40 +0000 (04:07 +0900)
committerMyun2 <myun2@nwhite.info>
Sat, 8 Jan 2011 19:07:40 +0000 (04:07 +0900)
roast/include/roast/lexical/exception.hpp [new file with mode: 0644]
roast/include/roast/lexical/rule.hpp

diff --git a/roast/include/roast/lexical/exception.hpp b/roast/include/roast/lexical/exception.hpp
new file mode 100644 (file)
index 0000000..a61c740
--- /dev/null
@@ -0,0 +1,120 @@
+//     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__
index 7f69e8a..3d7d002 100644 (file)
@@ -8,33 +8,15 @@
 
 #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 {};
@@ -241,83 +223,6 @@ namespace roast
                                }
                        };
 
-                       //////////
-
-                       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>