pyebnf/compiler.py
def _hoist_operands(self, operands, pred):
    """Flattens a list of optree operands based on a pred.

    This is used to convert concatenation([x, concatenation[y, ...]]) (or alternation) to
    concatenation([x, y, ...]).
    """
    hopper = list(operands)
    new_operands = []
    while hopper:
      target = hopper.pop(0)
      if pred(target):
        hopper = list(target.operands) + hopper
      else:
        new_operands.append(target)
    return new_operands
def _hoist_operands(self, operands, pred):
    """Flattens a list of optree operands based on a pred.

    This is used to convert concatenation([x, concatenation[y, ...]]) (or alternation) to
    concatenation([x, y, ...]).
    """
    hopper = list(operands)
    new_operands = []
    while hopper:
      target = hopper.pop(0)
      if pred(target):
        hopper = list(target.operands) + hopper
      else:
        new_operands.append(target)
    return new_operands
Flattens a list of optree operands based on a pred.

    This is used to convert concatenation([x, concatenation[y, ...]]) (or alternation) to
    concatenation([x, y, ...]).