Boost logo

Boost Users :

Subject: Re: [Boost-users] [spirit] This parser hang
From: Hartmut Kaiser (hartmut.kaiser_at_[hidden])
Date: 2010-12-01 09:49:52


> This code:
>
> std::string s("blablabla");
>
> std::string::iterator start = s.begin(); std::string::iterator finish =
> s.end();
>
> bool result = phrase_parse(start, finish, +(!char_(':')), space);
>
> It's just a simple parser that match string which doesn't have ':'
> character in it right ? But when I run it, function phrase_parse is hang,
> it never return anything.
> I'm using boost 1.44 with VC 2008

Are you using Spirit V2.x or Spirit.Classic? I'm asking as the meaning for
the operator '!' has changed. In Spirit.Classic it stands for 'optional',
while in Spirit V2.x it stands for the 'not predicate' (which is different).

I assume you're targeting V2.x, therefore it has to be:

    +(~char_(':'))

instead. Note, the operator~() is applicable to character parsers only. If
you need 'A but not B' in the general case, use:

   +(char_ - char_(':'))

(but for character parsers the first is much more efficient).

Regards Hartmut
---------------
http://boost-spirit.com


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net