OSDN Git Service

101112_dom3\8_illegal_term: rule_xml.hpp
authorMyun2 <myun2@nwhite.info>
Tue, 21 Dec 2010 14:06:02 +0000 (23:06 +0900)
committerMyun2 <myun2@nwhite.info>
Tue, 21 Dec 2010 14:06:02 +0000 (23:06 +0900)
roast/include/roast/xml/roast_xml/rule_xml.hpp
roast/test/lexical_test/dom_test.cpp

index 0c78125..18e7997 100644 (file)
@@ -69,6 +69,7 @@ namespace roast
 
                                        //      invalid termination.
                                        _error_code_invalid_term = 0x8200,
+                                       illegal_term,
                                        invalid_term_in_comment,
                                        invalid_term_in_processing_instruction,
                                        invalid_term_in_attrname,
@@ -127,14 +128,14 @@ namespace roast
 
                        ///
 
-                       struct comment_invalid_start : public xml_parse_exception{
-                               comment_invalid_start() : xml_parse_exception("Comment Format Invalid. (Need Start \"<!--\")") {} };
+                       struct invalid_comment_start_exception : public xml_parse_exception{
+                               invalid_comment_start_exception() : xml_parse_exception("Comment Format Invalid. (Need Start \"<!--\")") {} };
 
-                       struct comment_invalid_term : public xml_parse_exception{
-                               comment_invalid_term() : xml_parse_exception("Comment was not closed.") {} };
+                       struct invalid_term_in_comment_exception : public xml_parse_exception{
+                               invalid_term_in_comment_exception() : xml_parse_exception("Comment was not closed.") {} };
 
-                       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.") {} };
+                       struct invalid_comment_end_exception : public xml_parse_exception{
+                               invalid_comment_end_exception() : xml_parse_exception("The thing including \"--\" cannot be done in the Comment except the terminal.") {} };
 
                        template <int _EvtCode>
                        struct error_event_to_exception { typedef xml_parse_exception type; };
@@ -142,7 +143,9 @@ namespace roast
                        template <>
                        struct error_event_to_exception<pcode::not_angle_bracket_start> { typedef not_angle_bracket_start_exception type; };
                        template <>
-                       struct error_event_to_exception<pcode::root_cant_have_text> { typedef root_cant_have_text_exception type; };
+                       struct error_event_to_exception<pcode::invalid_comment_start> { typedef invalid_comment_start_exception type; };
+                       template <>
+                       struct error_event_to_exception<pcode::invalid_comment_end> { typedef invalid_comment_end_exception type; };
 
                        //////////////////////////////////////////////////
 
@@ -377,6 +380,12 @@ namespace roast
                                rule::body,                                     //      XML Body
                                comments_and_whitespaces,       //      Comments and Whitespaces
                                zeroterm
+                       > _rule_1;
+
+                       typedef exception_to_event<
+                               _rule_1,
+                               eoi_exception,
+                               error_event<pcode::illegal_term>
                        > _rule;
                }
                
index 6982d97..bd593c7 100644 (file)
@@ -74,6 +74,15 @@ int main()
 
                //      root_cant_have_text
                sax_error_test("   a", root_cant_have_text_exception().c_str() );
+               sax_error_test("   <! ", invalid_comment_start_exception().c_str() );
+               sax_error_test("   <!- ", invalid_comment_start_exception().c_str() );
+               sax_error_test("   <!-> ", invalid_comment_start_exception().c_str() );
+               sax_error_test("   <!--> ", invalid_comment_start_exception().c_str() );
+               sax_error_test("   <!--- ", invalid_comment_end_exception().c_str() );
+               sax_error_test("   <!---> ", invalid_term_in_comment_exception().c_str() );
+               sax_error_test("   <!----> ", invalid_comment_end_exception().c_str() );
+               sax_error_test("   <!-- --> ", invalid_term_in_comment_exception().c_str() );
+               sax_error_test("   <!-- -- ", invalid_comment_end_exception().c_str() );
        }
        catch(sax_exception& e)
        {