Subject: Re: [Boost-bugs] [Boost C++ Libraries] #8577: Multiple qi::match calls on the same stream corrupt input data
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2017-12-16 23:29:28
#8577: Multiple qi::match calls on the same stream corrupt input data
--------------------------------------+----------------------------
Reporter: Vadim Guchenko <yhw@â¦> | Owner: Joel de Guzman
Type: Bugs | Status: new
Milestone: To Be Determined | Component: spirit
Version: Boost Development Trunk | Severity: Problem
Resolution: | Keywords:
--------------------------------------+----------------------------
Comment (by Nikita Kniazev <nok.raven@â¦>):
> Probably it consumes some characters from the stream to do look-ahead
It will consume data even if your parser is LL(1).
> but doesn't return them back to the stream on destruction
You cannot return read data back to input stream (read about InputIterator
concept).
> so if it's the expected qi::match behavior, it's worth to be mentioned
in the documentation.
It should be clear to everyone that to parse data from an input stream you
must pull data from the stream and you cannot place the read data back to
it, even a single character.
----
All `qi::match` is doing is wrapping your iterators with
`spirit::basic_istream_iterator`, calling `qi::parse` and setting
`failbit` if parsing failed. You should not use `qi::match` in loop on the
same stream at least because it is slow (`spirit::basic_istream_iterator`
lots of heap allocations). Only use `qi::match` to match all of your
input.
Hint: Replace `+qi::lit(' ')` with a skipper (i.e. use `qi::phrase_match`)
-- Ticket URL: <https://svn.boost.org/trac10/boost/ticket/8577#comment:2> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-12-16 23:42:02 UTC