diff -r 69eddde11a65 -r e719e420cbc7 progs/matcher/re2.sc --- a/progs/matcher/re2.sc Fri Oct 03 10:10:33 2025 +0100 +++ b/progs/matcher/re2.sc Fri Oct 03 17:07:01 2025 +0100 @@ -12,15 +12,17 @@ // // amm re2.sc all - -abstract class Rexp -case object ZERO extends Rexp -case object ONE extends Rexp -case class CHAR(c: Char) extends Rexp -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 NTIMES(r: Rexp, n: Int) extends Rexp //explicit constructor for n-times +// regular expressions (as enum in Scala 3) +enum Rexp { + case ZERO // matches nothing + case ONE // matches an empty string + case CHAR(c: Char) // matches a character c + case ALT(r1: Rexp, r2: Rexp) // alternative + case SEQ(r1: Rexp, r2: Rexp) // sequence + case STAR(r: Rexp) // star + case NTIMES(r: Rexp, n: Int) // explicit n-times +} +import Rexp._ def nullable (r: Rexp) : Boolean = r match { @@ -145,8 +147,6 @@ size(ders(("a" * 20).toList, EVIL2)) // 7340068 - -@arg(doc = "All tests.") @main def all() = { test1(); test2() }