puml.hpp 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044
  1. // Copyright 2024 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_PUML_COMMON_H
  11. #define BOOST_MSM_FRONT_PUML_COMMON_H
  12. #include <cstdint>
  13. #include <string>
  14. #include <string_view>
  15. #include <vector>
  16. #include <boost/any.hpp>
  17. #include <boost/fusion/mpl.hpp>
  18. #include <boost/fusion/include/as_vector.hpp>
  19. #include <boost/fusion/container/vector.hpp>
  20. #include <boost/fusion/include/insert_range.hpp>
  21. #include <boost/fusion/include/at_c.hpp>
  22. #include <boost/fusion/include/for_each.hpp>
  23. #include <boost/fusion/include/make_vector.hpp>
  24. #include <boost/mpl/size.hpp>
  25. #include <boost/msm/front/states.hpp>
  26. // functors
  27. #include <boost/msm/front/functor_row.hpp>
  28. #include <boost/msm/front/operator.hpp>
  29. namespace boost::msm::front::puml
  30. {
  31. namespace detail {
  32. template <class T1, class T2>
  33. struct pair_type
  34. {
  35. using first = T1;
  36. using second = T2;
  37. };
  38. }
  39. template<typename T>
  40. struct convert_to_msm_names
  41. {
  42. using type = T;
  43. };
  44. template <std::uint32_t hash,
  45. class Flags = boost::fusion::vector0<>,
  46. class Entries = boost::fusion::vector0<>,
  47. class Exits = boost::fusion::vector0<>>
  48. struct State
  49. {
  50. using generated_type = State<hash>;
  51. using flag_list = boost::fusion::vector0<>;
  52. using entries = Entries;
  53. using exits = Exits;
  54. using internal_flag_list = Flags;
  55. template <class Event, class FSM>
  56. void on_entry(Event& evt, FSM& fsm)
  57. {
  58. boost::fusion::for_each(Entries{},
  59. [&](auto action_guard_pair)
  60. {
  61. if constexpr (
  62. std::is_same_v<typename decltype(action_guard_pair)::second,boost::msm::front::none>)
  63. {
  64. typename decltype(action_guard_pair)::first{}(evt, fsm, *this, *this);
  65. }
  66. else
  67. {
  68. if (typename decltype(action_guard_pair)::second{}(evt, fsm, *this, *this))
  69. {
  70. typename decltype(action_guard_pair)::first{}(evt, fsm, *this, *this);
  71. }
  72. }
  73. });
  74. }
  75. template <class Event, class FSM>
  76. void on_exit(Event& evt, FSM& fsm)
  77. {
  78. boost::fusion::for_each(Exits{},
  79. [&](auto action_guard_pair)
  80. {
  81. if constexpr (
  82. std::is_same_v<typename decltype(action_guard_pair)::second, boost::msm::front::none>)
  83. {
  84. typename decltype(action_guard_pair)::first{}(evt, fsm, *this, *this);
  85. }
  86. else
  87. {
  88. if (typename decltype(action_guard_pair)::second{}(evt, fsm, *this, *this))
  89. {
  90. typename decltype(action_guard_pair)::first{}(evt, fsm, *this, *this);
  91. }
  92. }
  93. });
  94. }
  95. // typedefs added for front::state compatibility
  96. typedef ::boost::mpl::vector<> internal_transition_table;
  97. typedef ::boost::fusion::vector<> internal_transition_table11;
  98. typedef ::boost::fusion::vector<> transition_table;
  99. typedef ::boost::fusion::vector0<> deferred_events;
  100. struct internal
  101. {
  102. typedef state_tag tag;
  103. };
  104. };
  105. template <std::uint32_t hash>
  106. struct Event
  107. {
  108. };
  109. template <std::uint32_t hash>
  110. struct Action
  111. {
  112. };
  113. template <std::uint32_t hash>
  114. struct Guard
  115. {
  116. };
  117. template <std::uint32_t hash>
  118. struct Flag
  119. {
  120. };
  121. namespace detail {
  122. // CRC32 Table (zlib polynomial)
  123. static constexpr std::uint32_t crc_table[256] =
  124. {
  125. 0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
  126. 0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,
  127. 0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L,
  128. 0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL,
  129. 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L,
  130. 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L,
  131. 0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L,
  132. 0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL,
  133. 0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L,
  134. 0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL,
  135. 0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L,
  136. 0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L,
  137. 0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L,
  138. 0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL,
  139. 0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL,
  140. 0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L,
  141. 0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL,
  142. 0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L,
  143. 0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L,
  144. 0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L,
  145. 0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL,
  146. 0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L,
  147. 0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L,
  148. 0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL,
  149. 0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L,
  150. 0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L,
  151. 0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L,
  152. 0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L,
  153. 0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L,
  154. 0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL,
  155. 0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL,
  156. 0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L,
  157. 0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L,
  158. 0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL,
  159. 0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL,
  160. 0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L,
  161. 0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL,
  162. 0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L,
  163. 0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL,
  164. 0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L,
  165. 0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL,
  166. 0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L,
  167. 0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L,
  168. 0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL,
  169. 0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L,
  170. 0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L,
  171. 0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L,
  172. 0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L,
  173. 0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L,
  174. 0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L,
  175. 0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL,
  176. 0x2d02ef8dL
  177. };
  178. constexpr std::uint32_t crc32(std::string_view str)
  179. {
  180. std::uint32_t crc = 0xffffffff;
  181. for (auto c : str)
  182. crc = (crc >> 8) ^ boost::msm::front::puml::detail::crc_table[(crc ^ c) & 0xff];
  183. return crc ^ 0xffffffff;
  184. }
  185. // removes training spaces or -
  186. constexpr std::string_view cleanup_token(const std::string_view& str)
  187. {
  188. auto first_not_whitespace = str.find_first_not_of("- \t");
  189. auto last_not_whitespace = str.find_last_not_of("- \t");
  190. if (first_not_whitespace != std::string::npos && last_not_whitespace != std::string::npos)
  191. {
  192. //return std::string(str, first_not_whitespace, last_not_whitespace - first_not_whitespace + 1);
  193. return str.substr(first_not_whitespace, last_not_whitespace - first_not_whitespace + 1);
  194. }
  195. else
  196. {
  197. return std::string_view{};
  198. }
  199. }
  200. struct Transition
  201. {
  202. std::string_view source;
  203. std::string_view target;
  204. std::string_view event;
  205. std::string_view guard;
  206. std::string_view action;
  207. };
  208. // finds guards [Guard]
  209. // requires all blanks to have been removed
  210. constexpr boost::msm::front::puml::detail::Transition
  211. parse_guards(std::string_view part)
  212. {
  213. boost::msm::front::puml::detail::Transition res;
  214. auto start_pos = part.find("[");
  215. auto end_pos = part.find("]");
  216. if (start_pos != std::string::npos && end_pos != std::string::npos)
  217. {
  218. ++start_pos;
  219. res.guard = boost::msm::front::puml::detail::cleanup_token(part.substr(start_pos, end_pos - start_pos));
  220. }
  221. return res;
  222. }
  223. // requires all blanks to have been removed
  224. constexpr boost::msm::front::puml::detail::Transition parse_row_right(std::string_view part)
  225. {
  226. auto action_pos = part.find("/");
  227. auto guard_pos = part.find("[");
  228. auto evt_pos = part.find(":");
  229. auto internal_pos = part.find("-");
  230. bool is_internal_transition =
  231. internal_pos != std::string::npos && internal_pos > evt_pos && internal_pos <= action_pos && internal_pos <= guard_pos;
  232. auto start_event_name_pos = (internal_pos == std::string::npos) ? evt_pos : internal_pos;
  233. boost::msm::front::puml::detail::Transition res;
  234. // target is until : or end of string if not provided
  235. if (evt_pos != std::string::npos && !is_internal_transition)
  236. {
  237. res.target = boost::msm::front::puml::detail::cleanup_token(part.substr(0, evt_pos));
  238. }
  239. else if (!is_internal_transition)
  240. {
  241. res.target = boost::msm::front::puml::detail::cleanup_token(part);
  242. }
  243. // event is between : and / or [, whatever comes first
  244. if (action_pos == std::string::npos && guard_pos == std::string::npos)
  245. {
  246. res.event = boost::msm::front::puml::detail::cleanup_token(part.substr(start_event_name_pos + 1));
  247. }
  248. else
  249. {
  250. auto length = std::min(action_pos, guard_pos) > 1 + start_event_name_pos ?
  251. std::min(action_pos, guard_pos) - 1 - start_event_name_pos
  252. : 0;
  253. res.event = boost::msm::front::puml::detail::cleanup_token(part.substr(start_event_name_pos + 1, length));
  254. }
  255. // handle different guard / action cases
  256. if (action_pos != std::string::npos && guard_pos != std::string::npos)
  257. {
  258. res.action = boost::msm::front::puml::detail::cleanup_token(part.substr(action_pos + 1, guard_pos - 1 - action_pos));
  259. }
  260. else if (action_pos != std::string::npos)
  261. {
  262. // we have an action => target until /
  263. res.action = boost::msm::front::puml::detail::cleanup_token(part.substr(action_pos + 1));
  264. }
  265. // handle guards
  266. res.guard = boost::msm::front::puml::detail::parse_guards(
  267. boost::msm::front::puml::detail::cleanup_token(part)).guard;
  268. return res;
  269. }
  270. constexpr boost::msm::front::puml::detail::Transition parse_row(std::string_view row)
  271. {
  272. auto arrow_pos = row.find("->");
  273. auto puml_event_pos = row.find(":");
  274. auto left = row.substr(0, arrow_pos);
  275. auto right = row.substr(arrow_pos + 2);
  276. if (puml_event_pos != std::string::npos)
  277. {
  278. return boost::msm::front::puml::detail::Transition{
  279. boost::msm::front::puml::detail::cleanup_token(left),
  280. boost::msm::front::puml::detail::parse_row_right(right).target,
  281. boost::msm::front::puml::detail::parse_row_right(right).event,
  282. boost::msm::front::puml::detail::parse_row_right(right).guard,
  283. boost::msm::front::puml::detail::parse_row_right(right).action };
  284. }
  285. else if (arrow_pos != std::string::npos)
  286. {
  287. // simple source -> target form
  288. return boost::msm::front::puml::detail::Transition{
  289. boost::msm::front::puml::detail::cleanup_token(left),
  290. boost::msm::front::puml::detail::cleanup_token(right),
  291. std::string_view{},
  292. std::string_view{},
  293. std::string_view{}
  294. };
  295. }
  296. return boost::msm::front::puml::detail::Transition{};
  297. }
  298. constexpr int count_transitions(std::string_view s)
  299. {
  300. //s = reduce(s, "");
  301. int occurrences = 0;
  302. std::string::size_type pos = 0;
  303. auto target = "->";
  304. while ((pos = s.find(target, pos)) != std::string::npos)
  305. {
  306. ++occurrences;
  307. pos += 2;
  308. }
  309. return occurrences;
  310. };
  311. constexpr int count_inits(std::string_view s, std::size_t occurrences=0)
  312. {
  313. auto target = "[*]";
  314. auto star_pos = s.find(target);
  315. auto endl_after_pos = s.find("\n", star_pos);
  316. auto arrow_after_pos = s.find("->", star_pos);
  317. if (star_pos != std::string::npos &&
  318. star_pos < arrow_after_pos &&
  319. arrow_after_pos < endl_after_pos)
  320. {
  321. return count_inits(s.substr(endl_after_pos), occurrences + 1);
  322. }
  323. return occurrences;
  324. };
  325. constexpr int count_actions(std::string_view s)
  326. {
  327. int occurrences = 0;
  328. if (!s.empty())
  329. {
  330. occurrences = 1;
  331. }
  332. std::string::size_type pos = 0;
  333. auto target = ",";
  334. while ((pos = s.find(target, pos)) != std::string::npos)
  335. {
  336. ++occurrences;
  337. pos += 1;
  338. }
  339. return occurrences;
  340. };
  341. template <int t>
  342. constexpr
  343. auto parse_stt(std::string_view stt)
  344. {
  345. auto prev_pos = std::string::size_type(0);
  346. auto pos = std::string::size_type(0);
  347. auto trans_cpt = 0;
  348. do
  349. {
  350. pos = stt.find("\n", prev_pos);
  351. auto transition_symbol = stt.find("->", prev_pos);
  352. auto init_symbol = stt.find("[*]", prev_pos);
  353. if (init_symbol < pos || transition_symbol >= pos)
  354. {
  355. prev_pos = pos + 1;
  356. }
  357. else
  358. {
  359. if (trans_cpt == t)
  360. {
  361. return boost::msm::front::puml::detail::parse_row(stt.substr(prev_pos, pos - prev_pos));
  362. }
  363. prev_pos = pos + 1;
  364. ++trans_cpt;
  365. }
  366. } while (pos != std::string::npos);
  367. // should not happen
  368. return boost::msm::front::puml::detail::Transition{};
  369. }
  370. template <int a>
  371. constexpr auto parse_action(std::string_view actions)
  372. {
  373. //actions = reduce(actions, "");
  374. auto prev_pos = std::string::size_type(0);
  375. auto pos = std::string::size_type(0);
  376. auto action_cpt = 0;
  377. do
  378. {
  379. pos = actions.find(",", prev_pos);
  380. if (action_cpt == a)
  381. {
  382. return boost::msm::front::puml::detail::cleanup_token(actions.substr(prev_pos, pos - prev_pos));
  383. }
  384. ++action_cpt;
  385. prev_pos = pos + 1;
  386. } while (pos != std::string::npos);
  387. // should not happen
  388. return std::string_view{};
  389. }
  390. template <int t>
  391. constexpr
  392. auto parse_inits(std::string_view stt)
  393. {
  394. //stt = reduce(stt, "");
  395. auto prev_pos = std::string::size_type(0);
  396. auto pos = std::string::size_type(0);
  397. auto trans_cpt = 0;
  398. do
  399. {
  400. pos = stt.find("\n", prev_pos);
  401. auto init_symbol = stt.find("[*]", prev_pos);
  402. if (pos > init_symbol)
  403. {
  404. auto init_symbol2 = stt.find("->", init_symbol);
  405. if (pos > init_symbol2)
  406. {
  407. if (trans_cpt == t)
  408. {
  409. return cleanup_token(stt.substr(init_symbol2 + 2, pos - init_symbol2 - 2));
  410. }
  411. ++trans_cpt;
  412. }
  413. }
  414. prev_pos = pos + 1;
  415. } while (pos != std::string::npos);
  416. // should not happen
  417. return std::string_view{};
  418. }
  419. } //namespace detail
  420. constexpr std::uint32_t by_name(std::string_view str)
  421. {
  422. return boost::msm::front::puml::detail::crc32(str) ^ 0xFFFFFFFF;
  423. }
  424. // specializations
  425. template<>
  426. struct convert_to_msm_names<State<by_name("")>>
  427. {
  428. using type = boost::msm::front::none;
  429. };
  430. template<>
  431. struct convert_to_msm_names<Event< by_name("")>>
  432. {
  433. using type = boost::msm::front::none;
  434. };
  435. template<>
  436. struct convert_to_msm_names<Action< by_name("")>>
  437. {
  438. using type = boost::msm::front::none;
  439. };
  440. template<>
  441. struct convert_to_msm_names<Guard< by_name("")>>
  442. {
  443. using type = boost::msm::front::none;
  444. };
  445. template<>
  446. struct convert_to_msm_names<Action< by_name("defer")>>
  447. {
  448. using type = boost::msm::front::Defer;
  449. };
  450. template<>
  451. struct convert_to_msm_names<Event< by_name("*")>>
  452. {
  453. using type = boost::any;
  454. };
  455. namespace detail
  456. {
  457. template <class Func>
  458. constexpr auto parse_guard_simple(Func guard_func)
  459. {
  460. constexpr auto and_pos = guard_func().find("&&");
  461. constexpr auto or_pos = guard_func().find("||");
  462. constexpr auto not_pos = guard_func().find("!");
  463. constexpr auto parens_begin_pos = guard_func().find("(");
  464. constexpr auto parens_end_pos = guard_func().find(")");
  465. constexpr auto last_and_pos = guard_func().find("&&", parens_end_pos);
  466. constexpr auto last_or_pos = guard_func().find("||", parens_end_pos);
  467. // check for operator of the lesser precedence after end parens
  468. if constexpr (parens_begin_pos != std::string::npos && parens_end_pos != std::string::npos &&
  469. last_or_pos != std::string::npos && parens_end_pos < last_or_pos)
  470. {
  471. return boost::msm::front::Or_<
  472. decltype(boost::msm::front::puml::detail::parse_guard_simple(
  473. [=]() {return boost::msm::front::puml::detail::cleanup_token(guard_func().substr(0, last_or_pos)); })),
  474. decltype(boost::msm::front::puml::detail::parse_guard_simple(
  475. [=]() {return boost::msm::front::puml::detail::cleanup_token(guard_func().substr(last_or_pos + 2)); })) > {};
  476. }
  477. else if constexpr (parens_begin_pos != std::string::npos && parens_end_pos != std::string::npos &&
  478. last_and_pos != std::string::npos && parens_end_pos < last_and_pos)
  479. {
  480. return boost::msm::front::And_<
  481. decltype(boost::msm::front::puml::detail::parse_guard_simple(
  482. [=]() {return boost::msm::front::puml::detail::cleanup_token(guard_func().substr(0, last_and_pos)); })),
  483. decltype(boost::msm::front::puml::detail::parse_guard_simple(
  484. [=]() {return boost::msm::front::puml::detail::cleanup_token(guard_func().substr(last_and_pos + 2)); })) > {};
  485. }
  486. else if constexpr (parens_begin_pos != std::string::npos && parens_end_pos != std::string::npos &&
  487. or_pos != std::string::npos && or_pos < and_pos && or_pos < parens_begin_pos)
  488. {
  489. return boost::msm::front::Or_<
  490. decltype(boost::msm::front::puml::detail::parse_guard_simple(
  491. [=]() {return boost::msm::front::puml::detail::cleanup_token(guard_func().substr(0, or_pos)); })),
  492. decltype(boost::msm::front::puml::detail::parse_guard_simple(
  493. [=]() {return boost::msm::front::puml::detail::cleanup_token(guard_func().substr(or_pos + 2)); })) > {};
  494. }
  495. else if constexpr (parens_begin_pos != std::string::npos && parens_end_pos != std::string::npos &&
  496. and_pos != std::string::npos && and_pos < or_pos && and_pos < parens_begin_pos)
  497. {
  498. return boost::msm::front::And_<
  499. decltype(boost::msm::front::puml::detail::parse_guard_simple(
  500. [=]() {return boost::msm::front::puml::detail::cleanup_token(guard_func().substr(0, and_pos)); })),
  501. decltype(boost::msm::front::puml::detail::parse_guard_simple(
  502. [=]() {return boost::msm::front::puml::detail::cleanup_token(guard_func().substr(and_pos + 2)); })) > {};
  503. }
  504. else if constexpr (parens_begin_pos != std::string::npos && parens_end_pos != std::string::npos &&
  505. not_pos != std::string::npos && not_pos < parens_begin_pos)
  506. {
  507. return boost::msm::front::Not_<decltype(boost::msm::front::puml::detail::parse_guard_simple(
  508. [=]() {return boost::msm::front::puml::detail::cleanup_token(guard_func().substr(not_pos + 1)); })) > {};
  509. }
  510. else if constexpr (parens_begin_pos != std::string::npos && parens_end_pos != std::string::npos)
  511. {
  512. return boost::msm::front::puml::detail::parse_guard_simple(
  513. [=]() {return boost::msm::front::puml::detail::cleanup_token(guard_func().substr(parens_begin_pos + 1, parens_end_pos - (parens_begin_pos + 1))); });
  514. }
  515. else if constexpr (and_pos == std::string::npos && or_pos == std::string::npos && not_pos == std::string::npos)
  516. {
  517. return typename boost::msm::front::puml::convert_to_msm_names < Guard <by_name(guard_func())> >::type{};
  518. }
  519. // at least one operator, break at pos of the lesser precedence
  520. else if constexpr (or_pos != std::string::npos)
  521. {
  522. return boost::msm::front::Or_<
  523. decltype(boost::msm::front::puml::detail::parse_guard_simple(
  524. [=]() {return boost::msm::front::puml::detail::cleanup_token(guard_func().substr(0, or_pos)); })),
  525. decltype(boost::msm::front::puml::detail::parse_guard_simple(
  526. [=]() {return boost::msm::front::puml::detail::cleanup_token(guard_func().substr(or_pos + 2)); })) > {};
  527. }
  528. else if constexpr (and_pos != std::string::npos)
  529. {
  530. return boost::msm::front::And_<
  531. decltype(boost::msm::front::puml::detail::parse_guard_simple(
  532. [=]() {return boost::msm::front::puml::detail::cleanup_token(guard_func().substr(0, and_pos)); })),
  533. decltype(boost::msm::front::puml::detail::parse_guard_simple(
  534. [=]() {return boost::msm::front::puml::detail::cleanup_token(guard_func().substr(and_pos + 2)); })) > {};
  535. }
  536. else
  537. {
  538. return boost::msm::front::Not_<decltype(boost::msm::front::puml::detail::parse_guard_simple(
  539. [=]() {return boost::msm::front::puml::detail::cleanup_token(guard_func().substr(not_pos + 1)); })) > {};
  540. }
  541. }
  542. template <class Func>
  543. constexpr auto parse_guard_advanced(Func guard_func)
  544. {
  545. constexpr auto and_pos = guard_func().find("And(");
  546. constexpr auto or_pos = guard_func().find("Or(");
  547. constexpr auto not_pos = guard_func().find("Not(");
  548. if constexpr (and_pos == std::string::npos && or_pos == std::string::npos && not_pos == std::string::npos)
  549. {
  550. return typename boost::msm::front::puml::convert_to_msm_names < Guard <by_name(guard_func())> >::type{};
  551. }
  552. // at least one operator, break at pos of the lesser precedence
  553. else if constexpr (or_pos != std::string::npos)
  554. {
  555. constexpr auto comma_pos = guard_func().find(",", or_pos);
  556. constexpr auto endparens_pos = guard_func().find(")", or_pos);
  557. return boost::msm::front::Or_<
  558. decltype(boost::msm::front::puml::detail::parse_guard_advanced(
  559. [=]() {return boost::msm::front::puml::detail::cleanup_token(guard_func().substr(or_pos + 3, comma_pos - (or_pos + 3))); })),
  560. decltype(boost::msm::front::puml::detail::parse_guard_advanced(
  561. [=]() {return boost::msm::front::puml::detail::cleanup_token(guard_func().substr(comma_pos + 1, endparens_pos - (comma_pos + 1))); }))
  562. > {};
  563. }
  564. else if constexpr (and_pos != std::string::npos)
  565. {
  566. constexpr auto comma_pos = guard_func().find(",", and_pos);
  567. constexpr auto endparens_pos = guard_func().find(")", and_pos);
  568. return boost::msm::front::And_<
  569. decltype(boost::msm::front::puml::detail::parse_guard_advanced(
  570. [=]() {return boost::msm::front::puml::detail::cleanup_token(guard_func().substr(and_pos + 4, comma_pos - (and_pos + 4))); })),
  571. decltype(boost::msm::front::puml::detail::parse_guard_advanced(
  572. [=]() {return boost::msm::front::puml::detail::cleanup_token(guard_func().substr(comma_pos + 1, endparens_pos - (comma_pos + 1))); }))
  573. > {};
  574. }
  575. else
  576. {
  577. constexpr auto endparens_pos = guard_func().find(")", not_pos);
  578. return boost::msm::front::Not_<
  579. decltype(boost::msm::front::puml::detail::parse_guard_advanced(
  580. [=]() {return boost::msm::front::puml::detail::cleanup_token(guard_func().substr(not_pos + 4, endparens_pos - (not_pos + 4))); }))
  581. > {};
  582. }
  583. }
  584. template <class Func>
  585. constexpr auto parse_guard(Func guard_func)
  586. {
  587. if constexpr (guard_func().find("And(") != std::string::npos ||
  588. guard_func().find("Or(") != std::string::npos ||
  589. guard_func().find("Not(") != std::string::npos)
  590. {
  591. return boost::msm::front::puml::detail::parse_guard_advanced(guard_func);
  592. }
  593. else
  594. {
  595. return boost::msm::front::puml::detail::parse_guard_simple(guard_func);
  596. }
  597. }
  598. constexpr int count_terminates(std::string_view s, std::size_t occurrences = 0)
  599. {
  600. if (s.empty())
  601. return occurrences;
  602. auto star_pos = s.find("[*]");
  603. auto arrow_pos = s.rfind("->", star_pos);
  604. auto endl_before_pos = s.rfind("\n", star_pos);
  605. if (star_pos != std::string::npos &&
  606. arrow_pos != std::string::npos &&
  607. arrow_pos > endl_before_pos )
  608. {
  609. return count_terminates(s.substr(star_pos + 3), occurrences + 1);
  610. }
  611. else if(star_pos != std::string::npos)
  612. {
  613. return count_terminates(s.substr(star_pos + 3), occurrences);
  614. }
  615. return occurrences;
  616. };
  617. template <class Func, class T>
  618. constexpr auto parse_terminate(Func stt, auto state_name, T vec = T{})
  619. {
  620. if constexpr (stt().empty())
  621. {
  622. return vec;
  623. }
  624. else
  625. {
  626. constexpr auto star_pos = stt().find("[*]");
  627. constexpr auto arrow_pos = stt().rfind("->", star_pos);
  628. constexpr auto endl_before_pos = stt().rfind("\n", star_pos);
  629. constexpr auto state_pos = stt().rfind(state_name(), arrow_pos);
  630. if constexpr (
  631. star_pos != std::string::npos &&
  632. arrow_pos != std::string::npos &&
  633. arrow_pos > endl_before_pos &&
  634. state_pos != std::string::npos &&
  635. state_pos > endl_before_pos &&
  636. cleanup_token(stt().substr(state_pos, arrow_pos - state_pos)) == state_name())
  637. {
  638. return
  639. typename ::boost::mpl::push_back<
  640. T,
  641. boost::msm::TerminateFlag
  642. >::type{};
  643. }
  644. else if constexpr (star_pos != std::string::npos)
  645. {
  646. return parse_terminate(
  647. [=]() {return stt().substr(star_pos + 3); },
  648. state_name,
  649. vec);
  650. }
  651. else
  652. {
  653. return vec;
  654. }
  655. }
  656. };
  657. template <class Func, class T = boost::fusion::vector0<>>
  658. constexpr auto parse_flags(Func stt, auto state_name, T vec = T{})
  659. {
  660. constexpr auto flag_pos = stt().find("flag");
  661. if constexpr (flag_pos != std::string::npos)
  662. {
  663. // we need to handle a flag
  664. constexpr auto endl_after_flag_pos = stt().find("\n", flag_pos);
  665. constexpr auto col_pos = stt().rfind(":",flag_pos);
  666. constexpr auto endl_before_flag_pos = stt().rfind("\n", flag_pos);
  667. if constexpr (endl_after_flag_pos != std::string::npos)
  668. {
  669. // the name start from end of prev line+1 to :
  670. if constexpr (cleanup_token(stt().substr(endl_before_flag_pos+1,col_pos- (endl_before_flag_pos+1))) == state_name())
  671. {
  672. // flag name is from flag tag until endline
  673. return parse_flags(
  674. [=]() {return stt().substr(endl_after_flag_pos + 1); },
  675. state_name,
  676. typename ::boost::mpl::push_back<
  677. T,
  678. typename boost::msm::front::puml::convert_to_msm_names<
  679. boost::msm::front::puml::Flag< by_name(cleanup_token(stt().substr(flag_pos + 4, endl_after_flag_pos - (flag_pos + 4))))>>::type
  680. >::type{});
  681. }
  682. else
  683. {
  684. // check starting from next line
  685. return parse_flags(
  686. [=]() {return stt().substr(endl_after_flag_pos + 1); },
  687. state_name,
  688. vec);
  689. }
  690. }
  691. else
  692. {
  693. // the flag line is the last line of the string so we will end recursion wether we found a flag or not
  694. if constexpr (cleanup_token(stt().substr(endl_before_flag_pos + 1, col_pos - (endl_before_flag_pos + 1))) == state_name())
  695. {
  696. return typename ::boost::mpl::push_back<
  697. T,
  698. typename boost::msm::front::puml::convert_to_msm_names<
  699. boost::msm::front::puml::Flag< by_name(cleanup_token(stt().substr(flag_pos + 4, endl_after_flag_pos - (flag_pos + 4))))>>::type
  700. >::type{};
  701. }
  702. else
  703. {
  704. return vec;
  705. }
  706. }
  707. }
  708. else
  709. {
  710. // no flag left, end recursion
  711. return vec;
  712. }
  713. }
  714. template <class Func, int actions_count, int anum, class T = boost::fusion::vector<>>
  715. constexpr auto create_action_sequence_helper(Func action_func, T vec = T{})
  716. {
  717. // stop condition
  718. if constexpr (anum >= actions_count)
  719. {
  720. return vec;
  721. }
  722. else
  723. {
  724. return boost::msm::front::puml::detail::create_action_sequence_helper<Func, actions_count, anum + 1>(
  725. action_func,
  726. typename ::boost::mpl::push_back<
  727. T,
  728. typename boost::msm::front::puml::convert_to_msm_names<
  729. Action<by_name(boost::msm::front::puml::detail::parse_action<anum>(action_func()))>>::type >::type{});
  730. }
  731. }
  732. template <class Func>
  733. constexpr auto create_action_sequence(Func action_func)
  734. {
  735. return boost::msm::front::puml::detail::create_action_sequence_helper<
  736. Func, boost::msm::front::puml::detail::count_actions(action_func()), 0>(action_func);
  737. }
  738. template <class Func, class T = boost::fusion::vector0<>>
  739. constexpr auto parse_state_actions(Func stt, auto state_name, auto tag_text, T vec = T{})
  740. {
  741. constexpr auto entry_pos = stt().find(std::string_view(tag_text()));
  742. constexpr auto tag_size = std::string_view(tag_text()).length();
  743. if constexpr (entry_pos != std::string::npos)
  744. {
  745. // we need to handle an entry
  746. constexpr auto endl_after_entry_pos = stt().find("\n", entry_pos);
  747. constexpr auto bracket_beg_after_entry_pos = stt().find("[", entry_pos);
  748. constexpr auto col_pos = stt().rfind(":", entry_pos);
  749. constexpr auto endl_before_entry_pos = stt().rfind("\n", entry_pos);
  750. auto make_action_sequence = [](auto actions)
  751. {
  752. if constexpr (boost::mpl::size<decltype(actions)>::value == 1)
  753. return boost::fusion::at_c<0>(actions);
  754. else if constexpr (boost::mpl::size<decltype(actions)>::value == 0)
  755. return boost::msm::front::none{};
  756. else
  757. return boost::msm::front::ActionSequence_<decltype(actions)>{};
  758. };
  759. if constexpr (endl_after_entry_pos != std::string::npos)
  760. {
  761. // the name start from end of prev line+1 to :
  762. if constexpr (by_name(cleanup_token(stt().substr(endl_before_entry_pos + 1, col_pos - (endl_before_entry_pos + 1)))) == by_name(state_name()))
  763. {
  764. if constexpr (bracket_beg_after_entry_pos != std::string::npos && bracket_beg_after_entry_pos < endl_after_entry_pos)
  765. {
  766. constexpr auto bracket_end_after_entry_pos = stt().find("]", entry_pos);
  767. auto guard_l = [=]() {return stt().substr(bracket_beg_after_entry_pos +1, bracket_end_after_entry_pos - (bracket_beg_after_entry_pos +1)) ; };
  768. auto action_l = [=]() {return stt().substr(entry_pos + tag_size, bracket_beg_after_entry_pos - (entry_pos + tag_size)); };
  769. // action name is from entry tag until [
  770. return parse_state_actions(
  771. [=]() {return stt().substr(endl_after_entry_pos + 1); },
  772. state_name,
  773. tag_text,
  774. typename ::boost::mpl::push_back<
  775. T,
  776. boost::msm::front::puml::detail::pair_type<
  777. decltype(make_action_sequence(boost::msm::front::puml::detail::create_action_sequence(action_l))),
  778. typename boost::msm::front::puml::convert_to_msm_names<
  779. decltype(boost::msm::front::puml::detail::parse_guard(guard_l))>::type
  780. >
  781. >::type{});
  782. }
  783. else
  784. {
  785. // action name is from entry tag until endline
  786. auto action_l = [=]() {return stt().substr(entry_pos + tag_size, endl_after_entry_pos - (entry_pos + tag_size)); };
  787. return parse_state_actions(
  788. [=]() {return stt().substr(endl_after_entry_pos + 1); },
  789. state_name,
  790. tag_text,
  791. typename ::boost::mpl::push_back<
  792. T,
  793. boost::msm::front::puml::detail::pair_type<
  794. decltype(make_action_sequence(boost::msm::front::puml::detail::create_action_sequence(action_l))),
  795. typename boost::msm::front::puml::convert_to_msm_names<
  796. boost::msm::front::puml::Guard<by_name("")>>::type
  797. >
  798. >::type{});
  799. }
  800. }
  801. else
  802. {
  803. // check starting from next line
  804. return parse_state_actions(
  805. [=]() {return stt().substr(endl_after_entry_pos + 1); },
  806. state_name,
  807. tag_text,
  808. vec);
  809. }
  810. }
  811. // last line of string
  812. else
  813. {
  814. // the entry line is the last line of the string so we will end recursion wether we found an entry or not
  815. if constexpr (by_name(cleanup_token(stt().substr(endl_before_entry_pos + 1, col_pos - (endl_before_entry_pos + 1)))) == by_name(state_name()))
  816. {
  817. if constexpr (bracket_beg_after_entry_pos != std::string::npos && bracket_beg_after_entry_pos < endl_after_entry_pos)
  818. {
  819. constexpr auto bracket_end_after_entry_pos = stt().find("]", entry_pos);
  820. auto guard_l = [stt]() {return stt().substr(bracket_beg_after_entry_pos +1, bracket_end_after_entry_pos - (bracket_beg_after_entry_pos +1)) ; };
  821. // action name is from entry tag until [
  822. auto action_l = [stt]() {return stt().substr(entry_pos + tag_size, bracket_beg_after_entry_pos - (entry_pos + tag_size)); };
  823. return
  824. typename ::boost::mpl::push_back<
  825. T,
  826. boost::msm::front::puml::detail::pair_type<
  827. decltype(make_action_sequence(boost::msm::front::puml::detail::create_action_sequence(action_l))),
  828. decltype(boost::msm::front::puml::detail::parse_guard(guard_l))
  829. >
  830. >::type{};
  831. }
  832. else
  833. {
  834. auto action_l = [stt]() {return stt().substr(entry_pos + tag_size, endl_after_entry_pos - (entry_pos + tag_size)); };
  835. return
  836. typename ::boost::mpl::push_back<
  837. T,
  838. boost::msm::front::puml::detail::pair_type <
  839. decltype(make_action_sequence(boost::msm::front::puml::detail::create_action_sequence(action_l))),
  840. boost::msm::front::puml::Guard<by_name("")>
  841. >
  842. >::type{};
  843. }
  844. }
  845. else
  846. {
  847. return vec;
  848. }
  849. }
  850. }
  851. else
  852. {
  853. // no entry left, end recursion
  854. return vec;
  855. }
  856. }
  857. // recursively fills fusion vector with transition (making a tansition_table)
  858. template <class Func, int transitions, int tnum, class T = boost::fusion::vector<>>
  859. constexpr auto create_transition_table_helper(Func stt, T vec = T{})
  860. {
  861. // stop condition
  862. if constexpr (tnum >= transitions)
  863. {
  864. return vec;
  865. }
  866. else
  867. {
  868. auto guard_l = [stt]() {return boost::msm::front::puml::detail::parse_stt<tnum>(stt()).guard; };
  869. auto action_l = [stt]() {return boost::msm::front::puml::detail::parse_stt<tnum>(stt()).action; };
  870. auto source_l = [stt]() {return boost::msm::front::puml::detail::parse_stt<tnum>(stt()).source; };
  871. auto target_l = [stt]() {return boost::msm::front::puml::detail::parse_stt<tnum>(stt()).target; };
  872. auto stt_l = [stt]() {return std::string_view(stt()); };
  873. auto entry_l = []() {return "entry"; };
  874. auto exit_l = []() {return "exit"; };
  875. auto make_action_sequence = [](auto actions)
  876. {
  877. if constexpr (boost::mpl::size<decltype(actions)>::value == 1)
  878. return boost::fusion::at_c<0>(actions);
  879. else if constexpr (boost::mpl::size<decltype(actions)>::value == 0)
  880. return boost::msm::front::none{};
  881. else
  882. return boost::msm::front::ActionSequence_<decltype(actions)>{};
  883. };
  884. using one_row =
  885. boost::msm::front::Row <
  886. State < by_name(boost::msm::front::puml::detail::parse_stt<tnum>(stt()).source),
  887. decltype(boost::msm::front::puml::detail::parse_terminate(
  888. stt_l, source_l, boost::msm::front::puml::detail::parse_flags(stt_l,source_l))),
  889. decltype(parse_state_actions(stt_l,source_l, entry_l)),
  890. decltype(parse_state_actions(stt_l,source_l, exit_l))
  891. >,
  892. typename boost::msm::front::puml::convert_to_msm_names<
  893. Event< by_name(boost::msm::front::puml::detail::parse_stt<tnum>(stt()).event)>>::type,
  894. typename boost::msm::front::puml::convert_to_msm_names<
  895. State< by_name(boost::msm::front::puml::detail::parse_stt<tnum>(stt()).target),
  896. decltype(boost::msm::front::puml::detail::parse_terminate(
  897. stt_l, target_l, boost::msm::front::puml::detail::parse_flags(stt_l,target_l))),
  898. decltype(parse_state_actions(stt_l, target_l, entry_l)),
  899. decltype(parse_state_actions(stt_l, target_l, exit_l))
  900. >>::type,
  901. decltype(make_action_sequence(boost::msm::front::puml::detail::create_action_sequence(action_l))),
  902. decltype(boost::msm::front::puml::detail::parse_guard(guard_l))
  903. >;
  904. return boost::msm::front::puml::detail::create_transition_table_helper<Func, transitions, tnum + 1>(
  905. stt, typename ::boost::mpl::push_back< T, one_row>::type{});
  906. }
  907. }
  908. template <class Func, int regions, int rnum, class T = boost::fusion::vector<>>
  909. constexpr auto create_inits_helper(Func stt, T vec = T{})
  910. {
  911. // stop condition
  912. if constexpr (rnum >= regions)
  913. {
  914. return vec;
  915. }
  916. else
  917. {
  918. return boost::msm::front::puml::detail::create_inits_helper<Func, regions, rnum + 1>(
  919. stt, typename ::boost::mpl::push_back< T, State<by_name(boost::msm::front::puml::detail::parse_inits<rnum>(stt()))> >::type{});
  920. }
  921. }
  922. }//namespace detail
  923. template <class Func>
  924. constexpr auto create_transition_table(Func stt_func)
  925. {
  926. return boost::msm::front::puml::detail::create_transition_table_helper<
  927. Func,
  928. boost::msm::front::puml::detail::count_transitions(
  929. stt_func()) -
  930. boost::msm::front::puml::detail::count_inits(stt_func()) -
  931. boost::msm::front::puml::detail::count_terminates(stt_func())
  932. , 0>(stt_func);
  933. }
  934. template <class Func>
  935. constexpr auto create_initial_states(Func stt_func)
  936. {
  937. return boost::msm::front::puml::detail::create_inits_helper<
  938. Func,
  939. boost::msm::front::puml::detail::count_inits(stt_func()), 0>(stt_func);
  940. }
  941. template <class Func>
  942. constexpr auto create_fsm_table(Func stt_func)
  943. {
  944. return boost::msm::front::puml::detail::pair_type <
  945. decltype(
  946. boost::msm::front::puml::detail::create_transition_table_helper<
  947. Func,
  948. boost::msm::front::puml::detail::count_transitions(
  949. stt_func()) -
  950. boost::msm::front::puml::detail::count_inits(stt_func()) -
  951. boost::msm::front::puml::detail::count_terminates(stt_func())
  952. , 0>(stt_func)),
  953. decltype(
  954. boost::msm::front::puml::detail::create_inits_helper<
  955. Func,
  956. boost::msm::front::puml::detail::count_inits(stt_func()), 0>(stt_func))>{};
  957. }
  958. }//boost::msm::front::puml
  959. // helper macro to hide declarations
  960. #define BOOST_MSM_PUML_DECLARE_TABLE(stt) \
  961. using Stt = decltype(create_fsm_table([]() {return stt;})); \
  962. using transition_table = typename Stt::first; \
  963. using initial_state = typename Stt::second;
  964. #endif // BOOST_MSM_FRONT_PUML_COMMON_H