__NVc@sddlZddlmZddlmZddlmZddlmZm Z m Z ddl m Z defd YZ ed krddlZddlZddlZndS( iN(tyacci(tc_ast(tCLexer(t PLYParsertCoordt ParseError(tfix_switch_casestCParserc Bs{eZedededdZdddZdZdZdZd Z d Z d Z d Z d Z dZdZdZdZdZedZdZdZddddddddddf Zd)Zd*Zd+Zd,Zd-Zd.Zd/Zd0Zd1Zd2Z d3Z!d4Z"d5Z#d6Z$d7Z%d8Z&d9Z'd:Z(d;Z)d<Z*d=Z+d>Z,d?Z-d@Z.dAZ/dBZ0dCZ1dDZ2dEZ3dFZ4dGZ5dHZ6dIZ7dJZ8dKZ9dLZ:dMZ;dNZ<dOZ=dPZ>dQZ?dRZ@dSZAdTZBdUZCdVZDdWZEdXZFdYZGdZZHd[ZId\ZJd]ZKd^ZLd_ZMd`ZNdaZOdbZPdcZQddZRdeZSdfZTdgZUdhZVdiZWdjZXdkZYdlZZdmZ[dnZ\doZ]dpZ^dqZ_drZ`dsZadtZbduZcdvZddwZedxZfdyZgdzZhd{Zid|Zjd}Zkd~ZldZmdZndZodZpdZqdZrdZsdZtdZudZvdZwdZxdZydZzdZ{dZ|dZ}dZ~dZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZRS(spycparser.lextabspycparser.yacctabtc Cstd|jd|jd|jd|j|_|jjd|d|d||jj|_dd d d d d ddddddddg}x|D]}|j|qWt j d|ddd|d|d|d||_ t g|_ d|_dS(s Create a new CParser. Some arguments for controlling the debug/optimization level of the parser are provided. The defaults are tuned for release/performance mode. The simple rules for using them are: *) When tweaking CParser/CLexer, set these to False *) When releasing a stable parser, set to True lex_optimize: Set to False when you're modifying the lexer. Otherwise, changes in the lexer won't be used, if some lextab.py file exists. When releasing with a stable lexer, set to True to save the re-generation of the lexer table on each run. lextab: Points to the lex table that's used for optimized mode. Only if you're modifying the lexer and want some tests to avoid re-generating the table, make this point to a local lex table file (that's been earlier generated with lex_optimize=True) yacc_optimize: Set to False when you're modifying the parser. Otherwise, changes in the parser won't be used, if some parsetab.py file exists. When releasing with a stable parser, set to True to save the re-generation of the parser table on each run. yacctab: Points to the yacc table that's used for optimized mode. Only if you're modifying the parser, make this point to a local yacc table file yacc_debug: Generate a parser.out file that explains how yacc built the parsing table from the grammar. taboutputdir: Set this parameter to control the location of generated lextab and yacctab files. t error_functon_lbrace_functon_rbrace_functtype_lookup_functoptimizetlextabt outputdirtabstract_declaratortassignment_expressiontdeclaration_listtdeclaration_specifierst designationt expressiontidentifier_listtinit_declarator_listtinitializer_listtparameter_type_listtspecifier_qualifier_listtblock_item_listttype_qualifier_listtstruct_declarator_listtmoduletstartttranslation_unit_or_emptytdebugt tabmoduleN(Rt_lex_error_funct_lex_on_lbrace_funct_lex_on_rbrace_funct_lex_type_lookup_functclextbuildttokenst_create_opt_ruleRtcparsertdictt _scope_stacktNonet_last_yielded_token( tselft lex_optimizeRt yacc_optimizetyacctabt yacc_debugt taboutputdirtrules_with_opttrule((s6/usr/lib/python2.7/site-packages/pycparser/c_parser.pyt__init__sF5        icCsS||j_|jjtg|_d|_|jjd|d|jd|S(s& Parses C code and returns an AST. text: A string containing the C source code filename: Name of the file being parsed (for meaningful error messages) debuglevel: Debug level to yacc tinputtlexerR!N( R'tfilenamet reset_linenoR,R-R.R/R+tparse(R0ttextR;t debuglevel((s6/usr/lib/python2.7/site-packages/pycparser/c_parser.pyR=~s     cCs|jjtdS(N(R-tappendR,(R0((s6/usr/lib/python2.7/site-packages/pycparser/c_parser.pyt _push_scopescCs,t|jdkst|jjdS(Ni(tlenR-tAssertionErrortpop(R0((s6/usr/lib/python2.7/site-packages/pycparser/c_parser.pyt _pop_scopescCsE|jdj|ts0|jd||nt|jd|s     cCs|d|ds$     c Cs:|jd|ddtd|dddg|d abstract_declarator : direct_abstract_declarator iiN((R0R((s6/usr/lib/python2.7/site-packages/pycparser/c_parser.pytp_abstract_declarator_3scCs|d|d labeled_statement : CASE constant_expression COLON statement iiiiN(RtCaseRRR(R0R((s6/usr/lib/python2.7/site-packages/pycparser/c_parser.pytp_labeled_statement_2CscCs3tj|dg|j|jd|dtj|d|d|d|j|jd|dR@RBRCRERFRHRIRJRKRMRORRRSRURVRWRXRYRZR[R\R^R`RbReRgRhRiRjRl(((s6/usr/lib/python2.7/site-packages/pycparser/c_parser.pyRsF c      ) 7 -  Y          ;                 &                                                                t__main__(tretplyRRRtc_lexerRt plyparserRRRtast_transformsRRRmtpprintttimetsys(((s6/usr/lib/python2.7/site-packages/pycparser/c_parser.pyt s