Changeset 3901 for proto/RE/Haskell
 Timestamp:
 Jun 27, 2014, 3:16:08 AM (5 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

proto/RE/Haskell/Nullable.hs
r3888 r3901 46 46 removeNullablePrefix (Alt as) = Alt (map removeNullablePrefix as) 47 47 removeNullablePrefix (Rep(r, lb, ub)) 48  lb == 0 = Seq [] 49  isNullable(r) = Seq [] 50  otherwise = Seq [removeNullablePrefix(r), Rep(r, lb1, lb1)] 48  lb == 0 = Seq [] 49  isNullable(r) = Seq [] 50  hasNullablePrefix(r) = mkSeq[removeNullablePrefix(r), mkRep(r, lb1, lb1)] 51  otherwise = mkRep(r, lb, lb) 51 52  default: do nothing 52 53 removeNullablePrefix r = r … … 62 63 removeNullableSuffix (Alt as) = Alt (map removeNullableSuffix as) 63 64 removeNullableSuffix (Rep(r, lb, ub)) 64  lb == 0 = Seq [] 65  isNullable(r) = Seq [] 66  otherwise = Seq [Rep(r, lb1, lb1), removeNullableSuffix(r)] 65  lb == 0 = Seq [] 66  isNullable(r) = Seq [] 67  hasNullableSuffix(r) = mkSeq[mkRep(r, lb1, lb1), removeNullableSuffix(r)] 68  otherwise = mkRep(r, lb, lb) 67 69  default: do nothing 68 70 removeNullableSuffix r = r … … 73 75  isNullableSeq(more) = [removeNullableSuffix(a)] 74 76  otherwise = a:removeNullableSeqSuffix(more) 77 78 79 hasNullablePrefix :: RE > Bool 80 hasNullablePrefix (Seq (e:es)) 81  isNullable(e) = True 82  otherwise = hasNullablePrefix(e) 83 hasNullablePrefix (Alt []) = False 84 hasNullablePrefix (Alt (a:as)) 85  hasNullablePrefix(a) = True 86  otherwise = hasNullablePrefix (Alt as) 87 hasNullablePrefix (Rep(r, lb, ub)) = hasNullablePrefix(r) 88 hasNullablePrefix r = False 89 90 hasNullableSuffix :: RE > Bool 91 hasNullableSuffix (Seq [e]) 92  isNullable(e) = True 93  otherwise = hasNullableSuffix(e) 94 hasNullableSuffix (Seq (e:es)) = hasNullableSuffix(Seq es) 95 hasNullableSuffix (Alt []) = False 96 hasNullableSuffix (Alt (a:as)) 97  hasNullableSuffix(a) = True 98  otherwise = hasNullableSuffix (Alt as) 99 hasNullableSuffix (Rep(r, lb, ub)) = hasNullableSuffix(r) 100 hasNullableSuffix r = False
Note: See TracChangeset
for help on using the changeset viewer.