Opened 7 years ago

#11824 new Bugs

[spirit][qi] skip_flag::dont_postskip not working as expected

Reported by: Daniel Starke <daniel.f.starke@…> 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.

Attachments (1)

patch.diff (23.6 KB ) - added by Daniel Starke <daniel.f.starke@…> 7 years ago.
possible patch for qi (boost 1.59) - untested

Download all attachments as: .zip

Change History (1)

by Daniel Starke <daniel.f.starke@…>, 7 years ago

Attachment: patch.diff added

possible patch for qi (boost 1.59) - untested

Note: See TracTickets for help on using tickets.