diff -r b93f4d2aeee1 -r 36e5752fa191 progs/re1.scala --- a/progs/re1.scala Mon Oct 17 13:18:34 2016 +0100 +++ b/progs/re1.scala Tue Oct 18 10:43:26 2016 +0100 @@ -5,6 +5,12 @@ case class ALT(r1: Rexp, r2: Rexp) extends Rexp case class SEQ(r1: Rexp, r2: Rexp) extends Rexp case class STAR(r: Rexp) extends Rexp +case class RANGE(cs: List[Char]) extends Rexp +case class PLUS(r: Rexp) extends Rexp +case class OPT(r: Rexp) extends Rexp +case class NTIMES(r: Rexp, n : Int) extends Rexp +case class NMTIMES(r: Rexp, n : Int, m : Int) extends Rexp + // nullable function: tests whether the regular // expression can recognise the empty string @@ -15,6 +21,7 @@ case ALT(r1, r2) => nullable(r1) || nullable(r2) case SEQ(r1, r2) => nullable(r1) && nullable(r2) case STAR(_) => true + } // derivative of a regular expression w.r.t. a character