pyebnf/primitive.py
def _get_alternation(extractors, text):
  """Tries each extractor on the given text and returns the 'best fit'.

  Best fit is defined by as the extractor whose result consumed the most text. If more than one
  extractor is the best fit, the result of the one that appeared earliest in the list is returned.

  If all extractors raise a DeadEnd, this method too will raise a DeadEnd.
  """
  candidates = []

  for extractor in extractors:
    try:
      candidates.append(_call_extractor(extractor, text))
    except DeadEnd:
      pass

  if not candidates:
    raise DeadEnd

  result, *remaining = candidates

  for candidate in remaining:
    if len(candidate) > len(result):
      result = candidate

  return result
def _get_alternation(extractors, text):
  """Tries each extractor on the given text and returns the 'best fit'.

  Best fit is defined by as the extractor whose result consumed the most text. If more than one
  extractor is the best fit, the result of the one that appeared earliest in the list is returned.

  If all extractors raise a DeadEnd, this method too will raise a DeadEnd.
  """
  candidates = []

  for extractor in extractors:
    try:
      candidates.append(_call_extractor(extractor, text))
    except DeadEnd:
      pass

  if not candidates:
    raise DeadEnd

  result, *remaining = candidates

  for candidate in remaining:
    if len(candidate) > len(result):
      result = candidate

  return result
def _get_alternation ( extractors , text ) : candidates = [ ] for extractor in extractors : try : candidates . append ( _call_extractor ( extractor , text ) ) except DeadEnd : pass if not candidates : raise DeadEnd result , * remaining = candidates for candidate in remaining : if len ( candidate ) > len ( result ) : result = candidate return result
Tries each extractor on the given text and returns the 'best fit'.

  Best fit is defined by as the extractor whose result consumed the most text. If more than one
  extractor is the best fit, the result of the one that appeared earliest in the list is returned.

  If all extractors raise a DeadEnd, this method too will raise a DeadEnd.
Tries each extractor on the given text and returns the best fit .