def token_value(string):
    """
    Return the associated value for a given token string (we parse
    through the version string one token at a time).

    :param string: a token string
    :returns: integer associated to the token (so we can compare them in
              functions further below, a digit (1) looses against a
              letter (2), because "letter" has a higher value).

    C equivalent: enum PARTS
    """
    order = {'invalid': -1, 'digit_or_zero': 0, 'digit': 1, 'letter': 2,
        'suffix': 3, 'suffix_no': 4, 'revision_no': 5, 'end': 6}
    return order[string]
