--- a/progs/re0.scala Tue Sep 26 14:07:29 2017 +0100
+++ b/progs/re0.scala Tue Sep 26 14:08:49 2017 +0100
@@ -1,4 +1,5 @@
import scala.annotation.tailrec
+import scala.language.implicitConversions
abstract class Rexp
@@ -16,7 +17,7 @@
// some convenience for typing in regular expressions
implicit def string2rexp(s : String) : Rexp = STR(s)
-implicit def RexpOps(r: Rexp) = new {
+implicit def RexpOps(r: Rexp) : Rexp = new {
def | (s: Rexp) = ALT(r, s)
def % = STAR(r)
def %(n: Int) = REP(r, n)
@@ -26,7 +27,7 @@
def ~ (s: Rexp) = SEQ(r, s)
}
-implicit def stringOps(s: String) = new {
+implicit def stringOps(s: String) : Rexp = new {
def | (r: Rexp) = ALT(s, r)
def | (r: String) = ALT(s, r)
def % = STAR(s)
@@ -72,6 +73,7 @@
if (i == 0) NULL else SEQ(der(c, r), REP(r, i - 1))
}
+
// derivative w.r.t. a string (iterates der)
@tailrec
def ders (s: List[Char], r: Rexp) : Rexp = s match {