A finite state machine implementation.
Bases: exceptions.Exception
Exception thrown when StateMachine has no state defined to handle the current input data.
Bases: object
Base class for building a finite state machine.
The state machine is controled by two externally provided data structures.
A compiled regex pattern instance that contains one or more named groups (i.e. (?P<name>...)) sub-patterns.
A dict that maps a handler function to a group name returned by a successful match in the regex_obj instance.
Warning
The change_state() method must be run to initialize the state machine before the StateMachine instance is called.
For each line of text in lines, a regex match is performed and a state handler function is called to finalize processing of the string.
Parameters: | lines (list) – Input data consumed by state machine |
---|
Modifies the control flow of the state machine.
Replaces the internal regex_obj or match_handlers. Using keywords, one paramter can be changed without effecting the other.
Parameters: |
|
---|