????

Your IP : 3.16.139.90


Current Path : /lib/python3.9/site-packages/pycparser/__pycache__/
Upload File :
Current File : //lib/python3.9/site-packages/pycparser/__pycache__/plyparser.cpython-39.pyc

a

��_^	�@sTddlZGdd�de�ZGdd�de�ZGdd�de�Zdd	�Zd
d�Zdd
�ZdS)�Nc@s&eZdZdZdZddd�Zdd�ZdS)	�Coordz� Coordinates of a syntactic element. Consists of:
            - File name
            - Line number
            - (optional) column number, for the Lexer
    )�file�line�column�__weakref__NcCs||_||_||_dS�N�rrr)�selfrrr�r
�7/usr/lib/python3.9/site-packages/pycparser/plyparser.py�__init__szCoord.__init__cCs(d|j|jf}|jr$|d|j7}|S)Nz%s:%sz:%sr)r	�strr
r
r�__str__sz
Coord.__str__)N)�__name__�
__module__�__qualname__�__doc__�	__slots__rrr
r
r
rr
s
rc@seZdZdS)�
ParseErrorN)rrrr
r
r
rr�rc@s.eZdZdd�Zd
dd�Zdd�Zdd	�ZdS)�	PLYParsercCs<|d}dd�}d||f|_d||_t|j|j|�dS)z� Given a rule name, creates an optional ply.yacc rule
            for it. The name of the optional rule is
            <rulename>_opt
        Z_optcSs|d|d<dS)N�rr
�r	�pr
r
r�optrule*sz+PLYParser._create_opt_rule.<locals>.optrulez%s : empty
| %szp_%sN)rr�setattr�	__class__)r	ZrulenameZoptnamerr
r
r�_create_opt_rule#s

zPLYParser._create_opt_ruleNcCst|jj||d�S)Nr)rZclex�filename)r	�linenorr
r
r�_coord1s
�zPLYParser._coordcCsF|jjj�dd|�|��}|dkr&d}|�|�|}|�|�|�|�S)z� Returns the coordinates for the YaccProduction objet 'p' indexed
            with 'token_idx'. The coordinate includes the 'lineno' and
            'column'. Both follow the lex semantic, starting from 1.
        �
r���)ZlexerZlexdata�rfindZlexposr r)r	rZ	token_idxZlast_crrr
r
r�_token_coord7s
zPLYParser._token_coordcCstd||f��dS)Nz%s: %s)r)r	�msgZcoordr
r
r�_parse_errorBszPLYParser._parse_error)N)rrrrr r$r&r
r
r
rr"s
rcs�fdd�}|S)a� Decorator to create parameterized rules.

    Parameterized rule methods must be named starting with 'p_' and contain
    'xxx', and their docstrings may contain 'xxx' and 'yyy'. These will be
    replaced by the given parameter tuples. For example, ``p_xxx_rule()`` with
    docstring 'xxx_rule  : yyy' when decorated with
    ``@parameterized(('id', 'ID'))`` produces ``p_id_rule()`` with the docstring
    'id_rule  : ID'. Using multiple tuples produces multiple rules.
    cs
�|_|Sr)�_params)Z	rule_func��paramsr
r�decoratePszparameterized.<locals>.decorater
)r)r*r
r(r�
parameterizedFs
r+cCsld}t|�D]Z}|�d�rt||�}t|d�rt||�|jdurNt||�q|stjdt	dd�d}q|S)	z� Class decorator to generate rules from parameterized rule templates.

    See `parameterized` for more information on parameterized rules.
    FZp_r'Nz@parsing methods must have __doc__ for pycparser to work properly�)�
stacklevelT)
�dir�
startswith�getattr�hasattr�delattrr�_create_param_rules�warnings�warn�RuntimeWarning)�clsZissued_nodoc_warningZ	attr_name�methodr
r
r�templateVs 




�r9csV�jD]J\}}�fdd�}�j�d|��d|�|_�j�d|�|_t||j|�qdS)a Create ply.yacc rules based on a parameterized rule function

    Generates new methods (one per each pair of parameters) based on the
    template rule function `func`, and attaches them to `cls`. The rule
    function's parameters must be accessible via its `_params` attribute.
    cs�||�dSrr
r��funcr
r�
param_rule}sz'_create_param_rules.<locals>.param_rule�xxx�yyyN)r'r�replacerr)r7r;r=r>r<r
r:rr3ts
r3)	r4�objectr�	Exceptionrrr+r9r3r
r
r
r�<module>s$