progs/automata/thompson.sc
changeset 753 d94fdbef1a4f
parent 742 b5b5583a3a08
child 779 5385c8342f02
--- a/progs/automata/thompson.sc	Tue Sep 01 16:00:37 2020 +0100
+++ b/progs/automata/thompson.sc	Wed Sep 02 23:34:19 2020 +0100
@@ -24,15 +24,6 @@
 type NFAtrans = (TState, Char) :=> Set[TState]
 type eNFAtrans = (TState, Option[Char]) :=> Set[TState]
 
-
-// for composing an eNFA transition with an NFA transition
-// | is for set union
-implicit def nfaOps(f: eNFAtrans) = new {
-  def +++(g: NFAtrans) : eNFAtrans = 
-  { case (q, None) =>  applyOrElse(f, (q, None)) 
-    case (q, Some(c)) => applyOrElse(f, (q, Some(c))) | applyOrElse(g, (q, c))  }
-}
-
  
 // NFA that does not accept any string
 def NFA_ZERO(): NFAt = {
@@ -53,6 +44,16 @@
   NFA(Set(Q1), { case (Q1, d) if (c == d) => Set(Q2) }, Set(Q2))
 }
 
+
+// for composing an eNFA transition with an NFA transition
+// | is for set union
+implicit def nfaOps(f: eNFAtrans) = new {
+  def +++(g: NFAtrans) : eNFAtrans = 
+  { case (q, None) =>  applyOrElse(f, (q, None)) 
+    case (q, Some(c)) => applyOrElse(f, (q, Some(c))) | applyOrElse(g, (q, c))  }
+}
+
+
 // sequence of two NFAs
 def NFA_SEQ(enfa1: NFAt, enfa2: NFAt) : NFAt = {
   val new_delta : eNFAtrans =