code: def generate(fn):
      '''Parser generator. (combinator syntax).'''
      if isinstance(fn, str):
          return lambda f: generate(f).desc(fn)
  
      @wraps(fn)
      @Parser
      def generated(text, index):
          iterator, value = fn(), None
          try:
              while True:
                  parser = iterator.send(value)
                  res = parser(text, index)
                  if not res.status:  # this parser failed.
                      return res
                  value, index = res.value, res.index  # iterate
          except StopIteration as stop:
              endval = stop.value
              if isinstance(endval, Parser):
                  return endval(text, index)
              else:
                  return Value.success(index, endval)
      return generated.desc(fn.__name__f generate(fn):
      '''Parser generator. (combinator syntax).'''
      if isinstance(fn, str):
          return lambda f: generate(f).desc(fn)
  
      @wraps(fn)
      @Parser
      def generated(text, index):
          iterator, value = fn(), None
          try:
              while True:
                  parser = iterator.send(value)
                  res = parser(text, index)
                  if not res.status:  # this parser failed.
                      return res
                  value, index = res.value, res.index  # iterate
          except StopIteration as stop:
              endval = stop.value
              if isinstance(endval, Parser):
                  return endval(text, index)
              else:
                  return Value.success(index, endval)
      return generated.desc(fn.__name__)
docs: Parser generator. (combinator syntax).