Your IP : 216.73.216.213


Current Path : /opt/alt/python35/lib64/python3.5/site-packages/Cython/Plex/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/site-packages/Cython/Plex/__pycache__/Traditional.cpython-35.pyc



Z��Z�@s�ddlmZddlmZmZmZmZmZmZm	Z	m
Z
mZmZddl
mZGdd�de�Zdd�ZGd	d
�d
e�ZdS)�)�absolute_import�)
�Alt�Seq�Rep�Rep1�Opt�Any�AnyBut�Bol�Eol�Char)�	PlexErrorc@seZdZdS)�RegexpSyntaxErrorN)�__name__�
__module__�__qualname__�rr�J/opt/alt/python35/lib64/python3.5/site-packages/Cython/Plex/Traditional.pyrsrcCst|�j�S)zk
    Convert traditional string representation of regular expression |s|
    into Plex representation.
    )�REParser�parse_re)�srrr�resrc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)rcCs)||_d|_d|_|j�dS)Nrr���)r�i�end�next)�selfrrrr�__init__s			zREParser.__init__cCs3|j�}|js/|jdt|j��|S)Nz
Unexpected %s)�	parse_altr�error�repr�c)rrrrrr"s	zREParser.parse_recCsg|j�}|jdkrc|g}x0|jdkrV|j�|j|j��q'Wt|�}|S)z#Parse a set of alternative regexps.�|)�	parse_seqr"r�appendr)rr�re_listrrrr(s	
zREParser.parse_altcCsCg}x0|jr8|jdkr8|j|j��q	Wt|�S)zParse a sequence of regexps.z|))rr"r%�	parse_modr)rr&rrrr$3szREParser.parse_seqcCs�|j�}xo|jr}|jdkr}|jdkrFt|�}n*|jdkrdt|�}nt|�}|j�qW|S)z7Parse a primitive regexp followed by *, +, ? modifiers.z*+?�*�+)�
parse_primrr"rrrr)rrrrrr':szREParser.parse_modcCs�|j�}|dkr'td�}n�|dkr<t}n�|dkrQt}nt|dkry|j�}|jd�nL|dkr�|j�}|jd�n$|d	kr�|j�}t|�}|S)
zParse a primitive regexp.�.�
�^�$�(�)�[�]�\)�getr
rrr�expect�
parse_charsetr
)rr"rrrrr*Gs"		zREParser.parse_primcCs1g}d}|jdkr+d}|j�|jdkrQ|jd�|j�x�|jr|jdkr|j�}|jdkr�|jd�dkr�|j�|j�}xJtt|�t|�d�D]}|jt|��q�WqT|j|�qTWdj	|�}|r#t
|�St|�SdS)z5Parse a charset. Does not include the surrounding [].rr-rr2�-�N)r"rr%rr4�	lookahead�range�ord�chr�joinr
r	)rZ	char_list�invertZc1Zc2�a�charsrrrr6\s(


$
&
zREParser.parse_charsetcCsU|j}|jd}|_|t|�kr?|||_nd|_d|_dS)zAdvance to the next char.rr8N)rr�lenr"r)rrrrrrrus		z
REParser.nextcCs-|jr|jd�|j}|j�|S)NzPremature end of string)rr r"r)rr"rrrr4s
	
	
zREParser.getcCs5|j|}|t|j�kr-|j|SdSdS)zLook ahead n chars.r8N)rrAr)r�n�jrrrr9�s
zREParser.lookaheadcCs7|j|kr|j�n|jdt|��dS)zj
        Expect to find character |c| at current position.
        Raises an exception otherwise.
        z
Missing %sN)r"rr r!)rr"rrrr5�s
zREParser.expectcCs)tdt|j�|j|f��dS)z1Raise exception to signal syntax error in regexp.z,Syntax error in regexp %s at position %d: %sN)rr!rr)rZmessrrrr �szREParser.errorN)rrrrrrr$r'r*r6rr4r9r5r rrrrrs


rN)�
__future__rZRegexpsrrrrrr	r
rrr
ZErrorsrrr�objectrrrrr�<module>	s
F