OSDN Git Service

roast_xml/rule_xml.hpp: コメント開始のフォーマットエラーチェック対応
authorMyun2 <myun2@nwhite.info>
Mon, 11 Oct 2010 07:54:04 +0000 (16:54 +0900)
committerMyun2 <myun2@nwhite.info>
Mon, 11 Oct 2010 07:54:04 +0000 (16:54 +0900)
roast/include/roast/lexical/string_rule.hpp
roast/include/roast/xml/roast_xml/rule_xml.hpp
roast/test/lexical_test/temp.xml

index ddd73de..82ea904 100644 (file)
@@ -27,14 +27,14 @@ namespace roast
                                bool analyze(_It& it, _Param& param)
                                {
                                        _asm nop;
-                                       _It it_backup=it;
+                                       char c=*it;
                                        T t;
                                        bool b = t.analyze(it, param);
                                        
                                        if ( b ){
-                                               if ( *it_backup == '\r' )
+                                               if ( c == '\r' )
                                                        param << _cr_t;
-                                               else if ( *it_backup == '\n' )
+                                               else if ( c == '\n' )
                                                        param << _lf_t;
                                        }
                                        return b;
index a7d755a..2588d1a 100644 (file)
@@ -39,8 +39,11 @@ namespace roast
                        struct angle_bracket_invalid : public xml_parse_exception{
                                angle_bracket_invalid() : xml_parse_exception("Angle bracket Invalid.") {} };
 
-                       struct comment_invalid_hyphyp : public xml_parse_exception{
-                               comment_invalid_hyphyp() : xml_parse_exception("The thing including \"--\" cannot be done in the Comment except the terminal.") {} };
+                       struct comment_invalid_start : public xml_parse_exception{
+                               comment_invalid_start() : xml_parse_exception("Comment Format Invalid. (Need Start \"<!--\")") {} };
+
+                       struct comment_invalid_end : public xml_parse_exception{
+                               comment_invalid_end() : xml_parse_exception("The thing including \"--\" cannot be done in the Comment except the terminal.") {} };
 
                        //////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
@@ -112,11 +115,15 @@ namespace roast
                        > comment_str;
        
                        typedef seq<
-                               lesser, exclamation, hyphen, hyphen,    //      <!--
+                               lesser, exclamation,                                            //      <!
+                               false_ret_to_exception<seq<hyphen, hyphen>,     //      --
+                                       comment_invalid_start>,
+
                                comment_str,
+
                                skip<2>, //hyphen, hyphen                               //      --
                                false_ret_to_exception<greater,                 //      >
-                                       comment_invalid_hyphyp>
+                                       comment_invalid_end>
                        > comment;
 
                        //typedef opt_repeat<comment> opt_comments;
index be77db5..c46bbc1 100644 (file)
@@ -1,16 +1,18 @@
-  <!-- aaaa -->
 
-<?xml
-version
-= "1.0"
 
- encoding =
-  "UTF-8"
-?>
-<hoge>
-<hoge>aaaa</hosge>
-<hoge></hoge>
-<hoge>bbbb</hoge>
-<hoge>
-</hoge>
-</hoge>
\ No newline at end of file
+<! --dd 
+ ddd--
+ -->
+ <!--dd 
+ -->
+ <?xml 
+ version="1.0"
+ encoding=
+ "UTF-8" ?>
+ <!--dd --> <hoge>
+</hogde>
+
+ <!--dd -->
\ No newline at end of file