Yet another finite automaton implementation.