@classmethod
def _parse_parameters(cls, spec: str):
    """Parse key=value;key=value;key=value into a dict"""
    fields = spec.split(';')
    result = dict()
    for field in fields:
        field = field.strip()
        if not field:
            continue
        key, equals, value = field.partition('=')
        if equals == '=' and value == '':
            raise ValueError('No value given')
        key = key.strip()
        if key not in cls.allowed_parameters:
            raise KeyError('Unknown parameter {}'.format(key))
        while cls.allowed_parameters[key] is not None:
            key = cls.allowed_parameters[key]
        value = value.strip()
        if value == '':
            value = True
        else:
            try:
                value = int(value)
            except ValueError:
                value = float(value)
        if key in result:
            raise KeyError('Key {} specified twice'.format(key))
        result[key] = value
    if 'optional' in result and 'required' in result:
        raise ValueError(
            "'optional' and 'required' cannot be specified at the same time")
    if 'optional' in result:
        result['required'] = False
        del result['optional']
    return result
