%PDF- %PDF-
Direktori : /usr/local/lib/python2.7/lib2to3/ |
Current File : //usr/local/lib/python2.7/lib2to3/patcomp.pyo |
ó Pêáac @ så d Z d Z d d l Z d d l m Z m Z m Z m Z m Z m Z d d l m Z d d l m Z d e f d „ ƒ YZ d „ Z d e f d „ ƒ YZ i e j d 6e j d 6e j d 6d d 6Z d „ Z d „ Z d „ Z d S( s Pattern compiler. The grammar is taken from PatternGrammar.txt. The compiler compiles a pattern to a pytree.*Pattern instance. s# Guido van Rossum <guido@python.org>iÿÿÿÿNi ( t drivert literalst tokent tokenizet parset grammar( t pytree( t pygramt PatternSyntaxErrorc B s e Z RS( ( t __name__t __module__( ( ( s+ /usr/local/lib/python2.7/lib2to3/patcomp.pyR s c c sw t t j t j t j f ƒ } t j t j | ƒ j ƒ } x7 | D]/ } | \ } } } } } | | k r@ | Vq@ q@ Wd S( s6 Tokenizes a string suppressing significant whitespace.N( t setR t NEWLINEt INDENTt DEDENTR t generate_tokenst StringIOt readline( t inputt skipt tokenst quintuplet typet valuet startt endt line_text( ( s+ /usr/local/lib/python2.7/lib2to3/patcomp.pyt tokenize_wrapper s t PatternCompilerc B sA e Z d d „ Z e e d „ Z d „ Z d d „ Z d „ Z RS( c C s… | d k r' t j | _ t j | _ n' t j | ƒ | _ t j | j ƒ | _ t j | _ t j | _ t j | j d t ƒ| _ d S( s^ Initializer. Takes an optional alternative filename for the pattern grammar. t convertN( t NoneR t pattern_grammarR t pattern_symbolst symsR t load_grammart Symbolst python_grammart pygrammart python_symbolst pysymst Drivert pattern_convert( t selft grammar_file( ( s+ /usr/local/lib/python2.7/lib2to3/patcomp.pyt __init__( s c C s} t | ƒ } y | j j | d | ƒ} Wn( t j k rR } t t | ƒ ƒ ‚ n X| rl | j | ƒ | f S| j | ƒ Sd S( s= Compiles a pattern string to a nested pytree.*Pattern object.t debugN( R R t parse_tokensR t ParseErrorR t strt compile_node( R* R R- t with_treeR t roott e( ( s+ /usr/local/lib/python2.7/lib2to3/patcomp.pyt compile_pattern7 s c C sT | j | j j k r% | j d } n | j | j j k rÁ g | j d d d … D] } | j | ƒ ^ qQ } t | ƒ d k r† | d St j g | D] } | g ^ q“ d d d d ƒ} | j ƒ S| j | j j k r=g | j D] } | j | ƒ ^ qà } t | ƒ d k r| d St j | g d d d d ƒ} | j ƒ S| j | j j k r| j | j d ƒ } t j | ƒ } | j ƒ Sd } | j } t | ƒ d k rÒ| d j t j k rÒ| d j } | d } n d } t | ƒ d k r| d j | j j k r| d } | d } n | j | | ƒ } | d k r2| j } | d } | j t j k rod } t j } nx | j t j k r“d } t j } nT | j t j k rç| j | d ƒ } } t | ƒ d k rç| j | d ƒ } qçn | d k sÿ| d k r2| j ƒ } t j | g g d | d | ƒ} q2n | d k rJ| | _ n | j ƒ S( sX Compiles a node, recursively. This is one big switch on the node type. i Ni i t mint maxi iÿÿÿÿi ( R R! t Matchert childrent AlternativesR1 t lenR t WildcardPatternt optimizet Alternativet NegatedUnitt compile_basict NegatedPatternR R t EQUALR t Repeatert STARt HUGEt PLUSt LBRACEt get_intt name( R* t nodet cht altst at pt unitst patternRI t nodest repeatR9 t childR6 R7 ( ( s+ /usr/local/lib/python2.7/lib2to3/patcomp.pyR1 C s^ 21 % ( + 'c C s½ | d } | j t j k rJ t t j | j ƒ ƒ } t j t | ƒ | ƒ S| j t j k rX| j } | j ƒ rº | t k r t d | ƒ ‚ n | d r© t d ƒ ‚ n t j t | ƒ S| d k rÏ d } nF | j d ƒ st | j | d ƒ } | d k rt d | ƒ ‚ qn | d r?| j | d j d ƒ g } n d } t j | | ƒ Sna | j d k rx| j | d ƒ S| j d k r¹| j | d ƒ } t j | g g d d d d ƒSd S( Ni s Invalid token: %ri s Can't have details for tokent anyt _s Invalid symbol: %rt (t [R6 R7 ( R R t STRINGt unicodeR t evalStringR R t LeafPatternt _type_of_literalt NAMEt isuppert TOKEN_MAPR R t startswitht getattrR' R1 R9 t NodePatternR<