def __copy__(self): # These instances are supposed to be singletons return self
def __deepcopy__(self, memo): # These instances are supposed to be singletons return self
Token = _TokenType()
# Special token types
Text = Token.Text
Whitespace = Text.Whitespace
Escape = Token.Escape
Error = Token.Error # Text that doesn't belong to this lexer (e.g. HTML in PHP)
Other = Token.Other
# Common token types for source code
Keyword = Token.Keyword
Name = Token.Name
Literal = Token.Literal
String = Literal.String
Number = Literal.Number
Punctuation = Token.Punctuation
Operator = Token.Operator
Comment = Token.Comment
# Generic types for non-source code
Generic = Token.Generic
# String and some others are not direct children of Token. # alias them:
Token.Token = Token
Token.String = String
Token.Number = Number
def is_token_subtype(ttype, other): """ ReturnTrueif ``ttype`` is a subtype of ``other``.
exists for backwards compatibility. use ``ttype in other`` now. """ return ttype in other
def string_to_tokentype(s): """
Convert a string into a token type::
Tokens that are already tokens are returned unchanged:
>>> string_to_token(String)
Token.Literal.String """ if isinstance(s, _TokenType): return s ifnot s: return Token
node = Token for item in s.split('.'):
node = getattr(node, item) return node
# Map standard token types to short names, used in CSS class naming. # If you add a new item, please be sure to run this file to perform # a consistency check for duplicate values.
STANDARD_TYPES = {
Token: '',
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.