��Qc)@sfdZddlTddlZddlZddlZdefd��YZddlmZm Z ddlm
Z
mZmZd�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!gZKiZLx'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%HscGst|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
�Zd�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|jtj6|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 tlisttparsertst2tupletcompile_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_declRFtsingle_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|�}|j|�}d}x5||krXt|||dd�}|d7}q$W|S(Nii(R*RCtGetattr(RGRhtlistlenR#Rj((s*/sys/lib/python2.7/compiler/transformer.pytdecorator_name�scCsL|j|dd�}t|�dkrB|j||d�}n|}|S(Nii(RpR*tcom_call_function(RGRhtfuncnameRT((s*/sys/lib/python2.7/compiler/transformer.pyt decorator�s
cCs;g}x(|D] }|j|j|d��q
Wt|�S(Ni(RRst
Decorators(RGRhR2tdec_nodelist((s*/sys/lib/python2.7/compiler/transformer.pyt
decorators�s
cCs�|ddtjkrC|dgt|dd�}|j|�S|ddtjkr�|j|dd�}|j|dd�}||_|St��dS(Nii(R0R]RLR^RvR(RGRhR`Rvtcls((s*/sys/lib/python2.7/compiler/transformer.pyt decorated�s
c
Cs�t|�dkr,|j|dd�}nd}|dd}|dd}|dd}|dtjkr�|j|d�\}}}nd }}d}|j|d�} |j|d�}
| dk r�|
jd=nt |||||| |
d|�S(
Niiii�ii�i�R(((
R*RvRR0tvarargslisttcom_arglistRcRmR!tFunction(RGRhRvR(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(((R0RyRzRmtLambda(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�|jd=nt||||d|dd�S(Nii�iiiR(( RcR5tCOLONtRPARt com_basesRmRR!tClass(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.pyRyMscCs
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.pytdotted_nameVscCs
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*tDiscardR(R5tEQUALR�Rt
com_assignRtAssignt
com_augassigntcom_augassign_opt AugAssignR(RGRhtentexprNodetnodeslRjtlvaltop((s*/sys/lib/python2.7/compiler/transformer.pyt expr_stmtjs
#!cCs�g}t|�dkr'd}d}n?|ddtjkrZ|j|d�}d}nd}d}x:t|t|�d�D] }|j|j||��qW|ddtjkr�t||d|dd�St ||d|dd�S(Niiiii�R((
R*RR5t
RIGHTSHIFTRmR�RtCOMMAtPrinttPrintnl(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((RmR�R((RGRhRT((s*/sys/lib/python2.7/compiler/transformer.pyt
yield_stmt�scCsLt|�dkr(|j|d�}ntd�}t|d|dd�S(NiR(ii(R*RmR�RtYield(RGRhRH((s*/sys/lib/python2.7/compiler/transformer.pyt
yield_expr�scCs�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|j|d�S(Ni(Rm(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�scCsd}x"||ddkr*|d7}q W|d}||dtjkrl|j||�}|d7}nd}||ddtjkr�t|dg|d|dd�S||d||ddtjk}t||j|�|d|dd�SdS( Nit.iRURR(i(RN( R0R�tcom_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 scCs�|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(tcom_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>scCs]t|�dkrP|ddtjkrP|j|d�}|j||d�S|j|�S(Niii(R*R0tcomp_forRmtcom_generator_expressionR�(RGRhttest((s*/sys/lib/python2.7/compiler/transformer.pyt
testlist_compHs)cCs�t|�dkr:|ddtjkr:|j|d�S|j|d�}t|�dkr�|j|d�}|j|d�}t|||d|dd�S|S(NiiiiR((R*R0R\RmtIfExp(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
td|�|dd|_
q,W|S(Niiisunexpected token: %s(RmR�R*R5R�tMultSLASHtDivtPERCENTtModtDOUBLESLASHtFloorDivRR((RGRhR_RjR�tt((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�R5R�tUnaryAddRtUnarySubtTILDEtInvert(RGRhteltR
R_((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�(RGRhRR_((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(R�R�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�td�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.pyRz-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&escCs\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
(cCsO|d}|j|dd�}t|�dkr=|dfS||ddfS(Niii(R�R*R(RGR_tdot((s*/sys/lib/python2.7/compiler/transformer.pytcom_dotted_as_namevs
cCsa|d}|j|d�g}x:tdt|�d�D] }|j|j||��q9W|S(Niii(R(R�R*R(RGR_R|Rj((s*/sys/lib/python2.7/compiler/transformer.pyR��s
cCsH|d}t|�dkr.|dddfS|dd|ddfS(Niii(R*R(RGR_((s*/sys/lib/python2.7/compiler/transformer.pytcom_import_as_name�s
cCsa|d}|j|d�g}x:tdt|�d�D] }|j|j||��q9W|S(Niii(R)R�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(iitelsetfinally(
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(RGRhR3R(tvarRT((s*/sys/lib/python2.7/compiler/transformer.pyR2�s
cCs|dS(Ni((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 SubscriptRnR%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\tdt|�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 assigningR
tprimaryRjtch((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_RAtassignsRj((s*/sys/lib/python2.7/compiler/transformer.pyR<s!cCs�g}x}tdt|�d�D]c}|dt|�kre||ddtjkretd�qen|j|j|||��qWt|dt|��S(Niiis"can't assign to list comprehensionR(( R�R*R0tlist_forR%RR�tAssListR%(RGR_RARERj((s*/sys/lib/python2.7/compiler/transformer.pyR?s!cCst|d|d|d�S(NiR(i(tAssName(RGR_RA((s*/sys/lib/python2.7/compiler/transformer.pyR@%scCs�|dd}|tjkr4|j||d|�S|tjkrZ|j||d|�S|tjkrutd�ntd|�dS(Niiiscan't assign to function callsunknown trailer type: %s(R5tDOTtcom_assign_attrR:tcom_subscriptlistR8R%(RGRBR_RAR
((s*/sys/lib/python2.7/compiler/transformer.pyR>(scCst||d|d|d�S(NiR(i�(tAssAttr(RGRBR_RA((s*/sys/lib/python2.7/compiler/transformer.pyRJ2scCs�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
$cCs9|j|�|d�}t|t�r,|St|g�S(Ni(R�R$Rg(RGR_R�((s*/sys/lib/python2.7/compiler/transformer.pyRaAscCsL|j|�|d�}t|t�r;|j|j�n
|j|�dS(Ni(R�R$RgtextendR!R(RGRkR_R�((s*/sys/lib/python2.7/compiler/transformer.pyReHscCs�g}x�tdt|��D]l}||dtjkrQ|j|d||�S||dtjkrnqn|j|j||��qWt |d|dj
�S(NiiR((R�R*R0RFtcom_list_comprehensionR5R�RRmRR((RGRhtvaluesRj((s*/sys/lib/python2.7/compiler/transformer.pyRPs
cCs|j|d|d�S(NRL(tcom_comprehensionR(RGRTR_((s*/sys/lib/python2.7/compiler/transformer.pyRO]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 �}qtd
||f�qW|dkr�t
||d|�S|dkr�t||d|�S|dkr�|||d|�Std
t|���dS(NiitforiiRLtifR(is'unexpected comprehension element: %s %dtsettdictsunexpected comprehension type: (R�RRmtListCompForR(RR*Rt
com_list_itert
com_comp_itert
ListCompIftifsR%tListComptSetComptDictCompRtrepr(
RGR�R�R_RR(tforsR
R�tcompNodetnewforR�tnewif((s*/sys/lib/python2.7/compiler/transformer.pyRQ`sD
cCs|dS(Ni((RGR_((s*/sys/lib/python2.7/compiler/transformer.pyRW�scCs|dS(Ni((RGR_((s*/sys/lib/python2.7/compiler/transformer.pyRX�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(NiiRRiR(iRSis.unexpected generator expression element: %s %di(R�RRmt
GenExprForRR*RRXt GenExprIfRZR%tTruet
is_outmosttGenExprtGenExprInner(RGRTR_R(R_R
R�tgenNodeRaR�Rb((s*/sys/lib/python2.7/compiler/transformer.pyR��s2
c Cs�|d}t|�dks3|ddtjkr�g}x:tdt|�d�D] }|j|j||��qRWt|d|dj�S|ddtj kr�|j|d�}|j
|d|dd�St|�dkr:|ddtj kr:|j|d�}|j|d�}|j
|||dd�Sg}xQtdt|�d�D]7}|j|j||�|j||d�f�qYWt|d|ddj�SdS( NiiiR(RTiRUi(
R*R5R�R�RRmtSetR(R0R�RQRR(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( R5R8RqRItcom_select_memberR:RKRR%(RGtprimaryNodeRhR
((s*/sys/lib/python2.7/compiler/transformer.pyR�scCs:|dtjkrtd�nt||dd|d�S(Nismember must be a nameiR(i(R5RDR%Rn(RGRmRh((s*/sys/lib/python2.7/compiler/transformer.pyRl�scCs�|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%RmRtcom_argumentR$RgR0R�R(RGRmRhR,tkwt star_nodet
dstar_nodetlen_nodelistRjR_R�((s*/sys/lib/python2.7/compiler/transformer.pyRq�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(RGRhRpRqR�R�R`R_((s*/sys/lib/python2.7/compiler/transformer.pyRos")
(c
Cs�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_subscriptR9R%(RGRBRhRAtsubt
subscriptsRj((s*/sys/lib/python2.7/compiler/transformer.pyRK"s
)cCs||d}|d}|tjkrA|ddtjkrAt�S|tjksbt|�dkro|j|�S|j|�S(Niii(R5RItEllipsisR�R*tcom_sliceobjRm(RGR_RCR
((s*/sys/lib/python2.7/compiler/transformer.pyRv6s
&!
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_R2RjtjRC((s*/sys/lib/python2.7/compiler/transformer.pyRz@s
)
cCs�d}}t|�dkr_|ddtjkrI|j|d�}q�|j|d�}n;t|�dkr�|j|d�}|j|d�}nt||||dt|��S(NiiiiiR((RR*R5R�RmR8R%(RGRBR_RAtlowertupper((s*/sys/lib/python2.7/compiler/transformer.pyRuds
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|tjkre|j|d�S|t
kr�t|�dkr�|j|d�SdS(NiiRU(RR0RRR*RcR�RZRR5RBRR�t
small_stmtt
_doc_nodes(RGR_R`RwtsR
((s*/sys/lib/python2.7/compiler/transformer.pyRcrs8
N(�RRt__doc__RJRQRRRWRORYRZR[RpRsRvRxR]R\told_lambdefR^R�Rt flow_stmtt
compound_stmtR�R�RyR�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�R�R�R�RRR�R;t testlist1R:R�R�R�told_testR�R�R�RTR�R�R�RRRRRR7R9R;R=R?R"RARCR�RmR4RzR$R&R�R(R�R)R�R�R�R�R2R�R�R�R<R?R@R>RJR�RaReRRORQRWRXR�RRRlRqRoRKRvRzRuRRc(((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�tcompiler.astRMR0R5t
StandardErrorRtcompiler.constsRRRRRRR
RR%R.RR�R�R;R�R�R�R�R�RTR�R�R�RRRRR�tLESStGREATERtEQEQUALR�t LESSEQUALtGREATEREQUALtNOTEQUALR�R]R^R�RR�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�RRR:Rt_legal_node_typesRRR�R�R=R�R1R2Rtvttok_nameR�(((s*/sys/lib/python2.7/compiler/transformer.pyt<module> s�
���
|