I'm having trouble in understanding exactly how and when Spirit decides to merge matches into single entities. What I am trying to do is to match a list of words inside double square brackets, and I would like to extract the full text inside the brackets. Example:
[[This is some single-spaced text]] -> "This is some single-spaced text"
My grammar is as follows:
qi::rule<Iterator, std::string()> word = +(char_ - char_(" []"));
qi::rule<Iterator, std::string()> entry = lit("[[") >> word >> *(char_(' ') >> word) >> lit("]]") >> -qi::eol;
std::string text;
bool r = parse( first, last, entry, text );
However, this parses the example text as follows:
[[This is some single-spaced text]] -> "Thisissomesingle-spacedtext"
I don't understand why this is happening. I'm not using lit
for the space, nor any rule or parser seems to ignore whitespace, if I understood Spirit correctly. I'm not sure how to verify that the results of my grammar are the ones I want (for example to avoid having the space in a tuple with each word, instead of being concatenated).
What should I do to obtain the result I want?