296 def loops() = { |
297 def loops() = { |
297 println("lexing Loops") |
298 println("lexing Loops") |
298 println(escape(lexing_simp(WHILE_REGS, prog3)).mkString("\n")) |
299 println(escape(lexing_simp(WHILE_REGS, prog3)).mkString("\n")) |
299 } |
300 } |
300 |
301 |
301 |
302 @doc("Email Test") |
|
303 @main |
|
304 def email() = { |
|
305 val lower = "abcdefghijklmnopqrstuvwxyz" |
|
306 |
|
307 val NAME = RECD("name", PLUS(RANGE(lower ++ "_.-"))) |
|
308 val DOMAIN = RECD("domain", PLUS(RANGE(lower ++ "-"))) |
|
309 val RE = RANGE(lower ++ ".") |
|
310 val TOPLEVEL = RECD("top", (RE ~ RE) | |
|
311 (RE ~ RE ~ RE) | |
|
312 (RE ~ RE ~ RE ~ RE) | |
|
313 (RE ~ RE ~ RE ~ RE ~ RE) | |
|
314 (RE ~ RE ~ RE ~ RE ~ RE ~ RE)) |
|
315 |
|
316 val EMAIL = NAME ~ "@" ~ DOMAIN ~ "." ~ TOPLEVEL |
|
317 |
|
318 println(lexing_simp(EMAIL, "christian.urban@kcl.ac.uk")) |
|
319 } |
302 |
320 |
303 |
321 |
304 @doc("All tests.") |
322 @doc("All tests.") |
305 @main |
323 @main |
306 def all() = { small(); fib() ; loops() } |
324 def all() = { small(); fib() ; loops() ; email() } |
307 |
325 |
308 |
326 |
309 val SYM1 = RANGE("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvwxyz_.-") |
327 |
310 val NAME = RECD("name", PLUS(SYM1)) |
328 |
311 |
|
312 val SYM2 = RANGE("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvwxyz-") |
|
313 val DOMAIN = RECD("domain", PLUS(SYM2)) |
|
314 |
|
315 val RE = RANGE("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvwxyz.") |
|
316 val TOPLEVEL = RECD("tl", (RE ~ RE) | |
|
317 (RE ~ RE ~ RE) | |
|
318 (RE ~ RE ~ RE ~ RE) | |
|
319 (RE ~ RE ~ RE ~ RE ~ RE) | |
|
320 (RE ~ RE ~ RE ~ RE ~ RE ~ RE)) |
|
321 |
|
322 val EMAIL = NAME ~ "@" ~ DOMAIN ~ "." ~ TOPLEVEL |
|
323 |
|
324 println(lexing_simp(EMAIL, "christian.urban@kcl.ac.uk")) |
|