Current File : //lib/python3.9/site-packages/pycparser/__pycache__/c_parser.cpython-39.pyc |
a
�,Nbq � @ sl d dl Z d dlmZ ddlmZ ddlmZ ddlmZm Z m
Z
mZmZ ddl
mZ eG dd � d e��ZdS )
� N)�yacc� )�c_ast)�CLexer)� PLYParser�Coord�
ParseError�
parameterized�template)�fix_switch_casesc @ s e Zd Zdedddddfdd�Z�dJd d
�Zdd� Zd
d� Zdd� Zdd� Z dd� Z
dd� Zdd� Zdd� Z
dd� Zdd� Zdd � Zd!d"� Z�dKd#d$�Z�dLd%d&�Zd'd(� Zd)d*� Zd+Zd,d-� Zd.d/� Zd0d1� Zd2d3� Zd4d5� Zd6d7� Zd8d9� Zd:d;� Zd<d=� Zd>d?� Z d@dA� Z!dBdC� Z"dDdE� Z#dFdG� Z$dHdI� Z%dJdK� Z&dLdM� Z'dNdO� Z(dPdQ� Z)dRdS� Z*dTdU� Z+dVdW� Z,dXdY� Z-dZd[� Z.d\d]� Z/d^d_� Z0d`da� Z1dbdc� Z2ddde� Z3dfdg� Z4dhdi� Z5djdk� Z6dldm� Z7dndo� Z8dpdq� Z9drds� Z:dtdu� Z;dvdw� Z<dxdy� Z=dzd{� Z>d|d}� Z?d~d� Z@d�d�� ZAd�d�� ZBd�d�� ZCd�d�� ZDd�d�� ZEd�d�� ZFd�d�� ZGd�d�� ZHd�d�� ZId�d�� ZJd�d�� ZKd�d�� ZLd�d�� ZMeNd�d�d��d�d�� �ZOeNd�d�d��d�d�� �ZPeNd�d�d��d�d�� �ZQeNd�d��d�d�� �ZReNd�d�d��d�d�� �ZSeNd�d�d��d�d�� �ZTeNd�d�d��d�d�� �ZUeNd�d�d��d�d�� �ZVd�d�� ZWd�d�� ZXd�d�� ZYd�d�� ZZd�d�� Z[d�d�� Z\d�d�� Z]d�d�� Z^d�d�� Z_d�d�� Z`d�d Zad�dĄ Zbd�dƄ Zcd�dȄ Zdd�dʄ Zed�d̄ Zfd�d΄ Zgd�dЄ Zhd�d҄ Zid�dԄ Zjd�dք Zkd�d Zld�dڄ Zmd�d܄ Znd�dބ Zod�d� Zpd�d� Zqd�d� Zrd�d� Zsd�d� Ztd�d� Zud�d� Zvd�d� Zwd�d� Zxd�d� Zyd�d� Zzd�d�� Z{d�d�� Z|d�d�� Z}d�d�� Z~d�d�� Zd��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�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#�d$� Z��d%�d&� Z��d'�d(� Z��d)�d*� Z��d+�d,� Z��d-�d.� Z��d/�d0� Z��d1�d2� Z��d3�d4� Z��d5�d6� Z��d7�d8� Z��d9�d:� Z��d;�d<� Z��d=�d>� Z��d?�d@� Z��dA�dB� Z��dC�dD� Z��dE�dF� Z��dG�dH� Z��dIS (M �CParserTzpycparser.lextabzpycparser.yacctabF� c
C s~ || j | j| j| jd�| _| jj|||d� | jj| _g d�}|D ]} | �| � qBtj| d||||d�| _ t
� g| _d| _dS )a 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.
lexer:
Set this parameter to define the lexer to use if
you're not using the default CLexer.
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.
)Z
error_funcZon_lbrace_funcZon_rbrace_funcZtype_lookup_func)�optimize�lextab� outputdir)Zabstract_declaratorZassignment_expressionZdeclaration_listZdeclaration_specifiers_no_typeZdesignationZ
expressionZidentifier_listZinit_declarator_listZid_init_declarator_listZinitializer_listZparameter_type_listZblock_item_listZtype_qualifier_listZstruct_declarator_listZtranslation_unit_or_empty)�module�start�debugr Z tabmoduler N)
�_lex_error_func�_lex_on_lbrace_func�_lex_on_rbrace_func�_lex_type_lookup_func�clexZbuild�tokensZ_create_opt_ruler �cparser�dict�_scope_stack�_last_yielded_token)
�selfZlex_optimize�lexerr Z
yacc_optimizeZyacctabZ
yacc_debugZtaboutputdirZrules_with_optZrule� r �6/usr/lib/python3.9/site-packages/pycparser/c_parser.py�__init__ s2 :��
�
zCParser.__init__r c C s6 || j _| j �� t� g| _d| _| jj|| j |d�S )a& 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
N)�inputr r )r �filenameZreset_linenor r r r �parse)r �textr$ Z
debuglevelr r r! r% � s
�z
CParser.parsec C s | j �t� � d S �N)r �appendr �r r r r! �_push_scope� s zCParser._push_scopec C s t | j�dksJ �| j�� d S )Nr )�lenr �popr) r r r! �
_pop_scope� s zCParser._pop_scopec C s4 | j d �|d�s"| �d| |� d| j d |<