| 251 | |
| 252 | |
| 253 | class OneOrMore(ParentPattern): |
| 254 | |
| 255 | def match(self, left, collected=None): |
| 256 | assert len(self.children) == 1 |
| 257 | collected = [] if collected is None else collected |
| 258 | l = left |
| 259 | c = collected |
| 260 | l_ = None |
| 261 | matched = True |
| 262 | times = 0 |
| 263 | while matched: |
| 264 | # could it be that something didn't match but changed l or c? |
| 265 | matched, l, c = self.children[0].match(l, c) |
| 266 | times += 1 if matched else 0 |
| 267 | if l_ == l: |
| 268 | break |
| 269 | l_ = l |
| 270 | if times >= 1: |
| 271 | return True, l, c |
| 272 | return False, left, collected |
| 273 | |
| 274 | |
| 275 | class Either(ParentPattern): |
no outgoing calls
searching dependent graphs…