File indexing completed on 2025-01-18 09:52:30
0001
0002
0003
0004
0005
0006
0007 #ifndef BOOST_SPIRIT_REPOSITORY_QI_SEEK
0008 #define BOOST_SPIRIT_REPOSITORY_QI_SEEK
0009
0010
0011 #if defined(_MSC_VER)
0012 #pragma once
0013 #endif
0014
0015
0016 #include <boost/spirit/home/qi/meta_compiler.hpp>
0017 #include <boost/spirit/home/qi/parser.hpp>
0018 #include <boost/spirit/home/qi/detail/attributes.hpp>
0019 #include <boost/spirit/home/support/info.hpp>
0020 #include <boost/spirit/home/support/unused.hpp>
0021 #include <boost/spirit/home/support/has_semantic_action.hpp>
0022 #include <boost/spirit/home/support/handles_container.hpp>
0023 #include <boost/spirit/repository/home/support/seek.hpp>
0024
0025
0026 namespace boost { namespace spirit
0027 {
0028
0029
0030
0031
0032
0033 template <>
0034 struct use_directive<qi::domain, repository::tag::seek>
0035 : mpl::true_ {};
0036 }}
0037
0038
0039 namespace boost { namespace spirit { namespace repository {namespace qi
0040 {
0041 #ifndef BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
0042 using repository::seek;
0043 #endif
0044 using repository::seek_type;
0045
0046 template <typename Subject>
0047 struct seek_directive
0048 : spirit::qi::unary_parser<seek_directive<Subject> >
0049 {
0050 typedef Subject subject_type;
0051
0052 template <typename Context, typename Iterator>
0053 struct attribute
0054 {
0055 typedef typename
0056 traits::attribute_of<subject_type, Context, Iterator>::type
0057 type;
0058 };
0059
0060 seek_directive(Subject const& subject)
0061 : subject(subject)
0062 {}
0063
0064 template
0065 <
0066 typename Iterator, typename Context
0067 , typename Skipper, typename Attribute
0068 >
0069 bool parse
0070 (
0071 Iterator& first, Iterator const& last
0072 , Context& context, Skipper const& skipper
0073 , Attribute& attr
0074 ) const
0075 {
0076 for (Iterator it(first); ; ++it)
0077 {
0078 if (subject.parse(it, last, context, skipper, attr))
0079 {
0080 first = it;
0081 return true;
0082 }
0083
0084 if (it == last)
0085 return false;
0086 }
0087 }
0088
0089 template <typename Context>
0090 info what(Context& context) const
0091 {
0092 return info("seek", subject.what(context));
0093 }
0094
0095 Subject subject;
0096 };
0097 }}}}
0098
0099
0100 namespace boost { namespace spirit { namespace qi
0101 {
0102
0103
0104
0105 template <typename Subject, typename Modifiers>
0106 struct make_directive<repository::tag::seek, Subject, Modifiers>
0107 {
0108 typedef repository::qi::seek_directive<Subject> result_type;
0109
0110 result_type operator()(unused_type, Subject const& subject, unused_type) const
0111 {
0112 return result_type(subject);
0113 }
0114 };
0115 }}}
0116
0117
0118 namespace boost { namespace spirit { namespace traits
0119 {
0120
0121 template <typename Subject>
0122 struct has_semantic_action<repository::qi::seek_directive<Subject> >
0123 : unary_has_semantic_action<Subject> {};
0124
0125
0126 template <typename Subject, typename Attribute, typename Context
0127 , typename Iterator>
0128 struct handles_container<repository::qi::seek_directive<Subject>, Attribute
0129 , Context, Iterator>
0130 : unary_handles_container<Subject, Attribute, Context, Iterator> {};
0131 }}}
0132
0133
0134 #endif