Reputation: 3741
In my parser, sometimes the grammar accommodates a match on just the first section of an input string. This seems to be normal behavior for phrase_parse(), but is not what I'm looking for in my application.
How can I require that the whole input string match the grammar for a successful parse, rather than returning success on shorter matches that don't consume all of the input string?
Upvotes: 2
Views: 274
Reputation: 393049
Just require qi::eoi
at the end:
bool ok = qi::phrase_parse(f, l, grammar >> eoi, skipper);
This also works to discard branches that didn't match all input:
myrule = (legA >> eoi) | (legB >> eoi) | (legC >> eoi);
See also
Upvotes: 3