annotate DEPENDENCIES/generic/include/boost/spirit/home/qi/parse_attr.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 // Copyright (c) 2001-2011 Hartmut Kaiser
Chris@16 2 // Copyright (c) 2001-2011 Joel de Guzman
Chris@16 3 // Copyright (c) 2009 Carl Barron
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_PP_IS_ITERATING)
Chris@16 9
Chris@16 10 #if !defined(BOOST_SPIRIT_PARSE_ATTR_APRIL_24_2009_1043AM)
Chris@16 11 #define BOOST_SPIRIT_PARSE_ATTR_APRIL_24_2009_1043AM
Chris@16 12
Chris@16 13 #include <boost/spirit/home/qi/parse.hpp>
Chris@16 14
Chris@16 15 #include <boost/fusion/include/vector.hpp>
Chris@16 16 #include <boost/preprocessor/cat.hpp>
Chris@16 17 #include <boost/preprocessor/iterate.hpp>
Chris@16 18 #include <boost/preprocessor/repetition/enum.hpp>
Chris@16 19 #include <boost/preprocessor/repetition/enum_params.hpp>
Chris@16 20 #include <boost/preprocessor/repetition/enum_binary_params.hpp>
Chris@16 21
Chris@16 22 #define BOOST_PP_FILENAME_1 <boost/spirit/home/qi/parse_attr.hpp>
Chris@16 23 #define BOOST_PP_ITERATION_LIMITS (2, SPIRIT_ARGUMENTS_LIMIT)
Chris@16 24 #include BOOST_PP_ITERATE()
Chris@16 25
Chris@16 26 #endif
Chris@16 27
Chris@16 28 ///////////////////////////////////////////////////////////////////////////////
Chris@16 29 //
Chris@16 30 // Preprocessor vertical repetition code
Chris@16 31 //
Chris@16 32 ///////////////////////////////////////////////////////////////////////////////
Chris@16 33 #else // defined(BOOST_PP_IS_ITERATING)
Chris@16 34
Chris@16 35 #define N BOOST_PP_ITERATION()
Chris@16 36 #define BOOST_SPIRIT_QI_ATTRIBUTE_REFERENCE(z, n, A) BOOST_PP_CAT(A, n)&
Chris@16 37
Chris@16 38 namespace boost { namespace spirit { namespace qi
Chris@16 39 {
Chris@16 40 ///////////////////////////////////////////////////////////////////////////
Chris@16 41 template <typename Iterator, typename Expr
Chris@16 42 , BOOST_PP_ENUM_PARAMS(N, typename A)>
Chris@16 43 inline bool
Chris@16 44 parse(
Chris@16 45 Iterator& first
Chris@16 46 , Iterator last
Chris@16 47 , Expr const& expr
Chris@16 48 , BOOST_PP_ENUM_BINARY_PARAMS(N, A, & attr))
Chris@16 49 {
Chris@16 50 // Make sure the iterator is at least a forward_iterator. If you got an
Chris@16 51 // compilation error here, then you are using an input_iterator while
Chris@16 52 // calling this function, you need to supply at least a
Chris@16 53 // forward_iterator instead.
Chris@16 54 BOOST_CONCEPT_ASSERT((ForwardIterator<Iterator>));
Chris@16 55
Chris@16 56 // Report invalid expression error as early as possible.
Chris@16 57 // If you got an error_invalid_expression error message here,
Chris@16 58 // then the expression (expr) is not a valid spirit qi expression.
Chris@16 59 BOOST_SPIRIT_ASSERT_MATCH(qi::domain, Expr);
Chris@16 60
Chris@16 61 typedef fusion::vector<
Chris@16 62 BOOST_PP_ENUM(N, BOOST_SPIRIT_QI_ATTRIBUTE_REFERENCE, A)
Chris@16 63 > vector_type;
Chris@16 64
Chris@16 65 vector_type lattr (BOOST_PP_ENUM_PARAMS(N, attr));
Chris@16 66 return compile<qi::domain>(expr).parse(first, last, unused, unused, lattr);
Chris@16 67 }
Chris@16 68
Chris@16 69 template <typename Iterator, typename Expr
Chris@16 70 , BOOST_PP_ENUM_PARAMS(N, typename A)>
Chris@16 71 inline bool
Chris@16 72 parse(
Chris@16 73 Iterator const& first_
Chris@16 74 , Iterator last
Chris@16 75 , Expr const& expr
Chris@16 76 , BOOST_PP_ENUM_BINARY_PARAMS(N, A, & attr))
Chris@16 77 {
Chris@16 78 Iterator first = first_;
Chris@16 79 return qi::parse(first, last, expr, BOOST_PP_ENUM_PARAMS(N, attr));
Chris@16 80 }
Chris@16 81
Chris@16 82 ///////////////////////////////////////////////////////////////////////////
Chris@16 83 template <typename Iterator, typename Expr, typename Skipper
Chris@16 84 , BOOST_PP_ENUM_PARAMS(N, typename A)>
Chris@16 85 inline bool
Chris@16 86 phrase_parse(
Chris@16 87 Iterator& first
Chris@16 88 , Iterator last
Chris@16 89 , Expr const& expr
Chris@16 90 , Skipper const& skipper
Chris@16 91 , BOOST_SCOPED_ENUM(skip_flag) post_skip
Chris@16 92 , BOOST_PP_ENUM_BINARY_PARAMS(N, A, & attr))
Chris@16 93 {
Chris@16 94 // Make sure the iterator is at least a forward_iterator. If you got an
Chris@16 95 // compilation error here, then you are using an input_iterator while
Chris@16 96 // calling this function, you need to supply at least a
Chris@16 97 // forward_iterator instead.
Chris@16 98 BOOST_CONCEPT_ASSERT((ForwardIterator<Iterator>));
Chris@16 99
Chris@16 100 // Report invalid expression error as early as possible.
Chris@16 101 // If you got an error_invalid_expression error message here,
Chris@16 102 // then either the expression (expr) or skipper is not a valid
Chris@16 103 // spirit qi expression.
Chris@16 104 BOOST_SPIRIT_ASSERT_MATCH(qi::domain, Expr);
Chris@16 105 BOOST_SPIRIT_ASSERT_MATCH(qi::domain, Skipper);
Chris@16 106
Chris@16 107 typedef
Chris@16 108 typename result_of::compile<qi::domain, Skipper>::type
Chris@16 109 skipper_type;
Chris@16 110 skipper_type const skipper_ = compile<qi::domain>(skipper);
Chris@16 111
Chris@16 112 typedef fusion::vector<
Chris@16 113 BOOST_PP_ENUM(N, BOOST_SPIRIT_QI_ATTRIBUTE_REFERENCE, A)
Chris@16 114 > vector_type;
Chris@16 115
Chris@16 116 vector_type lattr (BOOST_PP_ENUM_PARAMS(N, attr));
Chris@16 117 if (!compile<qi::domain>(expr).parse(
Chris@16 118 first, last, unused, skipper_, lattr))
Chris@16 119 return false;
Chris@16 120
Chris@16 121 if (post_skip == skip_flag::postskip)
Chris@16 122 qi::skip_over(first, last, skipper_);
Chris@16 123 return true;
Chris@16 124 }
Chris@16 125
Chris@16 126 template <typename Iterator, typename Expr, typename Skipper
Chris@16 127 , BOOST_PP_ENUM_PARAMS(N, typename A)>
Chris@16 128 inline bool
Chris@16 129 phrase_parse(
Chris@16 130 Iterator const& first_
Chris@16 131 , Iterator last
Chris@16 132 , Expr const& expr
Chris@16 133 , Skipper const& skipper
Chris@16 134 , BOOST_SCOPED_ENUM(skip_flag) post_skip
Chris@16 135 , BOOST_PP_ENUM_BINARY_PARAMS(N, A, & attr))
Chris@16 136 {
Chris@16 137 Iterator first = first_;
Chris@16 138 return qi::phrase_parse(first, last, expr, skipper, post_skip
Chris@16 139 , BOOST_PP_ENUM_PARAMS(N, attr));
Chris@16 140 }
Chris@16 141
Chris@16 142 ///////////////////////////////////////////////////////////////////////////
Chris@16 143 template <typename Iterator, typename Expr, typename Skipper
Chris@16 144 , BOOST_PP_ENUM_PARAMS(N, typename A)>
Chris@16 145 inline bool
Chris@16 146 phrase_parse(
Chris@16 147 Iterator& first
Chris@16 148 , Iterator last
Chris@16 149 , Expr const& expr
Chris@16 150 , Skipper const& skipper
Chris@16 151 , BOOST_PP_ENUM_BINARY_PARAMS(N, A, & attr))
Chris@16 152 {
Chris@16 153 return qi::phrase_parse(first, last, expr, skipper, skip_flag::postskip
Chris@16 154 , BOOST_PP_ENUM_PARAMS(N, attr));
Chris@16 155 }
Chris@16 156
Chris@16 157 template <typename Iterator, typename Expr, typename Skipper
Chris@16 158 , BOOST_PP_ENUM_PARAMS(N, typename A)>
Chris@16 159 inline bool
Chris@16 160 phrase_parse(
Chris@16 161 Iterator const& first_
Chris@16 162 , Iterator last
Chris@16 163 , Expr const& expr
Chris@16 164 , Skipper const& skipper
Chris@16 165 , BOOST_PP_ENUM_BINARY_PARAMS(N, A, & attr))
Chris@16 166 {
Chris@16 167 Iterator first = first_;
Chris@16 168 return qi::phrase_parse(first, last, expr, skipper, skip_flag::postskip
Chris@16 169 , BOOST_PP_ENUM_PARAMS(N, attr));
Chris@16 170 }
Chris@16 171 }}}
Chris@16 172
Chris@16 173 #undef BOOST_SPIRIT_QI_ATTRIBUTE_REFERENCE
Chris@16 174 #undef N
Chris@16 175
Chris@16 176 #endif
Chris@16 177