Your IP : 3.135.193.166


Current Path : /usr/lib/python3.6/site-packages/pycparser/__pycache__/
Upload File :
Current File : //usr/lib/python3.6/site-packages/pycparser/__pycache__/c_lexer.cpython-36.pyc

3

��]m8�@s<ddlZddlZddlmZddlmZGdd�de�ZdS)�N)�lex)�TOKENc<@sleZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Z�dZiZ
x<eD]4Zedkrree
d7<q\edkr�ee
d8<q\ee
ej�<q\We�d
ZdtZduZdvZdwZdxZdyZdzed{ed|Zd}eZeeeZeeeZd~ZdZd�Zd�Zd�Zd�ed�ed�ed�Z d�e d|Z!d�e!d�Z"d�e"Z#d�e!d�e!d�Z$d�e!d�ed�Z%d�e d|Z&d�e&d�Z'd�e'Z(d�e&d�ee&d�Z)d�Z*d�Z+d�e+d|e*d�e*d�Z,d�Z-d�ed�ed�ed�Z.d�ed�ed�e.d|e-d�Z/�dZ0d�d��Z1e2e'�d�d���Z3e2e�d�d���Z4d�d��Z5d�d��Z6d�Z7d�d��Z8d�d��Z9d�d��Z:d�Z;e2e'�d�d���Z<e2e�d�d���Z=d�d��Z>d�Z?d�d��Z@d�ZAd�ZBd�ZCd�ZDd�ZEd�ZFd�ZGd�ZHd�ZId�ZJd�ZKd�ZLd�ZMd�ZNd�ZOd�ZPd�ZQd�ZRd�ZSd�ZTd�ZUd�ZVd�ZWd�ZXd�ZYd�ZZd�Z[d�Z\d�Z]d�Z^d�Z_d�Z`d�Zad�Zbd�Zcd�Zdd�Zed�Zfd�Zgd�Zhd�Zid�Zjd�Zkd�Zle2d�d�d��Zme2d�d�d��Zne'Zoe2e,�d�d��Zpe2e/�d�d��Zqe2e�d�d��Zre2e�d�d��Zse2e�d�d���Zte2e�d�d���Zue2e�d�d���Zve2e"�d�d���Zwe2e#�d�d���Zxe2e$�d��d��Zye2e%��d�d��Zze2e(��d�d��Z{e2e)��d�d��Z|e2e��d�d��Z}�d	�d
�Z~�dS(�CLexera A lexer for the C language. After building it, set the
        input text with input(), and call token() to get new
        tokens.

        The public attribute filename can be set to an initial
        filaneme, but the lexer will update it upon #line
        directives.
    cCs@||_||_||_||_d|_d|_tjd�|_tjd�|_	dS)ab Create a new Lexer.

            error_func:
                An error function. Will be called with an error
                message, line and column as arguments, in case of
                an error during lexing.

            on_lbrace_func, on_rbrace_func:
                Called when an LBRACE or RBRACE is encountered
                (likely to push/pop type_lookup_func's scope)

            type_lookup_func:
                A type lookup function. Given a string, it must
                return True IFF this string is a name of a type
                that was defined with a typedef earlier.
        �Nz([ 	]*line\W)|([ 	]*\d+)z
[ 	]*pragma\W)
�
error_func�on_lbrace_func�on_rbrace_func�type_lookup_func�filename�
last_token�re�compile�line_pattern�pragma_pattern)�selfrrrr	�r�/usr/lib/python3.6/c_lexer.py�__init__szCLexer.__init__cKstjfd|i|��|_dS)z� Builds the lexer from the specification. Must be
            called after the lexer object is created.

            This method exists separately, because the PLY
            manual warns against calling lex.lex inside
            __init__
        �objectN)r�lexer)r�kwargsrrr�build:szCLexer.buildcCsd|j_dS)z? Resets the internal line number counter of the lexer.
        �N)r�lineno)rrrr�reset_linenoDszCLexer.reset_linenocCs|jj|�dS)N)r�input)r�textrrrrIszCLexer.inputcCs|jj�|_|jS)N)r�tokenr)rrrrrLszCLexer.tokencCs|jjjdd|j�}|j|S)z3 Find the column of the token in its line.
        �
r)r�lexdata�rfind�lexpos)rrZlast_crrrr�find_tok_columnPszCLexer.find_tok_columncCs0|j|�}|j||d|d�|jjd�dS)Nrr)�_make_tok_locationrr�skip)r�msgr�locationrrr�_error[s
z
CLexer._errorcCs|j|j|�fS)N)rr")rrrrrr#`szCLexer._make_tok_location�_BOOL�_COMPLEX�AUTO�BREAK�CASE�CHAR�CONST�CONTINUE�DEFAULT�DO�DOUBLE�ELSE�ENUM�EXTERN�FLOAT�FOR�GOTO�IF�INLINE�INT�LONG�REGISTER�OFFSETOF�RESTRICT�RETURN�SHORT�SIGNED�SIZEOF�STATIC�STRUCT�SWITCH�TYPEDEF�UNION�UNSIGNED�VOID�VOLATILE�WHILEZ_BoolZ_Complex�ID�TYPEID�
INT_CONST_DEC�
INT_CONST_OCT�
INT_CONST_HEX�
INT_CONST_BIN�FLOAT_CONST�HEX_FLOAT_CONST�
CHAR_CONST�WCHAR_CONST�STRING_LITERAL�WSTRING_LITERAL�PLUS�MINUS�TIMES�DIVIDE�MOD�OR�AND�NOT�XOR�LSHIFT�RSHIFT�LOR�LAND�LNOT�LT�LE�GT�GE�EQ�NE�EQUALS�
TIMESEQUAL�DIVEQUAL�MODEQUAL�	PLUSEQUAL�
MINUSEQUAL�LSHIFTEQUAL�RSHIFTEQUAL�ANDEQUAL�XOREQUAL�OREQUAL�PLUSPLUS�
MINUSMINUS�ARROW�CONDOP�LPAREN�RPAREN�LBRACKET�RBRACKET�LBRACE�RBRACE�COMMA�PERIOD�SEMI�COLON�ELLIPSIS�PPHASHz[a-zA-Z_$][0-9a-zA-Z_$]*z0[xX]z[0-9a-fA-F]+z0[bB]z[01]+zD(([uU]ll)|([uU]LL)|(ll[uU]?)|(LL[uU]?)|([uU][lL])|([lL][uU]?)|[uU])?z(0z)|([1-9][0-9]*�)z0[0-7]*z0[0-7]*[89]z([a-zA-Z._~!=&\^\-\\?'"])z(\d+)z(x[0-9a-fA-F]+)z#([\\][^a-zA-Z._~^!=&\^\-\\?'"x0-7])z(\\(�|z))z
([^'\\\n]|�'�Lz('z*\n)|('z*$)z[^'
]+')|('')|('z	[^'\n]*')z
([^"\\\n]|�"z*"�*z([eE][-+]?[0-9]+)z([0-9]*\.[0-9]+)|([0-9]+\.)z((((z
?)|([0-9]+z
))[FfLl]?)z([pP][+-]?[0-9]+)z(((z)?\.z)|(z\.))�(z[FfLl]?)�ppline�	exclusive�pppragmacCsf|jj|jj|jjd�r2|jjd�d|_|_n0|jj|jj|jjd�rX|jjd�n
d|_	|SdS)z[ \t]*\#)�posr�Nr�r�)
r�matchrrr!�begin�pp_line�pp_filenamer�type)r�trrr�t_PPHASH�szCLexer.t_PPHASHcCs0|jdkr|jd|�n|jjd�jd�|_dS)Nz$filename before line number in #liner�)r�r'�value�lstrip�rstripr�)rr�rrr�t_ppline_FILENAMEs
zCLexer.t_ppline_FILENAMEcCs|jdkr|j|_ndS)N)r�r�)rr�rrr�t_ppline_LINE_NUMBER
s

zCLexer.t_ppline_LINE_NUMBERcCsH|jdkr|jd|�n t|j�|j_|jdk	r8|j|_|jjd�dS)z\nNzline number missing in #line�INITIAL)r�r'�intrrr�r
r�)rr�rrr�t_ppline_NEWLINEs

zCLexer.t_ppline_NEWLINEcCsdS)�lineNr)rr�rrr�t_ppline_PPLINE szCLexer.t_ppline_PPLINEz 	cCs|jd|�dS)Nzinvalid #line directive)r')rr�rrr�t_ppline_error&szCLexer.t_ppline_errorcCs |jjd7_|jjd�dS)z\nrr�N)rrr�)rr�rrr�t_pppragma_NEWLINE,szCLexer.t_pppragma_NEWLINEcCsdS)ZpragmaNr)rr�rrr�t_pppragma_PPPRAGMA1szCLexer.t_pppragma_PPPRAGMAz$ 	<>.-{}();=+-*/$%@&^~!?:,0123456789cCsdS)Nr)rr�rrr�t_pppragma_STR7szCLexer.t_pppragma_STRcCsdS)Nr)rr�rrr�
t_pppragma_ID:szCLexer.t_pppragma_IDcCs|jd|�dS)Nzinvalid #pragma directive)r')rr�rrr�t_pppragma_error=szCLexer.t_pppragma_errorcCs|jj|jjd�7_dS)z\n+rN)rrr��count)rr�rrr�	t_NEWLINEFszCLexer.t_NEWLINEz\+�-z\*�/�%z\|�&�~z\^z<<z>>z\|\|z&&�!�<�>z<=z>=z==z!=�=z\*=z/=z%=z\+=z-=z<<=z>>=z&=z\|=z\^=z\+\+z--z->z\?z\(z\)z\[z\]�,z\.�;�:z\.\.\.z\{cCs|j�|S)N)r)rr�rrr�t_LBRACE�szCLexer.t_LBRACEz\}cCs|j�|S)N)r)rr�rrr�t_RBRACE�szCLexer.t_RBRACEcCs|S)Nr)rr�rrr�
t_FLOAT_CONST�szCLexer.t_FLOAT_CONSTcCs|S)Nr)rr�rrr�t_HEX_FLOAT_CONST�szCLexer.t_HEX_FLOAT_CONSTcCs|S)Nr)rr�rrr�t_INT_CONST_HEX�szCLexer.t_INT_CONST_HEXcCs|S)Nr)rr�rrr�t_INT_CONST_BIN�szCLexer.t_INT_CONST_BINcCsd}|j||�dS)NzInvalid octal constant)r')rr�r%rrr�t_BAD_CONST_OCT�szCLexer.t_BAD_CONST_OCTcCs|S)Nr)rr�rrr�t_INT_CONST_OCT�szCLexer.t_INT_CONST_OCTcCs|S)Nr)rr�rrr�t_INT_CONST_DEC�szCLexer.t_INT_CONST_DECcCs|S)Nr)rr�rrr�t_CHAR_CONST�szCLexer.t_CHAR_CONSTcCs|S)Nr)rr�rrr�
t_WCHAR_CONST�szCLexer.t_WCHAR_CONSTcCsd}|j||�dS)NzUnmatched ')r')rr�r%rrr�t_UNMATCHED_QUOTE�szCLexer.t_UNMATCHED_QUOTEcCsd|j}|j||�dS)NzInvalid char constant %s)r�r')rr�r%rrr�t_BAD_CHAR_CONST�s
zCLexer.t_BAD_CHAR_CONSTcCs|S)Nr)rr�rrr�t_WSTRING_LITERAL�szCLexer.t_WSTRING_LITERALcCsd}|j||�dS)Nz#String contains invalid escape code)r')rr�r%rrr�t_BAD_STRING_LITERAL�szCLexer.t_BAD_STRING_LITERALcCs2|jj|jd�|_|jdkr.|j|j�r.d|_|S)NrMrN)�keyword_map�getr�r�r	)rr�rrr�t_ID�szCLexer.t_IDcCs"dt|jd�}|j||�dS)NzIllegal character %sr)�reprr�r')rr�r%rrr�t_error�szCLexer.t_errorN)%r(r)r*r+r,r-r.r/r0r1r2r3r4r5r6r7r8r9r:r;r<r=r>r?r@rArBrCrDrErFrGrHrIrJrKrL);rMrNrOrPrQrRrSrTrUrVrWrXrYrZr[r\r]r^r_r`rarbrcrdrerfrgrhrirjrkrlrmrnrorprqrrrsrtrurvrwrxryrzr{r|r}r~rr�r�r�r�r�r�r�r��r�r��r�r�)r�r�)�__name__�
__module__�__qualname__�__doc__rrrrrr"r'r#�keywordsr��keyword�lower�tokensZ
identifierZ
hex_prefixZ
hex_digitsZ
bin_prefixZ
bin_digitsZinteger_suffix_optZdecimal_constantZoctal_constantZhex_constantZbin_constantZbad_octal_constantZ
simple_escapeZdecimal_escapeZ
hex_escapeZ
bad_escapeZescape_sequenceZcconst_charZ
char_constZwchar_constZunmatched_quoteZbad_char_constZstring_charZstring_literalZwstring_literalZbad_string_literalZ
exponent_partZfractional_constantZfloating_constantZbinary_exponent_partZhex_fractional_constantZhex_floating_constantZstatesr�rr�r�r�r�Zt_ppline_ignorer�r�r�Zt_pppragma_ignorer�r�r�Zt_ignorer�Zt_PLUSZt_MINUSZt_TIMESZt_DIVIDEZt_MODZt_ORZt_ANDZt_NOTZt_XORZt_LSHIFTZt_RSHIFTZt_LORZt_LANDZt_LNOTZt_LTZt_GTZt_LEZt_GEZt_EQZt_NEZt_EQUALSZt_TIMESEQUALZ
t_DIVEQUALZ
t_MODEQUALZt_PLUSEQUALZt_MINUSEQUALZ
t_LSHIFTEQUALZ
t_RSHIFTEQUALZ
t_ANDEQUALZ	t_OREQUALZ
t_XOREQUALZ
t_PLUSPLUSZt_MINUSMINUSZt_ARROWZt_CONDOPZt_LPARENZt_RPARENZ
t_LBRACKETZ
t_RBRACKETZt_COMMAZt_PERIODZt_SEMIZt_COLONZ
t_ELLIPSISr�r�Zt_STRING_LITERALr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrs@!



		$	
r)r�sysZplyrZply.lexrrrrrrr�<module>	s

?>