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