c_language:state_machines
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 C state machine design.
An article that might contain good stuff State machine shortcuts
A (not really) related pattern that can be used for parsing is the Chain of responsibility pattern.
Ragel – Generate state machines specialized at parsing
PADS – Also for parsing protocols
c_language/state_machines.txt · Last modified: 2022/09/12 00:30 by 127.0.0.1
