code: def selector_iter(self, pattern):
          
  
          # Ignore whitespace and comments at start and end of pattern
          m = RE_WS_BEGIN.search(pattern)
          index = m.end(0) if m else 0
          m = RE_WS_END.search(pattern)
          end = (m.start(0) - 1) if m else (len(pattern) - 1)
  
          if self.debug:  # pragma: no cover
              if self.quirks:
                  print('## QUIRKS MODE: Throwing out the spec!')
              print('## PARSING: {!r}'.format(pattern))
          while index <= end:
              m = None
              for v in self.css_tokens:
                  if not v.enabled(self.flags):  # pragma: no cover
                      continue
                  m = v.match(pattern, index)
                  if m:
                      name = v.get_name()
                      if self.debug:  # pragma: no cover
                          print("TOKEN: '{}' --> {!r} at position {}".format(name, m.group(0), m.start(0)))
                      index = m.end(0)
                      yield name, m
                      break
              if m is None:
                  c = pattern[index]
                  # If the character represents the start of one of the known selector types,
                  # throw an exception mentioning that the known selector type is in error;
                  # otherwise, report the invalid character.
                  if c == '[':
                      msg = "Malformed attribute selector at position {}".format(index)
                  elif c == '.':
                      msg = "Malformed class selector at position {}".format(index)
                  elif c == '#':
                      msg = "Malformed id selector at position {}".format(index)
                  elif c == ':':
                      msg = "Malformed pseudo-class selector at position {}".format(index)
                  else:
                      msg = "Invalid character {!r} position {}".format(c, index)
                  raise SelectorSyntaxError(msg, self.pattern, index)
          if self.debug:  # pragma: no cover
              print('## END PARSING')
docs: Iterate selector tokens.