File "btm_utils.cpython-33.pyc"

Full Path: /home/attunedd/public_html/byp/izo/con7ext_sym404/rintoar.txt/opt/alt/python33/lib64/python3.3/lib2to3/__pycache__/btm_utils.cpython-33.pyc
File size: 8.58 KB
MIME-type: text/x-bytecode.python
Charset: 8 bit


f'c@sdZddlmZddlmZmZddlmZmZeZ	eZ
ejZeZ
dZdZdZGdddeZdd	d
ZddZd
dZdS(u0Utility functions used by the btm_matcher modulei(upytree(ugrammarutoken(upattern_symbolsupython_symbolsiicBs\|EeZdZdZddddZddZddZdd	Zd
dZ	dS(
uMinNodeuThis class serves as an intermediate representation of the
    pattern tree during the conversion to sets of leaf-to-root
    subpatternscCsC||_||_g|_d|_d|_g|_g|_dS(NF(	utypeunameuchildrenuFalseuleafuNoneuparentualternativesugroup(uselfutypeuname((u6/opt/alt/python33/lib64/python3.3/lib2to3/btm_utils.pyu__init__s						uMinNode.__init__cCst|jdt|jS(Nu (ustrutypeuname(uself((u6/opt/alt/python33/lib64/python3.3/lib2to3/btm_utils.pyu__repr__suMinNode.__repr__cCsU|}g}xB|rP|jtkr|jj|t|jt|jkr|t|jg}g|_|j}qq|j}d}Pn|jt	kr|j
j|t|j
t|jkrt|j
}g|_
|j}qq|j}d}Pn|jtj
kr4|jr4|j|jn|j|j|j}qW|S(uInternal method. Returns a characteristic path of the
        pattern tree. This method must be run for all leaves until the
        linear subpatterns are merged into a singleN(utypeuTYPE_ALTERNATIVESualternativesuappendulenuchildrenutupleuparentuNoneu
TYPE_GROUPugroupuget_characteristic_subpatternutoken_labelsuNAMEuname(uselfunodeusubp((u6/opt/alt/python33/lib64/python3.3/lib2to3/btm_utils.pyuleaf_to_root!s8							
uMinNode.leaf_to_rootcCs1x*|jD]}|j}|r
|Sq
WdS(uDrives the leaf_to_root method. The reason that
        leaf_to_root must be run multiple times is because we need to
        reject 'group' matches; for example the alternative form
        (a | b c) creates a group [b c] that needs to be matched. Since
        matching multiple linear patterns overcomes the automaton's
        capabilities, leaf_to_root merges each group into a single
        choice based on 'characteristic'ity,

        i.e. (a|b c) -> (a|b) if b more characteristic than c

        Returns: The most 'characteristic'(as defined by
          get_characteristic_subpattern) path for the compiled pattern
          tree.
        N(uleavesuleaf_to_root(uselfulusubp((u6/opt/alt/python33/lib64/python3.3/lib2to3/btm_utils.pyuget_linear_subpatternKsuMinNode.get_linear_subpatternccsEx-|jD]"}x|jD]}|VqWq
W|jsA|VndS(u-Generator that returns the leaves of the treeN(uchildrenuleaves(uselfuchildux((u6/opt/alt/python33/lib64/python3.3/lib2to3/btm_utils.pyuleaves`s

	uMinNode.leavesN(
u__name__u
__module__u__qualname__u__doc__uNoneu__init__u__repr__uleaf_to_rootuget_linear_subpatternuleaves(u
__locals__((u6/opt/alt/python33/lib64/python3.3/lib2to3/btm_utils.pyuMinNodes	*uMinNodec
Csd}|jtjkr(|jd}n|jtjkrt|jdkrht|jd|}qtdt	}x|jD]P}|jj
|drqnt||}|dk	r|jj|qqWn'|jtjkrxt|jdkr_tdt
}x9|jD].}t||}|r|jj|qqW|jsud}quqt|jd|}n|jtjkrt|jdtjr|jdjdkrt|jd|St|jdtjr|jdjdks=t|jdkrAt|jddrA|jdjdkrAdSd}d}d}d}d}	d}
x|jD]}|jtjkrd}|}n<|jtjkrd}|}	n|jtjkr|}nt|dro|jdkrod}
qoqoW|
rA|jd}t|drN|jdkrN|jd	}qNn
|jd}|jtjkr|jd
krtdt}qTtt|jrtdtt|j}qTtdtt|j}n|jtjkr0|jjd}|tkrtdt|}qTtdtjd|}n$|jtjkrTt||}n|r|	jdjd
kryd}q|	jdjdkrqt n|r|dk	rxL|jddD]4}t||}|dk	r|jj|qqWqn|r||_!n|S(u
    Internal function. Reduces a compiled pattern tree to an
    intermediate representation suitable for feeding the
    automaton. This also trims off any optional pattern elements(like
    [a], a*).
    iiutypeiu(u[uvalueu=iuanyu'unameu*u+NTFi("uNoneutypeusymsuMatcheruchildrenuAlternativesulenureduce_treeuMinNodeuTYPE_ALTERNATIVESuindexuappenduAlternativeu
TYPE_GROUPuUnitu
isinstanceupytreeuLeafuvalueuhasattruTrueuFalseuDetailsuRepeaterutoken_labelsuNAMEuTYPE_ANYugetattrupysymsuSTRINGustriputokensuNotImplementedErroruparent(
unodeuparentunew_nodeuchildureduceduleafudetails_nodeualternatives_nodeuhas_repeateru
repeater_nodeuhas_variable_nameu	name_leafuname((u6/opt/alt/python33/lib64/python3.3/lib2to3/btm_utils.pyureduce_treehs				


	ureduce_treecs5t|ts|St|dkr-|dSg}g}dddddgg}dx|D]}tt|d	d
ratt|fdd
r|j|qtt|fdd
r|j|q|j|qaqaW|r|}n|r|}n|r%|}nt|d
tS(uPicks the most characteristic from a list of linear patterns
    Current order used is:
    names > common_names > common_chars
    iiuinuforuifunotuNoneu[]().,:cSst|tkS(N(utypeustr(ux((u6/opt/alt/python33/lib64/python3.3/lib2to3/btm_utils.pyu<lambda>su/get_characteristic_subpattern.<locals>.<lambda>cst|to|kS(N(u
isinstanceustr(ux(ucommon_chars(u6/opt/alt/python33/lib64/python3.3/lib2to3/btm_utils.pyu<lambda>scst|to|kS(N(u
isinstanceustr(ux(ucommon_names(u6/opt/alt/python33/lib64/python3.3/lib2to3/btm_utils.pyu<lambda>sukey(u
isinstanceulistulenuanyurec_testuappendumax(usubpatternsusubpatterns_with_namesusubpatterns_with_common_namesusubpatterns_with_common_charsu
subpattern((ucommon_charsucommon_namesu6/opt/alt/python33/lib64/python3.3/lib2to3/btm_utils.pyuget_characteristic_subpatterns2
					uget_characteristic_subpatternccsWxP|D]H}t|ttfrDx*t||D]}|Vq2Wq||VqWdS(uPTests test_func on all items of sequence and items of included
    sub-iterablesN(u
isinstanceulistutupleurec_test(usequenceu	test_funcuxuy((u6/opt/alt/python33/lib64/python3.3/lib2to3/btm_utils.pyurec_tests

urec_testNiii(u__doc__uupytreeupgen2ugrammarutokenupygramupattern_symbolsupython_symbolsusymsupysymsuopmaputokensutoken_labelsuTYPE_ANYuTYPE_ALTERNATIVESu
TYPE_GROUPuobjectuMinNodeuNoneureduce_treeuget_characteristic_subpatternurec_test(((u6/opt/alt/python33/lib64/python3.3/lib2to3/btm_utils.pyu<module>s	X%