File indexing completed on 2025-01-31 10:02:35
0001
0002
0003
0004
0005
0006
0007
0008
0009 #if !defined(BOOST_SPIRIT_X3_CONFIX_MAY_30_2014_1819PM)
0010 #define BOOST_SPIRIT_X3_CONFIX_MAY_30_2014_1819PM
0011
0012 #include <boost/spirit/home/x3/core/parser.hpp>
0013
0014 namespace boost { namespace spirit { namespace x3
0015 {
0016 template<typename Prefix, typename Subject, typename Postfix>
0017 struct confix_directive :
0018 unary_parser<Subject, confix_directive<Prefix, Subject, Postfix>>
0019 {
0020 typedef unary_parser<
0021 Subject, confix_directive<Prefix, Subject, Postfix>> base_type;
0022 static bool const is_pass_through_unary = true;
0023 static bool const handles_container = Subject::handles_container;
0024
0025 constexpr confix_directive(Prefix const& prefix
0026 , Subject const& subject
0027 , Postfix const& postfix) :
0028 base_type(subject),
0029 prefix(prefix),
0030 postfix(postfix)
0031 {
0032 }
0033
0034 template<typename Iterator, typename Context
0035 , typename RContext, typename Attribute>
0036 bool parse(
0037 Iterator& first, Iterator const& last
0038 , Context const& context, RContext& rcontext, Attribute& attr) const
0039 {
0040 Iterator save = first;
0041
0042 if (!(prefix.parse(first, last, context, rcontext, unused) &&
0043 this->subject.parse(first, last, context, rcontext, attr) &&
0044 postfix.parse(first, last, context, rcontext, unused)))
0045 {
0046 first = save;
0047 return false;
0048 }
0049
0050 return true;
0051 }
0052
0053 Prefix prefix;
0054 Postfix postfix;
0055 };
0056
0057 template<typename Prefix, typename Postfix>
0058 struct confix_gen
0059 {
0060 template<typename Subject>
0061 constexpr confix_directive<
0062 Prefix, typename extension::as_parser<Subject>::value_type, Postfix>
0063 operator[](Subject const& subject) const
0064 {
0065 return { prefix, as_parser(subject), postfix };
0066 }
0067
0068 Prefix prefix;
0069 Postfix postfix;
0070 };
0071
0072
0073 template<typename Prefix, typename Postfix>
0074 constexpr confix_gen<typename extension::as_parser<Prefix>::value_type,
0075 typename extension::as_parser<Postfix>::value_type>
0076 confix(Prefix const& prefix, Postfix const& postfix)
0077 {
0078 return { as_parser(prefix), as_parser(postfix) };
0079 }
0080
0081 }}}
0082
0083 #endif