Back to index

moin  1.9.0~rc2
Classes | Functions | Variables
MoinMoin.support.pygments.token Namespace Reference

Classes

class  _TokenType

Functions

def is_token_subtype
def string_to_tokentype

Variables

tuple Token = _TokenType()
 Text = Token.Text
 Whitespace = Text.Whitespace
 Error = Token.Error
 Other = Token.Other
 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 = Token.Generic
dictionary STANDARD_TYPES

Function Documentation

Return True if ``ttype`` is a subtype of ``other``.

exists for backwards compatibility. use ``ttype in other`` now.

Definition at line 84 of file token.py.

00084 
00085 def is_token_subtype(ttype, other):
00086     """
00087     Return True if ``ttype`` is a subtype of ``other``.
00088 
00089     exists for backwards compatibility. use ``ttype in other`` now.
00090     """
00091     return ttype in other
00092 

Convert a string into a token type::

    >>> string_to_token('String.Double')
    Token.Literal.String.Double
    >>> string_to_token('Token.Literal.Number')
    Token.Literal.Number
    >>> string_to_token('')
    Token

Tokens that are already tokens are returned unchanged:

    >>> string_to_token(String)
    Token.Literal.String

Definition at line 93 of file token.py.

00093 
00094 def string_to_tokentype(s):
00095     """
00096     Convert a string into a token type::
00097 
00098         >>> string_to_token('String.Double')
00099         Token.Literal.String.Double
00100         >>> string_to_token('Token.Literal.Number')
00101         Token.Literal.Number
00102         >>> string_to_token('')
00103         Token
00104 
00105     Tokens that are already tokens are returned unchanged:
00106 
00107         >>> string_to_token(String)
00108         Token.Literal.String
00109     """
00110     if isinstance(s, _TokenType):
00111         return s
00112     if not s:
00113         return Token
00114     node = Token
00115     for item in s.split('.'):
00116         node = getattr(node, item)
00117     return node
00118 
00119 
00120 # Map standard token types to short names, used in CSS class naming.
00121 # If you add a new item, please be sure to run this file to perform
# a consistency check for duplicate values.

Variable Documentation

Definition at line 72 of file token.py.

Definition at line 60 of file token.py.

Definition at line 75 of file token.py.

Definition at line 65 of file token.py.

Definition at line 67 of file token.py.

Definition at line 66 of file token.py.

Definition at line 69 of file token.py.

Definition at line 71 of file token.py.

Definition at line 62 of file token.py.

Definition at line 70 of file token.py.

Definition at line 122 of file token.py.

Definition at line 68 of file token.py.

Definition at line 58 of file token.py.

Definition at line 55 of file token.py.

Definition at line 59 of file token.py.