OSDN Git Service

lexical: rule_numeric.hpp への分離
authorMyun2 <myun2@nwhite.info>
Thu, 23 Dec 2010 15:55:40 +0000 (00:55 +0900)
committerMyun2 <myun2@nwhite.info>
Thu, 23 Dec 2010 15:56:49 +0000 (00:56 +0900)
roast/include/roast/lexical/lexical.hpp
roast/include/roast/lexical/rule.hpp
roast/include/roast/lexical/rule_numeric.hpp [new file with mode: 0644]

index 6371c4f..ad5c26c 100644 (file)
@@ -5,6 +5,7 @@
 #define __SFJP_ROAST__lexical__lexical_HPP__
 
 #include "roast/lexical/rule.hpp"
+#include "roast/lexical/rule_numeric.hpp"
 #include "roast/lexical/string_rule.hpp"
 #include "roast/lexical/generator_base.hpp"
 #include "roast/lexical/parser_base.hpp"
index 4b3db75..a4351c4 100644 (file)
@@ -973,140 +973,9 @@ namespace roast
                        
                        template <int N>
                        class marker : public lex_num_marker<N> {};
-
-                       ////////////////////////////////////////////////////////////
-
-                       template <typename T, T _Min, T _Max>
-                       class range : public lengthable
-                       {
-                       public:
-                               static const int length = sizeof(T);
-
-                               template <typename _It, typename _Param>
-                               bool analyze(_It& it, _Param& param)
-                               {
-                                       T n = *it;
-                                       if ( n >= _Min && n <= _Max )
-                                       {
-                                               it++;
-                                               return true;
-                                       }
-                                       else
-                                               return false;
-                               }
-                       };
-                       
-                       template <char _Min, char _Max>
-                       class char_range : public range<char, _Min, _Max> {};
-                       
-                       template <short _Min, short _Max>
-                       class short_range : public range<short, _Min, _Max> {};
-                       
-                       template <int _Min, int _Max>
-                       class int_range : public range<int, _Min, _Max> {};
-                       
-                       template <unsigned char _Min, unsigned char _Max>
-                       class uchar_range : public range<unsigned char, _Min, _Max> {};
-                       
-                       template <unsigned short _Min, unsigned short _Max>
-                       class ushort_range : public range<unsigned short, _Min, _Max> {};
-                       
-                       template <int _Min, int _Max>
-                       class uint_range : public range<unsigned int, _Min, _Max> {};
-
-                       /////////////////////////////////////////////////////////////
-
-                       template <typename T, T _Val>
-                       class fixed_numeric : public lengthable
-                       {
-                       public:
-                               static const int length = sizeof(T);
-
-                               template <typename _It, typename _Param>
-                               bool analyze(_It& it, _Param& param)
-                               {
-                                       switch(*it)
-                                       {
-                                       case _Val:
-                                               it++;
-                                               return true;
-                                       }
-                                       return false;
-                               }
-
-                               //----
-                               
-                               template <typename _Strm, typename _Document>
-                               bool generate(_Strm& strm, _Document& doc)
-                               {
-                                       //strm << _Val;
-                                       T v = _Val;
-                                       //strm << v;
-                                       strm << sized_ptr_<char>((char*)&v,sizeof(T));
-                                       return true;
-                               }       
-                               /*template <typename _Document>
-                               bool generate(::std::fstream& strm, _Document& doc)
-                               {
-                                       //strm << _Val;
-                                       T v = _Val;
-                                       strm.write((const char*)&v, sizeof(_Val));
-                                       return true;
-                               }*/
-                       };
-
-                       /////////////////////////////////////////////////////////////
-
-                       /*
-                       template <unsigned char _ByteCode>
-                       class unibyte
-                       {
-                       public:
-                               template <typename _It, typename _Param>
-                               bool analyze(_It& it, _Param& param)
-                               {
-                                       switch(*it)
-                                       {
-                                       case _Byte:
-                                               it++;
-                                               return true;
-                                       }
-                                       return false;
-                               }
-                               
-                               template <typename _Strm, typename _Document>
-                               bool generate(_Strm& strm, _Document& doc)
-                               {
-                                       strm << _ByteCode;
-                                       return true;
-                               }
-                       };
-                       */
-                       template <unsigned char _ByteCode>
-                       class unibyte : public fixed_numeric<unsigned char, _ByteCode> {};
-
-                       template <char _Val>
-                       class fixed_char : public fixed_numeric<char, _Val> {};
-                       template <short _Val>
-                       class fixed_short : public fixed_numeric<short, _Val> {};
-                       template <int _Val>
-                       class fixed_int : public fixed_numeric<int, _Val> {};
-                       template <long _Val>
-                       class fixed_long : public fixed_numeric<long, _Val> {};
-
-                       template <unsigned char _Val>
-                       class fixed_uchar : public fixed_numeric<unsigned char, _Val> {};
-                       template <unsigned short _Val>
-                       class fixed_ushort : public fixed_numeric<unsigned short, _Val> {};
-                       template <unsigned int _Val>
-                       class fixed_uint : public fixed_numeric<unsigned int, _Val> {};
-                       template <unsigned long _Val>
-                       class fixed_ulong : public fixed_numeric<unsigned long, _Val> {};
-
-                       typedef unibyte<0> zeroterm;
                }
 
-               ///////////////////////////////////////
+               //////////////////////////////////////////////////
        }
 }
 
diff --git a/roast/include/roast/lexical/rule_numeric.hpp b/roast/include/roast/lexical/rule_numeric.hpp
new file mode 100644 (file)
index 0000000..7ec0f3b
--- /dev/null
@@ -0,0 +1,149 @@
+//     Roast+ License
+/*
+*/
+#ifndef __SFJP_ROAST__lexical__rule_numeric_HPP__
+#define __SFJP_ROAST__lexical__rule_numeric_HPP__
+
+namespace roast
+{
+       namespace lexical
+       {
+               namespace rule
+               {
+                       ////////////////////////////////////////////////////////////////////
+                       
+                       template <typename T, T _Min, T _Max>
+                       class range : public lengthable
+                       {
+                       public:
+                               static const int length = sizeof(T);
+
+                               template <typename _It, typename _Param>
+                               bool analyze(_It& it, _Param& param)
+                               {
+                                       T n = *it;
+                                       if ( n >= _Min && n <= _Max )
+                                       {
+                                               it++;
+                                               return true;
+                                       }
+                                       else
+                                               return false;
+                               }
+                       };
+                       
+                       template <char _Min, char _Max>
+                       class char_range : public range<char, _Min, _Max> {};
+                       
+                       template <short _Min, short _Max>
+                       class short_range : public range<short, _Min, _Max> {};
+                       
+                       template <int _Min, int _Max>
+                       class int_range : public range<int, _Min, _Max> {};
+                       
+                       template <unsigned char _Min, unsigned char _Max>
+                       class uchar_range : public range<unsigned char, _Min, _Max> {};
+                       
+                       template <unsigned short _Min, unsigned short _Max>
+                       class ushort_range : public range<unsigned short, _Min, _Max> {};
+                       
+                       template <int _Min, int _Max>
+                       class uint_range : public range<unsigned int, _Min, _Max> {};
+
+                       /////////////////////////////////////////////////////////////
+
+                       template <typename T, T _Val>
+                       class fixed_numeric : public lengthable
+                       {
+                       public:
+                               static const int length = sizeof(T);
+
+                               template <typename _It, typename _Param>
+                               bool analyze(_It& it, _Param& param)
+                               {
+                                       switch(*it)
+                                       {
+                                       case _Val:
+                                               it++;
+                                               return true;
+                                       }
+                                       return false;
+                               }
+
+                               //----
+                               
+                               template <typename _Strm, typename _Document>
+                               bool generate(_Strm& strm, _Document& doc)
+                               {
+                                       //strm << _Val;
+                                       T v = _Val;
+                                       //strm << v;
+                                       strm << sized_ptr_<char>((char*)&v,sizeof(T));
+                                       return true;
+                               }       
+                               /*template <typename _Document>
+                               bool generate(::std::fstream& strm, _Document& doc)
+                               {
+                                       //strm << _Val;
+                                       T v = _Val;
+                                       strm.write((const char*)&v, sizeof(_Val));
+                                       return true;
+                               }*/
+                       };
+
+                       /////////////////////////////////////////////////////////////
+
+                       /*
+                       template <unsigned char _ByteCode>
+                       class unibyte
+                       {
+                       public:
+                               template <typename _It, typename _Param>
+                               bool analyze(_It& it, _Param& param)
+                               {
+                                       switch(*it)
+                                       {
+                                       case _Byte:
+                                               it++;
+                                               return true;
+                                       }
+                                       return false;
+                               }
+                               
+                               template <typename _Strm, typename _Document>
+                               bool generate(_Strm& strm, _Document& doc)
+                               {
+                                       strm << _ByteCode;
+                                       return true;
+                               }
+                       };
+                       */
+                       template <unsigned char _ByteCode>
+                       class unibyte : public fixed_numeric<unsigned char, _ByteCode> {};
+
+                       template <char _Val>
+                       class fixed_char : public fixed_numeric<char, _Val> {};
+                       template <short _Val>
+                       class fixed_short : public fixed_numeric<short, _Val> {};
+                       template <int _Val>
+                       class fixed_int : public fixed_numeric<int, _Val> {};
+                       template <long _Val>
+                       class fixed_long : public fixed_numeric<long, _Val> {};
+
+                       template <unsigned char _Val>
+                       class fixed_uchar : public fixed_numeric<unsigned char, _Val> {};
+                       template <unsigned short _Val>
+                       class fixed_ushort : public fixed_numeric<unsigned short, _Val> {};
+                       template <unsigned int _Val>
+                       class fixed_uint : public fixed_numeric<unsigned int, _Val> {};
+                       template <unsigned long _Val>
+                       class fixed_ulong : public fixed_numeric<unsigned long, _Val> {};
+
+                       typedef unibyte<0> zeroterm;
+                       
+                       ////////////////////////////////////////////////////////////////////
+               }
+       }
+}
+
+#endif//__SFJP_ROAST__lexical__rule_numeric_HPP__