Opened 7 years ago
#11824 new Bugs
[spirit][qi] skip_flag::dont_postskip not working as expected
Reported by: | Owned by: | Joel de Guzman | |
---|---|---|---|
Milestone: | To Be Determined | Component: | spirit |
Version: | Boost 1.59.0 | Severity: | Showstopper |
Keywords: | qi skip post-skip | Cc: |
Description
Assuming we want to create a primitive which checks if the skip parser is called at least once before the next terminal we need to disable post-skipping for this purpose. However, disabling post-skipping alone will not work if the previous parser failed on a input because all terminals do not revert to the position before the skip parser but just after it. A workaround could be add an and-prediction in front of each terminal but this makes the code unreadable. Attached is a possible patch for spirit qi which changes all terminals to revert to the position before the skip parser in case of a mismatch. Note: This might introduce some performance regression.
Example:
string input("a b"); string::const_iterator first(input.begin()), last(input.end()); phrase_parse(first, last, ((+char_("a", "z")) > no_skip[&blank]) >> char_, blank, dont_postskip);
This will fail to match in the current implementation even though it looks perfectly fine.
possible patch for qi (boost 1.59) - untested