Your IP : 3.145.166.223
�
i f� � @ s d Z d Z d d l 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
e j j e j j e � d � Z Gd d
� d
e � Z d d � Z Gd
d � d e � Z i e j d 6e j d 6e j d 6d d 6Z d d � Z d d � Z d d � Z d S)z�Pattern compiler.
The grammer is taken from PatternGrammar.txt.
The compiler compiles a pattern to a pytree.*Pattern instance.
z#Guido van Rossum <guido@python.org>� N� )�driver�literals�token�tokenize�parse�grammar)�pytree)�pygramzPatternGrammar.txtc @ s e Z d Z d S)�PatternSyntaxErrorN)�__name__�
__module__�__qualname__� r r �4/opt/alt/python34/lib64/python3.4/lib2to3/patcomp.pyr s r c c sq t j t j t j h } t j t j | � j � } x7 | D]/ } | \ } } } } } | | k r: | Vq: q: Wd S)z6Tokenizes a string suppressing significant whitespace.N) r �NEWLINE�INDENT�DEDENTr �generate_tokens�io�StringIO�readline) �input�skip�tokensZ quintuple�type�value�start�endZ line_textr r r �tokenize_wrapper! s
r c @ sX e Z d Z e d d � Z d d d d � Z d d � Z d d d
� Z d d � Z d S)
�PatternCompilerc C s^ t j | � | _ t j | j � | _ t j | _ t j | _ t j
| j d t �| _ d S)z^Initializer.
Takes an optional alternative filename for the pattern grammar.
�convertN)r Zload_grammarr r
ZSymbols�symsZpython_grammarZ pygrammarZpython_symbols�pysymsZDriver�pattern_convert)�selfZgrammar_filer r r �__init__- s
zPatternCompiler.__init__Fc C s� t | � } y | j j | d | �} Wn: t j k
rd } z t t | � � � WYd d } ~ Xn X| r~ | j | � | f S| j | � Sd S)z=Compiles a pattern string to a nested pytree.*Pattern object.�debugN)r r Zparse_tokensr Z
ParseErrorr �str�compile_node)r% r r'