guard_grammar.hpp 13 KB

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