progs/app5.scala
changeset 399 5c1fbb39c93e
parent 261 24531cfaa36a
child 412 1cef3924f7a2
--- a/progs/app5.scala	Tue Mar 22 17:09:24 2016 +0000
+++ b/progs/app5.scala	Wed Apr 06 11:51:33 2016 +0100
@@ -1,6 +1,6 @@
 def nullable (r: Rexp) : Boolean = r match {
-  case NULL => false
-  case EMPTY => true
+  case ZERO => false
+  case ONE => true
   case CHAR(_) => false
   case ALT(r1, r2) => nullable(r1) || nullable(r2)
   case SEQ(r1, r2) => nullable(r1) && nullable(r2)
@@ -8,9 +8,9 @@
 }
 
 def der (c: Char, r: Rexp) : Rexp = r match {
-  case NULL => NULL
-  case EMPTY => NULL
-  case CHAR(d) => if (c == d) EMPTY else NULL
+  case ZERO => ZERO
+  case ONE => ZERO
+  case CHAR(d) => if (c == d) ONE else ZERO
   case ALT(r1, r2) => ALT(der(c, r1), der(c, r2))
   case SEQ(r1, r2) => 
     if (nullable(r1)) ALT(SEQ(der(c, r1), r2), der(c, r2))