Plan 9 from Bell Labs’s /usr/web/sources/contrib/bichued/root/sys/lib/python/tokenize.pyc

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


�
��c@s�dZdZdZddkZddkZddkTddkZgZee�D]"ZeddjoeeqQqQ[dd	d
ddgZ	[[e
Zdee<e
d
Z
dee
<e
d7Z
d�Zd�Zd�ZdZdZeede�ee�ZdZdZdZdZeeee�ZdZedd�ee�ZdeZeee�Zeded�Zeeee�ZdZd Z d!Z!d"Z"ed#d$�Z#ed%d&�Z$ed'd(d)d*d+d,d-d.�Z%d/Z&ed0d1�Z'ee%e&e'�Z(eee(e$e�Z)ee)Z*ed2ed3d�d4ed5d��Z+edee#�Z,eee,ee(e+e�Z-e.ei/e*e-e!e"f�\Z0Z1Z2Z3hei/e�d3<ei/e �d5<e2d6<e3d7<e2d8<e3d9<e2d:<e3d;<e2d<<e3d=<e2d><e3d?<e2d@<e3dA<e2dB<e3dC<e2dD<e3dE<e2dF<e3dG<ddH<ddI<ddJ<ddK<Z5hZ6xdgD]Z7e7e6e7<q�WhZ8xdhD]Z7e7e8e7<q�Wd\Z9d]e:fd^��YZ;d_e:fd`��YZ<da�Z=e=db�Z>dc�Z?dd�Z@de�ZAeBdfjoTddkCZCeDeCiE�d
joe>eFeCiEd
�iG�q�e>eCiHiG�ndS(is�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 <ping@lfw.org>s@GvR, ESR, Tim Peters, Thomas Wouters, Fred Drake, Skip Montanaroi�N(t*it_tCOMMENTttokenizetgenerate_tokenstNLt
untokenizeiicGsddi|�dS(Nt(t|t)(tjoin(tchoices((s/sys/lib/python/tokenize.pytgroup,scGst|�dS(NR(R(R((s/sys/lib/python/tokenize.pytany-scGst|�dS(Nt?(R(R((s/sys/lib/python/tokenize.pytmaybe.ss[ \f\t]*s	#[^\r\n]*s\\\r?\ns[a-zA-Z_]\w*s0[xX][\da-fA-F]*[lL]?s0[0-7]*[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
[uU]?[rR]?'''s
[uU]?[rR]?"""s&[uU]?[rR]?'[^\n'\\]*(?:\\.[^\n'\\]*)*'s&[uU]?[rR]?"[^\n"\\]*(?:\\.[^\n"\\]*)*"s\*\*=?s>>=?s<<=?s<>s!=s//=?s[+\-*/%&|^=<>]=?t~s[][(){}]s\r?\ns[:;.,`@]s%[uU]?[rR]?'[^\n'\\]*(?:\\.[^\n'\\]*)*t's%[uU]?[rR]?"[^\n"\\]*(?:\\.[^\n"\\]*)*t"s'''s"""sr'''sr"""su'''su"""sur'''sur"""sR'''sR"""sU'''sU"""suR'''suR"""sUr'''sUr"""sUR'''sUR"""trtRtutUsr'sr"sR'sR"su'su"sU'sU"sur'sur"sUr'sUr"suR'suR"sUR'sUR"it
TokenErrorcBseZRS((t__name__t
__module__(((s/sys/lib/python/tokenize.pyR�stStopTokenizingcBseZRS((RR(((s/sys/lib/python/tokenize.pyR�sc	CsA|\}}|\}}d||||t|t|�fGHdS(Ns%d,%d-%d,%d:	%s	%s(ttok_nametrepr(	ttypettokent.2t.3tlinetsrowtscolterowtecol((s/sys/lib/python/tokenize.pyt
printtoken�scCs+yt||�Wntj
onXdS(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/python/tokenize.pyR�s
cCs%xt|�D]}||�q
WdS(N(R(R(R)t
token_info((s/sys/lib/python/tokenize.pyR'�s
cCs�t}g}g}|i}x�|D]�}|d \}}|ttfjo|d7}n|tjo|i|�q"ne|tjo|i�q"nG|ttt	fjo
t
}n'|o|o||d�t}n||�q"Wdi|�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.

    Round-trip invariant:
        # 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
    it i�t(tFalsetappendtNAMEtNUMBERtINDENTtDEDENTtpoptNEWLINERRtTrueR
(titerablet	startlinetindentsttoksttoks_appendttokttoknumttokval((s/sys/lib/python/tokenize.pyR�s,	





ccs�d}}}tidd}}d\}}d}dg}	x@y
|�}
Wntj
o
d}
nX|d}dt|
�}}|o�
ptd|
f�n|i|
�}|oO|id�}}t||
| |
||f||
fVd\}}d}qv|oY|
ddjoH|
d	d
jo7t	||
|
|t|
�f|fVd}d}q@qv||
}||
}q@n�djo�|o�|
pPnd}x~||jop|
|djo|d}nD|
|djo|t
dt
}n|
|d
jo
d}nP|d}q�W||joPn|
|djoEttf|
|dj|
|||f|t|
�f|
fVq@n||	djo5|	i
|�t|
| |df||f|
fVnx�||	djoZ||	jotdd|||
f��n|	d }	td||f||f|
fVq�Wn'|
ptd|dff�nd}x||jo�i|
|�}|o�|id�\}}||f||f|}}}|
||!|
|}}||jp|djo%|djot||||
fVqx|djo,|djotpt||||
fVqx|djot||||
fVqx|tjo~t|}|i|
|�}|o:|id�}|
||!}t||||f|
fVqB||f}
|
|}|
}Pqx|tjp"|d tjp|d tjoy|ddjoP||f}
t|pt|dpt|d}|
|d}}|
}PqBt||||
fVqx||jot||||
fVqx|djo
d}qx|djo|d}n|djo|d}nt||||
fVqyt	|
|||f||df|
fV|d}qyWq@x2|	dD]&}td|df|dfdfVq�Wtd|df|dfdfVdS(sS
    The generate_tokens() generator requires one argment, 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\
R+s	ss#
t#i�s3unindent does not match any outer indentation levels
<tokenize>sEOF in multi-line statementt.s
iis
s\s([{s)]}N(R,i(R,i(tstringt
ascii_letterstNonet
StopIterationtlenRtmatchtendtSTRINGt
ERRORTOKENttabsizeRRR.R1tIndentationErrorR2t
pseudoprogtspanR0R4t
triple_quotedtendprogst
single_quotedR/tOPt	ENDMARKER(R(tlnumtparenlevt	continuedt	namecharstnumcharstcontstrtneedconttcontlineR8R!tpostmaxtstrstarttendprogtendmatchRGtcolumntpseudomatchtstarttsposteposRtinitialtindent((s/sys/lib/python/tokenize.pyR�s�	


)


' 
(

) 











$t__main__(s'''s"""sr'''sr"""sR'''sR"""su'''su"""sU'''sU"""sur'''sur"""sUr'''sUr"""suR'''suR"""sUR'''sUR"""(RRsr'sr"sR'sR"su'su"sU'sU"sur'sur"sUr'sUr"suR'suR"sUR'sUR"(It__doc__t
__author__t__credits__RAtreRt_[1]tdirtxt__all__tN_TOKENSRRRRR
Rt
WhitespacetCommenttIgnoretNamet	Hexnumbert	Octnumbert	Decnumbert	IntnumbertExponentt
PointfloattExpfloattFloatnumbert
ImagnumbertNumbertSingletDoubletSingle3tDouble3tTripletStringtOperatortBrackettSpecialtFunnyt
PlainTokentTokentContStrtPseudoExtrastPseudoTokentmaptcompilet	tokenprogRLtsingle3progtdouble3progRCRORNttRPRJt	ExceptionRRR&RR'RRRtsysREtargvtopenR(tstdin(((s/sys/lib/python/tokenize.pys<module>s�
?



			
		

'(&			(	�4

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.