Ticket #8537: spirit.qi.skip.patch

File spirit.qi.skip.patch, 6.7 KB (added by K-ballo <kaballo86@…>, 9 years ago)

Tentative fix patch

  • boost/spirit/home/qi/detail/unused_skipper.hpp

     
    1111#endif
    1212
    1313#include <boost/spirit/home/support/unused.hpp>
     14#include <boost/mpl/bool.hpp>
    1415
    1516namespace boost { namespace spirit { namespace qi { namespace detail
    1617{
     
    2526        // silence MSVC warning C4512: assignment operator could not be generated
    2627        unused_skipper& operator= (unused_skipper const&);
    2728    };
     29   
     30    template <typename Skipper>
     31    struct is_unused_skipper
     32      : mpl::false_ {};
    2833
     34    template <typename Skipper>
     35    struct is_unused_skipper<unused_skipper<Skipper>>
     36      : mpl::true_ {};
     37
     38    template <>
     39    struct is_unused_skipper<unused_type>
     40      : mpl::true_ {};
     41
    2942    // If a surrounding lexeme[] directive was specified, the current
    3043    // skipper is of the type unused_skipper. In this case we
    3144    // re-activate the skipper which was active before the skip[]
  • boost/spirit/home/qi/directive/lexeme.hpp

     
    2020#include <boost/spirit/home/qi/detail/attributes.hpp>
    2121#include <boost/spirit/home/support/info.hpp>
    2222#include <boost/spirit/home/support/handles_container.hpp>
     23#include <boost/utility/enable_if.hpp>
    2324
    2425namespace boost { namespace spirit
    2526{
     
    5556
    5657        template <typename Iterator, typename Context
    5758          , typename Skipper, typename Attribute>
    58         bool parse(Iterator& first, Iterator const& last
     59        typename disable_if<detail::is_unused_skipper<Skipper>, bool>::type
     60        parse(Iterator& first, Iterator const& last
    5961          , Context& context, Skipper const& skipper
    6062          , Attribute& attr_) const
    6163        {
     
    6365            return subject.parse(first, last, context
    6466              , detail::unused_skipper<Skipper>(skipper), attr_);
    6567        }
     68        template <typename Iterator, typename Context
     69          , typename Skipper, typename Attribute>
     70        typename enable_if<detail::is_unused_skipper<Skipper>, bool>::type
     71        parse(Iterator& first, Iterator const& last
     72          , Context& context, Skipper const& skipper
     73          , Attribute& attr_) const
     74        {
     75            //  no need to pre-skip if skipper is unused
     76            //- qi::skip_over(first, last, skipper);
     77            return subject.parse(first, last, context
     78              , skipper, attr_);
     79        }
    6680
    6781        template <typename Context>
    6882        info what(Context& context) const
  • boost/spirit/home/qi/directive/no_skip.hpp

     
    2222#include <boost/spirit/home/support/info.hpp>
    2323#include <boost/spirit/home/support/has_semantic_action.hpp>
    2424#include <boost/spirit/home/support/handles_container.hpp>
     25#include <boost/utility/enable_if.hpp>
    2526
    2627namespace boost { namespace spirit
    2728{
     
    5859
    5960        template <typename Iterator, typename Context
    6061          , typename Skipper, typename Attribute>
    61         bool parse(Iterator& first, Iterator const& last
     62        typename disable_if<detail::is_unused_skipper<Skipper>, bool>::type
     63        parse(Iterator& first, Iterator const& last
    6264          , Context& context, Skipper const& skipper
    6365          , Attribute& attr_) const
    6466        {
    6567            return subject.parse(first, last, context
    6668              , detail::unused_skipper<Skipper>(skipper), attr_);
    6769        }
     70        template <typename Iterator, typename Context
     71          , typename Skipper, typename Attribute>
     72        typename enable_if<detail::is_unused_skipper<Skipper>, bool>::type
     73        parse(Iterator& first, Iterator const& last
     74          , Context& context, Skipper const& skipper
     75          , Attribute& attr_) const
     76        {
     77            return subject.parse(first, last, context
     78              , skipper, attr_);
     79        }
    6880
    6981        template <typename Context>
    7082        info what(Context& context) const
  • boost/spirit/home/qi/directive/skip.hpp

     
    2626#include <boost/spirit/home/support/handles_container.hpp>
    2727#include <boost/fusion/include/at.hpp>
    2828#include <boost/fusion/include/vector.hpp>
     29#include <boost/utility/enable_if.hpp>
    2930
    3031namespace boost { namespace spirit
    3132{
     
    7576
    7677        template <typename Iterator, typename Context
    7778          , typename Skipper, typename Attribute>
    78         bool parse(Iterator& first, Iterator const& last
     79        typename enable_if<detail::is_unused_skipper<Skipper>, bool>::type
     80        parse(Iterator& first, Iterator const& last
    7981          , Context& context, Skipper const& u // --> The skipper is reintroduced
    8082          , Attribute& attr_) const
    8183        {
    8284            return subject.parse(first, last, context
    8385              , detail::get_skipper(u), attr_);
    8486        }
     87        template <typename Iterator, typename Context
     88          , typename Skipper, typename Attribute>
     89        typename disable_if<detail::is_unused_skipper<Skipper>, bool>::type
     90        parse(Iterator& first, Iterator const& last
     91          , Context& context, Skipper const& skipper
     92          , Attribute& attr_) const
     93        {
     94            return subject.parse(first, last, context
     95              , skipper, attr_);
     96        }
    8597
    8698        template <typename Context>
    8799        info what(Context& context) const
  • libs/spirit/test/qi/skip.cpp

     
    3939        BOOST_TEST((test("ab c d", lexeme[lit('a') >> 'b' >> skip[lit('c') >> 'd']], space)));
    4040        BOOST_TEST((test("abcd", lexeme[lit('a') >> 'b' >> skip[lit('c') >> 'd']], space)));
    4141        BOOST_TEST(!(test("a bcd", lexeme[lit('a') >> 'b' >> skip[lit('c') >> 'd']], space)));
     42       
     43        BOOST_TEST((test("ab c d", lexeme[lexeme[lit('a') >> 'b' >> skip[lit('c') >> 'd']]], space)));
     44        BOOST_TEST((test("abcd", lexeme[lexeme[lit('a') >> 'b' >> skip[lit('c') >> 'd']]], space)));
     45        BOOST_TEST(!(test("a bcd", lexeme[lexeme[lit('a') >> 'b' >> skip[lit('c') >> 'd']]], space)));
    4246    }
    4347
    4448    { // lazy skip