annotate DEPENDENCIES/generic/include/boost/spirit/home/lex/argument_phoenix.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 c530137014c0
children
rev   line source
Chris@16 1 // Copyright (c) 2001-2011 Hartmut Kaiser
Chris@16 2 // Copyright (c) 2011 Thomas Heller
Chris@16 3 //
Chris@16 4 // Distributed under the Boost Software License, Version 1.0. (See accompanying
Chris@16 5 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Chris@16 6
Chris@16 7 #if !defined(BOOST_SPIRIT_LEX_ARGUMENT_PHEONIX_MARCH_25_2011_1841PM)
Chris@16 8 #define BOOST_SPIRIT_LEX_ARGUMENT_PHEONIX_MARCH_25_2011_1841PM
Chris@16 9
Chris@16 10 #if defined(_MSC_VER)
Chris@16 11 #pragma once
Chris@16 12 #endif
Chris@16 13
Chris@16 14 #include <boost/spirit/include/phoenix_core.hpp>
Chris@16 15
Chris@16 16 namespace boost { namespace spirit { namespace lex
Chris@16 17 {
Chris@16 18 ///////////////////////////////////////////////////////////////////////////
Chris@16 19 // The value_context is used as a noop Phoenix actor to create the
Chris@16 20 // placeholder '_val' (see below). It is a noop actor because it is used
Chris@16 21 // as a placeholder only, while it is being converted either to a
Chris@16 22 // value_getter (if used as a rvalue) or to a value_setter (if used as a
Chris@16 23 // lvalue). The conversion is achieved by specializing and overloading a
Chris@16 24 // couple of the Phoenix templates from the Phoenix expression composition
Chris@16 25 // engine (see the end of this file).
Chris@16 26 struct value_context
Chris@16 27 {
Chris@16 28 typedef mpl::true_ no_nullary;
Chris@16 29
Chris@16 30 typedef unused_type result_type;
Chris@16 31
Chris@16 32 template <typename Env>
Chris@16 33 struct result
Chris@16 34 {
Chris@16 35 typedef unused_type type;
Chris@16 36 };
Chris@16 37
Chris@16 38 template <typename Env>
Chris@16 39 unused_type
Chris@16 40 eval(Env const& env) const
Chris@16 41 {
Chris@16 42 return unused;
Chris@16 43 }
Chris@16 44 };
Chris@16 45
Chris@16 46 // forward declarations
Chris@16 47 struct value_getter;
Chris@16 48 template <typename> struct value_setter;
Chris@16 49
Chris@16 50 ///////////////////////////////////////////////////////////////////////////
Chris@16 51 // The state_context is used as a noop Phoenix actor to create the
Chris@16 52 // placeholder '_state' (see below). It is a noop actor because it is used
Chris@16 53 // as a placeholder only, while it is being converted either to a
Chris@16 54 // state_getter (if used as a rvalue) or to a state_setter (if used as a
Chris@16 55 // lvalue). The conversion is achieved by specializing and overloading a
Chris@16 56 // couple of the Phoenix templates from the Phoenix expression composition
Chris@16 57 // engine (see the end of this file).
Chris@16 58 struct state_context
Chris@16 59 {
Chris@16 60 typedef mpl::true_ no_nullary;
Chris@16 61
Chris@16 62 typedef unused_type result_type;
Chris@16 63
Chris@16 64 template <typename Env>
Chris@16 65 struct result
Chris@16 66 {
Chris@16 67 typedef unused_type type;
Chris@16 68 };
Chris@16 69
Chris@16 70 template <typename Env>
Chris@16 71 unused_type
Chris@16 72 eval(Env const& env) const
Chris@16 73 {
Chris@16 74 return unused;
Chris@16 75 }
Chris@16 76 };
Chris@16 77
Chris@16 78 // forward declarations
Chris@16 79 struct state_getter;
Chris@16 80 template <typename> struct state_setter;
Chris@16 81 struct eoi_getter;
Chris@16 82 }}}
Chris@16 83
Chris@16 84 ///////////////////////////////////////////////////////////////////////////////
Chris@16 85
Chris@16 86 BOOST_PHOENIX_DEFINE_EXPRESSION(
Chris@16 87 (boost)(spirit)(lex)(value_setter)
Chris@16 88 , (boost::phoenix::meta_grammar)
Chris@16 89 )
Chris@16 90
Chris@16 91 BOOST_PHOENIX_DEFINE_EXPRESSION(
Chris@16 92 (boost)(spirit)(lex)(state_setter)
Chris@16 93 , (boost::phoenix::meta_grammar)
Chris@16 94 )
Chris@16 95
Chris@16 96 namespace boost { namespace phoenix
Chris@16 97 {
Chris@16 98 namespace result_of
Chris@16 99 {
Chris@16 100 template <>
Chris@16 101 struct is_nullary<custom_terminal<boost::spirit::lex::value_context> >
Chris@16 102 : mpl::false_
Chris@16 103 {};
Chris@16 104 }
Chris@16 105
Chris@16 106 template <typename Dummy>
Chris@16 107 struct is_custom_terminal<boost::spirit::lex::value_context, Dummy>: mpl::true_ {};
Chris@16 108
Chris@16 109 template <typename Dummy>
Chris@16 110 struct custom_terminal<boost::spirit::lex::value_context, Dummy>
Chris@16 111 : proto::call<
Chris@16 112 v2_eval(
Chris@16 113 proto::make<boost::spirit::lex::value_getter()>
Chris@16 114 , proto::call<functional::env(proto::_state)>
Chris@16 115 )
Chris@16 116 >
Chris@16 117 {};
Chris@16 118
Chris@16 119 template <typename Dummy>
Chris@16 120 struct is_nullary::when<spirit::lex::rule::value_setter, Dummy>
Chris@16 121 : proto::make<mpl::false_()>
Chris@16 122 {};
Chris@16 123
Chris@16 124 template <typename Dummy>
Chris@16 125 struct default_actions::when<spirit::lex::rule::value_setter, Dummy>
Chris@16 126 : proto::call<
Chris@16 127 v2_eval(
Chris@16 128 proto::make<
Chris@16 129 spirit::lex::value_setter<proto::_child0>(
Chris@16 130 proto::_child0
Chris@16 131 )
Chris@16 132 >
Chris@16 133 , _env
Chris@16 134 )
Chris@16 135 >
Chris@16 136 {};
Chris@16 137
Chris@16 138 template <>
Chris@16 139 struct actor<spirit::lex::value_context>
Chris@16 140 : boost::phoenix::actor<proto::terminal<spirit::lex::value_context>::type>
Chris@16 141 {
Chris@16 142 typedef boost::phoenix::actor<
Chris@16 143 proto::terminal<spirit::lex::value_context>::type
Chris@16 144 > base_type;
Chris@16 145
Chris@16 146 actor(base_type const & base = base_type())
Chris@16 147 : base_type(base)
Chris@16 148 {}
Chris@16 149
Chris@16 150 template <typename Expr>
Chris@16 151 typename spirit::lex::expression::value_setter<
Chris@16 152 typename phoenix::as_actor<Expr>::type>::type const
Chris@16 153 operator=(Expr const & expr) const
Chris@16 154 {
Chris@16 155 return
Chris@16 156 spirit::lex::expression::value_setter<
Chris@16 157 typename phoenix::as_actor<Expr>::type
Chris@16 158 >::make(phoenix::as_actor<Expr>::convert(expr));
Chris@16 159 }
Chris@16 160 };
Chris@16 161
Chris@16 162 namespace result_of
Chris@16 163 {
Chris@16 164 template <>
Chris@16 165 struct is_nullary<custom_terminal<boost::spirit::lex::state_context> >
Chris@16 166 : mpl::false_
Chris@16 167 {};
Chris@16 168 }
Chris@16 169
Chris@16 170 template <typename Dummy>
Chris@16 171 struct is_custom_terminal<boost::spirit::lex::state_context, Dummy>: mpl::true_ {};
Chris@16 172
Chris@16 173 template <typename Dummy>
Chris@16 174 struct custom_terminal<boost::spirit::lex::state_context, Dummy>
Chris@16 175 : proto::call<
Chris@16 176 v2_eval(
Chris@16 177 proto::make<boost::spirit::lex::state_getter()>
Chris@16 178 , proto::call<functional::env(proto::_state)>
Chris@16 179 )
Chris@16 180 >
Chris@16 181 {};
Chris@16 182
Chris@16 183 template <typename Dummy>
Chris@16 184 struct is_nullary::when<spirit::lex::rule::state_setter, Dummy>
Chris@16 185 : proto::make<mpl::false_()>
Chris@16 186 {};
Chris@16 187
Chris@16 188 template <typename Dummy>
Chris@16 189 struct default_actions::when<spirit::lex::rule::state_setter, Dummy>
Chris@16 190 : proto::call<
Chris@16 191 v2_eval(
Chris@16 192 proto::make<
Chris@16 193 spirit::lex::state_setter<proto::_child0>(
Chris@16 194 proto::_child0
Chris@16 195 )
Chris@16 196 >
Chris@16 197 , _env
Chris@16 198 )
Chris@16 199 >
Chris@16 200 {};
Chris@16 201
Chris@16 202 template <>
Chris@16 203 struct actor<spirit::lex::state_context>
Chris@16 204 : boost::phoenix::actor<proto::terminal<spirit::lex::state_context>::type>
Chris@16 205 {
Chris@16 206 typedef boost::phoenix::actor<
Chris@16 207 proto::terminal<spirit::lex::state_context>::type
Chris@16 208 > base_type;
Chris@16 209
Chris@16 210 actor(base_type const & base = base_type())
Chris@16 211 : base_type(base)
Chris@16 212 {}
Chris@16 213
Chris@16 214 template <typename Expr>
Chris@16 215 typename spirit::lex::expression::state_setter<
Chris@16 216 typename phoenix::as_actor<Expr>::type>::type const
Chris@16 217 operator=(Expr const & expr) const
Chris@16 218 {
Chris@16 219 return
Chris@16 220 spirit::lex::expression::state_setter<
Chris@16 221 typename phoenix::as_actor<Expr>::type
Chris@16 222 >::make(phoenix::as_actor<Expr>::convert(expr));
Chris@16 223 }
Chris@16 224 };
Chris@16 225
Chris@16 226 namespace result_of
Chris@16 227 {
Chris@16 228 template <>
Chris@16 229 struct is_nullary<custom_terminal<boost::spirit::lex::eoi_getter> >
Chris@16 230 : mpl::false_
Chris@16 231 {};
Chris@16 232 }
Chris@16 233
Chris@16 234 template <typename Dummy>
Chris@16 235 struct is_custom_terminal<boost::spirit::lex::eoi_getter, Dummy>: mpl::true_ {};
Chris@16 236
Chris@16 237 template <typename Dummy>
Chris@16 238 struct custom_terminal<boost::spirit::lex::eoi_getter, Dummy>
Chris@16 239 : proto::call<
Chris@16 240 v2_eval(
Chris@16 241 proto::make<boost::spirit::lex::eoi_getter()>
Chris@16 242 , proto::call<functional::env(proto::_state)>
Chris@16 243 )
Chris@16 244 >
Chris@16 245 {};
Chris@16 246 }}
Chris@16 247
Chris@16 248 #endif