equal
deleted
inserted
replaced
64 der('y', der('x', r2)) |
64 der('y', der('x', r2)) |
65 der('z', der('y', der('x', r2))) |
65 der('z', der('y', der('x', r2))) |
66 |
66 |
67 |
67 |
68 // the optional regular expression (one or zero times) |
68 // the optional regular expression (one or zero times) |
69 def OPT(r: Rexp) = ALT(r, ONE) |
69 def OPT(r: Rexp) = ALT(r, ONE) // r + 1 |
70 |
70 |
71 // the n-times regular expression (explicitly expanded) |
71 // the n-times regular expression (explicitly expanded) |
72 def NTIMES(r: Rexp, n: Int) : Rexp = n match { |
72 def NTIMES(r: Rexp, n: Int) : Rexp = n match { |
73 case 0 => ONE |
73 case 0 => ONE |
74 case 1 => r |
74 case 1 => r |
77 |
77 |
78 |
78 |
79 // Test Cases |
79 // Test Cases |
80 //============ |
80 //============ |
81 |
81 |
82 // the evil regular expression a?{n} a{n} |
82 // the evil regular expression (a?){n} a{n} |
83 def EVIL1(n: Int) = SEQ(NTIMES(OPT(CHAR('a')), n), NTIMES(CHAR('a'), n)) |
83 def EVIL1(n: Int) = |
|
84 SEQ(NTIMES(OPT(CHAR('a')), n), NTIMES(CHAR('a'), n)) |
84 |
85 |
85 // the evil regular expression (a*)* b |
86 // the evil regular expression (a*)* b |
86 val EVIL2 = SEQ(STAR(STAR(CHAR('a'))), CHAR('b')) |
87 val EVIL2 = SEQ(STAR(STAR(CHAR('a'))), CHAR('b')) |
87 |
88 |
88 // for measuring time |
89 // for measuring time |