I'm not sure I understood the question correctly, but since you are following the steps in the sequence, I will assume that there is some contextual information, and therefore you are talking about choosing the next step based on the result of the current one.
This, in fact, is what concerns the machine. You have different states connected by transitions.
It is easy to ask each step about returning some tag , perhaps only a string or a specific type.
Then you define the automaton by defining the next step for each of the possible outputs of the current step.
For example, I actually use a framework (at work) that accepts these transitions as an xml file ... although I completely dislike the fact that the check is performed incorrectly or not ..
Please note that in C ++ it can be checked at compile time (I am thinking about using Boost.Variant and some metatheme programming tricks).
Matthieu M.
source share