Ticket #8537: spirit.qi.skip.patch
File spirit.qi.skip.patch, 6.7 KB (added by , 9 years ago) |
---|
-
boost/spirit/home/qi/detail/unused_skipper.hpp
11 11 #endif 12 12 13 13 #include <boost/spirit/home/support/unused.hpp> 14 #include <boost/mpl/bool.hpp> 14 15 15 16 namespace boost { namespace spirit { namespace qi { namespace detail 16 17 { … … 25 26 // silence MSVC warning C4512: assignment operator could not be generated 26 27 unused_skipper& operator= (unused_skipper const&); 27 28 }; 29 30 template <typename Skipper> 31 struct is_unused_skipper 32 : mpl::false_ {}; 28 33 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 29 42 // If a surrounding lexeme[] directive was specified, the current 30 43 // skipper is of the type unused_skipper. In this case we 31 44 // re-activate the skipper which was active before the skip[] -
boost/spirit/home/qi/directive/lexeme.hpp
20 20 #include <boost/spirit/home/qi/detail/attributes.hpp> 21 21 #include <boost/spirit/home/support/info.hpp> 22 22 #include <boost/spirit/home/support/handles_container.hpp> 23 #include <boost/utility/enable_if.hpp> 23 24 24 25 namespace boost { namespace spirit 25 26 { … … 55 56 56 57 template <typename Iterator, typename Context 57 58 , 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 59 61 , Context& context, Skipper const& skipper 60 62 , Attribute& attr_) const 61 63 { … … 63 65 return subject.parse(first, last, context 64 66 , detail::unused_skipper<Skipper>(skipper), attr_); 65 67 } 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 } 66 80 67 81 template <typename Context> 68 82 info what(Context& context) const -
boost/spirit/home/qi/directive/no_skip.hpp
22 22 #include <boost/spirit/home/support/info.hpp> 23 23 #include <boost/spirit/home/support/has_semantic_action.hpp> 24 24 #include <boost/spirit/home/support/handles_container.hpp> 25 #include <boost/utility/enable_if.hpp> 25 26 26 27 namespace boost { namespace spirit 27 28 { … … 58 59 59 60 template <typename Iterator, typename Context 60 61 , 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 62 64 , Context& context, Skipper const& skipper 63 65 , Attribute& attr_) const 64 66 { 65 67 return subject.parse(first, last, context 66 68 , detail::unused_skipper<Skipper>(skipper), attr_); 67 69 } 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 } 68 80 69 81 template <typename Context> 70 82 info what(Context& context) const -
boost/spirit/home/qi/directive/skip.hpp
26 26 #include <boost/spirit/home/support/handles_container.hpp> 27 27 #include <boost/fusion/include/at.hpp> 28 28 #include <boost/fusion/include/vector.hpp> 29 #include <boost/utility/enable_if.hpp> 29 30 30 31 namespace boost { namespace spirit 31 32 { … … 75 76 76 77 template <typename Iterator, typename Context 77 78 , 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 79 81 , Context& context, Skipper const& u // --> The skipper is reintroduced 80 82 , Attribute& attr_) const 81 83 { 82 84 return subject.parse(first, last, context 83 85 , detail::get_skipper(u), attr_); 84 86 } 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 } 85 97 86 98 template <typename Context> 87 99 info what(Context& context) const -
libs/spirit/test/qi/skip.cpp
39 39 BOOST_TEST((test("ab c d", lexeme[lit('a') >> 'b' >> skip[lit('c') >> 'd']], space))); 40 40 BOOST_TEST((test("abcd", lexeme[lit('a') >> 'b' >> skip[lit('c') >> 'd']], space))); 41 41 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))); 42 46 } 43 47 44 48 { // lazy skip