tokenize (version Ka-Ping Yee, 26 October 1997; patched, GvR 3/30/98)
index
/usr/lib/python1.6/tokenize.py

Tokenization help for Python programs.
 
This module exports a function called 'tokenize()' that breaks a stream of
text into Python tokens.  It accepts a readline-like method which is called
repeatedly to get the next line of input (or "" for EOF) and a "token-eater"
function which is called once for each token found.  The latter function is
passed the token type, a string containing the token, the starting and
ending (row, column) coordinates of the token, and the original line.  It is
designed to match the working of the Python tokenizer exactly, except that
it produces COMMENT tokens for comments and gives type OP for all operators.

 
Modules
            
re
string

 
Functions
            
any(*choices)
group(*choices)
maybe(*choices)
printtoken(type, token, (srow, scol), (erow, ecol), line)
tokenize(readline, tokeneater=<function printtoken at 8212e88>)

 
Data
             AMPER = 19
BACKQUOTE = 25
Bracket = '[][(){}]'
CIRCUMFLEX = 33
COLON = 11
COMMA = 12
COMMENT = 39
Comment = r'#[^\r\n]*'
ContStr = '([rR]?\'(\\\\.|[^\\n\'\\\\])*(\'|\\\\\\r?\\n)|[rR]?"(\\\\.|[^\\n"\\\\])*("|\\\\\\r?\\n))'
DEDENT = 6
DOT = 23
DOUBLESTAR = 36
Decnumber = r'[1-9]\d*[lL]?'
Double = r'([^"\\]|\\.)*"'
Double3 = r'([^"\\]|\\.|"[^"\\]|"\\.|""[^"\\]|""\\.)*"""'
ENDMARKER = 0
EQEQUAL = 28
EQUAL = 22
ERRORTOKEN = 38
Expfloat = r'[1-9]\d*[eE][-+]?\d+'
Exponent = r'[eE][-+]?\d+'
Floatnumber = r'((\d+\.\d*|\.\d+)([eE][-+]?\d+)?|[1-9]\d*[eE][-+]?\d+)'
Funny = r'((\+|\-|\*\*|\*|\^|~|/|%|&|\||<<|>>|==|<=|<>|!=|>=|=|<|>)|[][(){}]|(\r?\n|[:;.,`]))'
GREATER = 21
GREATEREQUAL = 31
Hexnumber = r'0[xX][\da-fA-F]*[lL]?'
INDENT = 5
Ignore = r'[ \f\t]*(\\\r?\n[ \f\t]*)*(#[^\r\n]*)?'
Imagnumber = r'(0[jJ]|[1-9]\d*[jJ]|((\d+\.\d*|\.\d+)([eE][-+]?\d+)?|[1-9]\d*[eE][-+]?\d+)[jJ])'
Intnumber = r'(0[xX][\da-fA-F]*[lL]?|0[0-7]*[lL]?|[1-9]\d*[lL]?)'
LBRACE = 26
LEFTSHIFT = 34
LESS = 20
LESSEQUAL = 30
LPAR = 7
LSQB = 9
MINUS = 15
NAME = 1
NEWLINE = 4
NL = 40
NOTEQUAL = 29
NT_OFFSET = 256
NUMBER = 2
N_TOKENS = 39
Name = r'[a-zA-Z_]\w*'
Number = r'((0[jJ]|[1-9]\d*[jJ]|((\d+\.\d*|\.\d+)([eE][-+]?...[xX][\da-fA-F]*[lL]?|0[0-7]*[lL]?|[1-9]\d*[lL]?))'
OP = 37
Octnumber = '0[0-7]*[lL]?'
Operator = r'(\+|\-|\*\*|\*|\^|~|/|%|&|\||<<|>>|==|<=|<>|!=|>=|=|<|>)'
PERCENT = 24
PLUS = 14
PlainToken = '(((0[jJ]|[1-9]\\d*[jJ]|((\\d+\\.\\d*|\\.\\d+)([eE][-+]...\'\\\\]|\\\\.)*\'|[rR]?"([^\\n"\\\\]|\\\\.)*")|[a-zA-Z_]\\w*)'
Pointfloat = r'(\d+\.\d*|\.\d+)([eE][-+]?\d+)?'
PseudoExtras = '(\\\\\\r?\\n|#[^\\r\\n]*|([rR]?\'\'\'|[rR]?"""))'
PseudoToken = '[ \\f\\t]*((\\\\\\r?\\n|#[^\\r\\n]*|([rR]?\'\'\'|[rR]?"""))...)|[rR]?"(\\\\.|[^\\n"\\\\])*("|\\\\\\r?\\n))|[a-zA-Z_]\\w*)'
RBRACE = 27
RIGHTSHIFT = 35
RPAR = 8
RSQB = 10
SEMI = 13
SLASH = 17
STAR = 16
STRING = 3
Single = r"([^'\\]|\\.)*'"
Single3 = r"([^'\\]|\\.|'[^'\\]|'\\.|''[^'\\]|''\\.)*'''"
Special = r'(\r?\n|[:;.,`])'
String = '([rR]?\'([^\\n\'\\\\]|\\\\.)*\'|[rR]?"([^\\n"\\\\]|\\\\.)*")'
TILDE = 32
Token = '[ \\f\\t]*(\\\\\\r?\\n[ \\f\\t]*)*(#[^\\r\\n]*)?(((0[jJ]|[...\'\\\\]|\\\\.)*\'|[rR]?"([^\\n"\\\\]|\\\\.)*")|[a-zA-Z_]\\w*)'
TokenError = 'TokenError'
Triple = '([rR]?\'\'\'|[rR]?""")'
VBAR = 18
Whitespace = r'[ \f\t]*'
__file__ = '/usr/lib/python1.6/tokenize.pyc'
__name__ = 'tokenize'
__version__ = 'Ka-Ping Yee, 26 October 1997; patched, GvR 3/30/98'
double3prog = <SRE_Pattern object at 8223788>
endprogs = {'"': <SRE_Pattern object at 8229728>, '"""': <SRE_Pattern object at 8223788>, "'": <SRE_Pattern object at 8227ae0>, "'''": <SRE_Pattern object at 821f430>, 'R': None, 'R"""': <SRE_Pattern object at 8223788>, "R'''": <SRE_Pattern object at 821f430>, 'r': None, 'r"""': <SRE_Pattern object at 8223788>, "r'''": <SRE_Pattern object at 821f430>}
pseudoprog = <SRE_Pattern object at 401a8008>
single3prog = <SRE_Pattern object at 821f430>
tabsize = 8
tok_name = {0: 'ENDMARKER', 1: 'NAME', 2: 'NUMBER', 3: 'STRING', 4: 'NEWLINE', 5: 'INDENT', 6: 'DEDENT', 7: 'LPAR', 8: 'RPAR', 9: 'LSQB', ...}
tokenprog = <SRE_Pattern object at 4017a008>