code: def _lex(s):
      
      s += '.'  # make sure there's a terminator to know when to stop parsing
      lines = enumerate(s.splitlines(), 1)
      lineno = pos = 0
      try:
          for lineno, line in lines:
              matches = _tsql_lex_re.finditer(line)
              for m in matches:
                  gid = m.lastindex
                  if gid == 11:
                      raise TSQLSyntaxError('unexpected input',
                                            lineno=lineno,
                                            offset=m.start(),
                                            text=line)
                  else:
                      token = m.group(gid)
                      yield (gid, token, lineno)
      except StopIteration:
          pass
docs: Lex the input string according to _tsql_lex_re.
  
      Yields
          (gid, token, line_number)