MCPcopy Create free account
hub / github.com/PlatformLab/NanoLog / Either

Class Either

preprocessor/docopt.py:268–279  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

266
267
268class Either(BranchPattern):
269
270 def match(self, left, collected=None):
271 collected = [] if collected is None else collected
272 outcomes = []
273 for pattern in self.children:
274 matched, _, _ = outcome = pattern.match(left, collected)
275 if matched:
276 outcomes.append(outcome)
277 if outcomes:
278 return min(outcomes, key=lambda outcome: len(outcome[1]))
279 return False, left, collected
280
281
282class Tokens(list):

Callers 2

transformFunction · 0.85
parse_exprFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected