/opt/alt/python311/lib64/python3.11/lib2to3/__pycache__
Edit: /opt/alt/python311/lib64/python3.11/lib2to3/__pycache__/btm_utils.cpython-311.opt-1.pyc (11530B)
p@s d Z ddlmZ ddlmZmZ ddlmZmZ eZ eZ
ej ZeZ
dZdZdZ G d d e ZddZd Zd
Zd
S )z0Utility functions used by the btm_matcher module )pytree)grammartoken)pattern_symbolspython_symbolsc 2 e Zd ZdZddZd Zd Zd Zd ZdS ) MinNodezThis class serves as an intermediate representation of the
pattern tree during the conversion to sets of leaf-to-root
subpatternsNc h || _ || _ g | _ d| _ d | _ g | _ g | _ d S )NF)typenamechildrenleafparentalternativesgroup)selfr r s 8/opt/alt/python311/lib64/python3.11/lib2to3/btm_utils.py__init__zMinNode.__init__ s8
c Z t | j dz t | j z S )N )strr r )r s r __repr__zMinNode.__repr__ s" 49~~#c$)nn44r c | }g }|r^|j t k rr|j | t |j t |j k r$t
|j g}g |_ |j }{|j }d}n|j t k rq|j | t |j t |j k r#t |j }g |_ |j }|j }d}n[|j t j k r"|j
r| |j
n| |j |j }|^|S )zInternal 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)r TYPE_ALTERNATIVESr appendlenr tupler
TYPE_GROUPr get_characteristic_subpatterntoken_labelsNAMEr )r nodesubps r leaf_to_rootzMinNode.leaf_to_root! sZ ! y---!((...t())S-?-???!$"3445D(*D%;D;DDyJ&&
!!$'''tz??c$-&8&8888DDD!#DJ;D;DDyL---$)-DI&&&&DI&&&;DC ! D r c h | D ]}| }|r|c S dS )a Drives 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)leavesr( )r lr' s r get_linear_subpatternzMinNode.get_linear_subpatternK sJ A>>##D
r c # l K | j D ]}| E d{V | j s| V dS dS )z-Generator that returns the leaves of the treeN)r r* )r childs r r* zMinNode.leaves` s[ ] &