marking4/re_test2.scala
changeset 245 975d34506e88
parent 227 b5f3e814a710
child 288 65731df141a5
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/marking4/re_test2.scala	Fri Dec 14 14:41:54 2018 +0000
@@ -0,0 +1,24 @@
+
+assert(der('a', ZERO | ONE) == (ZERO | ZERO))
+assert(der('a', (CHAR('a') | ONE) ~ CHAR('a')) == ALT((ONE | ZERO) ~ CHAR('a'), ONE))
+assert(der('a', (CHAR('a') | CHAR('a')) ~ CHAR('a')) == (ONE | ONE) ~ CHAR('a'))
+assert(der('a', STAR(CHAR('a'))) == (ONE ~ STAR(CHAR('a'))))
+assert(der('b', STAR(CHAR('a'))) == (ZERO ~ STAR(CHAR('a'))))
+
+
+val r0_urban = "a" ~ "b" ~ "c"
+assert(der('a', r0_urban) == (ONE ~ "b") ~ "c")
+assert(der('b', r0_urban) == (ZERO ~ "b") ~ "c")
+assert(der('c', r0_urban) == (ZERO ~ "b") ~ "c")
+
+val r1_urban = (ONE ~ "b") ~ "c"
+
+assert(der('a', r1_urban) == ((ZERO ~ "b") | ZERO) ~ "c")
+assert(der('b', r1_urban) == ((ZERO ~ "b") | ONE) ~ "c")
+assert(der('c', r1_urban) == ((ZERO ~ "b") | ZERO) ~ "c")
+
+val r2_urban = ((ZERO ~ "b") | ONE) ~ "c"
+
+assert(der('a', r2_urban) == ((((ZERO ~ "b") | ZERO) ~ "c") | ZERO))
+assert(der('b', r2_urban) == ((((ZERO ~ "b") | ZERO) ~ "c") | ZERO))
+assert(der('c', r2_urban) == ((((ZERO ~ "b") | ZERO) ~ "c") | ONE))