def string_to_tokentype(s):
 if isinstance(s, _TokenType):
  return s
 if (not s):
  return Token
 node = Token
 for item in s.split('.'):
  node = getattr(node, item)
 return node

def string_to_tokentype ( s ) : if isinstance ( s , _TokenType ) : return s if ( not s ) : return Token node = Token for item in s . split ( '.' ) : node = getattr ( node , item ) return node
convert a string into a token type:: .