File: //var/opt/nydus/ops/pycparser/__pycache__/c_parser.cpython-39.pyc
a
�,�h�& � @ sd d dl mZ d dlmZ d dlmZ d dlmZmZm Z m
Z
d dlmZm
Z
e
G dd� de��ZdS ) � )�yacc)�c_ast)�CLexer)� PLYParser�
ParseError�
parameterized�template)�fix_switch_cases�fix_atomic_specifiersc @ s� e Zd Zdedddddfdd�Z�dgdd �Zd
d� Zdd
� Zdd� Zdd� Z dd� Z
dd� Zdd� Zdd� Z
dd� Zdd� Zdd� Zd d!� Z�dhd"d#�Z�did$d%�Zd&d'� Zd(d)� Zd*Zd+d,� Zd-d.� Zd/d0� Zd1d2� Zd3d4� Zd5d6� Zd7d8� Zd9d:� Zd;d<� Zd=d>� Z d?d@� Z!dAdB� Z"dCdD� Z#dEdF� Z$dGdH� Z%dIdJ� Z&dKdL� Z'dMdN� Z(dOdP� Z)dQdR� Z*dSdT� Z+dUdV� Z,dWdX� Z-dYdZ� Z.d[d\� Z/d]d^� Z0d_d`� Z1dadb� Z2dcdd� Z3dedf� Z4dgdh� Z5didj� Z6dkdl� Z7dmdn� Z8dodp� Z9dqdr� Z:dsdt� Z;dudv� Z<dwdx� Z=dydz� Z>d{d|� Z?d}d~� Z@dd�� 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�� ZWeXd�d�d��d�d�� �ZYeXd�d�d��d�d�� �ZZeXd�d�d��d�d�� �Z[eXd�d��d�d�� �Z\eXd�d�d��d�d�� �Z]eXd�d�d��d�d�� �Z^eXd�d�d��d�d�� �Z_eXd�d�d��d�d�� �Z`d�d�� Zad�dÄ Zbd�dń Zcd�dDŽ 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.�d/� Z��d0�d1� Z��d2�d3� Z��d4�d5� Z��d6�d7� Z��d8�d9� Z��d:�d;� Z��d<�d=� Z��d>�d?� Z��d@�dA� Z��dB�dC� Z��dD�dE� Z��dF�dG� Z��dH�dI� Z��dJ�dK� Z��dL�dM� Z��dN�dO� Z��dP�dQ� Z��dR�dS� Z��dT�dU� Z��dV�dW� Z��dX�dY� Z��dZ�d[� Z��d\�d]� Z��d^�d_� Z��d`�da� Z��db�dc� Z��dd�de� Z��dfS (j �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�clex�build�tokensZ_create_opt_ruler �cparser�dict�_scope_stack�_last_yielded_token)
�selfZlex_optimize�lexerr Z
yacc_optimizeZyacctabZ
yacc_debugZtaboutputdirZrules_with_optZrule� r �C/opt/nydus/tmp/pip-target-wkfpz8uv/lib/python/pycparser/c_parser.py�__init__ s2 :��
�
zCParser.__init__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)
debug:
Debug flag to YACC
N)�inputr r )r �filenameZreset_linenor r r r �parse)r �textr$ r r 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 |<