equal
deleted
inserted
replaced
37 |
37 |
38 // main matcher function |
38 // main matcher function |
39 def matches(r: Rexp, s: String) : Boolean = nullable(ders(s.toList, r)) |
39 def matches(r: Rexp, s: String) : Boolean = nullable(ders(s.toList, r)) |
40 |
40 |
41 //example from the homework |
41 //example from the homework |
42 //val r = STAR(ALT(SEQ(CHAR('a'), CHAR('b')), CHAR('b'))) |
42 val r = STAR(ALT(SEQ(CHAR('a'), CHAR('b')), CHAR('b'))) |
43 //der('a', r) |
43 der('a', r) |
44 //der('b', r) |
44 der('b', r) |
45 //der('c', r) |
45 der('c', r) |
46 |
46 |
47 //optional: one or zero times |
47 //optional: one or zero times |
48 def OPT(r: Rexp) = ALT(r, EMPTY) |
48 def OPT(r: Rexp) = ALT(r, EMPTY) |
49 |
49 |
50 //n-times |
50 //n-times |