File: //var/opt/nydus/ops/pycparser/__pycache__/_ast_gen.cpython-39.pyc
a
�,�h;) � @ s8 d dl mZ G dd� de�ZG dd� de�ZdZdZdS ) � )�Templatec @ s( e Zd Zd dd�Zd
dd�Zdd� ZdS )�ASTCodeGenerator�
_c_ast.cfgc C s || _ dd� | �|�D �| _dS )zN Initialize the code generator from a configuration
file.
c S s g | ]\}}t ||��qS � )�NodeCfg)�.0�name�contentsr r �C/opt/nydus/tmp/pip-target-wkfpz8uv/lib/python/pycparser/_ast_gen.py�
<listcomp> s �z-ASTCodeGenerator.__init__.<locals>.<listcomp>N)�cfg_filename�
parse_cfgfile�node_cfg)�selfr r r r
�__init__ s �zASTCodeGenerator.__init__Nc C sD t t�j| jd�}|t7 }| jD ]}||�� d 7 }q |�|� dS )z< Generates the code into file, an open file buffer.
)r z
N)r �_PROLOGUE_COMMENT�
substituter �_PROLOGUE_CODEr �generate_source�write)r �file�srcr r r r
�generate s �
zASTCodeGenerator.generatec
c s� t |d���}|D ]�}|�� }|r|�d�r,q|�d�}|�d�}|�d�}|dk sb||ksb||krrtd||f ��|d|� }||d |� }|r�d d
� |�d�D �ng } || fV qW d � n1 s�0 Y dS )ze Parse the configuration file and yield pairs of
(name, contents) for each node.
�r�#�:�[�]� zInvalid line in %s:
%s
Nc S s g | ]}|� � �qS r )�strip)r �vr r r
r 6 � z2ASTCodeGenerator.parse_cfgfile.<locals>.<listcomp>�,)�openr �
startswith�find�RuntimeError�split)
r �filename�f�lineZcolon_iZ
lbracket_iZ
rbracket_ir �valZvallistr r r
r
% s
zASTCodeGenerator.parse_cfgfile)r )N)�__name__�
__module__�__qualname__r r r
r r r r
r s
r c @ s@ e Zd ZdZdd� Zdd� Zdd� Zdd � Zd
d� Zdd
� Z dS )r z� Node configuration.
name: node name
contents: a list of contents - attributes and child nodes
See comment at the top of the configuration file for details.
c C s~ || _ g | _g | _g | _g | _|D ]V}|�d�}| j�|� |�d�rT| j�|� q"|�d�rl| j�|� q"| j�|� q"d S )N�*z**)r �all_entries�attr�child� seq_child�rstrip�append�endswith)r r r �entryZclean_entryr r r
r B s
zNodeCfg.__init__c C s<