File indexing completed on 2025-01-19 09:47:46
0001
0002
0003
0004
0005
0006
0007 #ifndef BOOST_SPIRIT_QI_OPERATOR_DIFFERENCE_HPP
0008 #define BOOST_SPIRIT_QI_OPERATOR_DIFFERENCE_HPP
0009
0010 #if defined(_MSC_VER)
0011 #pragma once
0012 #endif
0013
0014 #include <boost/spirit/home/qi/domain.hpp>
0015 #include <boost/spirit/home/qi/meta_compiler.hpp>
0016 #include <boost/spirit/home/qi/parser.hpp>
0017 #include <boost/spirit/home/qi/detail/attributes.hpp>
0018 #include <boost/spirit/home/support/info.hpp>
0019 #include <boost/spirit/home/support/has_semantic_action.hpp>
0020 #include <boost/spirit/home/support/handles_container.hpp>
0021 #include <boost/fusion/include/at.hpp>
0022 #include <boost/proto/operators.hpp>
0023 #include <boost/proto/tags.hpp>
0024
0025 namespace boost { namespace spirit
0026 {
0027
0028
0029
0030 template <>
0031 struct use_operator<qi::domain, proto::tag::minus>
0032 : mpl::true_ {};
0033 }}
0034
0035 namespace boost { namespace spirit { namespace qi
0036 {
0037 template <typename Left, typename Right>
0038 struct difference : binary_parser<difference<Left, Right> >
0039 {
0040 typedef Left left_type;
0041 typedef Right right_type;
0042
0043 template <typename Context, typename Iterator>
0044 struct attribute
0045 {
0046 typedef typename
0047 traits::attribute_of<left_type, Context, Iterator>::type
0048 type;
0049 };
0050
0051 difference(Left const& left_, Right const& right_)
0052 : left(left_), right(right_) {}
0053
0054 template <typename Iterator, typename Context
0055 , typename Skipper, typename Attribute>
0056 bool parse(Iterator& first, Iterator const& last
0057 , Context& context, Skipper const& skipper
0058 , Attribute& attr_) const
0059 {
0060
0061
0062
0063
0064
0065
0066
0067
0068 Iterator start = first;
0069 if (right.parse(first, last, context, skipper, unused))
0070 {
0071
0072 first = start;
0073 return false;
0074 }
0075
0076 return left.parse(first, last, context, skipper, attr_);
0077 }
0078
0079 template <typename Context>
0080 info what(Context& context) const
0081 {
0082 return info("difference",
0083 std::make_pair(left.what(context), right.what(context)));
0084 }
0085
0086 Left left;
0087 Right right;
0088 };
0089
0090
0091
0092
0093 template <typename Elements, typename Modifiers>
0094 struct make_composite<proto::tag::minus, Elements, Modifiers>
0095 : make_binary_composite<Elements, difference>
0096 {};
0097 }}}
0098
0099 namespace boost { namespace spirit { namespace traits
0100 {
0101
0102 template <typename Left, typename Right>
0103 struct has_semantic_action<qi::difference<Left, Right> >
0104 : binary_has_semantic_action<Left, Right> {};
0105
0106
0107 template <typename Left, typename Right, typename Attribute
0108 , typename Context, typename Iterator>
0109 struct handles_container<qi::difference<Left, Right>, Attribute, Context
0110 , Iterator>
0111 : binary_handles_container<Left, Right, Attribute, Context, Iterator> {};
0112 }}}
0113
0114 #endif