424
|
1 |
import M3._
|
390
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2 |
|
463
|
3 |
assert(der('a', ZERO | ONE) == ALT(ZERO, ZERO))
|
|
4 |
assert(der('a', (CHAR('a') | ONE) ~ CHAR('a')) == ALTs(List(SEQ(ALT(ONE, ZERO), CHAR('a')), SEQs(List(ONE)))))
|
390
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
5 |
assert(der('a', (CHAR('a') | CHAR('a')) ~ CHAR('a')) == (ONE | ONE) ~ CHAR('a'))
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
6 |
assert(der('a', STAR(CHAR('a'))) == (ONE ~ STAR(CHAR('a'))))
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
7 |
assert(der('b', STAR(CHAR('a'))) == (ZERO ~ STAR(CHAR('a'))))
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
8 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
9 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
10 |
val r0_urban = "a" ~ "b" ~ "c"
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
11 |
assert(der('a', r0_urban) == (ONE ~ "b") ~ "c")
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
12 |
assert(der('b', r0_urban) == (ZERO ~ "b") ~ "c")
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
13 |
assert(der('c', r0_urban) == (ZERO ~ "b") ~ "c")
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
14 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
15 |
val r1_urban = (ONE ~ "b") ~ "c"
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
16 |
|
463
|
17 |
assert(der('a', r1_urban) == ((ZERO ~ "b") | SEQs(List(ZERO))) ~ "c")
|
|
18 |
assert(der('b', r1_urban) == ((ZERO ~ "b") | SEQs(List(ONE))) ~ "c")
|
|
19 |
assert(der('c', r1_urban) == ((ZERO ~ "b") | SEQs(List(ZERO))) ~ "c")
|
390
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
20 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
21 |
val r2_urban = ((ZERO ~ "b") | ONE) ~ "c"
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
22 |
|
463
|
23 |
assert(der('a', r2_urban) == ((((ZERO ~ "b") | ZERO) ~ "c") | SEQs(List(ZERO))))
|
|
24 |
assert(der('b', r2_urban) == ((((ZERO ~ "b") | ZERO) ~ "c") | SEQs(List(ZERO))))
|
|
25 |
assert(der('c', r2_urban) == ((((ZERO ~ "b") | ZERO) ~ "c") | SEQs(List(ONE))))
|
|
26 |
|