| Server IP : 52.25.153.185 / Your IP : 216.73.217.131 Web Server : Apache System : Linux ip-172-26-6-158 5.10.0-35-cloud-amd64 #1 SMP Debian 5.10.237-1 (2025-05-19) x86_64 User : daemon ( 1) PHP Version : 8.1.10 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /lib/python3.9/lib2to3/__pycache__/ |
Upload File : |
a
�0`� � @ s� d Z dZddlZddlmZmZmZmZmZm Z ddl
mZ ddl
mZ G dd � d e
�Zd
d� ZG dd
� d
e�Zejejejdd�Zdd� Zdd� Zdd� ZdS )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)�pygramc @ s e Zd ZdS )�PatternSyntaxErrorN)�__name__�
__module__�__qualname__� r r �%/usr/lib/python3.9/lib2to3/patcomp.pyr s r c c sL t jt jt jh}t�t�| �j�}|D ] }|\}}}}}||vr&|V q&dS )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 @ s: e Zd Zd
dd�Zddd�Zdd� Zdd d
�Zdd� ZdS )�PatternCompilerNc C sZ |du rt j| _t j| _nt�|�| _t �| j�| _t j| _ t j
| _tj| jt
d�| _dS )z^Initializer.
Takes an optional alternative filename for the pattern grammar.
N)Zconvert)r
Zpattern_grammarr Zpattern_symbols�symsr Zload_grammarZSymbolsZpython_grammarZ pygrammarZpython_symbols�pysymsZDriver�pattern_convert)�selfZgrammar_filer r r �__init__( s
zPatternCompiler.__init__Fc
C sr t |�}z| jj||d�}W n4 tjyP } ztt|��d�W Y d}~n
d}~0 0 |rd| �|�|fS | �|�S dS )z=Compiles a pattern string to a nested pytree.*Pattern object.)�debugN)r r Zparse_tokensr Z
ParseErrorr �str�compile_node)r$ r r&