equal
deleted
inserted
replaced
149 def lex(r: ARexp, s: List[Char]) : List[Boolean] = s match { |
149 def lex(r: ARexp, s: List[Char]) : List[Boolean] = s match { |
150 case Nil => if (nullable(r)) mkepsBC(r) else throw new Exception("Not matched") |
150 case Nil => if (nullable(r)) mkepsBC(r) else throw new Exception("Not matched") |
151 case c::cs => lex(der(c, r), cs) |
151 case c::cs => lex(der(c, r), cs) |
152 } |
152 } |
153 |
153 |
|
154 def pre_lexing(r: Rexp, s: String) = lex(internalise(r), s.toList) |
154 def lexing(r: Rexp, s: String) : Val = decode(r, lex(internalise(r), s.toList)) |
155 def lexing(r: Rexp, s: String) : Val = decode(r, lex(internalise(r), s.toList)) |
155 |
156 |
156 |
157 |
157 |
158 |
158 def simp(r: ARexp): ARexp = r match { |
159 def simp(r: ARexp): ARexp = r match { |
210 val end = System.nanoTime() |
211 val end = System.nanoTime() |
211 (end - start)/(i * 1.0e9) |
212 (end - start)/(i * 1.0e9) |
212 } |
213 } |
213 |
214 |
214 |
215 |
215 |
216 val rf = ("a" | "ab") ~ ("ab" | "") |
|
217 println(pre_lexing(rf, "ab")) |
|
218 println(lexing(rf, "ab")) |
|
219 println(lexing_simp(rf, "ab")) |
216 |
220 |
217 val r0 = ("a" | "ab") ~ ("b" | "") |
221 val r0 = ("a" | "ab") ~ ("b" | "") |
|
222 println(pre_lexing(r0, "ab")) |
218 println(lexing(r0, "ab")) |
223 println(lexing(r0, "ab")) |
219 println(lexing_simp(r0, "ab")) |
224 println(lexing_simp(r0, "ab")) |
220 |
225 |
221 val r1 = ("a" | "ab") ~ ("bcd" | "cd") |
226 val r1 = ("a" | "ab") ~ ("bcd" | "cd") |
222 println(lexing(r1, "abcd")) |
227 println(lexing(r1, "abcd")) |