def _parse_nested_name(self, memberPointer: bool=False) -> ASTNestedName:
    names = []
    templates = []
    self.skip_ws()
    rooted = False
    if self.skip_string('::'):
        rooted = True
    while 1:
        self.skip_ws()
        if (len(names) > 0):
            template = self.skip_word_and_ws('template')
        else:
            template = False
        templates.append(template)
        identOrOp = None
        if self.skip_word_and_ws('operator'):
            identOrOp = self._parse_operator()
        else:
            if (not self.match(identifier_re)):
                if (memberPointer and (len(names) > 0)):
                    templates.pop()
                    break
                self.fail('Expected identifier in nested name.')
            identifier = self.matched_text
            if (identifier in _keywords):
                self.fail(('Expected identifier in nested name, got keyword: %s' % identifier))
            identOrOp = ASTIdentifier(identifier)
        pos = self.pos
        try:
            templateArgs = self._parse_template_argument_list()
        except DefinitionError as ex:
            self.pos = pos
            templateArgs = None
            self.otherErrors.append(ex)
        names.append(ASTNestedNameElement(identOrOp, templateArgs))
        self.skip_ws()
        if (not self.skip_string('::')):
            if memberPointer:
                self.fail("Expected '::' in pointer to member (function).")
            break
    return ASTNestedName(names, templates, rooted)
def _parse_nested_name(self, memberPointer: bool=False) -> ASTNestedName:
    names = []
    templates = []
    self.skip_ws()
    rooted = False
    if self.skip_string('::'):
        rooted = True
    while 1:
        self.skip_ws()
        if (len(names) > 0):
            template = self.skip_word_and_ws('template')
        else:
            template = False
        templates.append(template)
        identOrOp = None
        if self.skip_word_and_ws('operator'):
            identOrOp = self._parse_operator()
        else:
            if (not self.match(identifier_re)):
                if (memberPointer and (len(names) > 0)):
                    templates.pop()
                    break
                self.fail('Expected identifier in nested name.')
            identifier = self.matched_text
            if (identifier in _keywords):
                self.fail(('Expected identifier in nested name, got keyword: %s' % identifier))
            identOrOp = ASTIdentifier(identifier)
        pos = self.pos
        try:
            templateArgs = self._parse_template_argument_list()
        except DefinitionError as ex:
            self.pos = pos
            templateArgs = None
            self.otherErrors.append(ex)
        names.append(ASTNestedNameElement(identOrOp, templateArgs))
        self.skip_ws()
        if (not self.skip_string('::')):
            if memberPointer:
                self.fail("Expected '::' in pointer to member (function).")
            break
    return ASTNestedName(names, templates, rooted)