Exemple #1
0
 def __and__(self, other):
     "Sequential composition"
     result = _glue("&", self, other)
     remove = set()
     for x, e in cross((self.status(exit), other.status(entry))):
         new = "[%s&%s]" % (x, e)
         new_x, new_e = "[%s&]" % x, "[&%s]" % e
         result.merge_places(new, (new_x, new_e), status=internal)
         remove.update((new_x, new_e))
     for p in remove:
         result.remove_place(p)
     return result
Exemple #2
0
 def __and__ (self, other) :
     "Sequential composition"
     result = _glue("&", self, other)
     remove = set()
     for x, e in cross((self.status(exit), other.status(entry))) :
         new = "[%s&%s]" % (x, e)
         new_x, new_e = "[%s&]" % x, "[&%s]" % e
         result.merge_places(new, (new_x, new_e), status=internal)
         remove.update((new_x, new_e))
     for p in remove :
         result.remove_place(p)
     return result
Exemple #3
0
 def __add__(self, other):
     "Choice"
     result = _glue("+", self, other)
     for status in (entry, exit):
         remove = set()
         for l, r in cross((self.status(status), other.status(status))):
             new = "[%s+%s]" % (l, r)
             new_l, new_r = "[%s+]" % l, "[+%s]" % r
             result.merge_places(new, (new_l, new_r), status=status)
             remove.update((new_l, new_r))
         for p in remove:
             result.remove_place(p)
     return result
 def cases(cls):
     keys = []
     ranges = []
     for key, boundaries in sorted(cls.params.items()):
         keys.append(key)
         if len(boundaries) == 2:
             start, stop = boundaries
             step = 1
         elif len(boundaries) == 3:
             start, stop, step = boundaries
         ranges.append(range(start, stop + 1, step))
     for x in cross(ranges):
         yield cls(**dict(zip(keys, x)))
Exemple #5
0
 def __add__ (self, other) :
     "Choice"
     result = _glue("+", self, other)
     for status in (entry, exit) :
         remove = set()
         for l, r in cross((self.status(status),
                            other.status(status))) :
             new = "[%s+%s]" % (l, r)
             new_l, new_r = "[%s+]" % l, "[+%s]" % r
             result.merge_places(new, (new_l, new_r), status=status)
             remove.update((new_l, new_r))
         for p in remove :
             result.remove_place(p)
     return result
Exemple #6
0
 def __mul__(self, other):
     "Iteration"
     result = _glue("*", self, other)
     remove = set()
     for e1, x1, e2 in cross(
         (self.status(entry), self.status(exit), other.status(entry))):
         new = "[%s,%s*%s]" % (e1, x1, e2)
         new_e1, new_x1 = "[%s*]" % e1, "[%s*]" % x1
         new_e2 = "[*%s]" % e2
         result.merge_places(new, (new_e1, new_x1, new_e2),
                             status=entry)
         remove.update((new_e1, new_x1, new_e2))
     for p in remove:
         result.remove_place(p)
     return result
Exemple #7
0
 def __mul__ (self, other) :
     "Iteration"
     result = _glue("*", self, other)
     remove = set()
     for e1, x1, e2 in cross((self.status(entry),
                              self.status(exit),
                              other.status(entry))) :
         new = "[%s,%s*%s]" % (e1, x1, e2)
         new_e1, new_x1 = "[%s*]" % e1, "[%s*]" % x1
         new_e2 = "[*%s]" % e2
         result.merge_places(new, (new_e1, new_x1, new_e2),
                             status=entry)
         remove.update((new_e1, new_x1, new_e2))
     for p in remove :
         result.remove_place(p)
     return result
Exemple #8
0
 def __and__(self, other):
     if other is None:
         return self
     return SetOfSets(l | r for l, r in cross([self.sets, other.sets]))