annotate DEPENDENCIES/generic/include/boost/spirit/home/qi/parse.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents 2665513ce2d3
children
rev   line source
Chris@16 1 /*=============================================================================
Chris@16 2 Copyright (c) 2001-2011 Joel de Guzman
Chris@16 3 Copyright (c) 2001-2011 Hartmut Kaiser
Chris@16 4
Chris@16 5 Distributed under the Boost Software License, Version 1.0. (See accompanying
Chris@16 6 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Chris@16 7 =============================================================================*/
Chris@16 8 #if !defined(BOOST_SPIRIT_PARSE_APRIL_16_2006_0442PM)
Chris@16 9 #define BOOST_SPIRIT_PARSE_APRIL_16_2006_0442PM
Chris@16 10
Chris@16 11 #if defined(_MSC_VER)
Chris@16 12 #pragma once
Chris@16 13 #endif
Chris@16 14
Chris@16 15 #include <boost/spirit/home/support/context.hpp>
Chris@16 16 #include <boost/spirit/home/support/nonterminal/locals.hpp>
Chris@16 17 #include <boost/spirit/home/qi/detail/parse.hpp>
Chris@16 18 #include <boost/concept_check.hpp>
Chris@16 19
Chris@16 20 namespace boost { namespace spirit { namespace qi
Chris@16 21 {
Chris@16 22 ///////////////////////////////////////////////////////////////////////////
Chris@16 23 template <typename Iterator, typename Expr>
Chris@16 24 inline bool
Chris@16 25 parse(
Chris@16 26 Iterator& first
Chris@16 27 , Iterator last
Chris@16 28 , Expr const& expr)
Chris@16 29 {
Chris@16 30 // Make sure the iterator is at least a forward_iterator. If you got a
Chris@16 31 // compilation error here, then you are using an input_iterator while
Chris@16 32 // calling this function, you need to supply at least a
Chris@16 33 // forward_iterator instead.
Chris@16 34 BOOST_CONCEPT_ASSERT((ForwardIterator<Iterator>));
Chris@16 35
Chris@16 36 return detail::parse_impl<Expr>::call(first, last, expr);
Chris@16 37 }
Chris@16 38
Chris@16 39 template <typename Iterator, typename Expr>
Chris@16 40 inline bool
Chris@16 41 parse(
Chris@16 42 Iterator const& first_
Chris@16 43 , Iterator last
Chris@16 44 , Expr const& expr)
Chris@16 45 {
Chris@16 46 Iterator first = first_;
Chris@16 47 return qi::parse(first, last, expr);
Chris@16 48 }
Chris@16 49
Chris@16 50 ///////////////////////////////////////////////////////////////////////////
Chris@16 51 namespace detail
Chris@16 52 {
Chris@16 53 template <typename T>
Chris@16 54 struct make_context
Chris@16 55 {
Chris@16 56 typedef context<fusion::cons<T&>, locals<> > type;
Chris@16 57 };
Chris@16 58
Chris@16 59 template <>
Chris@16 60 struct make_context<unused_type>
Chris@16 61 {
Chris@16 62 typedef unused_type type;
Chris@16 63 };
Chris@16 64 }
Chris@16 65
Chris@16 66 template <typename Iterator, typename Expr, typename Attr>
Chris@16 67 inline bool
Chris@16 68 parse(
Chris@16 69 Iterator& first
Chris@16 70 , Iterator last
Chris@16 71 , Expr const& expr
Chris@16 72 , Attr& attr)
Chris@16 73 {
Chris@16 74 // Make sure the iterator is at least a forward_iterator. If you got a
Chris@16 75 // compilation error here, then you are using an input_iterator while
Chris@16 76 // calling this function, you need to supply at least a
Chris@16 77 // forward_iterator instead.
Chris@16 78 BOOST_CONCEPT_ASSERT((ForwardIterator<Iterator>));
Chris@16 79
Chris@16 80 // Report invalid expression error as early as possible.
Chris@16 81 // If you got an error_invalid_expression error message here,
Chris@16 82 // then the expression (expr) is not a valid spirit qi expression.
Chris@16 83 BOOST_SPIRIT_ASSERT_MATCH(qi::domain, Expr);
Chris@16 84
Chris@16 85 typename detail::make_context<Attr>::type context(attr);
Chris@16 86 return compile<qi::domain>(expr).parse(first, last, context, unused, attr);
Chris@16 87 }
Chris@16 88
Chris@16 89 template <typename Iterator, typename Expr, typename Attr>
Chris@16 90 inline bool
Chris@16 91 parse(
Chris@16 92 Iterator const& first_
Chris@16 93 , Iterator last
Chris@16 94 , Expr const& expr
Chris@16 95 , Attr& attr)
Chris@16 96 {
Chris@16 97 Iterator first = first_;
Chris@16 98 return qi::parse(first, last, expr, attr);
Chris@16 99 }
Chris@16 100
Chris@16 101 ///////////////////////////////////////////////////////////////////////////
Chris@16 102 template <typename Iterator, typename Expr, typename Skipper>
Chris@16 103 inline bool
Chris@16 104 phrase_parse(
Chris@16 105 Iterator& first
Chris@16 106 , Iterator last
Chris@16 107 , Expr const& expr
Chris@16 108 , Skipper const& skipper
Chris@16 109 , BOOST_SCOPED_ENUM(skip_flag) post_skip = skip_flag::postskip)
Chris@16 110 {
Chris@16 111 // Make sure the iterator is at least a forward_iterator. If you got a
Chris@16 112 // compilation error here, then you are using an input_iterator while
Chris@16 113 // calling this function, you need to supply at least a
Chris@16 114 // forward_iterator instead.
Chris@16 115 BOOST_CONCEPT_ASSERT((ForwardIterator<Iterator>));
Chris@16 116
Chris@16 117 return detail::phrase_parse_impl<Expr>::call(
Chris@16 118 first, last, expr, skipper, post_skip);
Chris@16 119 }
Chris@16 120
Chris@16 121 template <typename Iterator, typename Expr, typename Skipper>
Chris@16 122 inline bool
Chris@16 123 phrase_parse(
Chris@16 124 Iterator const& first_
Chris@16 125 , Iterator last
Chris@16 126 , Expr const& expr
Chris@16 127 , Skipper const& skipper
Chris@16 128 , BOOST_SCOPED_ENUM(skip_flag) post_skip = skip_flag::postskip)
Chris@16 129 {
Chris@16 130 Iterator first = first_;
Chris@16 131 return qi::phrase_parse(first, last, expr, skipper, post_skip);
Chris@16 132 }
Chris@16 133
Chris@16 134 ///////////////////////////////////////////////////////////////////////////
Chris@16 135 template <typename Iterator, typename Expr, typename Skipper, typename Attr>
Chris@16 136 inline bool
Chris@16 137 phrase_parse(
Chris@16 138 Iterator& first
Chris@16 139 , Iterator last
Chris@16 140 , Expr const& expr
Chris@16 141 , Skipper const& skipper
Chris@16 142 , BOOST_SCOPED_ENUM(skip_flag) post_skip
Chris@16 143 , Attr& attr)
Chris@16 144 {
Chris@16 145 // Make sure the iterator is at least a forward_iterator. If you got a
Chris@16 146 // compilation error here, then you are using an input_iterator while
Chris@16 147 // calling this function, you need to supply at least a
Chris@16 148 // forward_iterator instead.
Chris@16 149 BOOST_CONCEPT_ASSERT((ForwardIterator<Iterator>));
Chris@16 150
Chris@16 151 // Report invalid expression error as early as possible.
Chris@16 152 // If you got an error_invalid_expression error message here,
Chris@16 153 // then either the expression (expr) or skipper is not a valid
Chris@16 154 // spirit qi expression.
Chris@16 155 BOOST_SPIRIT_ASSERT_MATCH(qi::domain, Expr);
Chris@16 156 BOOST_SPIRIT_ASSERT_MATCH(qi::domain, Skipper);
Chris@16 157
Chris@16 158 typedef
Chris@16 159 typename result_of::compile<qi::domain, Skipper>::type
Chris@16 160 skipper_type;
Chris@16 161 skipper_type const skipper_ = compile<qi::domain>(skipper);
Chris@16 162
Chris@16 163 typename detail::make_context<Attr>::type context(attr);
Chris@16 164 if (!compile<qi::domain>(expr).parse(
Chris@16 165 first, last, context, skipper_, attr))
Chris@16 166 return false;
Chris@16 167
Chris@16 168 if (post_skip == skip_flag::postskip)
Chris@16 169 qi::skip_over(first, last, skipper_);
Chris@16 170 return true;
Chris@16 171 }
Chris@16 172
Chris@16 173 template <typename Iterator, typename Expr, typename Skipper, typename Attr>
Chris@16 174 inline bool
Chris@16 175 phrase_parse(
Chris@16 176 Iterator const& first_
Chris@16 177 , Iterator last
Chris@16 178 , Expr const& expr
Chris@16 179 , Skipper const& skipper
Chris@16 180 , BOOST_SCOPED_ENUM(skip_flag) post_skip
Chris@16 181 , Attr& attr)
Chris@16 182 {
Chris@16 183 Iterator first = first_;
Chris@16 184 return qi::phrase_parse(first, last, expr, skipper, post_skip, attr);
Chris@16 185 }
Chris@16 186
Chris@16 187 ///////////////////////////////////////////////////////////////////////////
Chris@16 188 template <typename Iterator, typename Expr, typename Skipper, typename Attr>
Chris@16 189 inline bool
Chris@16 190 phrase_parse(
Chris@16 191 Iterator& first
Chris@16 192 , Iterator last
Chris@16 193 , Expr const& expr
Chris@16 194 , Skipper const& skipper
Chris@16 195 , Attr& attr)
Chris@16 196 {
Chris@16 197 return qi::phrase_parse(first, last, expr, skipper, skip_flag::postskip, attr);
Chris@16 198 }
Chris@16 199
Chris@16 200 template <typename Iterator, typename Expr, typename Skipper, typename Attr>
Chris@16 201 inline bool
Chris@16 202 phrase_parse(
Chris@16 203 Iterator const& first_
Chris@16 204 , Iterator last
Chris@16 205 , Expr const& expr
Chris@16 206 , Skipper const& skipper
Chris@16 207 , Attr& attr)
Chris@16 208 {
Chris@16 209 Iterator first = first_;
Chris@16 210 return qi::phrase_parse(first, last, expr, skipper, skip_flag::postskip, attr);
Chris@16 211 }
Chris@16 212 }}}
Chris@16 213
Chris@16 214 #endif
Chris@16 215