javascript interpreter for a finite state machine language