o
    "“i  ã                   @   sT   d dl Z G dd„ deƒZG dd„ deƒZG dd„ deƒZdd	„ Zd
d„ Zdd„ ZdS )é    Nc                   @   s&   e Zd ZdZdZddd„Zdd„ ZdS )	ÚCoordzž Coordinates of a syntactic element. Consists of:
            - File name
            - Line number
            - (optional) column number, for the Lexer
    )ÚfileÚlineÚcolumnÚ__weakref__Nc                 C   s   || _ || _|| _d S ©N©r   r   r   )Úselfr   r   r   © r
   úS/var/www/html/premium_crap/venv/lib/python3.10/site-packages/pycparser/plyparser.pyÚ__init__   s   
zCoord.__init__c                 C   s(   d| j | jf }| jr|d| j 7 }|S )Nz%s:%sz:%sr   )r	   Ústrr
   r
   r   Ú__str__   s   zCoord.__str__r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	__slots__r   r   r
   r
   r
   r   r      s
    
r   c                   @   s   e Zd ZdS )Ú
ParseErrorN)r   r   r   r
   r
   r
   r   r      s    r   c                   @   s.   e Zd Zdd„ Zd
dd„Zdd„ Zdd	„ ZdS )Ú	PLYParserc                 C   s<   |d }dd„ }d||f |_ d| |_t| j|j|ƒ dS )zŽ Given a rule name, creates an optional ply.yacc rule
            for it. The name of the optional rule is
            <rulename>_opt
        Ú_optc                 S   s   |d |d< d S )Né   r   r
   ©r	   Úpr
   r
   r   Úoptrule*   ó   z+PLYParser._create_opt_rule.<locals>.optrulez%s : empty
| %szp_%sN)r   r   ÚsetattrÚ	__class__)r	   ÚrulenameÚoptnamer   r
   r
   r   Ú_create_opt_rule#   s
   
zPLYParser._create_opt_ruleNc                 C   s   t | jj||d�S )Nr   )r   ÚclexÚfilename)r	   Úlinenor   r
   r
   r   Ú_coord1   s
   ýzPLYParser._coordc                 C   sF   |j j j dd| |¡¡}|dk rd}| |¡| }|  | |¡|¡S )z× Returns the coordinates for the YaccProduction object 'p' indexed
            with 'token_idx'. The coordinate includes the 'lineno' and
            'column'. Both follow the lex semantic, starting from 1.
        Ú
r   éÿÿÿÿ)ÚlexerÚlexdataÚrfindÚlexposr$   r#   )r	   r   Ú	token_idxÚlast_crr   r
   r
   r   Ú_token_coord7   s
   zPLYParser._token_coordc                 C   s   t d||f ƒ‚)Nz%s: %s)r   )r	   ÚmsgÚcoordr
   r
   r   Ú_parse_errorB   r   zPLYParser._parse_errorr   )r   r   r   r    r$   r-   r0   r
   r
   r
   r   r   "   s
    
r   c                     s   ‡ fdd„}|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.
    c                    s
   ˆ | _ | S r   )Ú_params)Ú	rule_func©Úparamsr
   r   ÚdecorateP   s   zparameterized.<locals>.decorater
   )r4   r5   r
   r3   r   ÚparameterizedF   s   
r6   c                 C   sl   d}t | ƒD ]-}| d¡r3t| |ƒ}t|dƒr3t| |ƒ |jdur't| |ƒ q|s3tjdt	dd� d}q| S )	z� Class decorator to generate rules from parameterized rule templates.

    See `parameterized` for more information on parameterized rules.
    FÚp_r1   Nz@parsing methods must have __doc__ for pycparser to work properlyé   )Ú
stacklevelT)
ÚdirÚ
startswithÚgetattrÚhasattrÚdelattrr   Ú_create_param_rulesÚwarningsÚwarnÚRuntimeWarning)ÚclsÚissued_nodoc_warningÚ	attr_nameÚmethodr
   r
   r   ÚtemplateV   s"   




ý€rG   c                    sV   ˆ j D ]%\}}‡ fdd„}ˆ j d|¡ d|¡|_ˆ j d|¡|_t| |j|ƒ qdS )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.
    c                    s   ˆ | |ƒ d S r   r
   r   ©Úfuncr
   r   Ú
param_rule}   s   z'_create_param_rules.<locals>.param_ruleÚxxxÚyyyN)r1   r   Úreplacer   r   )rC   rI   rK   rL   rJ   r
   rH   r   r?   t   s   ör?   )	r@   Úobjectr   Ú	Exceptionr   r   r6   rG   r?   r
   r
   r
   r   Ú<module>   s   
$