--- a/progs/re4.scala Tue Oct 18 11:13:37 2016 +0100
+++ b/progs/re4.scala Tue Oct 18 19:14:33 2016 +0100
@@ -30,8 +30,8 @@
if (nullable(r1)) ALT(SEQ(der(c, r1), r2), der(c, r2))
else SEQ(der(c, r1), r2)
case STAR(r1) => SEQ(der(c, r1), STAR(r1))
- case NTIMES(r, i) =>
- if (i == 0) ZERO else SEQ(der(c, r), NTIMES(r, i - 1))
+ case NTIMES(r1, i) =>
+ if (i == 0) ZERO else der(c, SEQ(r1, NTIMES(r1, i - 1)))
}
def simp(r: Rexp) : Rexp = r match {
@@ -47,11 +47,6 @@
case (r1s, ONE) => r1s
case (r1s, r2s) => SEQ(r1s, r2s)
}
- case NTIMES(r1, n) => simp(r1) match {
- case ZERO => ZERO
- case ONE => ONE
- case r1s => NTIMES(r1s, n)
- }
case r => r
}