skipper does not work

Jens Kallup <[email protected]>
Newsgroups gmane.comp.parsers.spirit.general
Message-ID <[email protected]>
Hello,

I wonder me, why the skipper don't work to parse comment lines:

&& comment
** comment
// comment
/* block */

What is wrong in the code bellow?:
-------------
#define BOOST_SPIRIT_DEBUG

#include <boost/config/warning_disable.hpp>

#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/phoenix.hpp>

#include <string>
#include <iostream>

namespace client
{
     namespace qi = boost::spirit::qi;
     namespace ascii = boost::spirit::ascii;

     template <typename Iterator>
     struct dbase_skipper : public qi::grammar<Iterator>
     {
         dbase_skipper() : dbase_skipper::base_type(my_skip, "dBase")
         {
             using qi::ascii::char_;
             using qi::ascii::space;
             using qi::eol;
             using qi::eoi;

             my_skip =
             *(char_("[ \\t\\n\\r]"))  |
             (("**") >> *(char_ - eol) >> (eol | eoi | char_("\\n"))) |
             (("&&") >> *(char_ - eol) >> (eol | eoi | char_("\\n"))) |
             (("//") >> *(char_ - eol) >> (eol | eoi | char_("\\n"))) |
             ("/*" >> *(char_ - "*/") >> "*/")
             ;
         }
         qi::rule<Iterator> my_skip;
     };

     template <typename Iterator, typename Skipper = 
dbase_skipper<Iterator>>
     struct dbase_grammar : public qi::grammar<Iterator, Skipper>
     {
         qi::rule<Iterator, Skipper> start, run_app;
         qi::rule<Iterator, Skipper> block;
         qi::rule<Iterator, Skipper> statement;

         dbase_grammar() : dbase_grammar::base_type(start)
         {
             start = run_app.alias();

             run_app =
                 symbol.alias()
                 ;

             symbol =
                 (symbol_raw.alias())
                 ;

             symbol_raw =
                 +(qi::alpha | qi::char_( "_" ))
                 ;

             BOOST_SPIRIT_DEBUG_NODE(start);
             BOOST_SPIRIT_DEBUG_NODE(symbol);
             BOOST_SPIRIT_DEBUG_NODE(symbol_raw);
         }

         qi::rule<Iterator, Skipper> symbol, symbol_raw;
     };
}

bool parseText(std::string str, int mode)
{
     typedef std::string::const_iterator iterator_t;

     typedef client::dbase_grammar <iterator_t> grammar;
     typedef client::dbase_skipper <iterator_t> skipper;

     grammar pg;
     skipper skp;

     iterator_t iter = str.begin();
     iterator_t end  = str.end();

     bool r = phrase_parse(iter, end, pg, skp);
     if (r == true) {
         std::cout << "Parsing SUCCESS.\n";
         return true;
     }

     if (iter != end)
         std::cout << "Remaining: '" << std::string(iter, end) << std::endl;

     std::cout << "Parsing ERROR.\n";
     return false;
}


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.