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