
CrX[c           @   sR   d  d l  Z  d  d l Z d d l m Z d d l m Z d e f d     YZ d S(   iNi   (   t   lex(   t   TOKENt   CLexerc        >   B   sa  e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d Z i  Z xP e D]H Z e d	 k r e e d/ <qg e d
 k r e e d0 <qg e e e j   <qg We d Z dn Z do Z dp Z dq Z dr Z ds Z dt e du e dv Z dw e Z e e e Z e e e Z dx Z dy Z dz Z d{ Z d| Z d} e d~ e d~ e d Z d e dv Z  d e  d Z! d e! Z" d e  d e  d Z# d e  d e d Z$ d e dv Z% d e% d Z& d e& Z' d e% d e e% d Z( d Z) d Z* d e* dv e) d e) d Z+ d Z, d e d e d e d Z- d e d e d~ e- dv e, d Z. d d f Z/ d   Z0 e1 e&  d    Z2 e1 e  d    Z3 d   Z4 d   Z5 d Z6 d   Z7 d   Z8 d   Z9 d Z: d   Z; d   Z< d Z= d   Z> d Z? d Z@ d ZA d ZB d ZC d ZD d ZE d ZF d ZG d ZH d ZI d ZJ d ZK d ZL d ZM d ZN d ZO d ZP d ZQ d ZR d ZS d ZT d ZU d ZV d ZW d ZX d ZY d ZZ d Z[ d Z\ d Z] d Z^ d Z_ d Z` d Za d Zb d Zc d Zd d Ze d Zf d Zg d Zh d Zi d Zj e1 d  d    Zk e1 d  d    Zl e& Zm e1 e+  d    Zn e1 e.  d    Zo e1 e  d    Zp e1 e  d    Zq e1 e  d    Zr e1 e  d    Zs e1 e  d    Zt e1 e!  d    Zu e1 e"  d    Zv e1 e#  d    Zw e1 e$  d    Zx e1 e'  d    Zy e1 e(  d    Zz e1 e  d    Z{ d   Z| RS(   s   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.
    c         C   s^   | |  _  | |  _ | |  _ | |  _ d |  _ d |  _ t j d  |  _	 t j d  |  _
 d S(   sb   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.
        t    s   ([ \t]*line\W)|([ \t]*\d+)s   [ \t]*pragma\WN(   t
   error_funct   on_lbrace_funct   on_rbrace_funct   type_lookup_funct   filenamet   Nonet
   last_tokent   ret   compilet   line_patternt   pragma_pattern(   t   selfR   R   R   R   (    (    s0   lib/python2.7/site-packages/pycparser/c_lexer.pyt   __init__   s    						c         K   s   t  j  d |  |  |  _ d S(   s    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__
        t   objectN(   R    t   lexer(   R   t   kwargs(    (    s0   lib/python2.7/site-packages/pycparser/c_lexer.pyt   build:   s    c         C   s   d |  j  _ d S(   s?    Resets the internal line number counter of the lexer.
        i   N(   R   t   lineno(   R   (    (    s0   lib/python2.7/site-packages/pycparser/c_lexer.pyt   reset_linenoD   s    c         C   s   |  j  j |  d  S(   N(   R   t   input(   R   t   text(    (    s0   lib/python2.7/site-packages/pycparser/c_lexer.pyR   I   s    c         C   s   |  j  j   |  _ |  j S(   N(   R   t   tokenR
   (   R   (    (    s0   lib/python2.7/site-packages/pycparser/c_lexer.pyR   L   s    c         C   s)   |  j  j j d d | j  } | j | S(   s3    Find the column of the token in its line.
        s   
i    (   R   t   lexdatat   rfindt   lexpos(   R   R   t   last_cr(    (    s0   lib/python2.7/site-packages/pycparser/c_lexer.pyt   find_tok_columnP   s    c         C   s>   |  j  |  } |  j | | d | d  |  j j d  d  S(   Ni    i   (   t   _make_tok_locationR   R   t   skip(   R   t   msgR   t   location(    (    s0   lib/python2.7/site-packages/pycparser/c_lexer.pyt   _error[   s    c         C   s   | j  |  j |  f S(   N(   R   R   (   R   R   (    (    s0   lib/python2.7/site-packages/pycparser/c_lexer.pyR   `   s    t   _BOOLt   _COMPLEXt   AUTOt   BREAKt   CASEt   CHARt   CONSTt   CONTINUEt   DEFAULTt   DOt   DOUBLEt   ELSEt   ENUMt   EXTERNt   FLOATt   FORt   GOTOt   IFt   INLINEt   INTt   LONGt   REGISTERt   OFFSETOFt   RESTRICTt   RETURNt   SHORTt   SIGNEDt   SIZEOFt   STATICt   STRUCTt   SWITCHt   TYPEDEFt   UNIONt   UNSIGNEDt   VOIDt   VOLATILEt   WHILEt   __INT128t   _Boolt   _Complext   IDt   TYPEIDt   INT_CONST_DECt   INT_CONST_OCTt   INT_CONST_HEXt   INT_CONST_BINt   FLOAT_CONSTt   HEX_FLOAT_CONSTt
   CHAR_CONSTt   WCHAR_CONSTt   STRING_LITERALt   WSTRING_LITERALt   PLUSt   MINUSt   TIMESt   DIVIDEt   MODt   ORt   ANDt   NOTt   XORt   LSHIFTt   RSHIFTt   LORt   LANDt   LNOTt   LTt   LEt   GTt   GEt   EQt   NEt   EQUALSt
   TIMESEQUALt   DIVEQUALt   MODEQUALt	   PLUSEQUALt
   MINUSEQUALt   LSHIFTEQUALt   RSHIFTEQUALt   ANDEQUALt   XOREQUALt   OREQUALt   PLUSPLUSt
   MINUSMINUSt   ARROWt   CONDOPt   LPARENt   RPARENt   LBRACKETt   RBRACKETt   LBRACEt   RBRACEt   COMMAt   PERIODt   SEMIt   COLONt   ELLIPSISt   PPHASHt   PPPRAGMAt   PPPRAGMASTRs   [a-zA-Z_$][0-9a-zA-Z_$]*s   0[xX]s   [0-9a-fA-F]+s   0[bB]s   [01]+sD   (([uU]ll)|([uU]LL)|(ll[uU]?)|(LL[uU]?)|([uU][lL])|([lL][uU]?)|[uU])?s   (0s   )|([1-9][0-9]*t   )s   0[0-7]*s   0[0-7]*[89]s   ([a-zA-Z._~!=&\^\-\\?'"])s   (\d+)s   (x[0-9a-fA-F]+)s#   ([\\][^a-zA-Z._~^!=&\^\-\\?'"x0-7])s   (\\(t   |s   ))s
   ([^'\\\n]|t   't   Ls   ('s   *\n)|('s   *$)s   [^'
]+')|('')|('s	   [^'\n]*')s
   ([^"\\\n]|t   "s   *"s   *?s   ([eE][-+]?[0-9]+)s   ([0-9]*\.[0-9]+)|([0-9]+\.)s   ((((s
   ?)|([0-9]+s
   ))[FfLl]?)s   ([pP][+-]?[0-9]+)s   (((s   )?\.s   )|(s   \.))t   (s   [FfLl]?)t   pplinet	   exclusivet   pppragmac         C   s   |  j  j | j j d | j j rG | j j d  d |  _ |  _ nD |  j	 j | j j d | j j r~ | j j d  n d | _
 | Sd S(   s   [ \t]*\#t   posR   R   R   N(   R   t   matchR   R   R   t   beginR	   t   pp_linet   pp_filenameR   t   type(   R   t   t(    (    s0   lib/python2.7/site-packages/pycparser/c_lexer.pyt   t_PPHASH   s    $$	c         C   sD   |  j  d  k r" |  j d |  n | j j d  j d  |  _ d  S(   Ns$   filename before line number in #lineR   (   R   R	   R#   t   valuet   lstript   rstripR   (   R   R   (    (    s0   lib/python2.7/site-packages/pycparser/c_lexer.pyt   t_ppline_FILENAME  s    c         C   s"   |  j  d  k r | j |  _  n  d  S(   N(   R   R	   R   (   R   R   (    (    s0   lib/python2.7/site-packages/pycparser/c_lexer.pyt   t_ppline_LINE_NUMBER  s    c         C   si   |  j  d k r" |  j d |  n3 t |  j   |  j _ |  j d k	 rU |  j |  _ n  | j j d  d S(   s   \ns   line number missing in #linet   INITIALN(	   R   R	   R#   t   intR   R   R   R   R   (   R   R   (    (    s0   lib/python2.7/site-packages/pycparser/c_lexer.pyt   t_ppline_NEWLINE  s    c         C   s   d S(   t   lineN(    (   R   R   (    (    s0   lib/python2.7/site-packages/pycparser/c_lexer.pyt   t_ppline_PPLINE!  s    s    	c         C   s   |  j  d |  d  S(   Ns   invalid #line directive(   R#   (   R   R   (    (    s0   lib/python2.7/site-packages/pycparser/c_lexer.pyt   t_ppline_error'  s    c         C   s&   | j  j d 7_ | j  j d  d S(   s   \ni   R   N(   R   R   R   (   R   R   (    (    s0   lib/python2.7/site-packages/pycparser/c_lexer.pyt   t_pppragma_NEWLINE-  s    c         C   s   | S(   t   pragma(    (   R   R   (    (    s0   lib/python2.7/site-packages/pycparser/c_lexer.pyt   t_pppragma_PPPRAGMA2  s    c         C   s   d | _  | S(   s   .+R   (   R   (   R   R   (    (    s0   lib/python2.7/site-packages/pycparser/c_lexer.pyt   t_pppragma_STR8  s    	c         C   s   |  j  d |  d  S(   Ns   invalid #pragma directive(   R#   (   R   R   (    (    s0   lib/python2.7/site-packages/pycparser/c_lexer.pyt   t_pppragma_error=  s    c         C   s"   | j  j | j j d  7_ d S(   s   \n+s   
N(   R   R   R   t   count(   R   R   (    (    s0   lib/python2.7/site-packages/pycparser/c_lexer.pyt	   t_NEWLINEF  s    s   \+t   -s   \*t   /t   %s   \|t   &t   ~s   \^s   <<s   >>s   \|\|s   &&t   !t   <t   >s   <=s   >=s   ==s   !=t   =s   \*=s   /=s   %=s   \+=s   -=s   <<=s   >>=s   &=s   \|=s   \^=s   \+\+s   --s   ->s   \?s   \(s   \)s   \[s   \]t   ,s   \.t   ;t   :s   \.\.\.s   \{c         C   s   |  j    | S(   N(   R   (   R   R   (    (    s0   lib/python2.7/site-packages/pycparser/c_lexer.pyt   t_LBRACE  s    
s   \}c         C   s   |  j    | S(   N(   R   (   R   R   (    (    s0   lib/python2.7/site-packages/pycparser/c_lexer.pyt   t_RBRACE  s    
c         C   s   | S(   N(    (   R   R   (    (    s0   lib/python2.7/site-packages/pycparser/c_lexer.pyt   t_FLOAT_CONST  s    c         C   s   | S(   N(    (   R   R   (    (    s0   lib/python2.7/site-packages/pycparser/c_lexer.pyt   t_HEX_FLOAT_CONST  s    c         C   s   | S(   N(    (   R   R   (    (    s0   lib/python2.7/site-packages/pycparser/c_lexer.pyt   t_INT_CONST_HEX  s    c         C   s   | S(   N(    (   R   R   (    (    s0   lib/python2.7/site-packages/pycparser/c_lexer.pyt   t_INT_CONST_BIN  s    c         C   s   d } |  j  | |  d  S(   Ns   Invalid octal constant(   R#   (   R   R   R!   (    (    s0   lib/python2.7/site-packages/pycparser/c_lexer.pyt   t_BAD_CONST_OCT  s    c         C   s   | S(   N(    (   R   R   (    (    s0   lib/python2.7/site-packages/pycparser/c_lexer.pyt   t_INT_CONST_OCT  s    c         C   s   | S(   N(    (   R   R   (    (    s0   lib/python2.7/site-packages/pycparser/c_lexer.pyt   t_INT_CONST_DEC  s    c         C   s   | S(   N(    (   R   R   (    (    s0   lib/python2.7/site-packages/pycparser/c_lexer.pyt   t_CHAR_CONST  s    c         C   s   | S(   N(    (   R   R   (    (    s0   lib/python2.7/site-packages/pycparser/c_lexer.pyt   t_WCHAR_CONST  s    c         C   s   d } |  j  | |  d  S(   Ns   Unmatched '(   R#   (   R   R   R!   (    (    s0   lib/python2.7/site-packages/pycparser/c_lexer.pyt   t_UNMATCHED_QUOTE  s    c         C   s!   d | j  } |  j | |  d  S(   Ns   Invalid char constant %s(   R   R#   (   R   R   R!   (    (    s0   lib/python2.7/site-packages/pycparser/c_lexer.pyt   t_BAD_CHAR_CONST  s    c         C   s   | S(   N(    (   R   R   (    (    s0   lib/python2.7/site-packages/pycparser/c_lexer.pyt   t_WSTRING_LITERAL  s    c         C   s   d } |  j  | |  d  S(   Ns#   String contains invalid escape code(   R#   (   R   R   R!   (    (    s0   lib/python2.7/site-packages/pycparser/c_lexer.pyt   t_BAD_STRING_LITERAL  s    c         C   sL   |  j  j | j d  | _ | j d k rH |  j | j  rH d | _ n  | S(   NRL   RM   (   t   keyword_mapt   getR   R   R   (   R   R   (    (    s0   lib/python2.7/site-packages/pycparser/c_lexer.pyt   t_ID  s    !c         C   s+   d t  | j d  } |  j | |  d  S(   Ns   Illegal character %si    (   t   reprR   R#   (   R   R   R!   (    (    s0   lib/python2.7/site-packages/pycparser/c_lexer.pyt   t_error  s    (&   R$   R%   R&   R'   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   (=   RL   RM   RN   RO   RP   RQ   RR   RS   RT   RU   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   (}   t   __name__t
   __module__t   __doc__R   R   R   R   R   R   R#   R   t   keywordsR   t   keywordt   lowert   tokenst
   identifiert
   hex_prefixt
   hex_digitst
   bin_prefixt
   bin_digitst   integer_suffix_optt   decimal_constantt   octal_constantt   hex_constantt   bin_constantt   bad_octal_constantt   simple_escapet   decimal_escapet
   hex_escapet
   bad_escapet   escape_sequencet   cconst_chart
   char_constt   wchar_constt   unmatched_quotet   bad_char_constt   string_chart   string_literalt   wstring_literalt   bad_string_literalt   exponent_partt   fractional_constantt   floating_constantt   binary_exponent_partt   hex_fractional_constantt   hex_floating_constantt   statesR   R   R   R   R   R   t   t_ppline_ignoreR   R   R   t   t_pppragma_ignoreR   R   t   t_ignoreR   t   t_PLUSt   t_MINUSt   t_TIMESt   t_DIVIDEt   t_MODt   t_ORt   t_ANDt   t_NOTt   t_XORt   t_LSHIFTt   t_RSHIFTt   t_LORt   t_LANDt   t_LNOTt   t_LTt   t_GTt   t_LEt   t_GEt   t_EQt   t_NEt   t_EQUALSt   t_TIMESEQUALt
   t_DIVEQUALt
   t_MODEQUALt   t_PLUSEQUALt   t_MINUSEQUALt   t_LSHIFTEQUALt   t_RSHIFTEQUALt
   t_ANDEQUALt	   t_OREQUALt
   t_XOREQUALt
   t_PLUSPLUSt   t_MINUSMINUSt   t_ARROWt   t_CONDOPt   t_LPARENt   t_RPARENt
   t_LBRACKETt
   t_RBRACKETt   t_COMMAt   t_PERIODt   t_SEMIt   t_COLONt
   t_ELLIPSISR   R   t   t_STRING_LITERALR   R   R   R   R   R   R   R   R   R   R   R   R   R   R   (    (    (    s0   lib/python2.7/site-packages/pycparser/c_lexer.pyR      sB  	!	
						                                 	
	

&											(   R   t   syst   plyR    t   ply.lexR   R   R   (    (    (    s0   lib/python2.7/site-packages/pycparser/c_lexer.pyt   <module>	   s   