OSDN Git Service

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

diff --git a/roast/include/roast/lexical/iterator_util.hpp b/roast/include/roast/lexical/iterator_util.hpp
new file mode 100644 (file)
index 0000000..910feb3
--- /dev/null
@@ -0,0 +1,100 @@
+//     Roast+ License
+/*
+*/
+#ifndef __SFJP_ROAST__lexical__iterator_util_HPP__
+#define __SFJP_ROAST__lexical__iterator_util_HPP__
+
+namespace roast
+{
+       namespace lexical
+       {
+               namespace rule
+               {
+                       ////////////////////////////////////////////////////////////////
+
+                       template <typename T>
+                       class work_iterator : public lengthable
+                       {
+                       public:
+                               static const int length = 0;
+
+                               template <typename _It, typename _Param>
+                               bool analyze(_It it, _Param& param)
+                               {
+                                       T t;
+                                       return t.analyze(it, param);
+                               }
+                               template <typename _It, typename _Param>
+                               bool generate(const _It&, const _Param&)
+                               {
+                                       return true;
+                               }
+                       };
+
+                       ////////////////////////////////////////////////////////////////
+
+                       template <int N>
+                       class iterator_move : public lengthable
+                       {
+                       public:
+                               static const int length = N;
+
+                               template <typename _It, typename _Param>
+                               bool analyze(_It &it, _Param&)
+                               {
+                                       it += N;
+                                       return true;
+                               }
+                               template <typename _It, typename _Param>
+                               bool generate(const _It&, const _Param&)
+                               {
+                                       return true;
+                               }
+                       };
+
+                       template <unsigned int N>
+                       class iteratort_move_front : public lengthable
+                       {
+                       public:
+                               static const int length = N;
+
+                               template <typename _It, typename _Param>
+                               bool analyze(_It &it, _Param&)
+                               {
+                                       it += N;
+                                       return true;
+                               }
+                               template <typename _It, typename _Param>
+                               bool generate(const _It&, const _Param&)
+                               {
+                                       return true;
+                               }
+                       };
+                       template <unsigned int N=1>
+                       class skip : public iteratort_move_front<N> {};
+
+                       template <unsigned int N>
+                       class iteratort_move_back : public lengthable
+                       {
+                       public:
+                               static const int length = -N;
+
+                               template <typename _It, typename _Param>
+                               bool analyze(_It &it, _Param&)
+                               {
+                                       it -= N;
+                                       return true;
+                               }
+                               template <typename _It, typename _Param>
+                               bool generate(const _It&, const _Param&)
+                               {
+                                       return true;
+                               }
+                       };
+                       
+                       ////////////////////////////////////////////////////////////////
+               }
+       }
+}
+
+#endif//__SFJP_ROAST__lexical__iterator_util_HPP__
index 5b22996..649b6cc 100644 (file)
@@ -6,6 +6,7 @@
 
 #include "roast/lexical/rule.hpp"
 #include "roast/lexical/repeat.hpp"
+#include "roast/lexical/iterator_util.hpp"
 #include "roast/lexical/rule_numeric.hpp"
 #include "roast/lexical/string_rule.hpp"
 #include "roast/lexical/debug_util.hpp"
index 04fd055..e4f4361 100644 (file)
@@ -75,25 +75,6 @@ namespace roast
                        //      Alias : test -> check
                        template <typename T> class check : public test<T> {};
 
-                       template <typename T>
-                       class work_iterator : public lengthable
-                       {
-                       public:
-                               static const int length = 0;
-
-                               template <typename _It, typename _Param>
-                               bool analyze(_It it, _Param& param)
-                               {
-                                       T t;
-                                       return t.analyze(it, param);
-                               }
-                               template <typename _It, typename _Param>
-                               bool generate(const _It&, const _Param&)
-                               {
-                                       return true;
-                               }
-                       };
-
                        /////////////////////////////////////////////////////////////
 
                        template <typename T, typename _OnTrueProc>
@@ -133,67 +114,6 @@ namespace roast
                                        }
                                }
                        };
-
-                       ////////////////////////////////////////////////////////////////
-
-                       template <int N>
-                       class iterator_move : public lengthable
-                       {
-                       public:
-                               static const int length = N;
-
-                               template <typename _It, typename _Param>
-                               bool analyze(_It &it, _Param&)
-                               {
-                                       it += N;
-                                       return true;
-                               }
-                               template <typename _It, typename _Param>
-                               bool generate(const _It&, const _Param&)
-                               {
-                                       return true;
-                               }
-                       };
-
-                       template <unsigned int N>
-                       class iteratort_move_front : public lengthable
-                       {
-                       public:
-                               static const int length = N;
-
-                               template <typename _It, typename _Param>
-                               bool analyze(_It &it, _Param&)
-                               {
-                                       it += N;
-                                       return true;
-                               }
-                               template <typename _It, typename _Param>
-                               bool generate(const _It&, const _Param&)
-                               {
-                                       return true;
-                               }
-                       };
-                       template <unsigned int N=1>
-                       class skip : public iteratort_move_front<N> {};
-
-                       template <unsigned int N>
-                       class iteratort_move_back : public lengthable
-                       {
-                       public:
-                               static const int length = -N;
-
-                               template <typename _It, typename _Param>
-                               bool analyze(_It &it, _Param&)
-                               {
-                                       it -= N;
-                                       return true;
-                               }
-                               template <typename _It, typename _Param>
-                               bool generate(const _It&, const _Param&)
-                               {
-                                       return true;
-                               }
-                       };
                        
                        ////////////////////////////////////////////////////////////////