From 57371dde68ee6e04e124ff085b8eced7faff3bae Mon Sep 17 00:00:00 2001 From: Myun2 Date: Sun, 9 Jan 2011 04:19:59 +0900 Subject: [PATCH] =?utf8?q?lexical/iterator=5Futil.hpp=20=E3=81=B8=E3=81=AE?= =?utf8?q?=E5=88=86=E9=9B=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- roast/include/roast/lexical/iterator_util.hpp | 100 ++++++++++++++++++++++++++ roast/include/roast/lexical/lexical.hpp | 1 + roast/include/roast/lexical/rule.hpp | 80 --------------------- 3 files changed, 101 insertions(+), 80 deletions(-) create mode 100644 roast/include/roast/lexical/iterator_util.hpp diff --git a/roast/include/roast/lexical/iterator_util.hpp b/roast/include/roast/lexical/iterator_util.hpp new file mode 100644 index 00000000..910feb3f --- /dev/null +++ b/roast/include/roast/lexical/iterator_util.hpp @@ -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 + class work_iterator : public lengthable + { + public: + static const int length = 0; + + template + bool analyze(_It it, _Param& param) + { + T t; + return t.analyze(it, param); + } + template + bool generate(const _It&, const _Param&) + { + return true; + } + }; + + //////////////////////////////////////////////////////////////// + + template + class iterator_move : public lengthable + { + public: + static const int length = N; + + template + bool analyze(_It &it, _Param&) + { + it += N; + return true; + } + template + bool generate(const _It&, const _Param&) + { + return true; + } + }; + + template + class iteratort_move_front : public lengthable + { + public: + static const int length = N; + + template + bool analyze(_It &it, _Param&) + { + it += N; + return true; + } + template + bool generate(const _It&, const _Param&) + { + return true; + } + }; + template + class skip : public iteratort_move_front {}; + + template + class iteratort_move_back : public lengthable + { + public: + static const int length = -N; + + template + bool analyze(_It &it, _Param&) + { + it -= N; + return true; + } + template + bool generate(const _It&, const _Param&) + { + return true; + } + }; + + //////////////////////////////////////////////////////////////// + } + } +} + +#endif//__SFJP_ROAST__lexical__iterator_util_HPP__ diff --git a/roast/include/roast/lexical/lexical.hpp b/roast/include/roast/lexical/lexical.hpp index 5b229969..649b6ccf 100644 --- a/roast/include/roast/lexical/lexical.hpp +++ b/roast/include/roast/lexical/lexical.hpp @@ -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" diff --git a/roast/include/roast/lexical/rule.hpp b/roast/include/roast/lexical/rule.hpp index 04fd0556..e4f43619 100644 --- a/roast/include/roast/lexical/rule.hpp +++ b/roast/include/roast/lexical/rule.hpp @@ -75,25 +75,6 @@ namespace roast // Alias : test -> check template class check : public test {}; - template - class work_iterator : public lengthable - { - public: - static const int length = 0; - - template - bool analyze(_It it, _Param& param) - { - T t; - return t.analyze(it, param); - } - template - bool generate(const _It&, const _Param&) - { - return true; - } - }; - ///////////////////////////////////////////////////////////// template @@ -133,67 +114,6 @@ namespace roast } } }; - - //////////////////////////////////////////////////////////////// - - template - class iterator_move : public lengthable - { - public: - static const int length = N; - - template - bool analyze(_It &it, _Param&) - { - it += N; - return true; - } - template - bool generate(const _It&, const _Param&) - { - return true; - } - }; - - template - class iteratort_move_front : public lengthable - { - public: - static const int length = N; - - template - bool analyze(_It &it, _Param&) - { - it += N; - return true; - } - template - bool generate(const _It&, const _Param&) - { - return true; - } - }; - template - class skip : public iteratort_move_front {}; - - template - class iteratort_move_back : public lengthable - { - public: - static const int length = -N; - - template - bool analyze(_It &it, _Param&) - { - it -= N; - return true; - } - template - bool generate(const _It&, const _Param&) - { - return true; - } - }; //////////////////////////////////////////////////////////////// -- 2.11.0