Plan 9 from Bell Labs’s /usr/web/sources/contrib/stallion/root/sys/lib/python2.7/compiler/transformer.pyc

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


�`^c)@sfdZddlTddlZddlZddlZdefd��YZddlmZm	Z	ddlm
Z
mZmZd�Z
d	d
�Zd�Zd�Zd
�Zdfd��YZejejejejejejejejejejejejejej ej!ej"gZ#idej$6dej%6dej&6dej'6dej(6dej)6dej*6Z+ej,ej-ej.ej/ej0ej1ej2ejej3ej4ej5ej6ej7ej8ej9ej:ej;ej<ej=ej>ej?ej@ejAejBejCejejejejejejejDejejejejejej ej!ej"ejEg)ZFeGed�r�eFjHejI�neGed�r�eFjHejJ�nejejejejejejejejejejej ej!gZKiZLx'ejMjN�D]\ZOZPePeLeO<qWx'ejQjN�D]\ZOZPePeLeO<q?Wd�ZRdS(s�Parse tree transformation module.

Transforms Python source code into an abstract syntax tree (AST)
defined in the ast module.

The simplest ways to invoke this module are via parse and parseFile.
parse(buf) -> AST
parseFile(path) -> AST
i�(t*NtWalkerErrorcBseZRS((t__name__t
__module__(((s*/sys/lib/python2.7/compiler/transformer.pyR!s(t
CO_VARARGStCO_VARKEYWORDS(t	OP_ASSIGNt	OP_DELETEtOP_APPLYcCs3t|d�}|j�d}|j�t|�S(NtUs
(topentreadtclosetparse(tpathtftsrc((s*/sys/lib/python2.7/compiler/transformer.pyt	parseFile's
texeccCsT|dks|dkr(t�j|�S|dkrDt�j|�Std��dS(NRtsingletevals4compile() arg 3 must be 'exec' or 'eval' or 'single'(tTransformert
parsesuitet	parseexprt
ValueError(tbuftmode((s*/sys/lib/python2.7/compiler/transformer.pyR
1s
cCs�g}x�|D]�}t|d�r8|j|j��q
t|�td�krl|jtt|���q
t|�tg�kr�|jt|��q
|j|�q
W|S(NtasList(NN(thasattrtappendRttypetNonettuple(tnodestltitem((s*/sys/lib/python2.7/compiler/transformer.pyR:s
cCsbt|dt�s|dSx@|dD]4}t|t�r&t|�}|dk	rZ|Sq&q&WdS(Nii(t
isinstanceR t
extractLineNoR(tasttchildtlineno((s*/sys/lib/python2.7/compiler/transformer.pyR%HscGst|d}|tkr]yt||d�SWqptk
rYt|Gt|�G|GH�qpXntdt|��dS(Niis$Can't find appropriate Node type: %s(R!t	TypeErrortlenRtstr(targstkind((s*/sys/lib/python2.7/compiler/transformer.pytNodeRs


RcBsUeZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�ZeZd�Zd�ZeZeZeZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d�Z"d�Z#d�Z$d�Z%d �Z&d!�Z'd"�Z(d#�Z)d$�Z*d%�Z+d&�Z,d'�Z-d(�Z.d)�Z/d*�Z0d+�Z1d,�Z2d-�Z3d.�Z4d/�Z5d0�Z6d1�Z7d2�Z8d3�Z9e9Z:e9Z;e9Z<d4�Z=d5�Z>d6�Z?e?Z@d7�ZAd8�ZBd9�ZCd:�ZDd;�ZEd<�ZFd=�ZGd>�ZHd?�ZId@�ZJdA�ZKdB�ZLdC�ZMdD�ZNdE�ZOdF�ZPdG�ZQdH�ZRdI�ZSdJ�ZTdK�ZUdL�ZVdM�ZWdN�ZXdO�ZYdP�ZZdQ�Z[dR�Z\dS�Z]dT�Z^dU�Z_dV�Z`dW�ZadX�ZbdY�ZcdZ�Zdd[�Zed\�Zfd]�Zgd^�Zhd_�Zid`�Zjda�Zkdb�Zldc�Zmdd�Znde�Zodf�Zpdg�Zqdh�Zrdi�Zsdj�Ztdk�Zudl�Zvdm�Zwdn�Zxdo�Zydp�Zzdq�Z{dr�Z|ds�Z}dudt�ZRS(vs�Utility object for transforming Python parse trees.

    Exposes the following methods:
        tree = transform(ast_tree)
        tree = parsesuite(text)
        tree = parseexpr(text)
        tree = parsefile(fileob | filename)
    cCs�i|_xEtjj�D]4\}}t||�rt||�|j|<qqW|j|jtj<i|j	tj
6|jtj6|j
tj6|jtj6|jtj6|jtj6|jtj6|_d|_dS(N(t	_dispatchtsymboltsym_nametitemsRtgetattrtcom_NEWLINEttokentNEWLINEt	atom_lpartLPARt	atom_lsqbtLSQBtatom_lbracetLBRACEtatom_backquotet	BACKQUOTEtatom_numbertNUMBERtatom_stringtSTRINGt	atom_nametNAMEt_atom_dispatchRtencoding(tselftvaluetname((s*/sys/lib/python2.7/compiler/transformer.pyt__init__hs	




cCsCt|t�pt|t�s6tj|dd�}n|j|�S(s,Transform an AST into a modified parse tree.t	line_infoi(R$R tlisttparsertst2tupletcompile_node(RGttree((s*/sys/lib/python2.7/compiler/transformer.pyt	transformxscCs|jtj|��S(s6Return a modified parse tree for the given suite text.(RQRMtsuite(RGttext((s*/sys/lib/python2.7/compiler/transformer.pyR~scCs|jtj|��S(s;Return a modified parse tree for the given expression text.(RQRMtexpr(RGRS((s*/sys/lib/python2.7/compiler/transformer.pyR�scCs:t|�td�kr't|�}n|j|j��S(s@Return a modified parse tree for the contents of the given file.t(RR
RR(RGtfile((s*/sys/lib/python2.7/compiler/transformer.pyt	parsefile�scCs|d}|tjkr=|d|_|d}|d}n|tjkr]|j|d�S|tjkr}|j|d�S|tjkr�|j|d�S|tjkr�|j|d�S|tjkr�|j|d�S|tjkr�j|d�St	d|f�dS(Niiisunexpected node type(
R0t
encoding_declRFtsingle_inputt
file_inputt
eval_inputtlambdeftfuncdeftclassdefR(RGtnodetn((s*/sys/lib/python2.7/compiler/transformer.pyRO�s$



cCs5|dd}|tjkr.|j|d�St�S(Ni(R5R6tcom_stmttPass(RGR_R`((s*/sys/lib/python2.7/compiler/transformer.pyRY�scCs�|j|tj�}|dk	r*d}nd}g}xK||D]?}|dtjkrA|dtjkrA|j||�qAqAWt|t	|��S(Nii(
t
get_docstringR0RZRR5t	ENDMARKERR6tcom_append_stmttModuletStmt(RGtnodelisttdoctitstmtsR_((s*/sys/lib/python2.7/compiler/transformer.pyRZ�s	&cCst|j|d��S(Ni(t
Expressiontcom_node(RGRh((s*/sys/lib/python2.7/compiler/transformer.pyR[�scCs�t|�}|dkr(|ddks.t�|j|�}d}xs||kr�||dtjksot�||ddtjks�t�t|||dd�}|d7}qFW|S(Niii(R*tAssertionErrorRCR5tDOTRDtGetattr(RGRhtlistlenR#Rj((s*/sys/lib/python2.7/compiler/transformer.pytdecorator_name�s"!cCs�t|�dkst�|ddtjks5t�|ddtjksRt�|ddtjksot�|j|dd�}t|�dkr�|ddtjks�t�|j	||d�}n|}|S(	Niiiii�ii(iii(
R*RnR5tATR6R0tdotted_nameRrR8tcom_call_function(RGRhtfuncnameRT((s*/sys/lib/python2.7/compiler/transformer.pyt	decorator�scCsTg}xA|D]9}|dtjks,t�|j|j|d��q
Wt|�S(Nii(R0RwRnRt
Decorators(RGRhR2tdec_nodelist((s*/sys/lib/python2.7/compiler/transformer.pyt
decorators�s

cCs�|ddtjkst�|ddtjkr`|dgt|dd�}|j|�S|ddtjkr�|j|dd�}|j|dd�}||_|St��dS(Nii(R0RzRnR]RLR^R(RGRhR`Rztcls((s*/sys/lib/python2.7/compiler/transformer.pyt	decorated�s
	c
Cset|�dkrI|ddtjks/t�|j|dd�}nt|�dksat�d}|dd}|dd}|dd}|dtjkr�|j|d�\}}}nd
}}d}|j|d�}	|j|d�}
|	dk	rCt	|
t
�st�t	|
jdt�s6t�|
jd=nt
||||||	|
d	|�S(Niiiii�ii�i�R(((R*R0RzRnRtvarargslisttcom_arglistRcRmR$RgR!tDiscardtFunction(RGRhRzR(RIR,tnamestdefaultstflagsRitcode((s*/sys/lib/python2.7/compiler/transformer.pyR]�s(

cCs~|ddtjkr:|j|dd�\}}}nd}}d}|j|d�}t||||d|dd�S(Niiii�R(((R0R}R~RmtLambda(RGRhR�R�R�R�((s*/sys/lib/python2.7/compiler/transformer.pyR\s#
cCs�|dd}|j|d�}|ddtjkrAg}n3|ddtjkrag}n|j|d�}|j|d�}|dk	r�t|t�s�t	�t|j
dt�s�t	�|j
d=nt||||d|dd�S(Nii�iiiR((
RcR5tCOLONtRPARt	com_basesRmRR$RgRnR!RtClass(RGRhRIRitbasesR�((s*/sys/lib/python2.7/compiler/transformer.pyR^&s		
cCs|j|d�S(Ni(Ra(RGRh((s*/sys/lib/python2.7/compiler/transformer.pytstmt<scCsGg}x4tdt|�d�D]}|j|||�qWt|�S(Nii(trangeR*ReRg(RGRhRkRj((s*/sys/lib/python2.7/compiler/transformer.pytsimple_stmtCscCs
t�dS(N(R(RGRh((s*/sys/lib/python2.7/compiler/transformer.pyt
parametersJscCs
t�dS(N(R(RGRh((s*/sys/lib/python2.7/compiler/transformer.pyR}MscCs
t�dS(N(R(RGRh((s*/sys/lib/python2.7/compiler/transformer.pytfpdefPscCs
t�dS(N(R(RGRh((s*/sys/lib/python2.7/compiler/transformer.pytfplistSscCs
t�dS(N(R(RGRh((s*/sys/lib/python2.7/compiler/transformer.pyRtVscCs
t�dS(N(R(RGRh((s*/sys/lib/python2.7/compiler/transformer.pytcomp_opYscCs
t�dS(N(R(RGRh((s*/sys/lib/python2.7/compiler/transformer.pyttrailer\scCs
t�dS(N(R(RGRh((s*/sys/lib/python2.7/compiler/transformer.pytsliceop_scCs
t�dS(N(R(RGRh((s*/sys/lib/python2.7/compiler/transformer.pytargumentbscCs|d}|j|�|d�}t|�dkrHt|d|j�S|ddtjkr�g}xAtdt|�dd�D]#}|j|j||t	��q�Wt
||d|dd�S|j|d�}|j|d�}t
||d|d|d�Std�dS(Ni�iR(iiscan't get here(tlookup_nodeR*RR(R5tEQUALR�Rt
com_assignRtAssignt
com_augassigntcom_augassign_opt	AugAssignR(RGRhtentexprNodetnodeslRjtlvaltop((s*/sys/lib/python2.7/compiler/transformer.pyt	expr_stmtjs
#!cCsg}t|�dkr'd}d}nn|ddtjkr�t|�dksm|ddtjksmt�|j|d�}d}nd}d}x:t|t|�d�D] }|j|j||��q�W|ddtjkrt	||d|dd�St
||d|dd�S(Niiiiii�R((R*RR5t
RIGHTSHIFTtCOMMARnRmR�RtPrinttPrintnl(RGRhR2tstarttdestRj((s*/sys/lib/python2.7/compiler/transformer.pyt
print_stmt{s 		cCs|j|dt�S(Ni(R�R(RGRh((s*/sys/lib/python2.7/compiler/transformer.pytdel_stmt�scCstd|dd�S(NR(ii(Rb(RGRh((s*/sys/lib/python2.7/compiler/transformer.pyt	pass_stmt�scCstd|dd�S(NR(ii(tBreak(RGRh((s*/sys/lib/python2.7/compiler/transformer.pyt
break_stmt�scCstd|dd�S(NR(ii(tContinue(RGRh((s*/sys/lib/python2.7/compiler/transformer.pyt
continue_stmt�scCsUt|�dkr0ttd�d|dd�St|j|d�d|dd�S(NiR(ii(R*tReturntConstRRm(RGRh((s*/sys/lib/python2.7/compiler/transformer.pytreturn_stmt�scCs&|j|d�}t|d|j�S(NiR((RmRR((RGRhRT((s*/sys/lib/python2.7/compiler/transformer.pyt
yield_stmt�scCsLt|�dkr(|j|d�}ntd�}t|d|dd�S(NiR(ii(R*RmR�RtYield(RGRhRH((s*/sys/lib/python2.7/compiler/transformer.pyt
yield_expr�scCs�t|�dkr(|j|d�}nd}t|�dkrV|j|d�}nd}t|�dkr�|j|d�}nd}t|||d|dd�S(NiiiR(ii(R*RmRtRaise(RGRhtexpr3texpr2texpr1((s*/sys/lib/python2.7/compiler/transformer.pyt
raise_stmt�scCs)t|�dkst�|j|d�S(Nii(R*RnRm(RGRh((s*/sys/lib/python2.7/compiler/transformer.pytimport_stmt�scCs%t|j|d�d|dd�S(NiR(ii(tImporttcom_dotted_as_names(RGRh((s*/sys/lib/python2.7/compiler/transformer.pytimport_name�scCs4|dddkst�d}x"||ddkrD|d7}q#W|d}||dtjkr�|j||�}|d7}nd}||ddks�t�||ddtjkr�|d
g|d|dd	�S||d||ddtjk}t||j	|�|d|dd	�SdS(Niitfromt.RUtimportRR(i(RN(
RnR0Rttcom_dotted_nameR5tSTARtFromRR8tcom_import_as_names(RGRhtidxtleveltfromnameR_((s*/sys/lib/python2.7/compiler/transformer.pytimport_from�s 

'cCsVg}x5tdt|�d�D]}|j||d�qWt|d|dd�S(NiiR(i(R�R*RtGlobal(RGRhR�Rj((s*/sys/lib/python2.7/compiler/transformer.pytglobal_stmt�scCs�|j|d�}t|�dkri|j|d�}t|�dkr`|j|d�}qsd}n
d}}t|||d|dd�S(	NiiiiiR(ii(RmR*RtExec(RGRhR�R�R�((s*/sys/lib/python2.7/compiler/transformer.pyt	exec_stmt�s	
cCs\|j|d�}t|�dkr;|j|d�}nd}t||d|dd�S(NiiiR(ii(RmR*RtAssert(RGRhR�R�((s*/sys/lib/python2.7/compiler/transformer.pytassert_stmt�s
cCs�g}xetdt|�dd�D]G}|j||d�}|j||d�}|j||f�q#Wt|�ddkr�|j|d�}nd}t||d|dd�S(Niiiii�R(i(R�R*RmRRtIf(RGRhttestsRjttestNodet	suiteNodetelseNode((s*/sys/lib/python2.7/compiler/transformer.pytif_stmt�s#cCsr|j|d�}|j|d�}t|�dkrN|j|d�}nd}t|||d|dd�S(NiiiiR(ii(RmR*RtWhile(RGRhR�tbodyNodeR�((s*/sys/lib/python2.7/compiler/transformer.pyt
while_stmt	scCs�|j|dt�}|j|d�}|j|d�}t|�dkrd|j|d�}nd}t||||d|dd�S(NiiiiR(ii(R�RRmR*RtFor(RGRht
assignNodetlistNodeR�R�((s*/sys/lib/python2.7/compiler/transformer.pytfor_stmtscCs
|j|�S(N(tcom_try_except_finally(RGRh((s*/sys/lib/python2.7/compiler/transformer.pyttry_stmt%scCs
|j|�S(N(tcom_with(RGRh((s*/sys/lib/python2.7/compiler/transformer.pyt	with_stmt(scCs
|j|�S(N(tcom_with_var(RGRh((s*/sys/lib/python2.7/compiler/transformer.pytwith_var+scCsjt|�dkr#|j|d�Sg}x4|D],}|dtjkr0|j||�q0q0Wt|�S(Nii(R*RaR0R�ReRg(RGRhRkR_((s*/sys/lib/python2.7/compiler/transformer.pyRR.s
cCs|jt|�S(N(t
com_binarytTuple(RGRh((s*/sys/lib/python2.7/compiler/transformer.pyttestlist>scCsz|ddtjkst�t|�dkrm|ddtjkrm|j|d�}|j||d�S|j|�S(Niii(R0ttestRnR*tcomp_forRmtcom_generator_expressionR�(RGRhR�((s*/sys/lib/python2.7/compiler/transformer.pyt
testlist_compHs
)cCs�t|�dkr:|ddtjkr:|j|d�S|j|d�}t|�dkr�|�dkswt�|dddks�t�|dddks�t�|j|d�}|j|d�}t|||d	|dd�S|S(
NiiitifitelseiiR((R*R0R\RmRntIfExp(RGRhtthenR�telse_((s*/sys/lib/python2.7/compiler/transformer.pyR�Ps)cCsJt|�dkr:|ddtjkr:|j|d�S|jt|�S(Nii(R*R0R\R�tOr(RGRh((s*/sys/lib/python2.7/compiler/transformer.pytor_test^s)cCs|jt|�S(N(R�tAnd(RGRh((s*/sys/lib/python2.7/compiler/transformer.pytand_testescCsA|j|d�}t|�dkr=t|d|dd�S|S(Ni�iR(i(RmR*tNot(RGRhtresult((s*/sys/lib/python2.7/compiler/transformer.pytnot_testisc	Cs	|j|d�}t|�dkr)|Sg}x�tdt|�d�D]�}||d}|d}|dtjkr�|d}t|�dkr�|dkr�d}q�d}q�nt|d}|dd}|j||j||�f�qHWt||d|�S(	Niiiitnotsnot insis notR((RmR*R�R5RDt
_cmp_typesRtCompare(	RGRhR_tresultsRjtnlR`RR(((s*/sys/lib/python2.7/compiler/transformer.pyt
comparisonps"

	$cCs|jt|�S(N(R�tBitor(RGRh((s*/sys/lib/python2.7/compiler/transformer.pyRT�scCs|jt|�S(N(R�tBitxor(RGRh((s*/sys/lib/python2.7/compiler/transformer.pytxor_expr�scCs|jt|�S(N(R�tBitand(RGRh((s*/sys/lib/python2.7/compiler/transformer.pytand_expr�scCs�|j|d�}x�tdt|�d�D]�}|j||�}||ddtjkr�t||gd|dd�}q,||ddtjkr�t||gd|dd�}q,td||dd�q,W|S(NiiiR(sunexpected token: %s(	RmR�R*R5t	LEFTSHIFTt	LeftShiftR�t
RightShiftR(RGRhR_Rjtright((s*/sys/lib/python2.7/compiler/transformer.pyt
shift_expr�s##cCs�|j|d�}x�tdt|�d�D]�}|j||�}||ddtjkr�t||gd|dd�}q,||ddtjkr�t||gd|dd�}q,td||dd�q,W|S(NiiiR(sunexpected token: %s(	RmR�R*R5tPLUStAddtMINUStSubR(RGRhR_RjR((s*/sys/lib/python2.7/compiler/transformer.pyt
arith_expr�s##cCs
|j|d�}x�dt|�d�D]�}|j||�}||dd}|tjkr{t||g�}ny|tjkr�t||g�}nU|tjkr�t	||g�}n1|tj
kr�||g�}n
td|�|dd|_
q,W|S(Niiisunexpected token: %s(RmR�R*R5R�tMultSLASHtDivtPERCENTtModtDOUBLESLASHtFloorDivRR((RGRhR_RjRtt((s*/sys/lib/python2.7/compiler/transformer.pytterm�s
cCs�|d}|d}|j|d�|dd�}|tjkrXt|d|d�S|tjkr{t|d|d�S|tjkr�t|d|d�}n|S(Nii�iR(i(R�R5RtUnaryAddRtUnarySubtTILDEtInvert(RGRhteltRR_((s*/sys/lib/python2.7/compiler/transformer.pytfactor�s

!cCs�|j|d�}xwtdt|��D]`}||}|dtjkrwt||j||d�gd|d�S|j||�}q)W|S(NiiR(i(RmR�R*R5t
DOUBLESTARtPowertcom_apply_trailer(RGRhR_RjR((s*/sys/lib/python2.7/compiler/transformer.pytpower�s
 cCs|j|dd|�S(Ni(RE(RGRh((s*/sys/lib/python2.7/compiler/transformer.pytatom�scCs@|ddtjkr/tdd|dd�S|j|d�S(NiiR(i((R5R�R�Rm(RGRh((s*/sys/lib/python2.7/compiler/transformer.pyR7�scCs@|ddtjkr/tdd|dd�S|j|d�S(NiiR(i((R5tRSQBtListtcom_list_constructor(RGRh((s*/sys/lib/python2.7/compiler/transformer.pyR9�scCs@|ddtjkr/tdd|dd�S|j|d�S(NiiR(i((R5tRBRACEtDicttcom_dictorsetmaker(RGRh((s*/sys/lib/python2.7/compiler/transformer.pyR;�scCst|j|d��S(Ni(t	BackquoteRm(RGRh((s*/sys/lib/python2.7/compiler/transformer.pyR=�scCs,t|dd�}t|d|dd�S(NiiR(i(RR�(RGRhtk((s*/sys/lib/python2.7/compiler/transformer.pyR?�scCs[|jrM|jdkr6t|d�j|j�}ntd|j|f�St|�SdS(Nsutf-8s
iso-8859-1s# coding: %s
%s(sutf-8s
iso-8859-1(RFtunicodetencodeR(RGtlit((s*/sys/lib/python2.7/compiler/transformer.pytdecode_literal�s
	cCsFd}x%|D]}||j|d�7}q
Wt|d|dd�S(NRUiR(ii(R)R�(RGRhR%R_((s*/sys/lib/python2.7/compiler/transformer.pyRAs
cCs t|ddd|dd�S(NiiR(i(tName(RGRh((s*/sys/lib/python2.7/compiler/transformer.pyRC
scCs|j|dS(Ni(R/(RGR_((s*/sys/lib/python2.7/compiler/transformer.pyR�scCs|j|d|d�S(Nii(R/(RGR_((s*/sys/lib/python2.7/compiler/transformer.pyRm scGsttd��S(N(RR�R(RGR,((s*/sys/lib/python2.7/compiler/transformer.pyR4'scCs�g}g}d}d}x�|t|�kr�||}|dtjks]|dtjkr+|dtjkr�||d}|dtjkr�|j|d�|tB}|d}q�n|t|�kr'||d}|tjkr�|d}n
td|�|j|d�|tB}nPn|j|j	|��|d}|t|�kr�||dtj
kr�|j|j||d��|d}nt|�r�td�n|d}qW|||fS(Niiisunexpected token: %sis-non-default argument follows default argument(
R*R5R�RRDRRRRt	com_fpdefR�RmtSyntaxError(RGRhR�R�R�RjR_R((s*/sys/lib/python2.7/compiler/transformer.pyR~-s<
&



)
cCs4|ddtjkr(|j|d�S|ddS(Niii(R5R8t
com_fplist(RGR_((s*/sys/lib/python2.7/compiler/transformer.pyR+_scCspt|�dkr#|j|d�Sg}x:tdt|�d�D] }|j|j||��qBWt|�S(Nii(R*R+R�RR (RGR_RLRj((s*/sys/lib/python2.7/compiler/transformer.pyR-escCs\d}xK|D]C}t|�td�kr
|ddkr
||dd}q
q
W|d S(NRUiiR�i�((R(RGR_RIR`((s*/sys/lib/python2.7/compiler/transformer.pyR�ns

(cCs�|dtjkst�|d}|j|dd�}t|�dkrV|dfS|dddkspt�|ddtjks�t�||ddfS(Niitasi(R0tdotted_as_nameRnR�R*RR5RD(RGR_tdot((s*/sys/lib/python2.7/compiler/transformer.pytcom_dotted_as_namevs

cCsz|dtjkst�|d}|j|d�g}x:tdt|�d�D] }|j|j||��qRW|S(Niii(R0tdotted_as_namesRnR1R�R*R(RGR_R�Rj((s*/sys/lib/python2.7/compiler/transformer.pyR��s
cCs�|dtjkst�|d}|ddtjks@t�t|�dkrd|dddfS|dddks�t|��|ddtjks�t�|dd|ddfS(NiiR.i(R0timport_as_nameRnR5RDR*R(RGR_((s*/sys/lib/python2.7/compiler/transformer.pytcom_import_as_name�s
 cCsz|dtjkst�|d}|j|d�g}x:tdt|�d�D] }|j|j||��qRW|S(Niii(R0timport_as_namesRnR4R�R*R(RGR_R�Rj((s*/sys/lib/python2.7/compiler/transformer.pyR��s
cCsGg}x:tdt|�d�D] }|j|j||��qW|S(Nii(R�R*RRm(RGR_R�Rj((s*/sys/lib/python2.7/compiler/transformer.pyR��sc
Cs�|ddtjkrLt|j|d�|j|d�d|dd�Sg}d}d}x4tdt|�d�D]}||}|dtjkr't|�dkr�j|d�}t|�dkr�j	|dt
�}q�}n
d}}|j|||j||d�f�n|dtjkrw|ddkrd|j||d�}q�|dd	kr�|j||d�}q�qwqwWt|j|d�||d|dd�}	|r�|	|d|dd�S|	SdS(
NiiiiR(iiR�tfinally(
R5RDt
TryFinallyRmRR�R*R0t
except_clauseR�RRt	TryExcept(
RGRhtclausesR�tfinallyNodeRjR_R�R�t
try_except((s*/sys/lib/python2.7/compiler/transformer.pyR��s6
	
*!cCsu|j|d�}x[tt|�ddd�D]=}|j||||dd�}|dkrg|S|}q0WdS(Ni�iii�ii(RmR�R*t
com_with_item(RGRhtbodyRjtret((s*/sys/lib/python2.7/compiler/transformer.pyR��s#!cCsZt|�dkr+|j|dt�}nd}|j|d�}t|||d|�S(NiiiR((R*R�RRRmtWith(RGRhR>R(tvarRT((s*/sys/lib/python2.7/compiler/transformer.pyR=�s
cCs!|dtjkst�|dS(Nii(R0t	augassignRn(RGR_((s*/sys/lib/python2.7/compiler/transformer.pyR��scCsE|j|�}|jttttfkr.|Std|jj�dS(s�Return node suitable for lvalue of augmented assignment

        Names, slices, and attributes are the only allowable nodes.
        scan't assign to %sN(Rmt	__class__R*tSlicet	SubscriptRpR,R(RGR_R"((s*/sys/lib/python2.7/compiler/transformer.pyR��scCsTxM|d}|tjtjtjtjfkr`t|�dkrS|j||�S|d}q|tkr�t|�dkr�td�n|d}q|tj	krq|ddtj
kr�td�nt|�dkrd|j|d�}x\tdt|�d�D]A}||}|dt
jkr7td�n|j||�}qW|j||d|�S|d}q|tj
kr@|dd}|t
jkr�|d}|dt
jkr=td�q=qM|t
jkr|d}|dt
jkrtd�n|j||�S|t
jkr4|j|d|�Std�qtd	|�qdS(
Niiiscan't assign to operatori�scan't assign to ()scan't assign to []scan't assign to literalsbad assignment (%s)(R0texprlistR�t
testlist_safeR�R*tcom_assign_tuplet
_assign_typesR,RRRmR�R5RRtcom_assign_trailerR8R�R:Rtcom_assign_listRDtcom_assign_name(RGR_t	assigningRtprimaryRjtch((s*/sys/lib/python2.7/compiler/transformer.pyR��sL
$

 



cCs\g}x=tdt|�d�D]#}|j|j|||��qWt|dt|��S(NiiR((R�R*RR�tAssTupleR%(RGR_RMtassignsRj((s*/sys/lib/python2.7/compiler/transformer.pyRHs!cCs�g}x�tdt|�d�D]�}|dt|�kr�||ddtjkrbtd�n||ddtjks�t||d��n|j|j	|||��qWt
|dt|��S(Niiis"can't assign to list comprehensionR((R�R*R0tlist_forR,R5R�RnRR�tAssListR%(RGR_RMRQRj((s*/sys/lib/python2.7/compiler/transformer.pyRKs2!cCst|d|d|d�S(NiR(i(tAssName(RGR_RM((s*/sys/lib/python2.7/compiler/transformer.pyRL%scCs�|dd}|tjkr4|j||d|�S|tjkrZ|j||d|�S|tjkrutd�ntd|�dS(Niiiscan't assign to function callsunknown trailer type: %s(R5Rotcom_assign_attrR:tcom_subscriptlistR8R,(RGRNR_RMR((s*/sys/lib/python2.7/compiler/transformer.pyRJ(scCst||d|d|d�S(NiR(i�(tAssAttr(RGRNR_RM((s*/sys/lib/python2.7/compiler/transformer.pyRU2scCs�t|�}|dkr9|d}|j|�|d�Sg}xDtd|d�D]0}||}|j|j|�|d��qRW||dt|��S(s=Compile 'NODE (OP NODE)*' into (type, [ node1, ..., nodeN ]).iiiR((R*R�R�RR%(RGtconstructorRhR"R`R2Rj((s*/sys/lib/python2.7/compiler/transformer.pyR�5s

$cCsK|j|�|d�}|dk	s+t�t|t�r>|St|g�S(Ni(R�RRnR$Rg(RGR_R�((s*/sys/lib/python2.7/compiler/transformer.pyRaAs
cCs^|j|�|d�}|dk	s+t�t|t�rM|j|j�n
|j|�dS(Ni(R�RRnR$RgtextendR!R(RGRkR_R�((s*/sys/lib/python2.7/compiler/transformer.pyReHs
cCs�g}x�tdt|��D]�}||dtjkrmt||�dksUt�|j|d||�S||dtjkr�qn|j|j	||��qWt
|d|dj�S(NiiR((R�R*R0RRRntcom_list_comprehensionR5R�RRmRR((RGRhtvaluesRj((s*/sys/lib/python2.7/compiler/transformer.pyR Ps
cCs|j|d|d�S(NRL(tcom_comprehensionR(RGRTR_((s*/sys/lib/python2.7/compiler/transformer.pyRZ]sc
Cs|dd}g}x|r�|dd}|dkr�j|dt�}|j|d�}	t||	g�}
|dd|
_|j|
�t|�dkr�d}q�|dkr�|j|d�}q�|j	|d�}q|dkr|j|d�}t
|d|dd�}|
jj|�t|�d	krGd}q�|dkri|j|d	�}q�|j	|d	�}qtd
||f�qW|dkr�t
||d|�S|dkr�t||d|�S|dkr�|||d|�Std
t|���dS(NiitforiiRLR�R(is'unexpected comprehension element: %s %dtsettdictsunexpected comprehension type: (R�RRmtListCompForR(RR*Rt
com_list_itert
com_comp_itert
ListCompIftifsR,tListComptSetComptDictCompRtrepr(
RGR�R�R_RR(tforsRR�tcompNodetnewforR�tnewif((s*/sys/lib/python2.7/compiler/transformer.pyR\`sD
	
		cCs!|dtjkst�|dS(Nii(R0t	list_iterRn(RGR_((s*/sys/lib/python2.7/compiler/transformer.pyRa�scCs!|dtjkst�|dS(Nii(R0t	comp_iterRn(RGR_((s*/sys/lib/python2.7/compiler/transformer.pyRb�scCsu|dd}g}x8|rN|dd}|dkr�|j|dt�}|j|d�}t||gd|dd�}|j|�t|�dkr�d}qK|j|d�}q|dkr8|j|d�}	t|	d|dd�}
|j	j|
�t|�dkr"d}qK|j|d�}qt
d	||f�qWt|d
_t
t||�d|�S(NiiR]iR(iR�is.unexpected generator expression element: %s %di(R�RRmt
GenExprForRR*RRbt	GenExprIfRdR,tTruet
is_outmosttGenExprtGenExprInner(RGRTR_R(RiRR�tgenNodeRkR�Rl((s*/sys/lib/python2.7/compiler/transformer.pyR��s2	
		
cCs�|dtjkst�|d}t|�dksL|ddtjkr�g}x:tdt|�d�D] }|j|j||��qkWt	|d|dj
�S|ddtjkr�j|d�}|j|d|dd�St|�dkrp|ddtjkrp|ddtjks0t�|j|d�}|j|d�}|j|||dd�Sg}xQtdt|�d�D]7}|j|j||�|j||d�f�q�Wt|d|ddj
�SdS(	NiiiR(R^iR_i(R0tdictorsetmakerRnR*R5R�R�RRmtSetR(R�R\RR�R"(RGRhR2RjRTtkeyRH((s*/sys/lib/python2.7/compiler/transformer.pyR#�s(
))cCs�|dd}|tjkr1|j||d�S|tjkrT|j||d�S|tjkrz|j||dt�Std|�dS(Niiisunknown node type: %s(	R5R8RuRotcom_select_memberR:RVRR,(RGtprimaryNodeRhR((s*/sys/lib/python2.7/compiler/transformer.pyR�scCs:|dtjkrtd�nt||dd|d�S(Nismember must be a nameiR(i(R5RDR,Rp(RGRzRh((s*/sys/lib/python2.7/compiler/transformer.pyRy�scCs�|dtjkr,t|gdt|��Sg}d}d}}t|�}d}x@||kr�||}	|	dtjkr�|dk	r�td�n|j||d�}|d}qWnR|	dtj	kr|dk	r�d�n|j||d�}|d}qWn|j
|	||�\}}
|dkr|t|
t�r|t|	�dkr||	ddt
jkr|td�n|j|
�|d}qWWt||||dt|��S(	NiR(is$already have the varargs indentifieris#already have the kwargs indentifieris&generator expression needs parenthesis(R5R�tCallFuncR%RR*R�R,RmRtcom_argumentR$RsR0R�R(RGRzRhR,tkwt	star_nodet
dstar_nodetlen_nodelistRjR_R�((s*/sys/lib/python2.7/compiler/transformer.pyRu�s:



)
cCsDt|�dkrV|ddtjkrV|j|d�}d|j||d�fSt|�dkr�|rztd�n|r�td�nd|j|d�fS|j|d�}|d}x3t|�dkr�dtjkr�d}q�W|dtjkrtd|d�nt|d|d|d�}d|fS(	Niiiis!non-keyword arg after keyword args+only named arguments may follow *expressions#keyword can't be an expression (%s)R((	R*R0R�RmR�R,R5RDtKeyword(RGRhR}R~R�R�R`R_((s*/sys/lib/python2.7/compiler/transformer.pyR|s")
(cCs�t|�dkr�|d}|ddtjks\t|�dkr�|ddtjkr�|ddtjkr�|j|||�Sng}x:tdt|�d�D] }|j|j||��q�Wt	|||dt
|��S(Niiii�R((R*R5R�R0R�t	com_sliceR�Rt
com_subscriptRER%(RGRNRhRMtsubt
subscriptsRj((s*/sys/lib/python2.7/compiler/transformer.pyRV"s
)cCs||d}|d}|tjkrA|ddtjkrAt�S|tjksbt|�dkro|j|�S|j|�S(Niii(R5RotEllipsisR�R*tcom_sliceobjRm(RGR_ROR((s*/sys/lib/python2.7/compiler/transformer.pyR�6s

&!
cCs>g}|ddtjkr9|jtd��d}n |j|j|d��d}|t|�kr�||dtjkr�|j|j||��|d}n|jtd��xit	|t|��D]R}||}t|�dkr
|jtd��q�|j|j|d��q�Wt
|dt|��S(NiiiiR((R5R�RR�RRmR*R0R�R�tSliceobjR%(RGR_R2RjtjRO((s*/sys/lib/python2.7/compiler/transformer.pyR�@s 
	)

cCs�d}}t|�dkr_|ddtjkrI|j|d�}q�|j|d�}n;t|�dkr�|j|d�}|j|d�}nt||||dt|��S(NiiiiiR((RR*R5R�RmRDR%(RGRNR_RMtlowertupper((s*/sys/lib/python2.7/compiler/transformer.pyR�ds
cCs�|dkr#|d}|d}n|tjkr�t|�dkrU|j|d�Sx.|D]&}|dtjkr\|j|�Sq\WdS|tjkr�x.|D]&}|dtjkr�|j|�Sq�WdS|tjkr'|ddtj	kr#d}x"|D]}|t
|d�}qW|SdS|tjksT|tjksT|tjkre|j|d�S|t
kr�t|�dkr�|j|d�SdS(NiiRU(RR0RRR*RcR�RZRR5RBRR�t
small_stmtt
_doc_nodes(RGR_R`R�tsR((s*/sys/lib/python2.7/compiler/transformer.pyRcrs8




N(�RRt__doc__RJRQRRRWRORYRZR[RrRwRzR|R]R\told_lambdefR^R�R�t	flow_stmtt
compound_stmtR�R�R}R�R�RtR�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�RRR�RGt	testlist1RFR�R�R�told_testR�R�R�RTR�R�RR	RRRRR7R9R;R=R?R)RARCR�RmR4R~R+R-R�R1R�R4R�R�R�R�R=R�R�R�RHRKRLRJRUR�RaReR RZR\RaRbR�R#RRyRuR|RVR�R�R�RRc(((s*/sys/lib/python2.7/compiler/transformer.pyR^s�							
							!																																
												!				
			
	
													2					
		
			)						
	,		
		
					
		1			"				'			
	$	t<t>s==s<=s>=s!=R�R�cCsxg}xk|D]c}t|t�r>|jtj||��q
t|t�r]|j|�q
|jt|��q
W|S(N(R$tintRt_namestgetR+t
debug_tree(RPR"R((s*/sys/lib/python2.7/compiler/transformer.pyR��s
(SR�tcompiler.astRMR0R5t
StandardErrorRtcompiler.constsRRRRRRR
RR%R.RR�R�RGR�R�R�R�R�RTR�R�RR	RRRR�tLESStGREATERtEQEQUALR�t	LESSEQUALtGREATEREQUALtNOTEQUALR�R]R^R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�RRRFRt_legal_node_typesRRR�R�RIR�R1R2R%tvttok_nameR�(((s*/sys/lib/python2.7/compiler/transformer.pyt<module>	s�
	
			
	���








Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].