code: def _iter_source(
      lines, *, maxtext=10_000, maxlines=200, showtext=False
  ):
      maxtext = maxtext if maxtext and maxtext > 0 else None
      maxlines = maxlines if maxlines and maxlines > 0 else None
      filestack = []
      allinfo = {}
      # "lines" should be (fileinfo, data), as produced by the preprocessor code.
      for fileinfo, line in lines:
          if fileinfo.filename in filestack:
              while fileinfo.filename != filestack[-1]:
                  filename = filestack.pop()
                  del allinfo[filename]
              filename = fileinfo.filename
              srcinfo = allinfo[filename]
          else:
              filename = fileinfo.filename
              srcinfo = SourceInfo(filename)
              filestack.append(filename)
              allinfo[filename] = srcinfo
  
          _logger.debug(f"-> {line}")
          srcinfo._add_line(line, fileinfo.lno)
          if srcinfo.too_much(maxtext, maxlines):
              break
          while srcinfo._used():
              yield srcinfo
              if showtext:
                  _logger.debug(f"=> {srcinfo.text}")
      else:
          if not filestack:
              srcinfo = SourceInfo("???")
          else:
              filename = filestack[-1]
              srcinfo = allinfo[filename]
              while srcinfo._used():
                  yield srcinfo
                  if showtext:
                      _logger.debug(f"=> {srcinfo.text}")
          yield srcinfo
          if showtext:
              _logger.debug(f"=> {srcinfo.text}")
          if not srcinfo._ready:
              return
      # At this point either the file ended prematurely
      # or there's "too much" text.
      filename, lno, text = (
          srcinfo.filename,
          srcinfo._start,
          srcinfo.text,
      )
      if len(text) > 500:
          text = text[:500] + "..."
      raise Exception(
          f"unmatched text ({filename} starting at line {lno}):\n{text}"
      )
  
imports: from ..info import ParsedItem
  from ._info import SourceInfo
  import logging
label_desc: Use image node_id 4 for calling a global function with example usage: _iter_source(lines) without return types