File indexing completed on 2025-01-18 09:52:29
0001
0002
0003
0004
0005
0006 #if !defined(BOOST_SPIRIT_REPOSITORY_QI_CONFIX_JUN_22_2009_1041AM)
0007 #define BOOST_SPIRIT_REPOSITORY_QI_CONFIX_JUN_22_2009_1041AM
0008
0009 #if defined(_MSC_VER)
0010 #pragma once
0011 #endif
0012
0013 #include <boost/spirit/home/qi/domain.hpp>
0014 #include <boost/spirit/home/qi/meta_compiler.hpp>
0015 #include <boost/spirit/home/qi/auxiliary/lazy.hpp>
0016 #include <boost/spirit/home/support/common_terminals.hpp>
0017 #include <boost/spirit/home/support/info.hpp>
0018 #include <boost/spirit/home/support/unused.hpp>
0019 #include <boost/spirit/home/qi/detail/attributes.hpp>
0020
0021 #include <boost/spirit/repository/home/support/confix.hpp>
0022
0023 #include <boost/fusion/include/vector.hpp>
0024 #include <boost/mpl/or.hpp>
0025
0026
0027 namespace boost { namespace spirit
0028 {
0029
0030
0031
0032
0033
0034 template <typename Prefix, typename Suffix>
0035 struct use_directive<qi::domain
0036 , terminal_ex<repository::tag::confix, fusion::vector2<Prefix, Suffix> > >
0037 : mpl::true_ {};
0038
0039
0040 template <>
0041 struct use_lazy_directive<qi::domain, repository::tag::confix, 2>
0042 : mpl::true_ {};
0043
0044 }}
0045
0046
0047 namespace boost { namespace spirit { namespace repository { namespace qi
0048 {
0049 #ifndef BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
0050 using repository::confix;
0051 #endif
0052 using repository::confix_type;
0053
0054
0055
0056 template <typename Subject, typename Prefix, typename Suffix>
0057 struct confix_parser
0058 : spirit::qi::unary_parser<confix_parser<Subject, Prefix, Suffix> >
0059 {
0060 typedef Subject subject_type;
0061
0062 template <typename Context, typename Iterator>
0063 struct attribute
0064 : traits::attribute_of<subject_type, Context, Iterator>
0065 {};
0066
0067 confix_parser(Subject const& subject, Prefix const& prefix
0068 , Suffix const& suffix)
0069 : subject(subject), prefix(prefix), suffix(suffix) {}
0070
0071 template <typename Iterator, typename Context
0072 , typename Skipper, typename Attribute>
0073 bool parse(Iterator& first, Iterator const& last
0074 , Context& context, Skipper const& skipper
0075 , Attribute& attr) const
0076 {
0077 Iterator iter = first;
0078
0079 if (!(prefix.parse(iter, last, context, skipper, unused) &&
0080 subject.parse(iter, last, context, skipper, attr) &&
0081 suffix.parse(iter, last, context, skipper, unused)))
0082 {
0083 return false;
0084 }
0085
0086 first = iter;
0087 return true;
0088 }
0089
0090 template <typename Context>
0091 info what(Context const& ctx) const
0092 {
0093 return info("confix", subject.what(ctx));
0094 }
0095
0096 Subject subject;
0097 Prefix prefix;
0098 Suffix suffix;
0099 };
0100
0101 }}}}
0102
0103
0104 namespace boost { namespace spirit { namespace qi
0105 {
0106
0107
0108
0109
0110
0111 template <typename Prefix, typename Suffix, typename Subject
0112 , typename Modifiers>
0113 struct make_directive<
0114 terminal_ex<repository::tag::confix, fusion::vector2<Prefix, Suffix> >
0115 , Subject, Modifiers>
0116 {
0117 typedef typename
0118 result_of::compile<qi::domain, Prefix, Modifiers>::type
0119 prefix_type;
0120 typedef typename
0121 result_of::compile<qi::domain, Suffix, Modifiers>::type
0122 suffix_type;
0123
0124 typedef repository::qi::confix_parser<
0125 Subject, prefix_type, suffix_type> result_type;
0126
0127 template <typename Terminal>
0128 result_type operator()(Terminal const& term, Subject const& subject
0129 , Modifiers const& modifiers) const
0130 {
0131 return result_type(subject
0132 , compile<qi::domain>(fusion::at_c<0>(term.args), modifiers)
0133 , compile<qi::domain>(fusion::at_c<1>(term.args), modifiers));
0134 }
0135 };
0136
0137 }}}
0138
0139 namespace boost { namespace spirit { namespace traits
0140 {
0141 template <typename Subject, typename Prefix, typename Suffix>
0142 struct has_semantic_action<
0143 repository::qi::confix_parser<Subject, Prefix, Suffix> >
0144 : mpl::or_<
0145 has_semantic_action<Subject>
0146 , has_semantic_action<Prefix>
0147 , has_semantic_action<Suffix>
0148 > {};
0149 }}}
0150
0151 #endif
0152