'Given a string and pos, return the number of chars in the
identifier which ends at pos, or 0 if there is no such one.
This ignores non-identifier eywords are not identifiers.'

@classmethod
def _eat_identifier(cls, str, limit, pos):

    is_ascii_id_char = _IS_ASCII_ID_CHAR
    i = pos
    while ((i > limit) and ((ord(str[(i - 1)]) < 128) and is_ascii_id_char[ord(str[(i - 1)])])):
        i -= 1
    if ((i > limit) and (ord(str[(i - 1)]) >= 128)):
        while (((i - 4) >= limit) and ('a' + str[(i - 4):pos]).isidentifier()):
            i -= 4
        if (((i - 2) >= limit) and ('a' + str[(i - 2):pos]).isidentifier()):
            i -= 2
        if (((i - 1) >= limit) and ('a' + str[(i - 1):pos]).isidentifier()):
            i -= 1
        if (not str[i:pos].isidentifier()):
            return 0
    elif (i < pos):
        if (not _IS_ASCII_ID_FIRST_CHAR[ord(str[i])]):
            return 0
    if ((i < pos) and (iskeyword(str[i:pos]) and (str[i:pos] not in cls._ID_KEYWORDS))):
        return 0
    return (pos - i)
