Re: Parser does not parse

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

Here, I provide code:

// gcc  -c -O2 --std=c++1y -D__BYTE_ORDER=__LITTLE_ENDIAN \
//        -I/usr/include -I/usr/include/boost parser1.cc

#include <boost/config/warning_disable.hpp>
#include <boost/spirit/include/qi.hpp>

#include <iostream>
#include <string>

#include <cstring>
#include <cstdlib>

using namespace std;
using namespace boost::spirit;
using namespace boost::spirit::qi;

namespace client {
template <typename Iterator, typename Skipper>
struct my_test : public qi::grammar<Iterator, Skipper>
{
     my_test() : my_test::base_type(vs, "test")
     {
         vs =
         lit("if") > ('(' > int_ > ')')
         >> *(
// uncomment below line -> crash
//            (char_("a-zA-Z0-9")  > '=' > int_ ) |
             (vs)
             )
         >> *(
             lit("else")
             >> *(
//                (char_("a-zA-Z0-9")  > '=' > int_ ) |
                 (vs)
                 )
             )
         >    lit("endif")
         ;
     }

     rule<Iterator,Skipper> vs;
};
}

int main()
{
     std::string source = "if (1221) if (1212) endif endif";

     typedef std::string::iterator iterator_t;
     typedef client::my_test      <iterator_t, decltype(qi::space)> grammar;

     grammar pg;

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

     bool ok = phrase_parse(iter,end, pg, space);
     if (ok) {
         std::cout
         << "successful"
         << std::endl;
     }

     return 0;
}


------------------------------------------------------------------------------
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.