grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026a ´ißã@shdZddlZddlZddlmZddlmZddlmZGdd„de ƒZ Gd d „d e ƒZ ia d d „Z dS) z+George Boutsioukis éN)Ú defaultdicté)Úpytree)Ú reduce_treec@seZdZe ¡Zdd„ZdS)ÚBMNodecCs"i|_g|_ttjƒ|_d|_dS)NÚ)Útransition_tableÚfixersÚnextrÚcountÚidÚcontent©Úself©rú+/usr/lib64/python3.9/lib2to3/btm_matcher.pyÚ__init__s zBMNode.__init__N)Ú__name__Ú __module__Ú __qualname__Ú itertoolsr rrrrrrsrc@s4eZdZdd„Zdd„Zdd„Zdd„Zd d „Zd S) Ú BottomMatchercCs0tƒ|_tƒ|_|jg|_g|_t d¡|_dS)NZRefactoringTool) ÚsetÚmatchrÚrootZnodesr ÚloggingÚ getLoggerÚloggerrrrrrs  zBottomMatcher.__init__cCsH|j |¡t|jƒ}| ¡}|j||jd�}|D]}|j |¡q2dS)N©Ústart)r ÚappendrZ pattern_treeZget_linear_subpatternÚaddr)rÚfixerZtreeZlinearÚ match_nodesZ match_noderrrÚ add_fixer%s   zBottomMatcher.add_fixerc CsÄ|s |gSt|dtƒr`g}|dD]6}|j||d�}|D]}| | |dd…|¡¡q:q$|S|d|jvr„tƒ}||j|d<n|j|d}|dd…r¶|j|dd…|d�}n|g}|SdS)Nrrr)Ú isinstanceÚtupler!Úextendrr)rÚpatternrr#Ú alternativeZ end_nodesÚendZ next_noderrrr!1s"  zBottomMatcher.addc Csî|j}ttƒ}|D]Ö}|}|rd|_|jD]$}t|tjƒr*|jdkr*d|_qPq*|j dkrb|j}n|j }||j vr˜|j |}|j D]}||  |¡q‚nH|j}|j dur²|j jr²q||j vrà|j |}|j D]}||  |¡qÌ|j }qq|S)NTú;Fr)rrÚlistZ was_checkedZchildrenr%rZLeafÚvalueÚtyperr r Úparent) rZleavesZcurrent_ac_nodeÚresultsZleafZcurrent_ast_nodeÚchildZ node_tokenr"rrrÚrunSs8      ÿ    zBottomMatcher.runcs*tdƒ‡fdd„‰ˆ|jƒtdƒdS)Nz digraph g{csZ|j ¡D]J}|j|}td|j|jt|ƒt|jƒfƒ|dkrLt|jƒˆ|ƒq dS)Nz%d -> %d [label=%s] //%sr)rÚkeysÚprintr Ú type_reprÚstrr r )ZnodeZ subnode_keyZsubnode©Ú print_noderrr8Žs ÿ z*BottomMatcher.print_ac..print_nodeú})r4rrrr7rÚprint_ac‹s  zBottomMatcher.print_acN)rrrrr$r!r2r:rrrrrs  "8rcCsDts8ddlm}|j ¡D]\}}t|ƒtkr|t|<qt ||¡S)Nr)Úpython_symbols)Ú _type_reprsZpygramr;Ú__dict__Úitemsr.ÚintÚ setdefault)Ztype_numr;ÚnameÚvalrrrr5›s  r5)Ú __author__rrÚ collectionsrrrZ btm_utilsrÚobjectrrr<r5rrrrÚs