]@sdZddlZddlZddlmZddlmZddlmZGddde Z Gd d d e Z ia d d Z dS) z+George Boutsioukis N) defaultdict)pytree) reduce_treec@s(eZdZejZddZdS)BMNodecCs1i|_g|_ttj|_d|_dS)N)transition_tablefixersnextrcountidcontent)selfr0/opt/alt/python35/lib64/python3.5/btm_matcher.py__init__s  zBMNode.__init__N)__name__ __module__ __qualname__ itertoolsr rrrrrrs  rc@sLeZdZddZddZddZddZd d Zd S) BottomMatchercCsFt|_t|_|jg|_g|_tjd|_dS)NZRefactoringTool) setmatchrrootZnodesr logging getLoggerlogger)rrrrrs    zBottomMatcher.__init__cCsh|jj|t|j}|j}|j|d|j}x|D]}|jj|qJWdS)Nstart)r appendrZ pattern_treeZget_linear_subpatternaddr)rfixerZtreeZlinear match_nodesZ match_noderrr add_fixer%s   zBottomMatcher.add_fixercCs |s |gSt|dtrg}x[|dD]O}|j|d|}x1|D])}|j|j|dd|qSWq1W|S|d|jkrt}||j|d|j D]3}||jkrdg||<||j |qBW|j }q+WqW|S)NT;Fr)rrlistZ was_checkedZchildrenr#rZLeafvaluetyperr rparentkeys) rZleavesZcurrent_ac_noderesultsZleafZcurrent_ast_nodeZchildZ node_tokenr rrrrunSs>     !          zBottomMatcher.runcs7tdfdd|jtddS)Nz digraph g{cs}xv|jjD]e}|j|}td|j|jt|t|jf|dkrkt|j|qWdS)Nz%d -> %d [label=%s] //%sr)rr-printr type_reprstrr r )ZnodeZ subnode_keyZsubnode) print_noderrr3s )  z*BottomMatcher.print_ac..print_node})r0r)rr)r3rprint_acs  zBottomMatcher.print_acN)rrrrr"rr/r5rrrrrs   " =rcCsbtsRddlm}x9|jjD](\}}t|tkr&|t|s