OSDN Git Service

mbstring: euc_jp.hpp, shift_jis.hpp 実装
authorMyun2 <myun2@nwhite.info>
Tue, 3 Aug 2010 13:11:40 +0000 (22:11 +0900)
committerMyun2 <myun2@nwhite.info>
Tue, 3 Aug 2010 13:11:40 +0000 (22:11 +0900)
roast/include/roast/str/multibyte/japanese/euc_jp.hpp
roast/include/roast/str/multibyte/japanese/shift_jis.hpp

index 3ccc885..2c520ab 100644 (file)
@@ -6,9 +6,53 @@
 #ifndef __SFJP_ROAST__str__multi_byte__japanese__euc_jp_HPP__
 #define __SFJP_ROAST__str__multi_byte__japanese__euc_jp_HPP__
 
+#include "roast/lexical/string_structure.hpp"
+
 namespace roast
 {
-
+       namespace multibyte
+       {
+               namespace jananese
+               {
+                       namespace euc_jp
+                       {
+                               using namespace ::roast::lexical::structure;
+                               
+                               /*
+                               \90§\8cä\83R\81[\83h
+                               0x00\81`0x1F\81A0x7F 
+                               ASCII\95\8e\9a
+                               0x20\81`0x7E 
+                               
+                               \8a¿\8e\9a
+                               0xA1A1\81`0xFEFE (\91æ1\83o\83C\83g\81E\91æ2\83o\83C\83g\82Æ\82à0xA1\81`0xFE) 
+                               \94¼\8ap\83J\83^\83J\83i
+                               0x8EA1\81`0x8EDF 
+                               \95â\8f\95\8a¿\8e\9a
+                               0x8FA1A1\81`0x8FFEFE (\91æ2\83o\83C\83g\81E\91æ3\83o\83C\83g\82Æ\82à0xA1\81`0xFE) 
+                               */
+                               typedef or<
+                                       //      1byte (00-7f)
+                                       int_range< 0x00, 0x7f >,
+                               
+                                       //      3byte (0x8FA1A1-0x8FFEFE)
+                                       seq<
+                                               int_range< 0x8f, 0x8f >,
+                                               int_range< 0xa1, 0xfe >,
+                                               int_range< 0xa1, 0xfe >
+                                       >,
+                               
+                                       //      2byte (0x8EA1\81`0x8EDF)
+                                       seq<
+                                               int_range< 0xa1, 0xfe >,
+                                               int_range< 0xa1, 0xfe >
+                                       >,
+                               
+                                       get_numeric<1>
+                               > lexical_rule;
+                       }
+               }
+       }
 }
 
 #endif//__SFJP_ROAST__str__multi_byte__japanese__euc_jp_HPP__
index 1a215eb..e9b98a6 100644 (file)
@@ -6,9 +6,47 @@
 #ifndef __SFJP_ROAST__str__multi_byte__japanese__shift_jis_HPP__
 #define __SFJP_ROAST__str__multi_byte__japanese__shift_jis_HPP__
 
+#include "roast/lexical/string_structure.hpp"
+
 namespace roast
 {
-
+       namespace multibyte
+       {
+               namespace jananese
+               {
+                       namespace euc_jp
+                       {
+                               using namespace ::roast::lexical::structure;
+                               
+                               //      Shift_JIS
+                               typedef or<
+                               
+                                       //      1byte (00-7f)
+                                       seq<
+                                               test<
+                                                       int_range< 0x00, 0x7f >
+                                               >,
+                                               get_numeric<1>
+                                       >,
+                               
+                                       //      2byte (0x81-0x9f | 0xe0-0xef) (0x40-0x7e | 0x80-0xfc)
+                                       seq<
+                                               test<//(0x81-0x9f | 0xe0-0xef)
+                                                       or<
+                                                               int_range< 0x81, 0x9f >,
+                                                               int_range< 0xe0, 0xef >
+                                                       >
+                                               >,
+                                               get_numeric<2>
+                                       >,
+                               
+                                       //      unknown (Get 1byte.)
+                                       get_numeric<1>
+                               >
+                                       lexical_rule;
+                       }
+               }
+       }
 }
 
 #endif//__SFJP_ROAST__str__multi_byte__japanese__shift_jis_HPP__