def find_column(lexer, lexpos):
    """Find column number for errors."""
    last_cr = lexer.globals.code.rfind('\n', 0, lexpos)
    if last_cr == -1:
        return lexpos + 1
    return lexpos - last_cr
