def read_env(src, expr):
contents = []<EOL>if expr.name in SKIP_ENVS:<EOL><INDENT>contents = [src.forward_until(lambda s: s == '<STR_LIT>')]<EOL><DEDENT>while src.hasNext() and not src.startswith('<STR_LIT>' % expr.name):<EOL><INDENT>contents.append(read_tex(src))<EOL><DEDENT>if not src.startswith('<STR_LIT>' % expr.name):<EOL><INDENT>end = src.peek((<NUM_LIT:0>, <NUM_LIT:5>))<EOL>explanation = '<STR_LIT>' % end if end else '<STR_LIT>'<EOL>raise EOFError('<STR_LIT>' % (expr.name, explanation))<EOL><DEDENT>else:<EOL><INDENT>src.forward(<NUM_LIT:4>)<EOL><DEDENT>expr.append(*contents)<EOL>return expr<EOL>
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