(self, left, collected=None)
| 275 | class Either(ParentPattern): |
| 276 | |
| 277 | def match(self, left, collected=None): |
| 278 | collected = [] if collected is None else collected |
| 279 | outcomes = [] |
| 280 | for p in self.children: |
| 281 | matched, _, _ = outcome = p.match(left, collected) |
| 282 | if matched: |
| 283 | outcomes.append(outcome) |
| 284 | if outcomes: |
| 285 | return min(outcomes, key=lambda outcome: len(outcome[1])) |
| 286 | return False, left, collected |
| 287 | |
| 288 | |
| 289 | class TokenStream(list): |
no outgoing calls