docs: def parse_extend(self, c, i, current, reset_dot=False):
          """Parse extended pattern lists."""
  
          # Save state
          temp_dir_start = self.dir_start
          temp_after_start = self.after_start
          temp_in_list = self.in_list
          temp_inv_ext = self.inv_ext
          self.in_list = True
          if reset_dot:
              self.allow_special_dir = False
  
          # Start list parsing
          success = True
          index = i.index
          list_type = c
          extended = []
          try:
              c = next(i)
              if c != '(':
                  raise StopIteration
              while c != ')':
                  c = next(i)
  
                  if self.extend and c in EXT_TYPES and self.parse_extend(c, i, extended):
                      # Nothing more to do
                      pass
                  elif c == '*':
                      self._handle_star(i, extended)
                  elif c == '.' and self.after_start:
                      extended.append(re.escape(c))
                      self.allow_special_dir = True
                      self.reset_dir_track()
                  elif c == '?':
                      extended.append(self._restrict_sequence() + _QMARK)
                  elif c == '/':
                      if self.pathname:
                          extended.append(self._restrict_extended_slash())
                      extended.append(re.escape(c))
                  elif c == "|":
                      self.clean_up_inverse(extended)
                      extended.append(c)
                      if temp_after_start:
                          self.set_start_dir()
                  elif c == '\\':
                      try:
                          extended.append(self._references(i))
                      except StopIteration:
                          # We've reached the end.
                          # Do nothing because this is going to abort the `extmatch` anyways.
                          pass
                  elif c == '[':
                      subindex = i.index
                      try:
                          extended.append(self._sequence(i))
                      except StopIteration:
                          i.rewind(i.index - subindex)
                          extended.append(r'\[')
                  elif c != ')':
                      extended.append(re.escape(c))
  
                  self.update_dir_state()
  
              self.clean_up_inverse(extended)
              if list_type == '?':
                  current.append(_QMARK_GROUP % ''.join(extended))
              elif list_type == '*':
                  current.append(_STAR_GROUP % ''.join(extended))
              elif list_type == '+':
                  current.append(_PLUS_GROUP % ''.join(extended))
              elif list_type == '@':
                  current.append(_GROUP % ''.join(extended))
              elif list_type == '!':
                  self.inv_ext += 1
                  # If pattern is at the end, anchor the match to the end.
                  current.append(_EXCLA_GROUP % ''.join(extended))
                  if self.pathname:
                      if not temp_after_start or self.allow_special_dir:
                          star = self.path_star
                      elif temp_after_start and not self.dot:
                          star = self.path_star_dot2
                      else:
                          star = self.path_star_dot1
                  else:
                      if not temp_after_start or self.dot:
                          star = _STAR
                      else:
                          star = _NO_DOT + _STAR
  
                  if temp_after_start:
                      star = _NEED_CHAR + star
                  # Place holder for closing, but store the proper star
                  # so we know which one to use
                  current.append(InvPlaceholder(star))
  
          except StopIteration:
              success = False
              self.inv_ext = temp_inv_ext
              i.rewind(i.index - index)
  
          # Either restore if extend parsing failed, or reset if it worked
          if not temp_in_list:
              self.in_list = False
          if success:
              self.reset_dir_track()
          else:
              self.dir_start = temp_dir_start
              self.after_start = temp_after_start
  
          return success