Changeset 3427
 Timestamp:
 Aug 12, 2013, 5:53:10 PM (6 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

proto/RE/doc/re_proto.hs
r3420 r3427 48 48 minMatchLen (Bounded i j r) = i * (minMatchLen r) 49 49 50  removeNullablePrefix takes a regular expression and returns 51  the version of it that has been transformed to remove any nullable 52  prefixes. A prefix p is nullable if it can possibly match the empty 53  string, i.e., minMatchLen(p) = 0. For example, in the regexp 54  [az]*[09]+ the prefix [az]* is nullable. 50 55 56 removeNullablePrefix :: RE > RE 57 removeNullablePrefix (CC s) = (CC s) 58 removeNullablePrefix (CCnot s) = (CCnot s) 59 removeNullablePrefix (Lit s) = (Lit s) 60 removeNullablePrefix Start = Start 61 removeNullablePrefix End = End 62 removeNullablePrefix Any = Any 63 removeNullablePrefix (Join []) = Join [] 64 removeNullablePrefix (Join (r:rs)) 65  minMatchLen(r) == 0 = removeNullablePrefix(Join rs) 66  otherwise = Join (r:rs) 67 removeNullablePrefix (Alt rs) = Alt (map removeNullablePrefix rs) 68 removeNullablePrefix (Opt r) = Join [] 69 removeNullablePrefix (Kstar r) = Join [] 70 removeNullablePrefix (Kplus r) 71  minMatchLen(r) == 0 = Join [] 72  otherwise = Join [removeNullablePrefix(r), Kstar r] 73 removeNullablePrefix (OrMore i r) 74  minMatchLen(r) == 0 = Join [] 75  i == 0 = Join [] 76  otherwise = Join [removeNullablePrefix(r), OrMore (i1) r] 77 removeNullablePrefix (Bounded i j r) 78  minMatchLen(r) == 0 = Join [] 79  i == 0 = Join [] 80  otherwise = Join [removeNullablePrefix(r), Bounded (i1) (j1) r] 51 81 52
Note: See TracChangeset
for help on using the changeset viewer.