Re: (follow up to): parse iterator going past end()

Seth <[email protected]> Thu, 30 Apr 2020 12:40:50 +0200
Newsgroups gmane.comp.parsers.spirit.general
Message-ID <[email protected]>
Indeed the bug arises when the input ends in a skippable:

    #include <boost/spirit/home/x3.hpp>
    namespace x3 = boost::spirit::x3;

    int main() {
        char const* x = " ";
        x3::phrase_parse(x, x+1, x3::seek['!'], x3::space);
    }


I suspect that there is a post-skip call somewhere that should be
guarded with an eoi condition.


Op 25-04-2020 om 21:58 schreef Dan Bloomquist via Spirit-general:
> Hi,
> I thought I would just do a work around with a simple seek and I ended
> up looking at what the problem was. So in seek with data like "x\n",
> the skipper takes the iterator to the end of the text and then the
> loop increments past end. So I would guess that instead of,(this is
> from seek):
>
>             for (/**/; current != last; ++current)
>             {
>                 if (this->subject.parse(current, last, context,
> rcontext, attr))
>                 {
>                     first = current;
>                     return true;
>                 }
>             }
>
> It should be:
>
>             for (; ; ++current)
>             {
>                 if (this->subject.parse(current, last, context,
> rcontext, attr))
>                 {
>                     first = current;
>                     return true;
>                 }
>              if(current == last)
>                    break;
>             }
>
>
> _______________________________________________
> Spirit-general mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/spirit-general

_______________________________________________
Spirit-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/spirit-general