def mark2(hole): if isinstance(hole, dot): return dotmarker(hole, True) if isinstance(hole, star): return starmarker(hole, hole.last, hole.first) if isinstance(hole, holepartial): return starmarker(hole.hole, hole.stop, hole.start)
def mark0(hole): if isinstance(hole, dot): return dotmarker(hole, False) if isinstance(hole, star): return starmarker(hole, 0, 0) if isinstance(hole, holepartial): return starmarker(hole.hole, hole.start, hole.start)
def mark1(hole): if isinstance(hole, dot): return dotmarker(hole, True) if isinstance(hole, star): cursor = hole.last return starmarker(hole, cursor, cursor) if isinstance(hole, holepartial): return starmarker(hole.hole, hole.stop, hole.stop)
def replace(self, data, branch_in=False): length = sum(editlength(obj) for obj in data) self.buffer.do(self.marker, replace(data)) if self.marker.dot: self.marker = dotmarker(self.marker.hole, visited = not branch_in) else: cursor = self.marker.start + length * (not branch_in) self.marker = starmarker(self.marker.hole, cursor, cursor) if branch_in: self.walk()