equal
deleted
inserted
replaced
1 // Another automaton construction |
1 // Another "automaton" construction |
2 //================================ |
2 //================================ |
3 |
3 |
4 import $file.dfa, dfa._ |
4 import $file.dfa, dfa._ |
5 |
5 |
6 // regular expressions |
6 // regular expressions |
46 val pseudo = flaw(r) |
46 val pseudo = flaw(r) |
47 println(pseudo.accepts("".toList)) // true |
47 println(pseudo.accepts("".toList)) // true |
48 println(pseudo.accepts("a".toList)) // true |
48 println(pseudo.accepts("a".toList)) // true |
49 println(pseudo.accepts("aa".toList)) // true |
49 println(pseudo.accepts("aa".toList)) // true |
50 println(pseudo.accepts("bb".toList)) // false |
50 println(pseudo.accepts("bb".toList)) // false |
|
51 |
|
52 // Moral: this is not really a construction of an automaton, because |
|
53 // it can potentially have infinitely many states. Our implementation |
|
54 // of an automaton does not prevent this. It takes some additional |
|
55 // wprk to make this method to work. |