Boost logo

Boost Users :

Subject: [Boost-users] Boost.Spirit Karma: Alternative generator
From: Matwey V. Kornilov (matwey.kornilov_at_[hidden])
Date: 2016-03-01 09:21:33


Hello,

I am construction karma::rule<OutputIterator, std::string()> which I
would like to be either a string or quoted string if the string contains
spaces.

Now I think that the rule should be something like:

    rule = (&true[...] << string) | (lit("\"") << string << lit("\""));

but I've failed to write proper semantic action. How could I obtain
std::string object reference to write something like:

    (obj.find(" ") == std::string::npos)

? Or maybe is there a better way to do the same?


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