Viewing File: /opt/alt/python35/lib64/python3.5/lib2to3/__pycache__/btm_matcher.cpython-35.opt-2.pyc



]@sdZddlZddlZddlmZddlmZddlmZGddde	Z
Gd	d
d
e	ZiaddZ
dS)
z+George Boutsioukis <gboutsioukis@gmail.com>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__	itertoolsrrrrrrrsrc@sLeZdZddZddZddZddZd	d
ZdS)
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)rfixerZtreeZlinearmatch_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<n|j|d}|ddr|j|ddd|}n	|g}|SdS)Nrrr)
isinstancetuplerextendrr)rpatternrr!ZalternativeZ	end_nodesendZ	next_noderrrr1s"
+	"	zBottomMatcher.addc	Cs|j}tt}xr|D]j}|}x[|rd|_x<|jD]1}t|tjrD|jdkrDd|_PqDW|j	dkr|j}n	|j	}||j
kr|j
|}x|jD]-}||krg||<||j|qWn|j}|j
dk	r|j
jrP||j
kry|j
|}x>|jD]3}||jkrdg||<||j|qBW|j
}q+WqW|S)NT;Fr)rrlistZwas_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
)ZnodeZsubnode_keyZsubnode)
print_noderrr3s
)
z*BottomMatcher.print_ac.<locals>.print_node})r0r)rr)r3rprint_acs

zBottomMatcher.print_acN)rrrrr"rr/r5rrrrrs
"=rcCsbtsRddlm}x9|jjD](\}}t|tkr&|t|<q&Wtj||S)Nr)python_symbols)_type_reprsZpygramr6__dict__itemsr+int
setdefault)Ztype_numr6namevalrrrr1sr1)
__author__rrcollectionsrrrZ	btm_utilsrobjectrrr7r1rrrr<module>s	
Back to Directory File Manager