main_testing3/re_test2.scala
author Christian Urban <christian.urban@kcl.ac.uk>
Fri, 26 Apr 2024 17:36:41 +0100
changeset 487 efad9725dfd8
parent 475 59e005dcf163
permissions -rw-r--r--
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
475
59e005dcf163 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 433
diff changeset
     1
59e005dcf163 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 433
diff changeset
     2
def urbanmain() = {
59e005dcf163 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 433
diff changeset
     3
  import M3._
153
4383809c176a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     4
475
59e005dcf163 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 433
diff changeset
     5
  assert(der('a', ZERO | ONE) == ALT(ZERO, ZERO))
59e005dcf163 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 433
diff changeset
     6
  assert(der('a', (CHAR('a') | ONE) ~ CHAR('a')) == ALTs(List(SEQ(ALT(ONE, ZERO), CHAR('a')), SEQs(List(ONE)))))
59e005dcf163 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 433
diff changeset
     7
  assert(der('a', (CHAR('a') | CHAR('a')) ~ CHAR('a')) == (ONE | ONE) ~ CHAR('a'))
59e005dcf163 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 433
diff changeset
     8
  assert(der('a', STAR(CHAR('a'))) == (ONE ~ STAR(CHAR('a'))))
59e005dcf163 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 433
diff changeset
     9
  assert(der('b', STAR(CHAR('a'))) == (ZERO ~ STAR(CHAR('a'))))
59e005dcf163 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 433
diff changeset
    10
}
59e005dcf163 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 433
diff changeset
    11
300
72688efdf17c updated testing files
Christian Urban <urbanc@in.tum.de>
parents: 221
diff changeset
    12
433
6af86ba1208f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 403
diff changeset
    13
/*
300
72688efdf17c updated testing files
Christian Urban <urbanc@in.tum.de>
parents: 221
diff changeset
    14
val r0_urban = "a" ~ "b" ~ "c"
72688efdf17c updated testing files
Christian Urban <urbanc@in.tum.de>
parents: 221
diff changeset
    15
assert(der('a', r0_urban) == (ONE ~ "b") ~ "c")
72688efdf17c updated testing files
Christian Urban <urbanc@in.tum.de>
parents: 221
diff changeset
    16
assert(der('b', r0_urban) == (ZERO ~ "b") ~ "c")
72688efdf17c updated testing files
Christian Urban <urbanc@in.tum.de>
parents: 221
diff changeset
    17
assert(der('c', r0_urban) == (ZERO ~ "b") ~ "c")
72688efdf17c updated testing files
Christian Urban <urbanc@in.tum.de>
parents: 221
diff changeset
    18
72688efdf17c updated testing files
Christian Urban <urbanc@in.tum.de>
parents: 221
diff changeset
    19
val r1_urban = (ONE ~ "b") ~ "c"
72688efdf17c updated testing files
Christian Urban <urbanc@in.tum.de>
parents: 221
diff changeset
    20
72688efdf17c updated testing files
Christian Urban <urbanc@in.tum.de>
parents: 221
diff changeset
    21
assert(der('a', r1_urban) == ((ZERO ~ "b") | ZERO) ~ "c")
72688efdf17c updated testing files
Christian Urban <urbanc@in.tum.de>
parents: 221
diff changeset
    22
assert(der('b', r1_urban) == ((ZERO ~ "b") | ONE) ~ "c")
72688efdf17c updated testing files
Christian Urban <urbanc@in.tum.de>
parents: 221
diff changeset
    23
assert(der('c', r1_urban) == ((ZERO ~ "b") | ZERO) ~ "c")
72688efdf17c updated testing files
Christian Urban <urbanc@in.tum.de>
parents: 221
diff changeset
    24
72688efdf17c updated testing files
Christian Urban <urbanc@in.tum.de>
parents: 221
diff changeset
    25
val r2_urban = ((ZERO ~ "b") | ONE) ~ "c"
72688efdf17c updated testing files
Christian Urban <urbanc@in.tum.de>
parents: 221
diff changeset
    26
72688efdf17c updated testing files
Christian Urban <urbanc@in.tum.de>
parents: 221
diff changeset
    27
assert(der('a', r2_urban) == ((((ZERO ~ "b") | ZERO) ~ "c") | ZERO))
72688efdf17c updated testing files
Christian Urban <urbanc@in.tum.de>
parents: 221
diff changeset
    28
assert(der('b', r2_urban) == ((((ZERO ~ "b") | ZERO) ~ "c") | ZERO))
72688efdf17c updated testing files
Christian Urban <urbanc@in.tum.de>
parents: 221
diff changeset
    29
assert(der('c', r2_urban) == ((((ZERO ~ "b") | ZERO) ~ "c") | ONE))
433
6af86ba1208f updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 403
diff changeset
    30
*/