progs/display/thompson2.scala
changeset 489 e28d7a327870
parent 488 598741d39d21
--- a/progs/display/thompson2.scala	Sun May 07 00:20:58 2017 +0100
+++ b/progs/display/thompson2.scala	Sun May 07 03:01:29 2017 +0100
@@ -24,13 +24,12 @@
 
 // alternative of two NFAs
 def NFA_ALT(enfa1: NFAt, enfa2: NFAt) : NFAt = {
-  val Q = TState()
-  val new_delta : eNFAtrans = 
-    { case (Q, None) => enfa1.starts | enfa2.starts }
+  val new_delta : NFAtrans = { 
+    case (q, c) => applyOrElse(enfa1.delta, (q, c)) | 
+                   applyOrElse(enfa2.delta, (q, c)) }
   val new_fins = (q: TState) => enfa1.fins(q) || enfa2.fins(q)
 
-  eNFA(Set(Q), new_delta +++ enfa1.delta +++ enfa2.delta, 
-       new_fins)
+  NFA(enfa1.starts | enfa2.starts, new_delta, new_fins)
 }
 
 // star of a NFA