equal
deleted
inserted
replaced
|
1 |
1 abstract class Rexp |
2 abstract class Rexp |
2 case object ZERO extends Rexp |
3 case object ZERO extends Rexp |
3 case object ONE extends Rexp |
4 case object ONE extends Rexp |
4 case class CHAR(c: Char) extends Rexp |
5 case class CHAR(c: Char) extends Rexp |
5 case class ALT(r1: Rexp, r2: Rexp) extends Rexp |
6 case class ALT(r1: Rexp, r2: Rexp) extends Rexp |
60 |
61 |
61 // the evil regular expression (a*)*b |
62 // the evil regular expression (a*)*b |
62 val EVIL2 = SEQ(STAR(STAR(CHAR('a'))), CHAR('b')) |
63 val EVIL2 = SEQ(STAR(STAR(CHAR('a'))), CHAR('b')) |
63 |
64 |
64 //for measuring time |
65 //for measuring time |
65 def time_needed[T](i: Int, code => T) = { |
66 def time_needed[T](i: Int, code: => T) = { |
66 val start = System.nanoTime() |
67 val start = System.nanoTime() |
67 for (j <- 1 to i) code() |
68 for (j <- 1 to i) code |
68 val end = System.nanoTime() |
69 val end = System.nanoTime() |
69 (end - start)/(i * 1.0e9) |
70 (end - start)/(i * 1.0e9) |
70 } |
71 } |
71 |
72 |
72 //test: (a?{n}) (a{n}) |
73 //test: (a?{n}) (a{n}) |