code: def lex(ds_str):
      """A generator which lexes a datashape string into a
      sequence of tokens.
  
      Example
      -------
  
          import datashape
          s = '   -> ... A... "string" 1234 Blah _eil(# comment'
          print('lexing %r' % s)
          for tok in datashape.lexer.lex(s):
              print(tok.id, tok.name, tok.span, repr(tok.val))
      """
      pos = 0
      # Skip whitespace
      m = _whitespace_re.match(ds_str, pos)
      if m:
          pos = m.end()
      while pos < len(ds_str):
          # Try to match a token
          m = _tokens_re.match(ds_str, pos)
          if m:
              # m.lastindex gives us which group was matched, which
              # is one greater than the index into the _tokens list.
              id = m.lastindex
              tokinfo = _tokens[id - 1]
              name = tokinfo[0]
              span = m.span()
              if len(tokinfo) > 2:
                  val = tokinfo[2](ds_str[span[0] : span[1]])
              else:
                  val = None
              pos = m.end()
              yield Token(id, name, span, val)
          else:
              raise error.DataShapeSyntaxError(
                  pos, "<nofile>", ds_str, "Invalid DataShape token"
              )
          # Skip whitespace
          m = _whitespace_re.match(ds_str, pos)
          if m:
              pos = m.end()
  
imports: from __future__ import absolute_import, division, print_function
  import re
  import ast
  import collections
  from .None import error
label_desc: Use image node_id 2 for calling a global function with example usage: lex(ds_str) without return types