Boost logo

Boost Users :

Subject: Re: [Boost-users] [Spirit] Qi lexeme only taking the first word
From: Gavin Lambert (boost_at_[hidden])
Date: 2018-11-07 03:28:01

On 7/11/2018 15:08, Michael Powell wrote:
>> When it matches
>> id >> *(char_('.') >> id)
>> this has an attribute of vector<string,vector<tuple<char,std::string>>> or something similar.
> Where are you getting that from? It makes no sense whatsoever given
> the struct full_it_t { std::string val; }, which is similarly mapped,
> and ruled, etc.

This might be wrong, but it's how I read the docs:

The output of parsing is a Fusion sequence of the attributes that were

So the output of

   id >> *(char_('.') >> id)

is something like (but not exactly)

   tuple<string, char, string>
   tuple<string, char, string, char, string>

string because that's the output attribute declared for id.
char because you've used char_ instead of using '.' by itself (otherwise
it would just disappear).
And the latter two can be repeated zero or more times because you've used *.

When you assign this to a rule with %=, it tries to best-fit this
against the rule's declared output attribute.

full_id_t contains a single string field, so the Fusion adaptation makes
it equivalent to tuple<string>, and apparently this results in any
additional values being discarded, not in concatenating as you expect.

You can probably use an explicit semantic action to build a single
string instead of using %=.

Or you can make full_id_t contain vector<string> as rmawatson and I
previously suggested, which should give you all the values.

Another possibility, which I can't test because coliru appears to be
grumpy at present, is to try using:

   full_id %= as_string[lexeme[id >> *(char_('.') >> id)]];

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at