From: Myun2 Date: Sat, 8 Jan 2011 19:19:59 +0000 (+0900) Subject: lexical/iterator_util.hpp への分離 X-Git-Tag: 20111130_shapeup_prev^2~63 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=57371dde68ee6e04e124ff085b8eced7faff3bae;p=roast%2Froast.git 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; - } - }; ////////////////////////////////////////////////////////////////