function Automaton(substr) {
this.delta = [{"a":0, "b":1}, {"a":1, "b":0}];
this.state = 0;
this.search = function(str) {
this.state = 0;
for (var i = 0; i < str.length; i++) {
this.state = this.delta[this.state][str.charAt(i)];
WSH.Echo(this.state);
}
}
}
var a = new Automaton("...");
a.search("ababbbba");