code: def get_tokendefs(cls):
          
          tokens = {}
          inheritable = {}
          for c in cls.__mro__:
              toks = c.__dict__.get('tokens', {})
  
              for state, items in iteritems(toks):
                  curitems = tokens.get(state)
                  if curitems is None:
                      # N.b. because this is assigned by reference, sufficiently
                      # deep hierarchies are processed incrementally (e.g. for
                      # A(B), B(C), C(RegexLexer), B will be premodified so X(B)
                      # will not see any inherits in B).
                      tokens[state] = items
                      try:
                          inherit_ndx = items.index(inherit)
                      except ValueError:
                          continue
                      inheritable[state] = inherit_ndx
                      continue
  
                  inherit_ndx = inheritable.pop(state, None)
                  if inherit_ndx is None:
                      continue
  
                  # Replace the "inherit" value with the items
                  curitems[inherit_ndx:inherit_ndx+1] = items
                  try:
                      # N.b. this is the index in items (that is, the superclass
                      # copy), so offset required when storing below.
                      new_inh_ndx = items.index(inherit)
                  except ValueError:
                      pass
                  else:
                      inheritable[state] = inherit_ndx + new_inh_ndx
  
          return tokens
docs: Merge tokens from superclasses in MRO order, returning a single tokendef
          dictionary.
  
          Any state that is not defined by a subclass will be inherited
          automatically.  States that *are* defined by subclasses will, by
          default, override that state in the superclass.  If a subclass wishes to
          inherit definitions from a superclass, it can use the special value
          "inherit", which will cause the superclass' state definition to be
          included at that point in the state.