File indexing completed on 2025-01-19 09:47:47
0001
0002
0003
0004
0005
0006
0007
0008 #if !defined(BOOST_SPIRIT_PARSE_APRIL_16_2006_0442PM)
0009 #define BOOST_SPIRIT_PARSE_APRIL_16_2006_0442PM
0010
0011 #if defined(_MSC_VER)
0012 #pragma once
0013 #endif
0014
0015 #include <boost/spirit/home/support/context.hpp>
0016 #include <boost/spirit/home/support/nonterminal/locals.hpp>
0017 #include <boost/spirit/home/qi/detail/parse.hpp>
0018 #include <boost/iterator/iterator_concepts.hpp>
0019
0020 namespace boost { namespace spirit { namespace qi
0021 {
0022
0023 template <typename Iterator, typename Expr>
0024 inline bool
0025 parse(
0026 Iterator& first
0027 , Iterator last
0028 , Expr const& expr)
0029 {
0030
0031
0032
0033
0034 BOOST_CONCEPT_ASSERT((boost_concepts::ReadableIteratorConcept<Iterator>));
0035 BOOST_CONCEPT_ASSERT((boost_concepts::ForwardTraversalConcept<Iterator>));
0036
0037 return detail::parse_impl<Expr>::call(first, last, expr);
0038 }
0039
0040 template <typename Iterator, typename Expr>
0041 inline bool
0042 parse(
0043 Iterator const& first_
0044 , Iterator last
0045 , Expr const& expr)
0046 {
0047 Iterator first = first_;
0048 return qi::parse(first, last, expr);
0049 }
0050
0051
0052 namespace detail
0053 {
0054 template <typename T>
0055 struct make_context
0056 {
0057 typedef context<fusion::cons<T&>, locals<> > type;
0058 };
0059
0060 template <>
0061 struct make_context<unused_type>
0062 {
0063 typedef unused_type type;
0064 };
0065 }
0066
0067 template <typename Iterator, typename Expr, typename Attr>
0068 inline bool
0069 parse(
0070 Iterator& first
0071 , Iterator last
0072 , Expr const& expr
0073 , Attr& attr)
0074 {
0075
0076
0077
0078
0079 BOOST_CONCEPT_ASSERT((boost_concepts::ReadableIteratorConcept<Iterator>));
0080 BOOST_CONCEPT_ASSERT((boost_concepts::ForwardTraversalConcept<Iterator>));
0081
0082
0083
0084
0085 BOOST_SPIRIT_ASSERT_MATCH(qi::domain, Expr);
0086
0087 typename detail::make_context<Attr>::type context(attr);
0088 return compile<qi::domain>(expr).parse(first, last, context, unused, attr);
0089 }
0090
0091 template <typename Iterator, typename Expr, typename Attr>
0092 inline bool
0093 parse(
0094 Iterator const& first_
0095 , Iterator last
0096 , Expr const& expr
0097 , Attr& attr)
0098 {
0099 Iterator first = first_;
0100 return qi::parse(first, last, expr, attr);
0101 }
0102
0103
0104 template <typename Iterator, typename Expr, typename Skipper>
0105 inline bool
0106 phrase_parse(
0107 Iterator& first
0108 , Iterator last
0109 , Expr const& expr
0110 , Skipper const& skipper
0111 , BOOST_SCOPED_ENUM(skip_flag) post_skip = skip_flag::postskip)
0112 {
0113
0114
0115
0116
0117 BOOST_CONCEPT_ASSERT((boost_concepts::ReadableIteratorConcept<Iterator>));
0118 BOOST_CONCEPT_ASSERT((boost_concepts::ForwardTraversalConcept<Iterator>));
0119
0120 return detail::phrase_parse_impl<Expr>::call(
0121 first, last, expr, skipper, post_skip);
0122 }
0123
0124 template <typename Iterator, typename Expr, typename Skipper>
0125 inline bool
0126 phrase_parse(
0127 Iterator const& first_
0128 , Iterator last
0129 , Expr const& expr
0130 , Skipper const& skipper
0131 , BOOST_SCOPED_ENUM(skip_flag) post_skip = skip_flag::postskip)
0132 {
0133 Iterator first = first_;
0134 return qi::phrase_parse(first, last, expr, skipper, post_skip);
0135 }
0136
0137
0138 template <typename Iterator, typename Expr, typename Skipper, typename Attr>
0139 inline bool
0140 phrase_parse(
0141 Iterator& first
0142 , Iterator last
0143 , Expr const& expr
0144 , Skipper const& skipper
0145 , BOOST_SCOPED_ENUM(skip_flag) post_skip
0146 , Attr& attr)
0147 {
0148
0149
0150
0151
0152 BOOST_CONCEPT_ASSERT((boost_concepts::ReadableIteratorConcept<Iterator>));
0153 BOOST_CONCEPT_ASSERT((boost_concepts::ForwardTraversalConcept<Iterator>));
0154
0155
0156
0157
0158
0159 BOOST_SPIRIT_ASSERT_MATCH(qi::domain, Expr);
0160 BOOST_SPIRIT_ASSERT_MATCH(qi::domain, Skipper);
0161
0162 typedef
0163 typename result_of::compile<qi::domain, Skipper>::type
0164 skipper_type;
0165 skipper_type const skipper_ = compile<qi::domain>(skipper);
0166
0167 typename detail::make_context<Attr>::type context(attr);
0168 if (!compile<qi::domain>(expr).parse(
0169 first, last, context, skipper_, attr))
0170 return false;
0171
0172 if (post_skip == skip_flag::postskip)
0173 qi::skip_over(first, last, skipper_);
0174 return true;
0175 }
0176
0177 template <typename Iterator, typename Expr, typename Skipper, typename Attr>
0178 inline bool
0179 phrase_parse(
0180 Iterator const& first_
0181 , Iterator last
0182 , Expr const& expr
0183 , Skipper const& skipper
0184 , BOOST_SCOPED_ENUM(skip_flag) post_skip
0185 , Attr& attr)
0186 {
0187 Iterator first = first_;
0188 return qi::phrase_parse(first, last, expr, skipper, post_skip, attr);
0189 }
0190
0191
0192 template <typename Iterator, typename Expr, typename Skipper, typename Attr>
0193 inline bool
0194 phrase_parse(
0195 Iterator& first
0196 , Iterator last
0197 , Expr const& expr
0198 , Skipper const& skipper
0199 , Attr& attr)
0200 {
0201 return qi::phrase_parse(first, last, expr, skipper, skip_flag::postskip, attr);
0202 }
0203
0204 template <typename Iterator, typename Expr, typename Skipper, typename Attr>
0205 inline bool
0206 phrase_parse(
0207 Iterator const& first_
0208 , Iterator last
0209 , Expr const& expr
0210 , Skipper const& skipper
0211 , Attr& attr)
0212 {
0213 Iterator first = first_;
0214 return qi::phrase_parse(first, last, expr, skipper, skip_flag::postskip, attr);
0215 }
0216 }}}
0217
0218 #endif
0219