File indexing completed on 2025-01-31 10:02:36
0001
0002
0003
0004
0005
0006
0007
0008 #if !defined(BOOST_SPIRIT_X3_SKIP_JANUARY_26_2008_0422PM)
0009 #define BOOST_SPIRIT_X3_SKIP_JANUARY_26_2008_0422PM
0010
0011 #include <boost/spirit/home/x3/support/context.hpp>
0012 #include <boost/spirit/home/x3/support/unused.hpp>
0013 #include <boost/spirit/home/x3/core/skip_over.hpp>
0014 #include <boost/spirit/home/x3/core/parser.hpp>
0015 #include <boost/utility/enable_if.hpp>
0016
0017 namespace boost { namespace spirit { namespace x3
0018 {
0019 template <typename Subject>
0020 struct reskip_directive : unary_parser<Subject, reskip_directive<Subject>>
0021 {
0022 typedef unary_parser<Subject, reskip_directive<Subject>> base_type;
0023 static bool const is_pass_through_unary = true;
0024 static bool const handles_container = Subject::handles_container;
0025
0026 constexpr reskip_directive(Subject const& subject)
0027 : base_type(subject) {}
0028
0029 template <typename Iterator, typename Context
0030 , typename RContext, typename Attribute>
0031 typename disable_if<has_skipper<Context>, bool>::type
0032 parse(Iterator& first, Iterator const& last
0033 , Context const& context, RContext& rcontext, Attribute& attr) const
0034 {
0035 auto const& skipper =
0036 detail::get_unused_skipper(x3::get<skipper_tag>(context));
0037
0038 return this->subject.parse(
0039 first, last
0040 , make_context<skipper_tag>(skipper, context)
0041 , rcontext
0042 , attr);
0043 }
0044 template <typename Iterator, typename Context
0045 , typename RContext, typename Attribute>
0046 typename enable_if<has_skipper<Context>, bool>::type
0047 parse(Iterator& first, Iterator const& last
0048 , Context const& context, RContext& rcontext, Attribute& attr) const
0049 {
0050 return this->subject.parse(
0051 first, last
0052 , context
0053 , rcontext
0054 , attr);
0055 }
0056 };
0057
0058 template <typename Subject, typename Skipper>
0059 struct skip_directive : unary_parser<Subject, skip_directive<Subject, Skipper>>
0060 {
0061 typedef unary_parser<Subject, skip_directive<Subject, Skipper>> base_type;
0062 static bool const is_pass_through_unary = true;
0063 static bool const handles_container = Subject::handles_container;
0064
0065 constexpr skip_directive(Subject const& subject, Skipper const& skipper)
0066 : base_type(subject)
0067 , skipper(skipper)
0068 {}
0069
0070 template <typename Iterator, typename Context
0071 , typename RContext, typename Attribute>
0072 bool parse(Iterator& first, Iterator const& last
0073 , Context const& context, RContext& rcontext, Attribute& attr) const
0074 {
0075 return this->subject.parse(
0076 first, last
0077 , make_context<skipper_tag>(skipper, context)
0078 , rcontext
0079 , attr);
0080 }
0081
0082 Skipper const skipper;
0083 };
0084
0085 struct reskip_gen
0086 {
0087 template <typename Skipper>
0088 struct skip_gen
0089 {
0090 constexpr skip_gen(Skipper const& skipper)
0091 : skipper_(skipper) {}
0092
0093 template <typename Subject>
0094 constexpr skip_directive<typename extension::as_parser<Subject>::value_type, Skipper>
0095 operator[](Subject const& subject) const
0096 {
0097 return { as_parser(subject), skipper_ };
0098 }
0099
0100 Skipper skipper_;
0101 };
0102
0103 template <typename Skipper>
0104 constexpr skip_gen<Skipper> const operator()(Skipper const& skipper) const
0105 {
0106 return { skipper };
0107 }
0108
0109 template <typename Subject>
0110 constexpr reskip_directive<typename extension::as_parser<Subject>::value_type>
0111 operator[](Subject const& subject) const
0112 {
0113 return { as_parser(subject) };
0114 }
0115 };
0116
0117 constexpr auto skip = reskip_gen{};
0118 }}}
0119
0120 #endif