marking4/re_test2.scala
author Christian Urban <christian.urban@kcl.ac.uk>
Mon, 08 Nov 2021 02:29:24 +0000
changeset 411 f55742af79ef
parent 288 65731df141a5
permissions -rw-r--r--
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
288
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
     1
import CW9c._
168
03530cb87cd0 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     2
03530cb87cd0 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     3
assert(der('a', ZERO | ONE) == (ZERO | ZERO))
03530cb87cd0 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     4
assert(der('a', (CHAR('a') | ONE) ~ CHAR('a')) == ALT((ONE | ZERO) ~ CHAR('a'), ONE))
03530cb87cd0 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     5
assert(der('a', (CHAR('a') | CHAR('a')) ~ CHAR('a')) == (ONE | ONE) ~ CHAR('a'))
03530cb87cd0 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     6
assert(der('a', STAR(CHAR('a'))) == (ONE ~ STAR(CHAR('a'))))
03530cb87cd0 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     7
assert(der('b', STAR(CHAR('a'))) == (ZERO ~ STAR(CHAR('a'))))
245
975d34506e88 added marking
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
     8
975d34506e88 added marking
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
     9
975d34506e88 added marking
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
    10
val r0_urban = "a" ~ "b" ~ "c"
975d34506e88 added marking
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
    11
assert(der('a', r0_urban) == (ONE ~ "b") ~ "c")
975d34506e88 added marking
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
    12
assert(der('b', r0_urban) == (ZERO ~ "b") ~ "c")
975d34506e88 added marking
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
    13
assert(der('c', r0_urban) == (ZERO ~ "b") ~ "c")
975d34506e88 added marking
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
    14
975d34506e88 added marking
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
    15
val r1_urban = (ONE ~ "b") ~ "c"
975d34506e88 added marking
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
    16
975d34506e88 added marking
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
    17
assert(der('a', r1_urban) == ((ZERO ~ "b") | ZERO) ~ "c")
975d34506e88 added marking
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
    18
assert(der('b', r1_urban) == ((ZERO ~ "b") | ONE) ~ "c")
975d34506e88 added marking
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
    19
assert(der('c', r1_urban) == ((ZERO ~ "b") | ZERO) ~ "c")
975d34506e88 added marking
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
    20
975d34506e88 added marking
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
    21
val r2_urban = ((ZERO ~ "b") | ONE) ~ "c"
975d34506e88 added marking
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
    22
975d34506e88 added marking
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
    23
assert(der('a', r2_urban) == ((((ZERO ~ "b") | ZERO) ~ "c") | ZERO))
975d34506e88 added marking
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
    24
assert(der('b', r2_urban) == ((((ZERO ~ "b") | ZERO) ~ "c") | ZERO))
975d34506e88 added marking
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
    25
assert(der('c', r2_urban) == ((((ZERO ~ "b") | ZERO) ~ "c") | ONE))