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__/Regexps.cpython-35.pyc



Z��ZP?�@s�ddlmZddlZyddlmZWn"ek
rTddlmZYnXddlmZdZ	dZ
d	Zed
�Z
dd�Zd
d�Zdd�Zdd�Zdd�ZGdd�de�Zdd�ZGdd�de�ZGdd�de�Ze�ZGdd�de�ZGdd �d e�ZGd!d"�d"e�ZGd#d$�d$e�ZGd%d&�d&e�Ze�Zd'e_d(e_ d)d*�Z!d+d,�Z"d-d.�Z#d/d0�Z$e$d1�Z%d2e%_d3e%_ dd4d5�Z&d6d7�Z'd8d9�Z(d:d;�Z)d<d=�Z*ee	�Z+d>e+_d?e+_ ee
�Z,d@e,_dAe,_ ee�Z-dBe-_dCe-_ dS)D�)�absolute_importN)�maxsize)�maxint�)�ErrorsZbol�eol�eof�
cCs�t|�}|j�d}t|�}g}x�||kr�t||�}|d}|d7}x:||kr�|t||�kr�|d7}|d7}qdW|j|�|j|�q1W|S)z�
    Return a list of character codes consisting of pairs
    [code1a, code1b, code2a, code2b,...] which cover all
    the characters in |s|.
    rr)�list�sort�len�ord�append)�sZ	char_list�i�n�result�code1�code2�r�F/opt/alt/python35/lib64/python3.5/site-packages/Cython/Plex/Regexps.py�chars_to_ranges"s


%

rcCsjt|td��}t|td�d�}||krbtd�td�}||||fSdSdS)z�
    If the range of characters from code1 to code2-1 includes any
    lower case letters, return the corresponding upper case range.
    �a�zr�AN)�maxr
�min)rr�code3�code4�drrr�uppercase_range9sr cCsjt|td��}t|td�d�}||krbtd�td�}||||fSdSdS)z�
    If the range of characters from code1 to code2-1 includes any
    upper case letters, return the corresponding lower case range.
    r�ZrrN)rr
r)rrrrrrrr�lowercase_rangeGsr"cs5�fdd�tdt��d�D�}t|�S)z�
    Given a list of codes as returned by chars_to_ranges, return
    an RE which will match a character in any of the ranges.
    cs+g|]!}t�|�|d��qS)r)�	CodeRange)�.0r)�	code_listrr�
<listcomp>Zs	zCodeRanges.<locals>.<listcomp>r�)�ranger�Alt)r%�re_listr)r%r�
CodeRangesUs+r+cCsS|tko|knrBtt|t�tttd|��St||�SdS)z�
    CodeRange(code1, code2) is an RE which matches any character
    with a code |c| in the range |code1| <= |c| < |code2|.
    rN)�nl_coder)�RawCodeRange�
RawNewline)rrrrrr#^s
r#c@s�eZdZdZdZdZdZdd�Zdd�Zdd	�Z	d
d�Z
dd
�Zdd�Zdd�Z
dd�Zdd�ZdS)�REaRE is the base class for regular expression constructors.
    The following operators are defined on REs:

         re1 + re2         is an RE which matches |re1| followed by |re2|
         re1 | re2         is an RE which matches either |re1| or |re2|
    rNcCstd|jj��dS)aM
        This method should add states to |machine| to implement this
        RE, starting at |initial_state| and ending at |final_state|.
        If |match_bol| is true, the RE must be able to match at the
        beginning of a line. If nocase is true, upper and lower case
        letters should be treated as equivalent.
        z %s.build_machine not implementedN)�NotImplementedError�	__class__�__name__)�self�machine�
initial_state�final_state�	match_bol�nocaserrr�
build_machine{s	zRE.build_machinecCs-|j�}|j|�|j||�|S)z~
        Given a state |s| of machine |m|, return a new state
        reachable from |s| on character |c| or epsilon.
        )�	new_state�link_to�add_transition)r3�mr5�crrrr�	build_opt�s
zRE.build_optcCs
t||�S)N)�Seq)r3�otherrrr�__add__�sz
RE.__add__cCs
t||�S)N)r))r3rArrr�__or__�sz	RE.__or__cCs|jr|jS|j�SdS)N)�str�calc_str)r3rrr�__str__�s	z
RE.__str__cCs&t|t�s"|j||d�dS)NzPlex.RE instance)�
isinstancer/�
wrong_type)r3�num�valuerrr�check_re�szRE.check_recCs/t|�td�kr+|j||d�dS)N��string)�typerH)r3rIrJrrr�check_string�szRE.check_stringcCsN|j||�t|�dkrJtjd||jjt|�f��dS)NrzOInvalid value for argument %d of Plex.%s.Expected a string of length 1, got: %s)rOrrZPlexValueErrorr1r2�repr)r3rIrJrrr�
check_char�s	z
RE.check_charcCslt|�tjkr4d|jj|jjf}nt|�j}tjd||jj||f��dS)Nz%s.%s instancez<Invalid type for argument %d of Plex.%s (expected %s, got %s)rN�typesZInstanceTyper1�
__module__r2rZ
PlexTypeError)r3rIrJZexpectedZgotrrrrH�s	z
RE.wrong_type)r2rS�__qualname__�__doc__�nullable�match_nlrDr9r?rBrCrFrKrOrQrHrrrrr/os
r/cCsWt|�dkr4tt|�t|�d�}nt|�}dt|�|_|S)z;
    Char(c) is an RE which matches the character |c|.
    rzChar(%s))rr#r
�
SpecialSymbolrPrD)r>rrrr�Char�s
"rYc@sXeZdZdZdZdZdZdZdZdd�Z	dd�Z
dd	�ZdS)
r-z�
    RawCodeRange(code1, code2) is a low-level RE which matches any character
    with a code |c| in the range |code1| <= |c| < |code2|, where the range
    does not include newline. For internal use only.
    rNcCs7||f|_t||�|_t||�|_dS)N)r(r r")r3rrrrr�__init__�szRawCodeRange.__init__cCsp|r|j||t�}|j|j|�|rl|jrP|j|j|�|jrl|j|j|�dS)N)r?�BOLr<r(r r")r3r=r5r6r7r8rrrr9�s		zRawCodeRange.build_machinecCsd|j|jfS)NzCodeRange(%d,%d))rr)r3rrrrEszRawCodeRange.calc_str)r2rSrTrUrVrWr(r r"rZr9rErrrrr-�s
r-c@s.eZdZdZdZdZdd�ZdS)�_RawNewlinezd
    RawNewline is a low-level RE which matches a newline character.
    For internal use only.
    rrcCsN|r|j||t�}|j||t�}|jttdf|�dS)Nr)r?r[�EOLr<r,)r3r=r5r6r7r8rrrrr9sz_RawNewline.build_machineN)r2rSrTrUrVrWr9rrrrr\sr\c@s@eZdZdZdZdZdZdd�Zdd�ZdS)rXzx
    SpecialSymbol(sym) is an RE which matches the special input
    symbol |sym|, which is one of BOL, EOL or EOF.
    rNcCs
||_dS)N)�sym)r3r^rrrrZ#szSpecialSymbol.__init__cCsA|r*|jtkr*|j||t�}|j|j|�dS)N)r^r]r?r[r<)r3r=r5r6r7r8rrrr9&szSpecialSymbol.build_machine)	r2rSrTrUrVrWr^rZr9rrrrrXsrXc@s:eZdZdZdd�Zdd�Zdd�ZdS)	r@z]Seq(re1, re2, re3...) is an RE which matches |re1| followed by
    |re2| followed by |re3|...cGs�d}x9t|�D]+\}}|j||�|o;|j}qW||_||_t|�}d}x8|r�|d8}||}|jr�d}P|jsiPqiW||_dS)Nrr)�	enumeraterKrVr*rrW)r3r*rVr�rerWrrrrZ2s"			

		zSeq.__init__cCs�|j}t|�dkr+|j|�n�|}t|�}xvt|�D]h\}	}
|	|dkru|j�}n|}|
j|||||�|}|
jp�|o�|
j}qJWdS)Nrr)r*rr;r_r:r9rWrV)r3r=r5r6r7r8r*�s1rrr`�s2rrrr9Es	zSeq.build_machinecCsddjtt|j��S)NzSeq(%s)�,)�join�maprDr*)r3rrrrEUszSeq.calc_strN)r2rSrTrUrZr9rErrrrr@.sr@c@s:eZdZdZdd�Zdd�Zdd�ZdS)	r)zRAlt(re1, re2, re3...) is an RE which matches either |re1| or
    |re2| or |re3|...cGs�||_d}d}g}g}d}xc|D][}|j||�|jrc|j|�d}n
|j|�|jrd}|d7}q.W||_||_||_||_dS)Nrr)r*rKrVrrW�nullable_res�non_nullable_res)r3r*rVrWrfrgrr`rrrrZ]s&	
	
	
				zAlt.__init__cCs�x*|jD]}|j|||||�q
W|jr~|rQ|j||t�}x*|jD]}|j|||d|�q[WdS)Nr)rfr9rgr?r[)r3r=r5r6r7r8r`rrrr9ss	zAlt.build_machinecCsddjtt|j��S)NzAlt(%s)rc)rdrerDr*)r3rrrrE|szAlt.calc_strN)r2rSrTrUrZr9rErrrrr)Ys	r)c@s:eZdZdZdd�Zdd�Zdd�ZdS)	�Rep1z@Rep1(re) is an RE which matches one or more repetitions of |re|.cCs5|jd|�||_|j|_|j|_dS)Nr)rKr`rVrW)r3r`rrrrZ�s	z
Rep1.__init__cCsk|j�}|j�}|j|�|jj||||pF|jj|�|j|�|j|�dS)N)r:r;r`r9rW)r3r=r5r6r7r8rarbrrrr9�s
(
zRep1.build_machinecCsd|jS)NzRep1(%s))r`)r3rrrrE�sz
Rep1.calc_strN)r2rSrTrUrZr9rErrrrrh�srhc@sFeZdZdZdZdZdd�Zdd�Zdd�ZdS)	�
SwitchCasez�
    SwitchCase(re, nocase) is an RE which matches the same strings as RE,
    but treating upper and lower case letters according to |nocase|. If
    |nocase| is true, case is ignored, otherwise it is not.
    NcCs.||_||_|j|_|j|_dS)N)r`r8rVrW)r3r`r8rrrrZ�s		zSwitchCase.__init__cCs#|jj|||||j�dS)N)r`r9r8)r3r=r5r6r7r8rrrr9�szSwitchCase.build_machinecCs)|jrd}nd}d||jfS)N�NoCase�Casez%s(%s))r8r`)r3�namerrrrE�s		zSwitchCase.calc_str)	r2rSrTrUr`r8rZr9rErrrrri�sriz8
    Empty is an RE which matches the empty string.
    �EmptycCs2tttt|���}dt|�|_|S)z@
    Str1(s) is an RE which matches the literal string |s|.
    zStr(%s))r@�tuplererYrPrD)rrrrr�Str1�srocGsbt|�dkr t|d�Stttt|���}ddjtt|��|_|SdS)z�
    Str(s) is an RE which matches the literal string |s|.
    Str(s1, s2, s3, ...) is an RE which matches any of |s1| or |s2| or |s3|...
    rrzStr(%s)rcN)rror)rnrerdrPrD)�strsrrrr�Str�s
rqcCs)tt|��}dt|�|_|S)zH
    Any(s) is an RE which matches any character in the string |s|.
    zAny(%s))r+rrPrD)rrrrr�Any�srrcCsMt|�}|jdt�|jt�t|�}dt|�|_|S)zp
    AnyBut(s) is an RE which matches any character (including
    newline) which is not in the string |s|.
    rz
AnyBut(%s))r�insertrrr+rPrD)r�rangesrrrr�AnyBut�s
rurLzT
    AnyChar is an RE which matches any single character (including a newline).
    �AnyCharcCs�|r;tt|�t|�d�}d||f|_nzg}xRtdt|�d�D]8}|jtt||�t||d�d��qZWt|�}dt|�|_|S)a
    Range(c1, c2) is an RE which matches any single character in the range
    |c1| to |c2| inclusive.
    Range(s) where |s| is a string of even length is an RE which matches
    any single character in the ranges |s[0]| to |s[1]|, |s[2]| to |s[3]|,...
    rzRange(%s,%s)rr'z	Range(%s))r#r
rDr(rrr)rP)rarbrrtrrrr�Range�s6rwcCs t|t�}d||_|S)zI
    Opt(re) is an RE which matches either |re| or the empty string.
    zOpt(%s))r)rmrD)r`rrrr�Opts
rxcCs#tt|��}d||_|S)zJ
    Rep(re) is an RE which matches zero or more repetitions of |re|.
    zRep(%s))rxrhrD)r`rrrr�Reps
rycCst|dd�S)z�
    NoCase(re) is an RE which matches the same strings as RE, but treating
    upper and lower case letters as equivalent.
    r8r)ri)r`rrrrjsrjcCst|dd�S)z�
    Case(re) is an RE which matches the same strings as RE, but treating
    upper and lower case letters as distinct, i.e. it cancels the effect
    of any enclosing NoCase().
    r8r)ri)r`rrrrk srkz=
    Bol is an RE which matches the beginning of a line.
    �Bolz7
    Eol is an RE which matches the end of a line.
    �Eolz9
    Eof is an RE which matches the end of the file.
    �Eof).�
__future__rrR�sysrr�ImportErrorrLrr[r]ZEOFr
r,rr r"r+r#�objectr/rYr-r\r.rXr@r)rhrirmrUrDrorqrrrurvrwrxryrjrkrzr{r|rrrr�<module>	sb
	n	+'!