This is not a string match. This is [attribute distribution] + [backlink] in action.
The string attribute is a container attribute, and many elements can be assigned to it by various parser subexpressions. Now, for reasons of efficiency, Spirit does not roll back the values โโof the emitted attributes upon return.
Often this is not a problem, but as you can see, the โaโ from the failed first branch of the alternative sticks.
Rename or use the "big gun" qi::hold[] directive:
(qi::hold [ string("a") >> string("a") ] | string("a")),
The entry may look like this:
qi::string("a") >> -qi::string("a"),
Also, if you are really trying to match specific text strings, consider:
(qi::raw [ qi::lit("aa") | "a" ]),
Now, which one works best depends on your grammar.
source share