Deterministic finite-state machine