257
|
1 |
|
|
2 |
Below is the feedback and provisional marks for your submission
|
288
|
3 |
for the core part of assignment 9. Please note all marks are provisional until
|
257
|
4 |
ratified by the assessment board -- this is not an official
|
|
5 |
results transcript.
|
|
6 |
|
288
|
7 |
re.scala does not contain vars, returns, Arrays, ListBuffers etc?
|
257
|
8 |
--> success
|
288
|
9 |
re.scala runs?
|
257
|
10 |
--> success
|
288
|
11 |
nullable(ZERO) == false
|
|
12 |
nullable(ONE) == true
|
|
13 |
nullable(CHAR('a')) == false
|
|
14 |
nullable(ZERO | ONE) == true
|
|
15 |
nullable(ZERO | CHAR('a')) == false
|
|
16 |
nullable(ONE ~ ONE) == true
|
|
17 |
nullable(ONE ~ CHAR('a')) == false
|
|
18 |
nullable(STAR(ZERO)) == true
|
257
|
19 |
--> success
|
288
|
20 |
der('a', ZERO | ONE) == (ZERO | ZERO)
|
|
21 |
der('a', (CHAR('a') | ONE) ~ CHAR('a')) == ALT((ONE | ZERO) ~ CHAR('a'), ONE)
|
|
22 |
der('a', (CHAR('a') | CHAR('a')) ~ CHAR('a')) == (ONE | ONE) ~ CHAR('a')
|
|
23 |
der('a', STAR(CHAR('a'))) == (ONE ~ STAR(CHAR('a')))
|
|
24 |
der('b', STAR(CHAR('a'))) == (ZERO ~ STAR(CHAR('a')))
|
|
25 |
|
|
26 |
val r0 = "a" ~ "b" ~ "c"
|
|
27 |
assert(der('a', r0) == (ONE ~ "b") ~ "c")
|
|
28 |
assert(der('b', r0) == (ZERO ~ "b") ~ "c")
|
|
29 |
assert(der('c', r0) == (ZERO ~ "b") ~ "c")
|
|
30 |
|
|
31 |
val r1 = (ONE ~ "b") ~ "c"
|
|
32 |
assert(der('a', r1) == ((ZERO ~ "b") | ZERO) ~ "c")
|
|
33 |
assert(der('b', r1) == ((ZERO ~ "b") | ONE) ~ "c")
|
|
34 |
assert(der('c', r1) == ((ZERO ~ "b") | ZERO) ~ "c")
|
|
35 |
|
|
36 |
val r2 = ((ZERO ~ "b") | ONE) ~ "c"
|
|
37 |
assert(der('a', r2) == ((((ZERO ~ "b") | ZERO) ~ "c") | ZERO))
|
|
38 |
assert(der('b', r2) == ((((ZERO ~ "b") | ZERO) ~ "c") | ZERO))
|
|
39 |
assert(der('c', r2) == ((((ZERO ~ "b") | ZERO) ~ "c") | ONE))
|
257
|
40 |
--> success
|
288
|
41 |
simp(ZERO | ONE) == ONE
|
|
42 |
simp(STAR(ZERO | ONE)) == STAR(ZERO | ONE)
|
|
43 |
simp(ONE ~ (ONE ~ (ONE ~ CHAR('a')))) == CHAR('a')
|
|
44 |
simp(((ONE ~ ONE) ~ ONE) ~ CHAR('a')) == CHAR('a')
|
|
45 |
simp(((ONE | ONE) ~ ONE) ~ CHAR('a')) == CHAR('a')
|
|
46 |
simp(ONE ~ (ONE ~ (ONE ~ ZERO))) == ZERO
|
|
47 |
simp(ALT(ONE ~ (ONE ~ (ONE ~ ZERO)), CHAR('a'))) == CHAR('a')
|
|
48 |
simp(CHAR('a') | CHAR('a')) == CHAR('a')
|
|
49 |
simp(CHAR('a') ~ CHAR('a')) == CHAR('a') ~ CHAR('a')
|
|
50 |
simp(ONE | CHAR('a')) == (ONE | CHAR('a'))
|
|
51 |
simp(ALT((CHAR('a') | ZERO) ~ ONE,
|
|
52 |
((ONE | CHAR('b')) | CHAR('c')) ~ (CHAR('d') ~ ZERO))) == CHAR('a')
|
|
53 |
simp((ZERO | ((ZERO | ZERO) | (ZERO | ZERO))) ~ ((ONE | ZERO) | ONE ) ~ (CHAR('a'))) == ZERO
|
|
54 |
simp(ALT(ONE | ONE, ONE | ONE)) == ONE
|
|
55 |
simp(ALT(ZERO | CHAR('a'), CHAR('a') | ZERO)) == CHAR('a')
|
257
|
56 |
--> success
|
288
|
57 |
val EVIL = SEQ(STAR(STAR(CHAR('a'))), CHAR('b'))
|
|
58 |
ders(("a" * 5).toList,EVIL) == SEQ(SEQ(STAR(CHAR('a')),STAR(STAR(CHAR('a')))),CHAR('b'))
|
|
59 |
ders(List('b'),EVIL) == ONE
|
|
60 |
ders(List('b','b'),EVIL) == ZERO
|
|
61 |
matcher(EVIL, "a" * 5 ++ "b") == true
|
|
62 |
matcher(EVIL, "a" * 50 ++ "b") == true
|
|
63 |
matcher(EVIL, "a" * 50) == false
|
|
64 |
matcher(EVIL, "b") == true
|
|
65 |
matcher(EVIL, "bb") == false
|
|
66 |
matcher("abc", "abc") == true
|
|
67 |
matcher("abc", "ab") == true
|
|
68 |
matcher(("ab" | "a") ~ (ONE | "bc"), "abc") == true
|
|
69 |
matcher(ONE, "") == true
|
|
70 |
matcher(ZERO, "") == false
|
|
71 |
matcher(ONE | CHAR('a'), "") == true
|
|
72 |
matcher(ONE | CHAR('a'), "a") == true
|
|
73 |
--> success
|
|
74 |
val EVIL = SEQ(STAR(STAR(CHAR('a'))), CHAR('b'))
|
|
75 |
size(der('a', der('a', EVIL))) == 28
|
|
76 |
size(der('a', der('a', der('a', EVIL)))) == 58
|
|
77 |
size(ders("aaaaaa".toList, EVIL)) == 8
|
|
78 |
size(ders(("a" * 50).toList, EVIL)) == 8
|
|
79 |
--> success
|
|
80 |
simp(Iterator.iterate(ONE:Rexp)(r => SEQ(r, ONE | ONE)).drop(50).next) == ONE
|
|
81 |
...the Iterator produces the rexp
|
|
82 |
|
|
83 |
SEQ(SEQ(SEQ(..., ONE | ONE) , ONE | ONE), ONE | ONE)
|
|
84 |
|
|
85 |
where SEQ is nested 50 times.
|
|
86 |
|
|
87 |
simp(Iterator.iterate(ONE:Rexp)(r => ALT(r, r)).drop(20).next) == ONE
|
|
88 |
... the Iterator produces a rexp of size 2097151
|
|
89 |
|
|
90 |
val EVIL = SEQ(STAR(STAR(CHAR('a'))), CHAR('b'))
|
|
91 |
matcher(EVIL, "a" * 1000000 ++ "b") == true
|
|
92 |
matcher(EVIL, "a" * 1000000) == false
|
|
93 |
--> success
|
|
94 |
Overall mark for CW 9, Core Part
|
|
95 |
6
|