Your IP : 3.144.116.34
��Yf� � @ 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 d e j d e j d e j d d i Z d d � Z d d � Z d d � Z d S)z�Pattern compiler.
The grammar 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/python35/lib64/python3.5/lib2to3/patcomp.pyr s r c c sn t j t j t j h } t j t j | � j � } x4 | D], } | \ } } } } } | | k r: | Vq: 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.
ZconvertN)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&