def parse_declaration(self, objectType: str, directiveType: str) -> ASTDeclaration:
    if (objectType not in ('class', 'union', 'function', 'member', 'type', 'concept', 'enum', 'enumerator')):
        raise Exception(('Internal error, unknown objectType "%s".' % objectType))
    if (directiveType not in ('class', 'struct', 'union', 'function', 'member', 'var', 'type', 'concept', 'enum', 'enum-struct', 'enum-class', 'enumerator')):
        raise Exception(('Internal error, unknown directiveType "%s".' % directiveType))
    visibility = None
    templatePrefix = None
    declaration = None
    self.skip_ws()
    if self.match(_visibility_re):
        visibility = self.matched_text
    if (objectType in ('type', 'concept', 'member', 'function', 'class')):
        templatePrefix = self._parse_template_declaration_prefix(objectType)
    if (objectType == 'type'):
        prevErrors = []
        pos = self.pos
        try:
            if (not templatePrefix):
                declaration = self._parse_type(named=True, outer='type')
        except DefinitionError as e:
            prevErrors.append((e, 'If typedef-like declaration'))
            self.pos = pos
        pos = self.pos
        try:
            if (not declaration):
                declaration = self._parse_type_using()
        except DefinitionError as e:
            self.pos = pos
            prevErrors.append((e, 'If type alias or template alias'))
            header = 'Error in type declaration.'
            raise self._make_multi_error(prevErrors, header)
    elif (objectType == 'concept'):
        declaration = self._parse_concept()
    elif (objectType == 'member'):
        declaration = self._parse_type_with_init(named=True, outer='member')
    elif (objectType == 'function'):
        declaration = self._parse_type(named=True, outer='function')
    elif (objectType == 'class'):
        declaration = self._parse_class()
    elif (objectType == 'union'):
        declaration = self._parse_union()
    elif (objectType == 'enum'):
        declaration = self._parse_enum()
    elif (objectType == 'enumerator'):
        declaration = self._parse_enumerator()
    else:
        assert False
    templatePrefix = self._check_template_consistency(declaration.name, templatePrefix, fullSpecShorthand=False, isMember=(objectType == 'member'))
    return ASTDeclaration(objectType, directiveType, visibility, templatePrefix, declaration)
def parse_declaration(self, objectType: str, directiveType: str) -> ASTDeclaration:
    if (objectType not in ('class', 'union', 'function', 'member', 'type', 'concept', 'enum', 'enumerator')):
        raise Exception(('Internal error, unknown objectType "%s".' % objectType))
    if (directiveType not in ('class', 'struct', 'union', 'function', 'member', 'var', 'type', 'concept', 'enum', 'enum-struct', 'enum-class', 'enumerator')):
        raise Exception(('Internal error, unknown directiveType "%s".' % directiveType))
    visibility = None
    templatePrefix = None
    declaration = None
    self.skip_ws()
    if self.match(_visibility_re):
        visibility = self.matched_text
    if (objectType in ('type', 'concept', 'member', 'function', 'class')):
        templatePrefix = self._parse_template_declaration_prefix(objectType)
    if (objectType == 'type'):
        prevErrors = []
        pos = self.pos
        try:
            if (not templatePrefix):
                declaration = self._parse_type(named=True, outer='type')
        except DefinitionError as e:
            prevErrors.append((e, 'If typedef-like declaration'))
            self.pos = pos
        pos = self.pos
        try:
            if (not declaration):
                declaration = self._parse_type_using()
        except DefinitionError as e:
            self.pos = pos
            prevErrors.append((e, 'If type alias or template alias'))
            header = 'Error in type declaration.'
            raise self._make_multi_error(prevErrors, header)
    elif (objectType == 'concept'):
        declaration = self._parse_concept()
    elif (objectType == 'member'):
        declaration = self._parse_type_with_init(named=True, outer='member')
    elif (objectType == 'function'):
        declaration = self._parse_type(named=True, outer='function')
    elif (objectType == 'class'):
        declaration = self._parse_class()
    elif (objectType == 'union'):
        declaration = self._parse_union()
    elif (objectType == 'enum'):
        declaration = self._parse_enum()
    elif (objectType == 'enumerator'):
        declaration = self._parse_enumerator()
    else:
        assert False
    templatePrefix = self._check_template_consistency(declaration.name, templatePrefix, fullSpecShorthand=False, isMember=(objectType == 'member'))
    return ASTDeclaration(objectType, directiveType, visibility, templatePrefix, declaration)