Convert javascript state machine to DOT