--- a/progs/nfa2.scala Tue Apr 11 06:22:46 2017 +0800
+++ b/progs/nfa2.scala Sat Apr 15 22:03:59 2017 +0800
@@ -173,26 +173,26 @@
// some examples for Thompson's
val A = thompson(CHAR('a'))
-println(A.accepts("a"))
-println(A.accepts("c"))
-println(A.accepts("aa"))
+println(A.accepts("a")) // true
+println(A.accepts("c")) // false
+println(A.accepts("aa")) // false
val B = thompson(ALT("ab","ac"))
-
-println(B.accepts("ab"))
-println(B.accepts("ac"))
-println(B.accepts("bb"))
-println(B.accepts("aa"))
+
+println(B.accepts("ab")) // true
+println(B.accepts("ac")) // true
+println(B.accepts("bb")) // false
+println(B.accepts("aa")) // false
val C = thompson(STAR("ab"))
-println(C.accepts(""))
-println(C.accepts("a"))
-println(C.accepts("ababab"))
-println(C.accepts("ab"))
-println(C.accepts("ac"))
-println(C.accepts("bb"))
-println(C.accepts("aa"))
+println(C.accepts("")) // true
+println(C.accepts("a")) // false
+println(C.accepts("ababab")) // true
+println(C.accepts("ab")) // true
+println(C.accepts("ac")) // false
+println(C.accepts("bb")) // false
+println(C.accepts("aa")) // false
// regular expression matcher using Thompson's
def matcher(r: Rexp, s: String) : Boolean = thompson(r).accepts(s)