ok

Mini Shell

Direktori : /lib/python3.6/site-packages/ply/__pycache__/
Upload File :
Current File : //lib/python3.6/site-packages/ply/__pycache__/cpp.cpython-36.pyc

3

r��W���
@slddlmZddlZejjdkr*eefZneZeZ	d3Z
dZdd�ZdZ
dZdZdd�ZeZdZdd�Zdd�Zdd�Zdd�Zdd�ZddlZddlZddlZddlZejd �Zd!d"d#d$d%d&d'd(d)d*�	Zd+d,�Z Gd-d.�d.e!�Z"Gd/d0�d0e!�Z#e$d1k�rhddl%j&Z&e&j&�Z'ddlZe(ej)d2�Z*e*j+�Z,e#e'�Z-e-j.e,ej)d2�x"e-j/�Z0e0�sVPe1e-j2e0��qFWdS)4�)�
generatorsN��CPP_ID�CPP_INTEGER�	CPP_FLOAT�
CPP_STRING�CPP_CHAR�CPP_WS�CPP_COMMENT1�CPP_COMMENT2�	CPP_POUND�
CPP_DPOUNDz+-*/%|&~^<>=!?()[]{}.,;:\'"cCs|jj|jjd�7_|S)z\s+�
)�lexer�lineno�value�count)�t�r�/usr/lib/python3.6/cpp.py�t_CPP_WS!srz\#z\#\#z[A-Za-z_][\w_]*cCs|S)zA(((((0x)|(0X))[0-9a-fA-F]+)|(\d+))([uU][lL]|[lL][uU]|[uU]|[lL])?)r)rrrrr-sz?((\d+)(\.\d+)(e(\+|-)?(\d+))? | (\d+)e(\+|-)?(\d+))([lL]|[fF])?cCs|jj|jjd�7_|S)z\"([^\\\n]|(\\(.|\n)))*?\"r)rrrr)rrrr�t_CPP_STRING7srcCs|jj|jjd�7_|S)z(L)?\'([^\\\n]|(\\(.|\n)))*?\'r)rrrr)rrrr�
t_CPP_CHAR=srcCs8|jjd�}|jj|7_d|_|r.d|nd|_|S)z(/\*(.|\n)*?\*/)rr	� )rrrr�type)rZncrrrr�t_CPP_COMMENT1Cs
rcCsd|_d|_dS)z
(//.*?(\n|$))r	rN)rr)rrrr�t_CPP_COMMENT2LsrcCs(|jd|_|jd|_|jjd�|S)Nr�)rrr�skip)rrrr�t_errorQsrz\?\?[=/\'\(\)\!<>\-]�#�\�^�[�]�|�{�}�~)	�=�/�'�(�)�!�<�>�-cCstjdd�|�S)NcSst|j�dS)Nr���)�
_trigraph_rep�group)�grrr�<lambda>{sztrigraph.<locals>.<lambda>)�
_trigraph_pat�sub)�inputrrr�trigraphzsr:c@seZdZddd�ZdS)�MacroNFcCs0||_||_||_||_|r&|d|_d|_dS)Nrr2)�namer�arglist�variadic�vararg�source)�selfr<rr=r>rrr�__init__�s
zMacro.__init__)NF)�__name__�
__module__�__qualname__rBrrrrr;�sr;c@s�eZdZd&dd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zd'dd�Z
dd�Zd(dd�Zdd�Zdd�Zd d!�Zdifd"d#�Zd$d%�ZdS))�PreprocessorNcCsl|dkrtj}||_i|_g|_g|_|j�tj�}|jdtj	d|��|jdtj	d|��d|_
dS)Nz
__DATE__ "%s"z%b %d %Yz
__TIME__ "%s"z%H:%M:%S)�lexr�macros�path�	temp_path�lexprobe�timeZ	localtime�defineZstrftime�parser)rArZtmrrrrB�szPreprocessor.__init__cCs4g}|jj|�x|jj�}|s"P|j|�qW|S)N)rr9�token�append)rA�text�tokens�tokrrr�tokenize�s
zPreprocessor.tokenizecCstd|||f�dS)Nz%s:%d %s)�print)rA�file�line�msgrrr�error�szPreprocessor.errorc	Cs�|jjd�|jj�}|s&|jdkr0td�n|j|_|jjd�|jj�}|sbt|j�dkrltd�n|j|_t|j�|_	|jjd�|jj�}|s�|jdkr�td�n|j|_
|jjd�|jj�}|s�|jdkr�d|_n|j|_|jjd	�|jj�}|�s|jd	k�r(d|_td
�n|j|_|j|jf|_
ddd
ddddddg	}xD|D]<}|jj|�|jj�}|�s�|j|k�rZtd|��qZWdS)NZ
identifierz"Couldn't determine identifier typeZ12345i90zCouldn't determine integer typez
"filename"zCouldn't determine string typez  rz%Couldn't determine token for newlinesr/r0r z##r!r,r-�,�.z,Unable to lex '%s' required for preprocessor)rr9rOrrUr�t_ID�int�	t_INTEGER�t_INTEGER_TYPE�t_STRINGZt_SPACEZ	t_NEWLINE�t_WS)rArS�chars�crrrrK�sD










zPreprocessor.lexprobecCs|jj|�dS)N)rIrP)rArIrrr�add_pathszPreprocessor.add_pathccs�|jj�}dd�|j�D�}xhtt|��D]X}|d}xJ||jd�r�|t|�kr�||dd�||||<d||<|d7}q8Wq*Wdj|�}|j|�d|_g}x<|j	�}|s�P|j
|�|j|jkr�d|j
kr�|Vg}q�W|r�|VdS)NcSsg|]}|j��qSr)�rstrip)�.0�xrrr�
<listcomp>sz,Preprocessor.group_lines.<locals>.<listcomp>rr!�rr2)rZclone�
splitlines�xrange�len�endswith�joinr9rrOrPrrar)rAr9rG�lines�i�jZcurrent_linerSrrr�group_liness,



zPreprocessor.group_linescCs|d}x(|t|�kr,||j|jkr,|d7}qW|d|�=t|�d}x$|dkrh||j|jkrh|d8}qFW||dd�=|S)Nrr)rlrra)rArRrprrr�
tokenstrip9s
zPreprocessor.tokenstripc	Cs�g}g}g}d}t|�}d}x$||kr@||j|jkr@|d7}qW||krh||jdkrh|j|d�n |j|j|djd�dggfS|d7}x�||k�rf||}|jdkr�|j|�|d7}n�|jdk�r|d8}|dk�r|r�|j|j|��|j|�|d||fS|j|�nD|jdk�rR|dk�rR|j|j|��|j|d�g}n
|j|�|d7}q�W|j|j|djd�dggfS)	Nrrr,zMissing '(' in macro argumentsr-rZzMissing ')' in macro argumentsr2)	rlrrarrPrYr@rrs)	rAZ	tokenlist�args�	positionsZcurrent_argZnestingZtokenlenrprrrr�collect_argsUsD






zPreprocessor.collect_argscCsg|_g|_g|_d}�x�|t|j�k�r|j|j|jkoL|j|j|jk�rh|jj|j|j�}|dkr�|j|djdkr�t	j	|j|�|j|<|j
|j|_|j|d=|jj||df�qn�|dko�|j|djdk�r|jjd||df�|j|d=qnZ|dt|j�k�rT|j|djdk�rT|jjd||f�|d7}qn|jjd||f�n�|j|jdk�r�|j�r�|dk�r�|j|djdk�r�|dt|j�k�r�|j|dj|jk�r�|j|dj|j
k�r�|jj|d�|d7}qW|jjdd	�d
d�dS)Nrrr z##rc�erZcSs|dS)N�r)rgrrrr6�sz,Preprocessor.macro_prescan.<locals>.<lambda>T)�key�reverse)�patch�	str_patch�var_comma_patchrlrrr\r=�index�copyr`rPr>r?�sort)rA�macrorp�argnumrrr�
macro_prescan�s:&*(,zPreprocessor.macro_prescanc
Cs0dd�|jD�}i}xb|jD]X\}}||krTddjdd�||D��jdd�||<tj||�||<||||_qWd}|jr�|dr�x|jD]}d||<d
}q�Wi}xj|jD]`\}	}}|	dkr�|||||d	�<q�|	dkr�||k�r|j||�||<|||||d	�<q�W|�r,d
d�|D�}|S)NcSsg|]}tj|��qSr)r)rf�_xrrrrh�sz2Preprocessor.macro_expand_args.<locals>.<listcomp>z"%s"ricSsg|]
}|j�qSr)r)rfrgrrrrh�sr!z\\FrTrcrwcSsg|]}|r|�qSrr)rf�_irrrrh�sr2)	rr|rn�replacerr>r}r{�
expand_macros)
rAr�rt�repZ
str_expansionr�rpZcomma_patch�expandedZptyperrr�macro_expand_args�s.(
zPreprocessor.macro_expand_argscCs�|dkri}d}�x�|t|�k�r�||}|j|jk�r�|j|jkoL|j|k�r�d||j<|j|j}|js�|jdd�|jD�|�}x|D]}|j|_q�W||||d�<|t|�7}�n�|d}x(|t|�kr�||j|jkr�|d7}q�W||jdk�r�|j	||d��\}	}
}|j
�r`t|
�t|j�k�r`|j|j|jd|jt|j�f�||	}�nD|j
�r�t|
�t|j�dk�r�t|j�dk�r�|j|j|jd	|jt|j�df�n&|j|j|jd
|jt|j�df�||	}n�|j
�rXt|
�t|j�dk�r|
j
g�nD|||t|j�d||	d�|
t|j�d<|
t|j�d�=|j||
�}|j||�}x|D]}
|j|
_�qvW|||||	�<|t|�7}||j=qn"|jdk�r�|j|_|j|j�|_|d7}qW|S)NrTcSsg|]}tj|��qSr)r)rfr�rrrrh�sz.Preprocessor.expand_macros.<locals>.<listcomp>rr,zMacro %s requires %d argumentsrxz(Macro %s must have at least %d argumentsz'Macro %s must have at least %d argumentZ__LINE__)rlrr\rrHr=r�rrarvr>rYr@rPr�r^r_)rArRr�rpr�mZexrwrq�tokcountrtrur��rrrrr��s\

" (&
4
zPreprocessor.expand_macroscCs^d}�x|t|�k�r"||j|jko2||jdk�r|d}d}d}x�|t|�kr�||j|jkrp|d7}qHnn||j|jkr�||j|jkr�d}nd}|s�Pn<||jdkr�d}n(||jd	kr�Pn|j|j||jd
�|d7}qHW|j	||_|j
|�||_||d|d�=|d7}qW|j|�}x�t|�D]�\}}|j|jk�rzt
j
|�||<|j	||_|j
d�||_nd|j|j	k�r8t
j
|�||<t||j�||_x2||jddk�r�||jdd�||_�q�W�q8Wdjd
d�|D��}|jdd�}|jdd�}|jdd�}yt|�}Wn0tk
�rX|j|j|djd�d}YnX|S)NrZdefinedrFZ0LZ1Lr,Tr-zMalformed defined()Z0123456789abcdefABCDEFricSsg|]}t|j��qSr)�strr)rfrgrrrrhTsz)Preprocessor.evalexpr.<locals>.<listcomp>z&&z and z||z or r.z not zCouldn't evaluate expressionr2r2)rlrr\rrarHrYr@rr^r_r��	enumeraterr�rnr��eval�	Exception)rArRrprqZ	needparen�resultr�exprrrr�evalexpr)s^ 
$
zPreprocessor.evalexprccs�t|�}|j|�}|sd}|jd|�||_g}d}d}g}�xN|D�]D}	x"t|	�D]\}
}|j|jkrVPqVW|jdk�r~x,|	D]$}|j|jkr�d|jkr�|j|�q�W|j	|	|
dd��}|r�|dj}
|j	|dd��}nd}
g}|
d	k�r(|�r|x|j
|�D]}|V�qWg}|j|��q�|
d
k�r�|�r|x|j
|�D]}|V�qDWg}|jd}x|j|�D]}|V�qnW||jd<||_�q�|
dk�r�|�r|x|j
|�D]}|V�q�Wg}|j
|��q�|
d
k�r|j||f�|�r||dj|jk�r
d}d}nd}�q�|
dk�rT|j||f�|�r||dj|jk�rLd}d}nd}�q�|
dk�r�|j||f�|�r||j|�}|�s�d}d}nd}n�|
dk�r�|�r�|dd�r�|�r�d}n|�s�|j|�}|�r�d}d}n|j|j|djd�n�|
dk�rF|�r.|dd�rD|�rd}n|�sDd}d}n|j|j|djd�n6|
dk�r�|�rd|j�\}}n|j|j|djd�nqF|rF|j|	�qFWx|j
|�D]}|V�q�Wg}dS)Nriz
__FILE__ "%s"TFr rrrrM�includeZ__FILE__�undefZifdefZifndef�if�elifzMisplaced #elif�elsezMisplaced #elseZendifzMisplaced #endifr2r2)r:rrrMr@r�rrarrPrsr�rHr�r�r�rYr�pop�extend)rAr9r@rro�chunk�enableZ	iftriggerZifstackrgrprSZ	dirtokensr<rtZoldfiler�rrr�parsegends�
















zPreprocessor.parsegenc
cs�|sdS|r�|djdkr4|dj|jkr4|j|�}|djdkr�d}x4|t|�krn||jdkrdP|d7}qHWtd�dSdjdd�|d|�D��}|jdg|j}nB|dj|jkr�|djdd�}|jdg|j}ntd	�dSx�|D]�}t	jj||�}y`t
|d
�j�}t	jj|�}|�r6|jj
d|�x|j||�D]}	|	V�qDW|�rb|jd=PWq�tk
�r|Yq�Xq�Wtd|�dS)
Nrr/rr0zMalformed #include <...>ricSsg|]
}|j�qSr)r)rfrgrrrrh�sz(Preprocessor.include.<locals>.<listcomp>zMalformed #include statementr�zCouldn't find '%s'r2)rrr`r�rlrUrnrIrJ�os�open�read�dirname�insertr��IOError)
rArRrp�filenamerI�pZiname�dataZdnamerSrrrr��sF


zPreprocessor.includecCs�t|t�r|j|�}|}�y||d}t|�dkr:|d}nd}|s^t|jg�}||j|j<�n6|j|jkr�t|j|j	|dd���}||j|j<�n|jdk�r�|j
|dd��\}}}d}	�x�|D]�}
|	r�td�Pdjdd	�|
D��}|d
k�r d}	|j
|
d_d|
d_d}	|
dd�=q�nb|dd�d
k�r�|
dj|j
k�r�d}	|
dd�=|
djdd�d
kr�|
djdd�|
d_q�t|
�dk�s�|
dj|j
kr�td�Pq�W|j	|d|d��}d}
x�|
t|�k�rX|
dt|�k�rL||
j|jk�r||
djdk�r||
=�q�n0||
jdk�rL||
dj|jk�rL||
d=|
d7}
�q�Wt|j|dd	�|D�|	�}|j|�||j|j<ntd�Wntk
�r�td�YnXdS)Nrrrxr,Fz0No more arguments may follow a variadic argumentricSsg|]}t|j��qSr)r�r)rfr�rrrrh2sz'Preprocessor.define.<locals>.<listcomp>z...TZ__VA_ARGS__rzInvalid macro argumentz##cSsg|]}|dj�qS)r)r)rfrgrrrrhPszBad macro definition���r�r�)�
isinstance�STRING_TYPESrTrlr;rrHrrarsrvrUrnr\r��LookupError)rArRZlinetokr<Zmtyper�r�rtrur>�aZastrZmvaluerprrrrMsl





$
&&

zPreprocessor.definecCs0|dj}y|j|=Wntk
r*YnXdS)Nr)rrHr�)rArR�idrrrr�^s

zPreprocessor.undefcCs||_|j||�|_dS)N)�ignorer�rN)rAr9r@r�rrr�parsejszPreprocessor.parsecCsDy$xt|j�}|j|jkr|SqWWntk
r>d|_dSXdS)N)�nextrNrr��
StopIteration)rArSrrrrOss
zPreprocessor.token)N)N)N)rCrDrErBrTrYrKrdrrrsrvr�r�r�r�r�r�rMr�r�rOrrrrrF�s&
<!5+2
B;
1F	rF�__main__r)
rrrrrr	r
rrr
)3Z
__future__r�sys�version_info�majorr�Zunicoder��rangerkrR�literalsrZt_CPP_POUNDZt_CPP_DPOUNDZt_CPP_IDrZ
t_CPP_INTEGERZt_CPP_FLOATrrrrr�rerrLZos.pathr��compiler7r3r:�objectr;rFrCZply.lexrGrr��argv�fr�r9r�r�rOrSrUr@rrrr�<module>
sl
	
c



Zerion Mini Shell 1.0