tzh
2024-08-22 c7d0944258c7d0943aa7b2211498fd612971ce27
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
X\¬Qc@sdZdZddlZddlZddlmZmZmZmZm    Z    m
Z
ddl m Z ddl m Z ejjejjeƒdƒZd    efd
„ƒYZd „Zd efd „ƒYZiejd6ejd6ejd6dd6Zd„Zd„Zd„ZdS(sPattern compiler.
 
The grammer is taken from PatternGrammar.txt.
 
The compiler compiles a pattern to a pytree.*Pattern instance.
s#Guido van Rossum <guido@python.org>iÿÿÿÿNi(tdrivertliteralsttokenttokenizetparsetgrammar(tpytree(tpygramsPatternGrammar.txttPatternSyntaxErrorcBseZRS((t__name__t
__module__(((sW/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/lib2to3/patcomp.pyRsc    cswttjtjtjfƒ}tjtj|ƒjƒ}x7|D]/}|\}}}}}||kr@|Vq@q@WdS(s6Tokenizes a string suppressing significant whitespace.N(    tsetRtNEWLINEtINDENTtDEDENTRtgenerate_tokenstStringIOtreadline(    tinputtskipttokenst    quintuplettypetvaluetstarttendt    line_text((sW/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/lib2to3/patcomp.pyttokenize_wrapper!s   tPatternCompilercBsAeZed„Zeed„Zd„Zdd„Zd„Z    RS(cCs^tj|ƒ|_tj|jƒ|_tj|_tj|_    tj
|jdt ƒ|_dS(s^Initializer.
 
        Takes an optional alternative filename for the pattern grammar.
        tconvertN( Rt load_grammarRRtSymbolstsymstpython_grammart    pygrammartpython_symbolstpysymstDrivertpattern_convert(tselft grammar_file((sW/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/lib2to3/patcomp.pyt__init__-s
  cCs}t|ƒ}y|jj|d|ƒ}Wn(tjk
rR}tt|ƒƒ‚nX|rl|j|ƒ|fS|j|ƒSdS(s=Compiles a pattern string to a nested pytree.*Pattern object.tdebugN(RRt parse_tokensRt
ParseErrorRtstrt compile_node(R'RR*t    with_treeRtrootte((sW/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/lib2to3/patcomp.pytcompile_pattern8s c    CsT|j|jjkr%|jd}n|j|jjkrÁg|jddd…D]}|j|ƒ^qQ}t|ƒdkr†|dStjg|D]}|g^q“ddddƒ}|j    ƒS|j|jj
kr=g|jD]}|j|ƒ^qà}t|ƒdkr|dStj|gddddƒ}|j    ƒS|j|jj kr|j |jdƒ}tj |ƒ}|j    ƒSd}|j}    t|    ƒdkrÒ|    djtjkrÒ|    dj}|    d}    nd}
t|    ƒdkr|    dj|jjkr|    d}
|    d }    n|j |    |
ƒ}|
dk    r2|
j} | d} | jtjkrod} tj}nx| jtjkr“d} tj}nT| jtjkrç|j| dƒ} }t| ƒd    krç|j| dƒ}qçn| dksÿ|dkr2|j    ƒ}tj|ggd| d|ƒ}q2n|dk    rJ||_n|j    ƒS(
sXCompiles a node, recursively.
 
        This is one big switch on the node type.
        iNiitmintmaxiiÿÿÿÿi(RR tMatchertchildrent AlternativesR.tlenRtWildcardPatterntoptimizet Alternativet NegatedUnitt compile_basictNegatedPatterntNoneRtEQUALRtRepeatertSTARtHUGEtPLUStLBRACEtget_inttname(R'tnodetchtaltstatptunitstpatternRGtnodestrepeatR6tchildR3R4((sW/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/lib2to3/patcomp.pyR.Ds^21
%
 
    (  +
      
   '  cCs½|d}|jtjkrJttj|jƒƒ}tjt    |ƒ|ƒS|jtj
krX|j}|j ƒrº|t krt d|ƒ‚n|dr©t dƒ‚ntjt |ƒS|dkrÏd}nF|jdƒst|j|dƒ}|dkrt d|ƒ‚qn|dr?|j|djdƒg}nd}tj||ƒSna|jdkrx|j|dƒS|jd    kr¹|j|dƒ}tj|ggd
dd dƒSdS( NisInvalid token: %risCan't have details for tokentanyt_sInvalid symbol: %rt(t[R3R4(RRtSTRINGtunicodeRt
evalStringRRt LeafPatternt_type_of_literaltNAMEtisuppert    TOKEN_MAPRR?t
startswithtgetattrR$R.R6t NodePatternR9(R'RORPRHRRtcontentt
subpattern((sW/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/lib2to3/patcomp.pyR=‹s8
      
      
 cCs t|jƒS(N(tintR(R'RH((sW/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/lib2to3/patcomp.pyRF®sN(
R    R
t_PATTERN_GRAMMAR_FILER)tFalseR2R.R?R=RF(((sW/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/lib2to3/patcomp.pyR+s
     G #R[RVtNUMBERtTOKENcCs9|djƒrtjS|tjkr1tj|SdSdS(Ni(tisalphaRR[RtopmapR?(R((sW/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/lib2to3/patcomp.pyRZºs
 cCsW|\}}}}|s'||jkr=tj||d|ƒStj||d|ƒSdS(s9Converts raw node information to a Node or Leaf instance.tcontextN(t number2symbolRtNodetLeaf(Rt raw_node_infoRRRjR6((sW/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/lib2to3/patcomp.pyR&ÃscCstƒj|ƒS(N(RR2(RN((sW/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/lib2to3/patcomp.pyR2Ìs( t__doc__t
__author__tosRtpgen2RRRRRRtRRtpathtjointdirnamet__file__Rdt    ExceptionRRtobjectRR[RVRfR?R]RZR&R2(((sW/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/lib2to3/patcomp.pyt<module>    s$  .        
‰