|
Boost Users : |
Subject: Re: [Boost-users] [spirit] Parsing quoted string
From: TONGARI (tongari95_at_[hidden])
Date: 2012-10-24 09:01:40
2012/10/24 Giampiero Gabbiani <giampiero_at_[hidden]>
> Hi together,
> I have to parse the following row:
>
> "a_token": true|false,
>
> the last comma is optional.
>
> Testing the following:
>
> bool value;
> test_parser(" \"orig_bool\": true,",
> qi::lit('"') >> *(ascii::alnum | qi::char_('_')) >> qi::lit('"') >>
> qi::lit(':') >> boost::spirit::qi::bool_[phx::ref(value)=_1] >>
> -(qi::lit(',')));
>
> it works, but with the following instead the program compile but hangs ...
>
> bool value;
> test_parser(" \"orig_bool\": true,",
> qi::lit('"') >> *(!qi::lit('"')) >> qi::lit('"') >> qi::lit(':') >>
> boost::spirit::qi::bool_[phx::ref(value)=_1] >> -(qi::lit(',')));
>
> the only difference is the way by means I get the content of the quoted
> string, actually instead of using
>
> *(ascii::alnum | qi::char_('_'))
>
> I'd like to use
>
> *(!qi::lit('"'))
>
> that - imho - should be better but it actually hangs.
>
> What/where am I actually missing/wrong?
>
For one thing, qi::lit exposes no attribute, for another, op"!" conusmes no
input, that's why it hangs.
I'd suggest *~qi::char_('"').
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