====== Brainstorm ====== Three different approaches: * State is kept as a number in a variable. E.g. from a enum. And handled by switch-case * State is kept as pointer to struct with function pointers * State is kept as a index pointing to a state-transition table SO question with interesting answers [[https://stackoverflow.com/questions/1647631/c-state-machine-design|C state machine design]]. An article that might contain good stuff [[https://www.embedded.com/state-machine-shortcuts/|State machine shortcuts]] A (not really) related pattern that can be used for parsing is the [[https://stackoverflow.com/questions/33531587/chain-of-responsibility-vs-finite-state-machine-differences|Chain of responsibility]] pattern. [[http://www.colm.net/open-source/ragel/|Ragel]] -- Generate state machines specialized at parsing [[http://www.padsproj.org/|PADS]] -- Also for parsing protocols