From 59c1d0e6af265a494dc91e1e6c076b61cfcfaa00 Mon Sep 17 00:00:00 2001 From: Myun2 Date: Wed, 21 Jul 2010 11:53:48 +0900 Subject: [PATCH] =?utf8?q?lexical:=20seq2,=20seq3=E5=AE=9F=E8=A3=85=20requ?= =?utf8?q?re=5Fwhitespace,=20no=5Frequre=5Fwhitespace=20=E3=81=A8=E3=81=97?= =?utf8?q?=E3=81=A6=E3=81=93=E3=82=8C=E3=82=92typedef=E3=80=82no=5Frequre?= =?utf8?q?=5Fwhitespace=20=E3=82=92=E5=AE=9F=E8=A3=85=20=E3=81=9D=E3=81=AE?= =?utf8?q?=E4=BB=96=E8=89=B2=E3=80=85=E3=80=82=E4=B8=80=E5=BF=9C=E3=81=A8?= =?utf8?q?=E3=82=8A=E3=81=82=E3=81=88=E3=81=9A=E3=82=B3=E3=83=B3=E3=83=91?= =?utf8?q?=E3=82=A4=E3=83=AB=E9=80=9A=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= =?utf8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- roast/include/roast/lexical/structure_base.hpp | 92 ++++++++++++++++++---- .../roast/xml/roast_xml/roast_xml_sax_parser.hpp | 5 +- roast/include/roast/xml/roast_xml/structure.hpp | 8 +- roast/test/lexical_test/parser_test.cpp | 3 +- 4 files changed, 88 insertions(+), 20 deletions(-) diff --git a/roast/include/roast/lexical/structure_base.hpp b/roast/include/roast/lexical/structure_base.hpp index ff228696..5bc5e93f 100644 --- a/roast/include/roast/lexical/structure_base.hpp +++ b/roast/include/roast/lexical/structure_base.hpp @@ -18,14 +18,46 @@ namespace roast { }; + //////////////////////////////////////////////////////////////// template class seq2 { - }; + public: + template + bool analyze(const T& it) + { + T1 t1; + if ( t1.analyze(it) == false ) + return false; + T1 t2; + if ( t2.analyze(it) == false ) + return false; + return true; + } + }; + //////////////////////////////////////////////////////////////// + template class seq3 { - }; + public: + template + bool analyze(const T& it) + { + T1 t1; + if ( t1.analyze(it) == false ) + return false; + T1 t2; + if ( t2.analyze(it) == false ) + return false; + T1 t3; + if ( t3.analyze(it) == false ) + return false; + return true; + } + }; + //////////////////////////////////////////////////////////////// + template class seq4 { @@ -62,22 +94,44 @@ namespace roast { }; - class _reqws - { - }; - class _nrqws - { - }; + /////////////////////////////////////////////////// - class reqws - { - }; - class nrqws + typedef + class requre_whitespace { - }; - class optws - { - }; + } + _reqws, reqws; + + ///////////////////// + + typedef + class no_requre_whitespace + { + public: + template + bool analyze(const T& it) + { + for(;;) + { + //char c = it.operator *(); + switch(*it) + { + case ' ': + case '\t': + case '\r': + case '\n': + continue; + } + + break; + } + + return true; + } + } + _nrqws, _noreqws, nrqws, noreqws, optws; + + /////////////////////////////////////////////////// } /////////////////////////////////////// @@ -85,6 +139,12 @@ namespace roast template class structure_base { + public: + template + bool analyze(const T& s) + { + return ( *s == '>' ); + } }; } } diff --git a/roast/include/roast/xml/roast_xml/roast_xml_sax_parser.hpp b/roast/include/roast/xml/roast_xml/roast_xml_sax_parser.hpp index a6671c60..1770faa7 100644 --- a/roast/include/roast/xml/roast_xml/roast_xml_sax_parser.hpp +++ b/roast/include/roast/xml/roast_xml/roast_xml_sax_parser.hpp @@ -14,14 +14,15 @@ namespace roast { //////////////////////////////////////////////////////////////// - class sax_parser_impl + /*class sax_parser_impl { public: bool analyze(const char* s) { return true; } - }; + };*/ + typedef _structure sax_parser_impl; //////////////////////////////////////////////////////////////// diff --git a/roast/include/roast/xml/roast_xml/structure.hpp b/roast/include/roast/xml/roast_xml/structure.hpp index 198bda3c..08f1d96a 100644 --- a/roast/include/roast/xml/roast_xml/structure.hpp +++ b/roast/include/roast/xml/roast_xml/structure.hpp @@ -120,12 +120,18 @@ namespace roast //////////////////////////////////////////////////// - typedef lexical::structure_base< + /*typedef lexical::structure_base< ::roast::lexical::structure::seq3< structure::nothing_, structure::nothing_, structure::nothing > + > _structure;*/ + typedef ::roast::lexical::structure::seq3 + < + structure::nothing_, + structure::nothing_, + structure::nothing > _structure; } } diff --git a/roast/test/lexical_test/parser_test.cpp b/roast/test/lexical_test/parser_test.cpp index 9cc900c7..5b26e319 100644 --- a/roast/test/lexical_test/parser_test.cpp +++ b/roast/test/lexical_test/parser_test.cpp @@ -13,7 +13,8 @@ int main() fread(work,sizeof(work),1,fp); //roast_xml::dom_parser wss("aaa"); - roast_xml::sax_parser wss(work); + roast_xml::sax_parser sax(work); + sax.analyze(); return 0; } -- 2.11.0