__NVc@sRddlZddlZddlmZddlmZdefdYZdS(iN(tlex(tTOKENtCLexerc<BseZdZdZdZdZdZdZdZdZ dZ dZ iZ xPe D]HZ e d kre e d.dZ?dZ@dZAdZBdZCdZDdZEdZFdZGdZHdZIdZJdZKdZLdZMdZNdZOdZPdZQdZRdZSdZTdZUdZVdZWdZXdZYdZZdZ[dZ\dZ]dZ^dZ_dZ`dZadZbdZcdZddZedZfdZgdZhdZidZjdZke1ddZle1ddZme&Zne1e+dZoe1e.dZpe1edZqe1edZre1edZse1edZte1edZue1e!dZve1e"dZwe1e#dZxe1e$dZye1e'dZze1e(dZ{e1edZ|dZ}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. cCs^||_||_||_||_d|_d|_tjd|_ tjd|_ dS(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. ts([ ]*line\W)|([ ]*\d+)s [ ]*pragma\WN( t error_functon_lbrace_functon_rbrace_functtype_lookup_functfilenametNonet last_tokentretcompilet line_patterntpragma_pattern(tselfRRRR((s5/usr/lib/python2.7/site-packages/pycparser/c_lexer.pyt__init__s      cKstjd|||_dS(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__ tobjectN(Rtlexer(Rtkwargs((s5/usr/lib/python2.7/site-packages/pycparser/c_lexer.pytbuild:scCsd|j_dS(s? Resets the internal line number counter of the lexer. iN(Rtlineno(R((s5/usr/lib/python2.7/site-packages/pycparser/c_lexer.pyt reset_linenoDscCs|jj|dS(N(Rtinput(Rttext((s5/usr/lib/python2.7/site-packages/pycparser/c_lexer.pyRIscCs|jj|_|jS(N(RttokenR (R((s5/usr/lib/python2.7/site-packages/pycparser/c_lexer.pyRLscCs)|jjjdd|j}|j|S(s3 Find the column of the token in its line. s i(Rtlexdatatrfindtlexpos(RRtlast_cr((s5/usr/lib/python2.7/site-packages/pycparser/c_lexer.pytfind_tok_columnPscCs>|j|}|j||d|d|jjddS(Nii(t_make_tok_locationRRtskip(RtmsgRtlocation((s5/usr/lib/python2.7/site-packages/pycparser/c_lexer.pyt_error[scCs|j|j|fS(N(RR(RR((s5/usr/lib/python2.7/site-packages/pycparser/c_lexer.pyR`st_BOOLt_COMPLEXtAUTOtBREAKtCASEtCHARtCONSTtCONTINUEtDEFAULTtDOtDOUBLEtELSEtENUMtEXTERNtFLOATtFORtGOTOtIFtINLINEtINTtLONGtREGISTERtOFFSETOFtRESTRICTtRETURNtSHORTtSIGNEDtSIZEOFtSTATICtSTRUCTtSWITCHtTYPEDEFtUNIONtUNSIGNEDtVOIDtVOLATILEtWHILEt_Boolt_ComplextIDtTYPEIDt INT_CONST_DECt INT_CONST_OCTt INT_CONST_HEXt INT_CONST_BINt FLOAT_CONSTtHEX_FLOAT_CONSTt CHAR_CONSTt WCHAR_CONSTtSTRING_LITERALtWSTRING_LITERALtPLUStMINUStTIMEStDIVIDEtMODtORtANDtNOTtXORtLSHIFTtRSHIFTtLORtLANDtLNOTtLTtLEtGTtGEtEQtNEtEQUALSt TIMESEQUALtDIVEQUALtMODEQUALt PLUSEQUALt MINUSEQUALt LSHIFTEQUALt RSHIFTEQUALtANDEQUALtXOREQUALtOREQUALtPLUSPLUSt MINUSMINUStARROWtCONDOPtLPARENtRPARENtLBRACKETtRBRACKETtLBRACEtRBRACEtCOMMAtPERIODtSEMItCOLONtELLIPSIStPPHASHs[a-zA-Z_$][0-9a-zA-Z_$]*s0[xX]s [0-9a-fA-F]+s0[bB]s[01]+sD(([uU]ll)|([uU]LL)|(ll[uU]?)|(LL[uU]?)|([uU][lL])|([lL][uU]?)|[uU])?s(0s)|([1-9][0-9]*t)s0[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'tLs('s*\n)|('s*$)s[^' ]+')|('')|('s [^'\n]*')s ([^"\\\n]|t"s*"t*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]?)tpplinet exclusivetpppragmacCs|jj|jjd|jjrG|jjdd|_|_nD|j j|jjd|jjr~|jjdn d|_ |SdS(s[ \t]*\#tposRRRN( R tmatchRRRtbeginR tpp_linet pp_filenameRttype(Rtt((s5/usr/lib/python2.7/site-packages/pycparser/c_lexer.pytt_PPHASHs$$ cCsD|jdkr"|jd|n|jjdjd|_dS(Ns$filename before line number in #lineR(RR R#tvaluetlstriptrstripR(RR((s5/usr/lib/python2.7/site-packages/pycparser/c_lexer.pytt_ppline_FILENAMEscCs"|jdkr|j|_ndS(N(RR R(RR((s5/usr/lib/python2.7/site-packages/pycparser/c_lexer.pytt_ppline_LINE_NUMBER scCsi|jdkr"|jd|n3t|j|j_|jdk rU|j|_n|jjddS(s\nsline number missing in #linetINITIALN( RR R#tintRRRRR(RR((s5/usr/lib/python2.7/site-packages/pycparser/c_lexer.pytt_ppline_NEWLINEs cCsdS(tlineN((RR((s5/usr/lib/python2.7/site-packages/pycparser/c_lexer.pytt_ppline_PPLINE ss cCs|jd|dS(Nsinvalid #line directive(R#(RR((s5/usr/lib/python2.7/site-packages/pycparser/c_lexer.pytt_ppline_error&scCs&|jjd7_|jjddS(s\niRN(RRR(RR((s5/usr/lib/python2.7/site-packages/pycparser/c_lexer.pytt_pppragma_NEWLINE,scCsdS(tpragmaN((RR((s5/usr/lib/python2.7/site-packages/pycparser/c_lexer.pytt_pppragma_PPPRAGMA1ss$ <>.-{}();=+-*/$%@&^~!?:,0123456789cCsdS(N((RR((s5/usr/lib/python2.7/site-packages/pycparser/c_lexer.pytt_pppragma_STR7scCsdS(N((RR((s5/usr/lib/python2.7/site-packages/pycparser/c_lexer.pyt t_pppragma_ID:scCs|jd|dS(Nsinvalid #pragma directive(R#(RR((s5/usr/lib/python2.7/site-packages/pycparser/c_lexer.pytt_pppragma_error=scCs"|jj|jjd7_dS(s\n+s N(RRRtcount(RR((s5/usr/lib/python2.7/site-packages/pycparser/c_lexer.pyt t_NEWLINEFss\+t-s\*t/t%s\|t&t~s\^s<>s\|\|s&&t!ts<=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\{cCs|j|S(N(R(RR((s5/usr/lib/python2.7/site-packages/pycparser/c_lexer.pytt_LBRACEs s\}cCs|j|S(N(R(RR((s5/usr/lib/python2.7/site-packages/pycparser/c_lexer.pytt_RBRACEs cCs|S(N((RR((s5/usr/lib/python2.7/site-packages/pycparser/c_lexer.pyt t_FLOAT_CONSTscCs|S(N((RR((s5/usr/lib/python2.7/site-packages/pycparser/c_lexer.pytt_HEX_FLOAT_CONSTscCs|S(N((RR((s5/usr/lib/python2.7/site-packages/pycparser/c_lexer.pytt_INT_CONST_HEXscCs|S(N((RR((s5/usr/lib/python2.7/site-packages/pycparser/c_lexer.pytt_INT_CONST_BINscCsd}|j||dS(NsInvalid octal constant(R#(RRR!((s5/usr/lib/python2.7/site-packages/pycparser/c_lexer.pytt_BAD_CONST_OCTscCs|S(N((RR((s5/usr/lib/python2.7/site-packages/pycparser/c_lexer.pytt_INT_CONST_OCTscCs|S(N((RR((s5/usr/lib/python2.7/site-packages/pycparser/c_lexer.pytt_INT_CONST_DECscCs|S(N((RR((s5/usr/lib/python2.7/site-packages/pycparser/c_lexer.pyt t_CHAR_CONSTscCs|S(N((RR((s5/usr/lib/python2.7/site-packages/pycparser/c_lexer.pyt t_WCHAR_CONSTscCsd}|j||dS(Ns Unmatched '(R#(RRR!((s5/usr/lib/python2.7/site-packages/pycparser/c_lexer.pytt_UNMATCHED_QUOTEscCs!d|j}|j||dS(NsInvalid char constant %s(RR#(RRR!((s5/usr/lib/python2.7/site-packages/pycparser/c_lexer.pytt_BAD_CHAR_CONSTs cCs|S(N((RR((s5/usr/lib/python2.7/site-packages/pycparser/c_lexer.pytt_WSTRING_LITERALscCsd}|j||dS(Ns#String contains invalid escape code(R#(RRR!((s5/usr/lib/python2.7/site-packages/pycparser/c_lexer.pytt_BAD_STRING_LITERALscCsL|jj|jd|_|jdkrH|j|jrHd|_n|S(NRKRL(t keyword_maptgetRRR(RR((s5/usr/lib/python2.7/site-packages/pycparser/c_lexer.pytt_IDs! cCs+dt|jd}|j||dS(NsIllegal character %si(treprRR#(RRR!((s5/usr/lib/python2.7/site-packages/pycparser/c_lexer.pytt_errors(%R$R%R&R'R(R)R*R+R,R-R.R/R0R1R2R3R4R5R6R7R8R9R:R;R<R=R>R?R@RARBRCRDRERFRGRH(;sIDsTYPEIDRMRNRORPRQRRRSRTRURVRWRXRYRZR[R\R]R^R_R`RaRbRcRdReRfRgRhRiRjRkRlRmRnRoRpRqRrRsRtRuRvRwRxRyRzR{R|R}R~RRRRRRsPPHASH(spplineR(spppragmaR(~t__name__t __module__t__doc__RRRRRRR#RtkeywordsRtkeywordtlowerttokenst identifiert hex_prefixt hex_digitst bin_prefixt bin_digitstinteger_suffix_opttdecimal_constanttoctal_constantt hex_constantt bin_constanttbad_octal_constantt simple_escapetdecimal_escapet hex_escapet bad_escapetescape_sequencet cconst_chart char_constt wchar_consttunmatched_quotetbad_char_constt string_chartstring_literaltwstring_literaltbad_string_literalt exponent_parttfractional_constanttfloating_constanttbinary_exponent_partthex_fractional_constantthex_floating_constanttstatesRRRRRRtt_ppline_ignoreRRRtt_pppragma_ignoreRRRtt_ignoreRtt_PLUStt_MINUStt_TIMEStt_DIVIDEtt_MODtt_ORtt_ANDtt_NOTtt_XORtt_LSHIFTtt_RSHIFTtt_LORtt_LANDtt_LNOTtt_LTtt_GTtt_LEtt_GEtt_EQtt_NEtt_EQUALSt t_TIMESEQUALt t_DIVEQUALt t_MODEQUALt t_PLUSEQUALt t_MINUSEQUALt t_LSHIFTEQUALt t_RSHIFTEQUALt t_ANDEQUALt t_OREQUALt t_XOREQUALt t_PLUSPLUSt t_MINUSMINUStt_ARROWtt_CONDOPtt_LPARENtt_RPARENt t_LBRACKETt t_RBRACKETtt_COMMAtt_PERIODtt_SEMItt_COLONt t_ELLIPSISRRtt_STRING_LITERALRRRRRRRRRRRRRRR(((s5/usr/lib/python2.7/site-packages/pycparser/c_lexer.pyRs@ !               &        (R tsystplyRtply.lexRRR(((s5/usr/lib/python2.7/site-packages/pycparser/c_lexer.pyt s