Finite-state machine generator