3
ãdeC  ã               @   s4   d dl Z ddlmZ ddlmZ G dd„ deƒZdS )é    Né   )Úlex)ÚTOKENc            E   @   sZ  e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dd„ Z
dd„ Z�d+Z�d,Zi ZxeD ]Zeeejƒ < qbW x0eD ](Zeeed>d?… jƒ ed?d>… jƒ  < q|W ee �d- Zd„Zd…Zd†Zd‡ZdˆZd‰ZdŠe d‹ e dŒ Zd�e Zee e Zee e ZdŽZd�Zd�Zd‘Z d’Z!d“e d” e d” e  d• Z"d–Z#d—e" dŒ Z$d˜e$ d˜ Z%d™e% Z&dše% Z'd›e% Z(dœe% Z)d˜e$ d� Z*dže$ dŸ e$ d  Z+dže$ d¡ e! d¢ Z,d£e# dŒ Z-d¤e- d¥ Z.d™e. Z/dše. Z0d›e. Z1dœe. Z2d¤e- d¦ e! e- d¥ Z3d§Z4d¨Z5d©e5 dŒ e4 dª e4 d« Z6d¬Z7d­e d® e d¯ e d° Z8d±e d± e d” e8 dŒ e7 d² Z9�d0Z:d¶d·„ Z;e<e.ƒd¸d¹„ ƒZ=e<eƒdºd»„ ƒZ>d¼d½„ Z?d¾d¿„ Z@dÀZAdÁdÂ„ ZBdÃdÄ„ ZCdÅdÆ„ ZDdÀZEdÇdÈ„ ZFdÉdÊ„ ZGdÀZHdËdÌ„ 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ïZldðZmdñZndòZodóZpdôZqdõZrdöZsd÷ZtdøZue<dùƒdúdû„ ƒZve<düƒdýdþ„ ƒZwe.Zxe<e6ƒdÿ�d „ ƒZye<e9ƒ�d�d„ ƒZze<eƒ�d�d„ ƒZ{e<eƒ�d�d„ ƒZ|e<eƒ�d�d„ ƒZ}e<eƒ�d	�d
„ ƒZ~e<eƒ�d�d„ ƒZe<e*ƒ�d�d„ ƒZ€e<e%ƒ�d�d„ ƒZ�e<e&ƒ�d�d„ ƒZ‚e<e'ƒ�d�d„ ƒZƒe<e(ƒ�d�d„ ƒZ„e<e)ƒ�d�d„ ƒZ…e<e+ƒ�d�d„ ƒZ†e<e,ƒ�d�d„ ƒZ‡e<e/ƒ�d�d„ ƒZˆe<e0ƒ�d�d „ ƒZ‰e<e1ƒ�d!�d"„ ƒZŠe<e2ƒ�d#�d$„ ƒZ‹e<e3ƒ�d%�d&„ ƒZŒe<eƒ�d'�d(„ ƒZ��d)�d*„ ZŽd>S (1  Ú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
        filename, but the lexer will update it upon #line
        directives.
    c             C   s@   || _ || _|| _|| _d| _d| _tjdƒ| _tjdƒ| _	dS )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([ \t]*line\W)|([ \t]*\d+)z[ \t]*pragma\W)
Ú
error_funcÚon_lbrace_funcÚon_rbrace_funcÚtype_lookup_funcÚfilenameÚ
last_tokenÚreÚcompileÚline_patternÚpragma_pattern)Úselfr   r   r	   r
   © r   úH/var/www/agendate/envp3/lib/python3.6/site-packages/pycparser/c_lexer.pyÚ__init__   s    zCLexer.__init__c             K   s   t j f d| i|—Ž| _dS )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   Úkwargsr   r   r   Úbuild9   s    zCLexer.buildc             C   s   d| j _dS )z? Resets the internal line number counter of the lexer.
        r   N)r   Úlineno)r   r   r   r   Úreset_linenoC   s    zCLexer.reset_linenoc             C   s   | j j|ƒ d S )N)r   Úinput)r   Útextr   r   r   r   H   s    zCLexer.inputc             C   s   | j jƒ | _| jS )N)r   Útokenr   )r   r   r   r   r   K   s    zCLexer.tokenc             C   s   | j jjdd|jƒ}|j| S )z3 Find the column of the token in its line.
        Ú
r   )r   ÚlexdataÚrfindÚlexpos)r   r   Zlast_crr   r   r   Úfind_tok_columnO   s    zCLexer.find_tok_columnc             C   s0   | j |ƒ}| j||d |d ƒ | jjdƒ d S )Nr   r   )Ú_make_tok_locationr   r   Úskip)r   Úmsgr   Úlocationr   r   r   Ú_errorZ   s    
zCLexer._errorc             C   s   |j | j|ƒfS )N)r   r"   )r   r   r   r   r   r#   _   s    zCLexer._make_tok_locationÚ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ÚWHILEÚ__INT128Ú_BOOLÚ_COMPLEXÚ	_NORETURNÚ_THREAD_LOCALÚ_STATIC_ASSERTÚ_ATOMICÚ_ALIGNOFÚ_ALIGNASNé   ÚIDÚTYPEIDÚINT_CONST_DECÚINT_CONST_OCTÚINT_CONST_HEXÚINT_CONST_BINÚINT_CONST_CHARÚFLOAT_CONSTÚHEX_FLOAT_CONSTÚ
CHAR_CONSTÚWCHAR_CONSTÚU8CHAR_CONSTÚU16CHAR_CONSTÚU32CHAR_CONSTÚSTRING_LITERALÚWSTRING_LITERALÚU8STRING_LITERALÚU16STRING_LITERALÚU32STRING_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ÚPPHASHÚPPPRAGMAÚPPPRAGMASTRz[a-zA-Z_$][0-9a-zA-Z_$]*z0[xX]z[0-9a-fA-F]+z0[bB]z[01]+zD(([uU]ll)|([uU]LL)|(ll[uU]?)|(LL[uU]?)|([uU][lL])|([lL][uU]?)|[uU])?z(0z)|([1-9][0-9]*ú)z0[0-7]*z0[0-7]*[89]z,([a-wyzA-Z._~!=&\^\-\\?'"]|x(?![0-9a-fA-F]))z(\d+)(?!\d)z(x[0-9a-fA-F]+)(?![0-9a-fA-F])z#([\\][^a-zA-Z._~^!=&\^\-\\?'"x0-9])z(\\(ú|z))z(\\[0-9a-zA-Z._~!=&\^\-\\?'"])z
([^'\\\n]|ú'ÚLÚu8ÚuÚUz{2,4}'z('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Úpppragmac             C   sf   | j j|jj|jjd�r2|jjdƒ d | _| _n0| jj|jj|jjd�rX|jjdƒ n
d|_	|S dS )z[ \t]*\#)Úposr£   Nr¥   r–   )
r   Úmatchr   r   r!   ÚbeginÚpp_lineÚpp_filenamer   Útype)r   Útr   r   r   Út_PPHASH!  s    zCLexer.t_PPHASHc             C   s0   | j d kr| jd|ƒ n|jjdƒjdƒ| _d S )Nz$filename before line number in #liner    )r©   r'   ÚvalueÚlstripÚrstriprª   )r   r¬   r   r   r   Út_ppline_FILENAME/  s    
zCLexer.t_ppline_FILENAMEc             C   s   | j d kr|j| _ n d S )N)r©   r®   )r   r¬   r   r   r   Út_ppline_LINE_NUMBER6  s    

zCLexer.t_ppline_LINE_NUMBERc             C   sH   | j dkr| jd|ƒ n t| j ƒ| j_| jdk	r8| j| _|jjdƒ dS )z\nNzline number missing in #lineÚINITIAL)r©   r'   Úintr   r   rª   r   r¨   )r   r¬   r   r   r   Út_ppline_NEWLINE?  s    

zCLexer.t_ppline_NEWLINEc             C   s   dS )ÚlineNr   )r   r¬   r   r   r   Út_ppline_PPLINEK  s    zCLexer.t_ppline_PPLINEz 	c             C   s   | j d|ƒ d S )Nzinvalid #line directive)r'   )r   r¬   r   r   r   Út_ppline_errorQ  s    zCLexer.t_ppline_errorc             C   s    |j  jd7  _|j jdƒ dS )z\nr   r³   N)r   r   r¨   )r   r¬   r   r   r   Út_pppragma_NEWLINEW  s    zCLexer.t_pppragma_NEWLINEc             C   s   |S )Zpragmar   )r   r¬   r   r   r   Út_pppragma_PPPRAGMA\  s    zCLexer.t_pppragma_PPPRAGMAc             C   s
   d|_ |S )z.+r˜   )r«   )r   r¬   r   r   r   Út_pppragma_STRb  s    zCLexer.t_pppragma_STRc             C   s   | j d|ƒ d S )Nzinvalid #pragma directive)r'   )r   r¬   r   r   r   Út_pppragma_errorg  s    zCLexer.t_pppragma_errorc             C   s   |j  j|jjdƒ7  _dS )z\n+r   N)r   r   r®   Úcount)r   r¬   r   r   r   Ú	t_NEWLINEp  s    zCLexer.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\{c             C   s   | j ƒ  |S )N)r   )r   r¬   r   r   r   Út_LBRACE¸  s    zCLexer.t_LBRACEz\}c             C   s   | j ƒ  |S )N)r	   )r   r¬   r   r   r   Út_RBRACE¼  s    zCLexer.t_RBRACEc             C   s   |S )Nr   )r   r¬   r   r   r   Út_FLOAT_CONSTÈ  s    zCLexer.t_FLOAT_CONSTc             C   s   |S )Nr   )r   r¬   r   r   r   Út_HEX_FLOAT_CONSTÌ  s    zCLexer.t_HEX_FLOAT_CONSTc             C   s   |S )Nr   )r   r¬   r   r   r   Út_INT_CONST_HEXÐ  s    zCLexer.t_INT_CONST_HEXc             C   s   |S )Nr   )r   r¬   r   r   r   Út_INT_CONST_BINÔ  s    zCLexer.t_INT_CONST_BINc             C   s   d}| j ||ƒ d S )NzInvalid octal constant)r'   )r   r¬   r%   r   r   r   Út_BAD_CONST_OCTØ  s    zCLexer.t_BAD_CONST_OCTc             C   s   |S )Nr   )r   r¬   r   r   r   Út_INT_CONST_OCTÝ  s    zCLexer.t_INT_CONST_OCTc             C   s   |S )Nr   )r   r¬   r   r   r   Út_INT_CONST_DECá  s    zCLexer.t_INT_CONST_DECc             C   s   |S )Nr   )r   r¬   r   r   r   Út_INT_CONST_CHARè  s    zCLexer.t_INT_CONST_CHARc             C   s   |S )Nr   )r   r¬   r   r   r   Út_CHAR_CONSTì  s    zCLexer.t_CHAR_CONSTc             C   s   |S )Nr   )r   r¬   r   r   r   Út_WCHAR_CONSTð  s    zCLexer.t_WCHAR_CONSTc             C   s   |S )Nr   )r   r¬   r   r   r   Út_U8CHAR_CONSTô  s    zCLexer.t_U8CHAR_CONSTc             C   s   |S )Nr   )r   r¬   r   r   r   Út_U16CHAR_CONSTø  s    zCLexer.t_U16CHAR_CONSTc             C   s   |S )Nr   )r   r¬   r   r   r   Út_U32CHAR_CONSTü  s    zCLexer.t_U32CHAR_CONSTc             C   s   d}| j ||ƒ d S )NzUnmatched ')r'   )r   r¬   r%   r   r   r   Út_UNMATCHED_QUOTE   s    zCLexer.t_UNMATCHED_QUOTEc             C   s   d|j  }| j||ƒ d S )NzInvalid char constant %s)r®   r'   )r   r¬   r%   r   r   r   Út_BAD_CHAR_CONST  s    
zCLexer.t_BAD_CHAR_CONSTc             C   s   |S )Nr   )r   r¬   r   r   r   Út_WSTRING_LITERAL
  s    zCLexer.t_WSTRING_LITERALc             C   s   |S )Nr   )r   r¬   r   r   r   Út_U8STRING_LITERAL  s    zCLexer.t_U8STRING_LITERALc             C   s   |S )Nr   )r   r¬   r   r   r   Út_U16STRING_LITERAL  s    zCLexer.t_U16STRING_LITERALc             C   s   |S )Nr   )r   r¬   r   r   r   Út_U32STRING_LITERAL  s    zCLexer.t_U32STRING_LITERALc             C   s   d}| j ||ƒ d S )Nz#String contains invalid escape code)r'   )r   r¬   r%   r   r   r   Út_BAD_STRING_LITERAL  s    zCLexer.t_BAD_STRING_LITERALc             C   s2   | j j|jdƒ|_|jdkr.| j|jƒr.d|_|S )NrU   rV   )Úkeyword_mapÚgetr®   r«   r
   )r   r¬   r   r   r   Út_ID!  s    zCLexer.t_IDc             C   s"   dt |jd ƒ }| j||ƒ d S )NzIllegal character %sr   )Úreprr®   r'   )r   r¬   r%   r   r   r   Út_error(  s    zCLexer.t_error)$r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   rH   rI   rJ   rK   )rL   rM   rN   rO   rP   rQ   rR   rS   )DrU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   r_   r`   ra   rb   rc   rd   re   rf   rg   rh   ri   rj   rk   rl   rm   rn   ro   rp   rq   rr   rs   rt   ru   rv   rw   rx   ry   rz   r{   r|   r}   r~   r   r€   r�   r‚   rƒ   r„   r…   r†   r‡   rˆ   r‰   rŠ   r‹   rŒ   r�   rŽ   r�   r�   r‘   r’   r“   r”   r•   r–   r—   r˜   ©r£   r¤   ©r¥   r¤   )ræ   rç   )�Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r"   r'   r#   ÚkeywordsZkeywords_newrá   ÚkeywordÚlowerÚupperÚtokensÚ
identifierZ
hex_prefixZ
hex_digitsÚ
bin_prefixZ
bin_digitsZinteger_suffix_optZdecimal_constantZoctal_constantZhex_constantZbin_constantZbad_octal_constantZsimple_escapeZdecimal_escapeZ
hex_escapeZ
bad_escapeZescape_sequenceZescape_sequence_start_in_stringZcconst_charZ
char_constZwchar_constZu8char_constZu16char_constZu32char_constZmulticharacter_constantZunmatched_quoteZbad_char_constZstring_charZstring_literalZwstring_literalZu8string_literalZu16string_literalZu32string_literalZbad_string_literalZexponent_partZfractional_constantZfloating_constantZbinary_exponent_partZhex_fractional_constantZhex_floating_constantZstatesr­   r   r±   r²   rµ   r·   Zt_ppline_ignorer¸   r¹   rº   Zt_pppragma_ignorer»   r¼   Zt_ignorer¾   Zt_PLUSZt_MINUSZt_TIMESZt_DIVIDEZt_MODZt_ORZt_ANDZt_NOTZt_XORZt_LSHIFTZt_RSHIFTZt_LORZt_LANDZt_LNOTZt_LTZt_GTZt_LEZt_GEZt_EQZt_NEZt_EQUALSZt_TIMESEQUALZ
t_DIVEQUALZ
t_MODEQUALZt_PLUSEQUALZt_MINUSEQUALZt_LSHIFTEQUALZt_RSHIFTEQUALZ
t_ANDEQUALZ	t_OREQUALZ
t_XOREQUALZ
t_PLUSPLUSZt_MINUSMINUSZt_ARROWZt_CONDOPZt_LPARENZt_RPARENZ
t_LBRACKETZ
t_RBRACKETZt_COMMAZt_PERIODZt_SEMIZt_COLONZ
t_ELLIPSISrË   rÌ   Zt_STRING_LITERALrÍ   rÎ   rÏ   rÐ   rÑ   rÒ   rÓ   rÔ   rÕ   rÖ   r×   rØ   rÙ   rÚ   rÛ   rÜ   rÝ   rÞ   rß   rà   rã   rå   r   r   r   r   r      sn  !
        

(                                 	$ 	r   )r   Zplyr   Zply.lexr   r   r   r   r   r   r   Ú<module>	   s   