�`^c@s�dZdZdZddlmZddlZddlZddlTddlZgee�D]Z e j
d�s]e ^q]Zedd d
ddg7Z[ [eZ
dee
<ed
Zdee<ed7Zd�Zd�Zd�ZdZdZeede�ee�ZdZdZdZdZdZeeeee�ZdZedd�ee�ZdeZeee�Zeded�Z ee ee�Z!d Z"d!Z#d"Z$d#Z%ed$d%�Z&ed&d'�Z'ed(d)d*d+d,d-d.d/�Z(d0Z)ed1d2�Z*ee(e)e*�Z+ee!e+e'e�Z,ee,Z-ed3ed4d�d5ed6d��Z.ed7ee&�Z/eee/e!e+e.e�Z0e1ej2e-e0e$e%f�\Z3Z4Z5Z6i&ej2e"�d46ej2e#�d66e5d86e6d96e5d:6e6d;6e5d<6e6d=6e5d>6e6d?6e5d@6e6dA6e5dB6e6dC6e5dD6e6dE6e5dF6e6dG6e5dH6e6dI6e5dJ6e6dK6e5dL6e6dM6e5dN6e6dO6e5dP6e6dQ6e5dR6e6dS6e5dT6e6dU6ddV6ddW6ddX6ddY6ddZ6dd[6Z8iZ9xd�D]Z:e:e9e:<q�iZ;xd�D]Z:e:e;e:<qWdxZ<dye=fdz��YZ>d{e=fd|��YZ?d}�Z@e@d~�ZAd�ZBd�d�d���YZCd��ZDd��ZEeFd�kr�dlGZGeHeGjI�d
kr�AeJeGjId
�jK�q�eGjLjK�ndS(�s�Tokenization help for Python programs.
generate_tokens(readline) is a generator 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). It generates
5-tuples with these members:
the token type (see token.py)
the token (a string)
the starting (row, column) indices of the token (a 2-tuple of ints)
the ending (row, column) indices of the token (a 2-tuple of ints)
the original line (string)
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
Older entry points
tokenize_loop(readline, tokeneater)
tokenize(readline, tokeneater=printtoken)
are the same, except instead of generating tokens, tokeneater is a callback
function to which the 5 fields described above are passed as 5 arguments,
each time a new token is found.sKa-Ping Yee <[email protected]>sSGvR, ESR, Tim Peters, Thomas Wouters, Fred Drake, Skip Montanaro, Raymond Hettingeri�(tchainN(t*t_tCOMMENTttokenizetgenerate_tokenstNLt
untokenizeiicGsddj|�dS(Nt(t|t)(tjoin(tchoices((s/sys/lib/python2.7/tokenize.pytgroup-scGst|�dS(NR(R
(R((s/sys/lib/python2.7/tokenize.pytany.scGst|�dS(Nt?(R
(R((s/sys/lib/python2.7/tokenize.pytmaybe/ss[ \f\t]*s #[^\r\n]*s\\\r?\ns[a-zA-Z_]\w*s0[xX][\da-fA-F]+[lL]?s(0[oO][0-7]+)|(0[0-7]*)[lL]?s0[bB][01]+[lL]?s
[1-9]\d*[lL]?s[eE][-+]?\d+s\d+\.\d*s\.\d+s\d+s\d+[jJ]s[jJ]s[^'\\]*(?:\\.[^'\\]*)*'s[^"\\]*(?:\\.[^"\\]*)*"s%[^'\\]*(?:(?:\\.|'(?!''))[^'\\]*)*'''s%[^"\\]*(?:(?:\\.|"(?!""))[^"\\]*)*"""s[uUbB]?[rR]?'''s[uUbB]?[rR]?"""s([uUbB]?[rR]?'[^\n'\\]*(?:\\.[^\n'\\]*)*'s([uUbB]?[rR]?"[^\n"\\]*(?:\\.[^\n"\\]*)*"s\*\*=?s>>=?s<<=?s<>s!=s//=?s[+\-*/%&|^=<>]=?t~s[][(){}]s\r?\ns[:;.,`@]s'[uUbB]?[rR]?'[^\n'\\]*(?:\\.[^\n'\\]*)*t's'[uUbB]?[rR]?"[^\n"\\]*(?:\\.[^\n"\\]*)*t"s
\\\r?\n|\Zs'''s"""sr'''sr"""su'''su"""sur'''sur"""sR'''sR"""sU'''sU"""suR'''suR"""sUr'''sUr"""sUR'''sUR"""sb'''sb"""sbr'''sbr"""sB'''sB"""sbR'''sbR"""sBr'''sBr"""sBR'''sBR"""trtRtutUtbtBsr'sr"sR'sR"su'su"sU'sU"sur'sur"sUr'sUr"suR'suR"sUR'sUR"sb'sb"sB'sB"sbr'sbr"sBr'sBr"sbR'sbR"sBR'sBR"it
TokenErrorcBseZRS((t__name__t
__module__(((s/sys/lib/python2.7/tokenize.pyR�stStopTokenizingcBseZRS((RR(((s/sys/lib/python2.7/tokenize.pyR�sc CsA|\}}|\}}d||||t|t|�fGHdS(Ns%d,%d-%d,%d: %s %s(ttok_nametrepr( ttypettokent srow_scolt erow_ecoltlinetsrowtscolterowtecol((s/sys/lib/python2.7/tokenize.pyt
printtoken�scCs)yt||�Wntk
r$nXdS(s:
The tokenize() function accepts two parameters: one representing the
input stream, and one providing an output mechanism for tokenize().
The first parameter, readline, must be a callable object which provides
the same interface as the readline() method of built-in file objects.
Each call to the function should return one line of input as a string.
The second parameter, tokeneater, must also be a callable object. It is
called once for each token, with five arguments, corresponding to the
tuples generated by generate_tokens().
N(t
tokenize_loopR(treadlinet
tokeneater((s/sys/lib/python2.7/tokenize.pyR�s
cCs%xt|�D]}||�q
WdS(N(R(R+R,t
token_info((s/sys/lib/python2.7/tokenize.pyR*�stUntokenizercBs,eZd�Zd�Zd�Zd�ZRS(cCsg|_d|_d|_dS(Nii(ttokenstprev_rowtprev_col(tself((s/sys/lib/python2.7/tokenize.pyt__init__�s cCs�|\}}||jks9||jkr`||jkr`tdj|||j|j���n||j}|r�|jjd|�d|_n||j}|r�|jjd|�ndS(Ns+start ({},{}) precedes previous end ({},{})s\
it (R0R1t
ValueErrortformatR/tappend(R2tstarttrowtcolt
row_offsett
col_offset((s/sys/lib/python2.7/tokenize.pytadd_whitespace�s-
c Cs�t|�}x�|D]�}t|�dkr?|j||�Pn|\}}}}}|tkrdPn|j|�|jj|�|\|_|_|t t
fkr|jd7_d|_qqWdj|j�S(Niiit(titertlentcompatt ENDMARKERR=R/R7R0R1tNEWLINERR( R2titerabletitttttok_typeR!R8tendR$((s/sys/lib/python2.7/tokenize.pyR�s
c
Cs/g}|jj}|dttfk}t}x�|g|�D]�|d \}} |ttfkrv| d7} n|tkr�|r�d| } nt }nt}|t
kr�|j| �qAnZ|tkr�|j�qAn>|ttfkr�}n#|r|r||d�t}n|| �qAWdS(NiiR4i�(
R/R7RCRtFalseRtNAMEtNUMBERtSTRINGtTruetINDENTtDEDENTtpop(
R2R!RDtindentsttoks_appendt startlinet
prevstringttokttoknumttokval((s/sys/lib/python2.7/tokenize.pyRA�s2
(RRR3R=RRA(((s/sys/lib/python2.7/tokenize.pyR.�s
cCst�}|j|�S(s�Transform tokens back into Python source code.
Each element returned by the iterable must be a token sequence
with at least two elements, a token number and token value. If
only two tokens are passed, the resulting output is poor.
Round-trip invariant for full input:
Untokenized source will match input source exactly
Round-trip invariant for limited intput:
# Output text will tokenize the back to the input
t1 = [tok[:2] for tok in generate_tokens(f.readline)]
newcode = untokenize(t1)
readline = iter(newcode.splitlines(1)).next
t2 = [tok[:2] for tok in generate_tokens(readline)]
assert t1 == t2
(R.R(RDtut((s/sys/lib/python2.7/tokenize.pyR�s ccsDd}}}tjdd}}d\}}d}dg} x�y
|�}
Wntk
rfd}
nX|d7}dt|
�}}|r{|
s�td|
f�n|j|
�}|r|jd�}}t||
| |
||f||
fVd\}}d}q�|ra|
ddkra|
d d
krat ||
|
|t|
�f|fVd}d}q@q�||
}||
}q@n`|dkr�|r�|
s�Pnd}xv||kr|
|dkr�|d7}n?|
|dkr�t
dt
}n|
|d
krd}nP|d7}q�W||kr'Pn|
|dkr|
|dkr�|
|jd�}|t|�}t|||f||t|�f|
fVt
|
|||f|t|
�f|
fVq@t
tf|
|dk|
|||f|t|
�f|
fVq@n|| dkrI| j|�t|
| |df||f|
fVnx�|| dkr�|| kr�tdd|||
f��n| d } td||f||f|
fVqLWn$|
s�td|dff�nd}x
||kr�j|
|�}|r�|jd�\}}||f||f|}}}||krIq�n|
||!|
|}}||ks�|dkr�|dkr�t||||
fVq�dkr�|dkr�t
nt||||
fVq�dkr
|jd�s��t||||
fVq�tkr�t|}|j|
|�}|rq|jd�}|
||!}t||||f|
fVq�||f}
|
|}|
}Pq�tks�|d tks�|d tkr1|ddkr||f}
t|p�|dp�|d}|
|d}}|
}Pq�t||||
fVq�|krTt||||
fVq�dkrid}q�dkr�|d7}n|dkr�|d8}nt||||
fVq�t |
|||f||df|
fV|d7}q�Wq@x2| dD]&}td|df|dfdfVq�d|df|dfdfVdS(sT
The generate_tokens() generator requires one argument, readline, which
must be a callable object which provides the same interface as the
readline() method of built-in file objects. Each call to the function
should return one line of input as a string. Alternately, readline
can be a callable function terminating with StopIteration:
readline = open(myfile).next # Example of alternate readline
The generator produces 5-tuples with these members: the token type; the
token string; a 2-tuple (srow, scol) of ints specifying the row and
column where the token begins in the source; a 2-tuple (erow, ecol) of
ints specifying the row and column where the token ends in the source;
and the line on which the token was found. The line passed is the
logical line; continuation lines are included.
iRt
0123456789R>isEOF in multi-line stringi�s\
i�s\
R4s ss#
t#s
i�s3unindent does not match any outer indentation levels
<tokenize>sEOF in multi-line statementt.s
iis\s([{s)]}N(R>i(R>i(tstringt
ascii_letterstNonet
StopIterationR@RtmatchRHRLt
ERRORTOKENttabsizetrstripRRR7RNtIndentationErrorROt
pseudoprogtspanRKRCtendswithtAssertionErrort
triple_quotedtendprogst
single_quotedRJtOPRB(R+tlnumtparenlevt continuedt namecharstnumcharstcontstrtneedconttcontlineRQR$tpostmaxtstrstarttendprogtendmatchRHtcolumnt
comment_tokentnl_postpseudomatchR8tsposteposR!tinitialtindent((s/sys/lib/python2.7/tokenize.pyRs�
&
$
#
'
'
$t__main__(s'''s"""sr'''sr"""sR'''sR"""su'''su"""sU'''sU"""sur'''sur"""sUr'''sUr"""suR'''suR"""sUR'''sUR"""sb'''sb"""sB'''sB"""sbr'''sbr"""sBr'''sBr"""sbR'''sbR"""sBR'''sBR"""(RRsr'sr"sR'sR"su'su"sU'sU"sur'sur"sUr'sUr"suR'suR"sUR'sUR"sb'sb"sB'sB"sbr'sbr"sBr'sBr"sbR'sbR"sBR'sBR"((Mt__doc__t
__author__t__credits__t itertoolsRR\treR!tdirtxt
startswitht__all__tN_TOKENSRRRR
RRt
WhitespacetCommenttIgnoretNamet Hexnumbert Octnumbert Binnumbert Decnumbert IntnumbertExponentt
PointfloattExpfloattFloatnumbert
ImagnumbertNumbertSingletDoubletSingle3tDouble3tTripletStringtOperatortBrackettSpecialtFunnyt
PlainTokentTokentContStrtPseudoExtrastPseudoTokentmaptcompilet tokenprogRetsingle3progtdouble3progR^RjRiRFRkRbt ExceptionRRR)RR*R.RRRtsysR@targvtopenR+tstdin(((s/sys/lib/python2.7/tokenize.pyt<module>s�
.
'#
F �
|