code: def read_env(src, expr):
      r
      contents = []
      if expr.name in SKIP_ENVS:
          contents = [src.forward_until(lambda s: s == '\\end')]
      while src.hasNext() and not src.startswith('\\end{%s}' % expr.name):
          contents.append(read_tex(src))
      if not src.startswith('\\end{%s}' % expr.name):
          end = src.peek((0, 5))
          explanation = 'Instead got %s' % end if end else 'Reached end of file.'
          raise EOFError('Expecting \\end{%s}. %s' % (expr.name, explanation))
      else:
          src.forward(4)
      expr.append(*contents)
      return expr
docs: r"""Read the environment from buffer.
  
      Advances the buffer until right after the end of the environment. Adds
      parsed content to the expression automatically.
  
      :param Buffer src: a buffer of tokens
      :param TexExpr expr: expression for the environment
      :rtype: TexExpr