--- /dev/null
+// 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__
#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"
// 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>
}
}
};
-
- ////////////////////////////////////////////////////////////////
-
- 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;
- }
- };
////////////////////////////////////////////////////////////////