]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // Copyright 2008 Christophe Henry |
2 | // henry UNDERSCORE christophe AT hotmail DOT com | |
3 | // This is an extended version of the state machine available in the boost::mpl library | |
4 | // Distributed under the same license as the original. | |
5 | // Copyright for the original version: | |
6 | // Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed | |
7 | // under the Boost Software License, Version 1.0. (See accompanying | |
8 | // file LICENSE_1_0.txt or copy at | |
9 | // http://www.boost.org/LICENSE_1_0.txt) | |
10 | ||
11 | #ifndef BOOST_MSM_FRONT_EUML_GUARD_GRAMMAR_H | |
12 | #define BOOST_MSM_FRONT_EUML_GUARD_GRAMMAR_H | |
13 | ||
14 | #include <boost/msm/front/euml/common.hpp> | |
15 | #include <boost/msm/front/euml/operator.hpp> | |
16 | #include <boost/msm/front/euml/state_grammar.hpp> | |
17 | ||
18 | namespace boost { namespace msm { namespace front { namespace euml | |
19 | { | |
20 | struct BuildGuards; | |
21 | struct BuildActions; | |
22 | ||
23 | struct BuildGuardsCases | |
24 | { | |
25 | // The primary template matches nothing: | |
26 | template<typename Tag> | |
27 | struct case_ | |
28 | : proto::not_<proto::_> | |
29 | {}; | |
30 | }; | |
31 | template<> | |
32 | struct BuildGuardsCases::case_<proto::tag::logical_or> | |
33 | : proto::when< | |
34 | proto::logical_or<BuildGuards,BuildGuards >, | |
35 | Or_<BuildGuards(proto::_left),BuildGuards(proto::_right)>() | |
36 | > | |
37 | {}; | |
38 | template<> | |
39 | struct BuildGuardsCases::case_<proto::tag::logical_and> | |
40 | : proto::when< | |
41 | proto::logical_and<BuildGuards,BuildGuards >, | |
42 | And_<BuildGuards(proto::_left),BuildGuards(proto::_right)>() | |
43 | > | |
44 | {}; | |
45 | template<> | |
46 | struct BuildGuardsCases::case_<proto::tag::logical_not> | |
47 | : proto::when< | |
48 | proto::logical_not<BuildGuards >, | |
49 | Not_<BuildGuards(proto::_child)>() | |
50 | > | |
51 | {}; | |
52 | template<> | |
53 | struct BuildGuardsCases::case_<proto::tag::less> | |
54 | : proto::when< | |
55 | proto::less<BuildGuards, BuildGuards >, | |
56 | Less_<BuildGuards(proto::_left),BuildGuards(proto::_right)>() | |
57 | > | |
58 | {}; | |
59 | template<> | |
60 | struct BuildGuardsCases::case_<proto::tag::less_equal> | |
61 | : proto::when< | |
62 | proto::less_equal<BuildGuards, BuildGuards >, | |
63 | LessEqual_<BuildGuards(proto::_left),BuildGuards(proto::_right)>() | |
64 | > | |
65 | {}; | |
66 | template<> | |
67 | struct BuildGuardsCases::case_<proto::tag::greater> | |
68 | : proto::when< | |
69 | proto::greater<BuildGuards, BuildGuards >, | |
70 | Greater_<BuildGuards(proto::_left),BuildGuards(proto::_right)>() | |
71 | > | |
72 | {}; | |
73 | template<> | |
74 | struct BuildGuardsCases::case_<proto::tag::greater_equal> | |
75 | : proto::when< | |
76 | proto::greater_equal<BuildGuards, BuildGuards >, | |
77 | GreaterEqual_<BuildGuards(proto::_left),BuildGuards(proto::_right)>() | |
78 | > | |
79 | {}; | |
80 | template<> | |
81 | struct BuildGuardsCases::case_<proto::tag::equal_to> | |
82 | : proto::when< | |
83 | proto::equal_to<BuildGuards, BuildGuards >, | |
84 | EqualTo_<BuildGuards(proto::_left),BuildGuards(proto::_right)>() | |
85 | > | |
86 | {}; | |
87 | template<> | |
88 | struct BuildGuardsCases::case_<proto::tag::not_equal_to> | |
89 | : proto::when< | |
90 | proto::not_equal_to<BuildGuards, BuildGuards >, | |
91 | NotEqualTo_<BuildGuards(proto::_left),BuildGuards(proto::_right)>() | |
92 | > | |
93 | {}; | |
94 | template<> | |
95 | struct BuildGuardsCases::case_<proto::tag::pre_inc> | |
96 | : proto::when< | |
97 | proto::pre_inc<BuildGuards >, | |
98 | Pre_inc_<BuildGuards(proto::_child)>() | |
99 | > | |
100 | {}; | |
101 | template<> | |
102 | struct BuildGuardsCases::case_<proto::tag::dereference> | |
103 | : proto::when< | |
104 | proto::dereference<BuildGuards >, | |
105 | Deref_<BuildGuards(proto::_child)>() | |
106 | > | |
107 | {}; | |
108 | template<> | |
109 | struct BuildGuardsCases::case_<proto::tag::pre_dec> | |
110 | : proto::when< | |
111 | proto::pre_dec<BuildGuards >, | |
112 | Pre_dec_<BuildGuards(proto::_child)>() | |
113 | > | |
114 | {}; | |
115 | template<> | |
116 | struct BuildGuardsCases::case_<proto::tag::post_inc> | |
117 | : proto::when< | |
118 | proto::post_inc<BuildGuards >, | |
119 | Post_inc_<BuildGuards(proto::_child)>() | |
120 | > | |
121 | {}; | |
122 | template<> | |
123 | struct BuildGuardsCases::case_<proto::tag::post_dec> | |
124 | : proto::when< | |
125 | proto::post_dec<BuildGuards >, | |
126 | Post_dec_<BuildGuards(proto::_child)>() | |
127 | > | |
128 | {}; | |
129 | template<> | |
130 | struct BuildGuardsCases::case_<proto::tag::plus> | |
131 | : proto::when< | |
132 | proto::plus<BuildGuards,BuildGuards >, | |
133 | Plus_<BuildGuards(proto::_left),BuildGuards(proto::_right)>() | |
134 | > | |
135 | {}; | |
136 | template<> | |
137 | struct BuildGuardsCases::case_<proto::tag::minus> | |
138 | : proto::when< | |
139 | proto::minus<BuildGuards,BuildGuards >, | |
140 | Minus_<BuildGuards(proto::_left),BuildGuards(proto::_right)>() | |
141 | > | |
142 | {}; | |
143 | template<> | |
144 | struct BuildGuardsCases::case_<proto::tag::multiplies> | |
145 | : proto::when< | |
146 | proto::multiplies<BuildGuards,BuildGuards >, | |
147 | Multiplies_<BuildGuards(proto::_left),BuildGuards(proto::_right)>() | |
148 | > | |
149 | {}; | |
150 | template<> | |
151 | struct BuildGuardsCases::case_<proto::tag::divides> | |
152 | : proto::when< | |
153 | proto::divides<BuildGuards,BuildGuards >, | |
154 | Divides_<BuildGuards(proto::_left),BuildGuards(proto::_right)>() | |
155 | > | |
156 | {}; | |
157 | template<> | |
158 | struct BuildGuardsCases::case_<proto::tag::modulus> | |
159 | : proto::when< | |
160 | proto::modulus<BuildGuards,BuildGuards >, | |
161 | Modulus_<BuildGuards(proto::_left),BuildGuards(proto::_right)>() | |
162 | > | |
163 | {}; | |
164 | template<> | |
165 | struct BuildGuardsCases::case_<proto::tag::bitwise_and> | |
166 | : proto::when< | |
167 | proto::bitwise_and<BuildGuards,BuildGuards >, | |
168 | Bitwise_And_<BuildGuards(proto::_left),BuildGuards(proto::_right)>() | |
169 | > | |
170 | {}; | |
171 | template<> | |
172 | struct BuildGuardsCases::case_<proto::tag::bitwise_or> | |
173 | : proto::when< | |
174 | proto::bitwise_or<BuildGuards,BuildGuards >, | |
175 | Bitwise_Or_<BuildGuards(proto::_left),BuildGuards(proto::_right)>() | |
176 | > | |
177 | {}; | |
178 | template<> | |
179 | struct BuildGuardsCases::case_<proto::tag::subscript> | |
180 | : proto::when< | |
181 | proto::subscript<BuildGuards,BuildGuards >, | |
182 | Subscript_<BuildGuards(proto::_left),BuildGuards(proto::_right)>() | |
183 | > | |
184 | {}; | |
185 | template<> | |
186 | struct BuildGuardsCases::case_<proto::tag::plus_assign> | |
187 | : proto::when< | |
188 | proto::plus_assign<BuildGuards,BuildGuards >, | |
189 | Plus_Assign_<BuildGuards(proto::_left),BuildGuards(proto::_right)>() | |
190 | > | |
191 | {}; | |
192 | template<> | |
193 | struct BuildGuardsCases::case_<proto::tag::minus_assign> | |
194 | : proto::when< | |
195 | proto::minus_assign<BuildGuards,BuildGuards >, | |
196 | Minus_Assign_<BuildGuards(proto::_left),BuildGuards(proto::_right)>() | |
197 | > | |
198 | {}; | |
199 | template<> | |
200 | struct BuildGuardsCases::case_<proto::tag::multiplies_assign> | |
201 | : proto::when< | |
202 | proto::multiplies_assign<BuildGuards,BuildGuards >, | |
203 | Multiplies_Assign_<BuildGuards(proto::_left),BuildGuards(proto::_right)>() | |
204 | > | |
205 | {}; | |
206 | template<> | |
207 | struct BuildGuardsCases::case_<proto::tag::divides_assign> | |
208 | : proto::when< | |
209 | proto::divides_assign<BuildGuards,BuildGuards >, | |
210 | Divides_Assign_<BuildGuards(proto::_left),BuildGuards(proto::_right)>() | |
211 | > | |
212 | {}; | |
213 | template<> | |
214 | struct BuildGuardsCases::case_<proto::tag::modulus_assign> | |
215 | : proto::when< | |
216 | proto::modulus_assign<BuildGuards,BuildGuards >, | |
217 | Modulus_Assign_<BuildGuards(proto::_left),BuildGuards(proto::_right)>() | |
218 | > | |
219 | {}; | |
220 | template<> | |
221 | struct BuildGuardsCases::case_<proto::tag::shift_left_assign> | |
222 | : proto::when< | |
223 | proto::shift_left_assign<BuildGuards,BuildGuards >, | |
224 | ShiftLeft_Assign_<BuildGuards(proto::_left),BuildGuards(proto::_right)>() | |
225 | > | |
226 | {}; | |
227 | template<> | |
228 | struct BuildGuardsCases::case_<proto::tag::shift_right_assign> | |
229 | : proto::when< | |
230 | proto::shift_right_assign<BuildGuards,BuildGuards >, | |
231 | ShiftRight_Assign_<BuildGuards(proto::_left),BuildGuards(proto::_right)>() | |
232 | > | |
233 | {}; | |
234 | template<> | |
235 | struct BuildGuardsCases::case_<proto::tag::shift_left> | |
236 | : proto::when< | |
237 | proto::shift_left<BuildGuards,BuildGuards >, | |
238 | ShiftLeft_<BuildGuards(proto::_left),BuildGuards(proto::_right)>() | |
239 | > | |
240 | {}; | |
241 | template<> | |
242 | struct BuildGuardsCases::case_<proto::tag::shift_right> | |
243 | : proto::when< | |
244 | proto::shift_right<BuildGuards,BuildGuards >, | |
245 | ShiftRight_<BuildGuards(proto::_left),BuildGuards(proto::_right)>() | |
246 | > | |
247 | {}; | |
248 | template<> | |
249 | struct BuildGuardsCases::case_<proto::tag::assign> | |
250 | : proto::when< | |
251 | proto::assign<BuildGuards,BuildGuards >, | |
252 | Assign_<BuildGuards(proto::_left),BuildGuards(proto::_right)>() | |
253 | > | |
254 | {}; | |
255 | template<> | |
256 | struct BuildGuardsCases::case_<proto::tag::bitwise_xor> | |
257 | : proto::when< | |
258 | proto::bitwise_xor<BuildGuards,BuildGuards >, | |
259 | Bitwise_Xor_<BuildGuards(proto::_left),BuildGuards(proto::_right)>() | |
260 | > | |
261 | {}; | |
262 | template<> | |
263 | struct BuildGuardsCases::case_<proto::tag::negate> | |
264 | : proto::when< | |
265 | proto::negate<BuildGuards >, | |
266 | Unary_Minus_<BuildGuards(proto::_child)>() | |
267 | > | |
268 | {}; | |
269 | ||
270 | template<> | |
271 | struct BuildGuardsCases::case_<proto::tag::function> | |
272 | : proto::or_< | |
273 | proto::when< | |
274 | proto::function<proto::terminal<if_tag>,BuildGuards,BuildGuards,BuildGuards >, | |
275 | If_Else_<BuildGuards(proto::_child_c<1>), | |
276 | BuildGuards(proto::_child_c<2>), | |
277 | BuildGuards(proto::_child_c<3>) >() | |
278 | >, | |
279 | proto::when< | |
280 | proto::function<proto::terminal<proto::_> >, | |
281 | get_fct<proto::_child_c<0> >() | |
282 | >, | |
283 | proto::when< | |
284 | proto::function<proto::terminal<proto::_>,BuildActions >, | |
285 | get_fct<proto::_child_c<0>,BuildActions(proto::_child_c<1>) >() | |
286 | >, | |
287 | proto::when< | |
288 | proto::function<proto::terminal<proto::_>,BuildActions,BuildActions >, | |
289 | get_fct<proto::_child_c<0>,BuildActions(proto::_child_c<1>),BuildActions(proto::_child_c<2>) >() | |
290 | >, | |
291 | proto::when< | |
292 | proto::function<proto::terminal<proto::_>,BuildActions,BuildActions,BuildActions >, | |
293 | get_fct<proto::_child_c<0>,BuildActions(proto::_child_c<1>) | |
294 | ,BuildActions(proto::_child_c<2>),BuildActions(proto::_child_c<3>) >() | |
295 | >, | |
296 | proto::when< | |
297 | proto::function<proto::terminal<proto::_>,BuildActions,BuildActions,BuildActions,BuildActions >, | |
298 | get_fct<proto::_child_c<0> | |
299 | ,BuildActions(proto::_child_c<1>),BuildActions(proto::_child_c<2>) | |
300 | ,BuildActions(proto::_child_c<3>),BuildActions(proto::_child_c<4>) >() | |
301 | >, | |
302 | proto::when< | |
303 | proto::function<proto::terminal<proto::_>,BuildActions,BuildActions,BuildActions,BuildActions,BuildActions >, | |
304 | get_fct<proto::_child_c<0> | |
305 | ,BuildActions(proto::_child_c<1>),BuildActions(proto::_child_c<2>) | |
306 | ,BuildActions(proto::_child_c<3>),BuildActions(proto::_child_c<4>),BuildActions(proto::_child_c<5>) >() | |
307 | > | |
308 | #ifdef BOOST_MSVC | |
309 | ,proto::when< | |
310 | proto::function<proto::terminal<proto::_>,BuildActions,BuildActions,BuildActions,BuildActions,BuildActions,BuildActions >, | |
311 | get_fct<proto::_child_c<0> | |
312 | ,BuildActions(proto::_child_c<1>),BuildActions(proto::_child_c<2>) | |
313 | ,BuildActions(proto::_child_c<3>),BuildActions(proto::_child_c<4>) | |
314 | ,BuildActions(proto::_child_c<5>),BuildActions(proto::_child_c<6>) >() | |
315 | > | |
316 | #endif | |
317 | > | |
318 | {}; | |
319 | ||
320 | template<> | |
321 | struct BuildGuardsCases::case_<proto::tag::terminal> | |
322 | : proto::or_< | |
323 | proto::when < | |
324 | proto::terminal<action_tag>, | |
325 | get_action_name<proto::_ >() | |
326 | >, | |
327 | proto::when< | |
328 | proto::terminal<state_tag>, | |
329 | get_state_name<proto::_>() | |
330 | >, | |
331 | proto::when< | |
332 | proto::terminal<flag_tag>, | |
333 | proto::_ | |
334 | >, | |
335 | proto::when< | |
336 | proto::terminal<event_tag>, | |
337 | proto::_ | |
338 | >, | |
339 | proto::when< | |
340 | proto::terminal<fsm_artefact_tag>, | |
341 | get_fct<proto::_ >() | |
342 | >, | |
343 | proto::when< | |
344 | proto::terminal<proto::_>, | |
345 | proto::_value | |
346 | > | |
347 | > | |
348 | {}; | |
349 | ||
350 | struct BuildGuards | |
351 | : proto::switch_<BuildGuardsCases> | |
352 | {}; | |
353 | ||
354 | }}}} | |
355 | ||
356 | #endif //BOOST_MSM_FRONT_EUML_GUARD_GRAMMAR_H |