main_marking3/re_test3.scala
author Christian Urban <christian.urban@kcl.ac.uk>
Sat, 11 Mar 2023 22:42:09 +0000
changeset 464 73ced118f73d
parent 463 0315d9983cd0
permissions -rw-r--r--
updated to scala 3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
424
Christian Urban <christian.urban@kcl.ac.uk>
parents: 390
diff changeset
     1
import M3._
390
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     2
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     3
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     4
assert(simp(ZERO | ONE) == ONE)
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     5
assert(simp(STAR(ZERO | ONE)) == STAR(ZERO | ONE))
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     6
assert(simp(ONE ~ (ONE ~ (ONE ~ CHAR('a')))) == CHAR('a'))
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     7
assert(simp(((ONE ~ ONE) ~ ONE) ~ CHAR('a')) == CHAR('a'))
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     8
assert(simp(((ONE | ONE) ~ ONE) ~ CHAR('a')) == CHAR('a'))
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     9
assert(simp(ONE ~ (ONE ~ (ONE ~ ZERO))) == ZERO)
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    10
assert(simp(ALT(ONE ~ (ONE ~ (ONE ~ ZERO)), CHAR('a'))) == CHAR('a'))
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    11
assert(simp(CHAR('a') | CHAR('a')) == CHAR('a'))
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    12
assert(simp(CHAR('a') ~ CHAR('a')) == CHAR('a') ~ CHAR('a'))
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    13
assert(simp(ONE | CHAR('a')) == (ONE | CHAR('a')))
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    14
assert(simp(ALT((CHAR('a') | ZERO) ~ ONE,
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    15
                  ((ONE | CHAR('b')) | CHAR('c')) ~ (CHAR('d') ~ ZERO))) == CHAR('a'))
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    16
assert(simp((ZERO | ((ZERO | ZERO) | (ZERO | ZERO))) ~ ((ONE | ZERO) | ONE ) ~ (CHAR('a'))) == ZERO)
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    17
assert(simp(ALT(ONE | ONE, ONE | ONE)) == ONE)
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    18
assert(simp(ALT(ZERO | CHAR('a'), CHAR('a') | ZERO)) == CHAR('a'))
424
Christian Urban <christian.urban@kcl.ac.uk>
parents: 390
diff changeset
    19
assert(simp(ALT(ONE | CHAR('a'), CHAR('a') | ONE)) == ALT(ONE, CHAR('a')))
463
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
    20
assert(simp(ALTs(Nil)) == ZERO)
0315d9983cd0 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 424
diff changeset
    21
assert(simp(SEQs(List(CHAR('a')))) == CHAR('a'))
390
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    22