Utils/Console: Join multiple consecutive '/' chars in parser
g0dil [Fri, 13 Nov 2009 15:29:12 +0000 (15:29 +0000)]
git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1525 270642c3-0616-0410-b53a-bc976706d245

senf/Utils/Console/Parse.ih
senf/Utils/Console/Parse.test.cc

index 3af920f..e0e42d6 100644 (file)
@@ -293,12 +293,12 @@ namespace detail {
 
                 relpath
                     =    (   word                 [ push_back(path_, token_) ]
-                           % ch_p('/') )
-                      >> ( ! ch_p('/')            [ push_back(path_, construct_<Token>()) ] )
+                           % +ch_p('/') )
+                      >> ( ! (+ch_p('/') )        [ push_back(path_, construct_<Token>()) ] )
                     ;
 
                 abspath
-                    =    ch_p('/')                [ push_back(path_, construct_<Token>()) ]
+                    =    (+ch_p('/'))             [ push_back(path_, construct_<Token>()) ]
                       >> ( relpath
                          | eps_p                  [ push_back(path_, construct_<Token>()) ] )
                     ;
index 17ff943..dc9bafb 100644 (file)
@@ -89,7 +89,7 @@ BOOST_AUTO_UNIT_TEST(commandGrammar)
     {
         static char text[] = 
             "# Comment\n"
-            "doo / bii / doo arg"
+            "doo / bii / // doo arg"
             "                flab::blub"
             "                123.434>a"
             "                (a,b;c (huhu/{haha}))"
@@ -128,7 +128,7 @@ BOOST_AUTO_UNIT_TEST(commandGrammar)
     {
         ss.str("");
         BOOST_CHECK( boost::spirit::parse( 
-                         "ls /foo/bar;", 
+                         "ls //foo/bar;", 
                          grammar.use_parser<Grammar::CommandParser>(), 
                          grammar.use_parser<Grammar::SkipParser>() ) . full );
         BOOST_CHECK_EQUAL( ss.str(), "builtin_ls( None('')/Word('foo')/Word('bar') )\n" );
@@ -164,7 +164,7 @@ BOOST_AUTO_UNIT_TEST(commandGrammar)
     {
         ss.str("");
         BOOST_CHECK( boost::spirit::parse( 
-                         "foo/bar/ {", 
+                         "foo/bar// {", 
                          grammar.use_parser<Grammar::CommandParser>(), 
                          grammar.use_parser<Grammar::SkipParser>() ) . full );
         BOOST_CHECK_EQUAL( ss.str(),