Opened 10 years ago

Closed 5 years ago

#7371 closed Bugs (fixed)

boost::spirit::classic::char_parser<DerivedT>::parse is incrementing the scanner's first iterator directly instead of using the provided iterator_policy

Reported by: mhilferink@… Owned by: Joel de Guzman
Milestone: To Be Determined Component: spirit
Version: Boost 1.51.0 Severity: Problem
Keywords: scanner iterator_policy Cc:

Description

In boost\spirit\home\classic\core\primitives\primitives.hpp

boost::spirit::classic::char_parser<DerivedT>::parse is defined to increment the scanner's first iterator directly instead of using the provided iterator_policy.

I'm using a scanner with an iterator that doesn't have a ++ operator and provided an iteration policy with redefined advance, get, and at_end methods.

This works fine if the following patch is implemented in boost\spirit\home\classic\core\primitives\primitives.hpp:

  if (!scan.at_end())
  {
      value_t ch = *scan;
      if (this->derived().test(ch))
      {
          iterator_t save(scan.first);
-         ++scan.first; 
+         ++scan; 
          return scan.create_match(1, ch, save, scan.first);
      }
  }

This patch forwards the increment request to scanner_policies<streamer_policy>::advance to let it do its thing with scan.first

I've seen this (and corrected it locally) at least in boost.sprit from boost version 1.40.0 and 1.51.0

Can somebody with RW access to boost.spirit implement this? Or tell me I should adapt my iterator objects directly.

I'm new to GIT and not a spirit developer, but I can try to make a git pull request if that is the way to send-in change requests.

Attachments (1)

primitives.hpp.patch (556 bytes ) - added by mhilferink@… 10 years ago.
here's the patch

Download all attachments as: .zip

Change History (3)

by mhilferink@…, 10 years ago

Attachment: primitives.hpp.patch added

here's the patch

comment:1 by Nikita Kniazev <nok.raven@…>, 5 years ago

comment:2 by Joel de Guzman, 5 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.