/*============================================================================= Copyright (c) 2001-2010 Joel de Guzman Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ #if !defined(SPIRIT_SKIP_JANUARY_26_2008_0422PM) #define SPIRIT_SKIP_JANUARY_26_2008_0422PM #if defined(_MSC_VER) #pragma once #endif #include #include #include #include #include #include #include #include #include #include #include #include #include namespace boost { namespace spirit { /////////////////////////////////////////////////////////////////////////// // Enablers /////////////////////////////////////////////////////////////////////////// template <> struct use_directive // enables skip[p] : mpl::true_ {}; template struct use_directive > > : boost::spirit::traits::matches {}; template <> // enables *lazy* skip(s)[p] struct use_lazy_directive< qi::domain , tag::skip , 1 // arity > : mpl::true_ {}; }} namespace boost { namespace spirit { namespace qi { using spirit::skip; using spirit::skip_type; template struct reskip_parser : unary_parser > { typedef Subject subject_type; template struct attribute { typedef typename traits::attribute_of::type type; }; reskip_parser(Subject const& subject) : subject(subject) {} template bool parse(Iterator& first, Iterator const& last , Context& context, Skipper const& u // --> The skipper is reintroduced , Attribute& attr) const { return subject.parse(first, last, context , detail::get_skipper(u), attr); } template info what(Context& context) const { return info("skip", subject.what(context)); } Subject subject; }; template struct skip_parser : unary_parser > { typedef Subject subject_type; typedef Skipper skipper_type; template struct attribute { typedef typename traits::attribute_of::type type; }; skip_parser(Subject const& subject, Skipper const& skipper) : subject(subject), skipper(skipper) {} template bool parse(Iterator& first, Iterator const& last , Context& context, Skipper_ const& //skipper --> bypass the supplied skipper , Attribute& attr) const { return subject.parse(first, last, context, skipper, attr); } template info what(Context& context) const { return info("skip", subject.what(context)); } Subject subject; Skipper skipper; }; /////////////////////////////////////////////////////////////////////////// // Parser generators: make_xxx function (objects) /////////////////////////////////////////////////////////////////////////// template struct make_directive { typedef reskip_parser result_type; result_type operator()(unused_type, Subject const& subject, unused_type) const { return result_type(subject); } }; template struct make_directive< terminal_ex >, Subject, Modifiers> { typedef typename result_of::compile::type skipper_type; typedef skip_parser result_type; template result_type operator()(Terminal const& term, Subject const& subject , Modifiers const& modifiers) const { return result_type(subject , compile(fusion::at_c<0>(term.args), modifiers)); } }; }}} namespace boost { namespace spirit { namespace traits { template struct has_semantic_action > : unary_has_semantic_action {}; template struct has_semantic_action > : unary_has_semantic_action {}; }}} #endif