A state machine implementation for Python --- which *isn't* solely designed to parse strings!