Commit dae40f2a authored by Dominik Charousset's avatar Dominik Charousset

Add transition_if and unstable_state to FSM DSL

parent fec1f77c
...@@ -61,6 +61,15 @@ ...@@ -61,6 +61,15 @@
goto s_fin; \ goto s_fin; \
e_##name : e_##name :
/// Defines a state in the FSM that doesn't check for end-of-input. Unstable
/// states are supposed to contain epsilon transitions only.
#define unstable_state(name) \
CAF_FSM_EVAL_MISMATCH_EC \
} \
{ \
static constexpr auto mismatch_ec = caf::pec::trailing_character; \
s_##name : \
e_##name :
/// Ends the definition of an FSM. /// Ends the definition of an FSM.
#define fin() \ #define fin() \
...@@ -238,6 +247,12 @@ ...@@ -238,6 +247,12 @@
#endif // CAF_MSVC #endif // CAF_MSVC
// Makes a transition into another state if the `statement` is true.
#define transition_if(statement, ...) \
if (statement) { \
transition(__VA_ARGS__) \
}
// Makes an epsiolon transition into another state if the `statement` is true. // Makes an epsiolon transition into another state if the `statement` is true.
#define epsilon_if(statement, ...) \ #define epsilon_if(statement, ...) \
if (statement) { \ if (statement) { \
......
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
#undef term_state #undef term_state
#undef unstable_state
#undef fin #undef fin
#undef CAF_TRANSITION_IMPL1 #undef CAF_TRANSITION_IMPL1
...@@ -74,6 +76,8 @@ ...@@ -74,6 +76,8 @@
#undef fsm_epsilon #undef fsm_epsilon
#undef transition_if
#undef epsilon_if #undef epsilon_if
#undef fsm_transition_if #undef fsm_transition_if
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment