def read_math_env(src, expr):
content = src.forward_until(lambda s: s == expr.end)<EOL>if not src.startswith(expr.end):<EOL><INDENT>end = src.peek()<EOL>explanation = '<STR_LIT>' % end if end else '<STR_LIT>'<EOL>raise EOFError('<STR_LIT>' % (expr.end, explanation))<EOL><DEDENT>else:<EOL><INDENT>src.forward(<NUM_LIT:1>)<EOL><DEDENT>expr.append(content)<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