Viewing File: /opt/alt/python35/lib64/python3.5/lib2to3/pgen2/__pycache__/tokenize.cpython-35.opt-1.pyc



Yf,UT@s
dZdZdZddlZddlZddlmZmZddlTddl	m
Z
d	d
ee
Dddd
gZ[
ye
Wnek
reZ
YnXddZddZddZdZdZeedeeeZdZdZdZdZdZeeeeeZdZeddeeZdeZeeeZed ed!Z ee eeZ!d"Z"d#Z#d$Z$d%Z%ed&d'Z&ed(d)Z'ed*d+d,d-d.d/d0d1d2	Z(d3Z)ed4d5Z*ee(e)e*Z+ee!e+e'eZ,ee,Z-ed6ed7dd8ed9dZ.edee&Z/eee/e!e+e.eZ0e1e2ej3e-e0e$e%f\Z4Z5Z6Z7d7ej3e"d9ej3e#d:e6d;e7d<e6d=e7d>e6d?e7d@e6dAe7dBe6dCe7dDe6dEe7dFe6dGe7dHe6dIe7dJe6dKe7dLe6dMe7dNe6dOe7dPe6dQe7dRe6dSe7dTe6dUe7dVe6dWe7dXddYddZdd[dd\dd]di&Z8iZ9xdD]Z:e:e9e:<qWiZ;xdD]Z:e:e;e:<qWdzZ<Gd{d|d|e=Z>Gd}d~d~e=Z?ddZ@e@ddZAddZBGdddZCej3dejDZEej3dejDZFddZGddZHdd
ZIddZJeKdkr	ddlLZLeMeLjNdkreAeOeLjNdjPneAeLjQjPdS)aTokenization 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.zKa-Ping Yee <ping@lfw.org>z@GvR, ESR, Tim Peters, Thomas Wouters, Fred Drake, Skip MontanaroN)BOM_UTF8lookup)*)tokencCs&g|]}|ddkr|qS)r_).0xrr;/opt/alt/python35/lib64/python3.5/lib2to3/pgen2/tokenize.py
<listcomp>%s	rtokenizegenerate_tokens
untokenizecGsddj|dS)N(|))join)choicesrrrgroup0srcGst|dS)Nr)r)rrrrany1srcGst|dS)N?)r)rrrrmaybe2srz[ \f\t]*z	#[^\r\n]*z\\\r?\nz[a-zA-Z_]\w*z
0[bB][01]*z0[xX][\da-fA-F]*[lL]?z0[oO]?[0-7]*[lL]?z
[1-9]\d*[lL]?z[eE][-+]?\d+z\d+\.\d*z\.\d+z\d+z\d+[jJ]z[jJ]z[^'\\]*(?:\\.[^'\\]*)*'z[^"\\]*(?:\\.[^"\\]*)*"z%[^'\\]*(?:(?:\\.|'(?!''))[^'\\]*)*'''z%[^"\\]*(?:(?:\\.|"(?!""))[^"\\]*)*"""z[ubUB]?[rR]?'''z[ubUB]?[rR]?"""z&[uU]?[rR]?'[^\n'\\]*(?:\\.[^\n'\\]*)*'z&[uU]?[rR]?"[^\n"\\]*(?:\\.[^\n"\\]*)*"z\*\*=?z>>=?z<<=?z<>z!=z//=?z->z[+\-*/%&@|^=<>]=?~z[][(){}]z\r?\nz[:;.,`@]z'[uUbB]?[rR]?'[^\n'\\]*(?:\\.[^\n'\\]*)*'z'[uUbB]?[rR]?"[^\n"\\]*(?:\\.[^\n"\\]*)*"'''"""r'''r"""u'''u"""b'''b"""ur'''ur"""br'''br"""R'''R"""U'''U"""B'''B"""uR'''uR"""Ur'''Ur"""UR'''UR"""bR'''bR"""Br'''Br"""BR'''BR"""rRuUbBr'r"R'R"u'u"U'U"b'b"B'B"ur'ur"Ur'Ur"uR'uR"UR'UR"br'br"Br'Br"bR'bR"BR'BR"c@seZdZdS)
TokenErrorN)__name__
__module____qualname__rrrrr]sr]c@seZdZdS)StopTokenizingN)r^r_r`rrrrrasrac		CsF|\}}|\}}td||||t|t|fdS)Nz%d,%d-%d,%d:	%s	%s)printtok_namerepr)	typerZxxx_todo_changemeZxxx_todo_changeme1lineZsrowZscolZerowZecolrrr
printtokensrgcCs*yt||Wntk
r%YnXdS)a:
    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)
tokenize_loopra)readline
tokeneaterrrrr
s

cCs%xt|D]}||q
WdS)N)r)rirjZ
token_inforrrrhsrhc@s@eZdZddZddZddZddZd	S)
UntokenizercCsg|_d|_d|_dS)Nrr)tokensprev_rowprev_col)selfrrr__init__s		zUntokenizer.__init__cCs7|\}}||j}|r3|jjd|dS)N )rnrlappend)rostartrowcol
col_offsetrrradd_whitespaces
zUntokenizer.add_whitespacecCsx|D]}t|dkr0|j||P|\}}}}}|j||jj||\|_|_|ttfkr|jd7_d|_qWdj	|jS)Nrr)
lencompatrwrlrrrmrnNEWLINENLr)roiterablettok_typerrsendrfrrrrs


zUntokenizer.untokenizec	Cs%d}g}|jj}|\}}|ttfkr@|d7}|ttfkrXd}x|D]}|dd\}}|ttttfkr|d7}|tkr|j|q_nW|t	kr|j
q_n;|ttfkrd}n |r|r||dd}||q_WdS)NFrqTrxr)rlrrNAMENUMBERr|r}ASYNCAWAITINDENTDEDENTpop)	rorr~	startlineindentstoks_appendtoknumtokvaltokrrrr{s0




	zUntokenizer.compatN)r^r_r`rprwrr{rrrrrksrkz&^[ \t\f]*#.*?coding[:=][ \t]*([-\w.]+)s^[ \t\f]*(?:[#\r\n]|$)cCsd|ddjjdd}|dks=|jdrAdS|d
ks\|jdr`dS|S)z(Imitates get_normal_name in tokenizer.c.Nr-zutf-8zutf-8-latin-1
iso-8859-1iso-latin-1latin-1-iso-8859-1-iso-latin-1-)rrr)rrr)lowerreplace
startswith)orig_encencrrr_get_normal_names"rcsdd}d}fdd}fdd}|}|jtrjd|d	d}d
}|sz|gfS||}|r||gfStj|s||gfS|}|s||gfS||}|r|||gfS|||gfS)a
    The detect_encoding() function is used to detect the encoding that should
    be used to decode a Python source file. It requires one argument, readline,
    in the same way as the tokenize() generator.

    It will call readline a maximum of twice, and return the encoding used
    (as a string) and a list of any lines (left as bytes) it has read
    in.

    It detects the encoding from the presence of a utf-8 bom or an encoding
    cookie as specified in pep-0263. If both a bom and a cookie are present, but
    disagree, a SyntaxError will be raised. If the encoding cookie is an invalid
    charset, raise a SyntaxError.  Note that if a utf-8 bom is found,
    'utf-8-sig' is returned.

    If no encoding is specified, then the default of 'utf-8' will be returned.
    FNzutf-8cs+ySWntk
r&tSYnXdS)N)
StopIterationbytesr)rirrread_or_stops
z%detect_encoding.<locals>.read_or_stopcsy|jd}Wntk
r+dSYnXtj|}|sEdSt|jd}yt|}Wn"tk
rtd|YnXr|j	dkrtd|d7}|S)Nasciirzunknown encoding: zutf-8zencoding problem: utf-8z-sig)
decodeUnicodeDecodeError	cookie_rematchrrrLookupErrorSyntaxErrorname)rfline_stringrencodingcodec)	bom_foundrrfind_cookies"
	

z$detect_encoding.<locals>.find_cookieTz	utf-8-sig)rrblank_rer)rirdefaultrrfirstsecondr)rrirdetect_encodings0	


	
rcCst}|j|S)aTransform 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 tokin generate_tokens(readline)]
        assert t1 == t2
    )rkr)r~utrrrrFs	c!csY	d}}}tjdd}}d \}}d}dg}	d}
d}d}d}
xy
|}Wntk
rd}YnX|d}dt|}}|r|std||j|}|r!|jd}}t||d||||f||fVd!\}}d}qv|r|d"dd
kr|d#ddkrt||||t|f|fVd}d}qXqv||}||}qXn|dkrU|rU|sPd}xv||kr;||d
kr|d}n?||dkr|t	dt	}n||dkr-d}nP|d}qW||krIP|
rZ|
Vd}
||dkrG||dkr||dj
d}|t|}t|||f||t|f|fVt||d||f|t|f|fVqXttf||dk||d||f|t|f|fVqX||	d$kr|	j
|t|d||df||f|fVx||	d%kr#||	krtdd|||f|	dd&}	|r||	d'krd}d}
d}td||f||f|fVqW|rv|
rv||	d(krvd}d}
d}n!|sptd|dfd}xl||krtj||}|r|jd\}}||f||f|}}}|||||}}||ks|dkr(|dkr(t||||fVq|dkrt}|dkrOt}n|r[d}
|
rl|
Vd}
|||||fVq|dkr|
r|
Vd}
t||||fVq|tkrXt|}|j||}|r2|jd}|||}|
r|
Vd}
t||||f|fVq||f}||d}|}Pq|tks|dd	tks|ddtkr|d)dkr||f}t|pt|dpt|d	}||dd}}|}Pq|
r|
Vd}
t||||fVq||kr|d*krb|rb|dkrKtnt||||fVqyt||||f}|dkr|
r|}
qy|dkr|
r|
dtkr|
ddkrd}|	d+}t|
d|
d	|
d|
dfVd}
|
r|
Vd}
|Vq|dkrX|
r5|
Vd}
t||||f|fVd}q|dkrq|d}n|dkr|d}|
r|
Vd}
t||||fVqyt||||f||df|fV|d}qyWqXW|
r|
Vd}
x8|	ddD]&} td|df|dfdfVq	Wtd|df|dfdfVdS),aT
    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.
    rr
0123456789ryNFrzEOF in multi-line stringrxz\
rz\
rq	z#
#z
z3unindent does not match any outer indentation levelz
<tokenize>zEOF in multi-line statement.T
asyncawaitdef\z([{z)]})ryr)ryrrrrrrr)rrr)stringZ
ascii_lettersrrzr]rrSTRING
ERRORTOKENtabsizerstripCOMMENTr}rrrIndentationErrorr
pseudoprogspanrr|
triple_quotedendprogs
single_quotedrrrOP	ENDMARKER)!rilnumparenlev	continuedZ	namecharsnumcharscontstrneedcontcontlinerstashed	async_defasync_def_indentasync_def_nlrfposmaxstrstartendprogendmatchrcolumn
comment_tokennl_pospseudomatchrssposeposrinitialnewlinerindentrrrr[sp	


	2



	$#$ 
*$	 	


	


$__main__)rrrrr(r)r r!r*r+r"r#r,r-r$r%r0r1r.r/r2r3r&r'r6r7r4r5r8r9)rrr@rArBrCrDrErFrGrHrIrJrKrLrMrNrOrPrQrRrSrTrUrVrWrXrYrZr[)R__doc__
__author____credits__rrecodecsrrZlib2to3.pgen2.tokenryrdir__all__r	NameErrorstrrrr
WhitespaceCommentIgnoreName	Binnumber	Hexnumber	Octnumber	Decnumber	IntnumberExponent
PointfloatExpfloatFloatnumber
ImagnumberNumberSingleDoubleSingle3Double3TripleStringOperatorBracketSpecialFunny
PlainTokenTokenContStrPseudoExtrasPseudoTokenlistmapcompileZ	tokenprogrZsingle3progZdouble3progrrrrr	Exceptionr]rargr
rhrkASCIIrrrrrrr^sysrzargvopenristdinrrrr<module>s



		

*

8I
Back to Directory File Manager