
    Mh                     t    d dl Z  G d de          Z G d de          Z G d de          Zd Zd	 Zd
 ZdS )    Nc                   $    e Zd ZdZdZddZ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                 0    || _         || _        || _        d S Nr   r   r   )selfr   r   r   s       S/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/pycparser/plyparser.py__init__zCoord.__init__   s    		    c                 P    | j         d| j        }| j        r|d| j        z  z  }|S )N:z:%sr   )r   strs     r   __str__zCoord.__str__   s3    DII.;2ut{22
r   r
   )__name__
__module____qualname____doc__	__slots__r   r    r   r   r   r      sH         
 :I   
    r   r   c                       e Zd ZdS )
ParseErrorN)r   r   r   r   r   r   r   r      s          r   r   c                   (    e Zd Zd ZddZd Zd ZdS )	PLYParserc                 x    |dz   }d }|d||_         d|z  |_        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                     |d         |d<   d S )N   r   r   )r   ps     r   optrulez+PLYParser._create_opt_rule.<locals>.optrule*   s    Q4AaDDDr   z : empty
| zp_%sN)r   r   setattr	__class__)r   rulenameoptnamer#   s       r   _create_opt_rulezPLYParser._create_opt_rule#   s[    
 V#	 	 	 18B!G+ 0':::::r   Nc                 :    t          | j        j        ||          S )Nr   )r   clexfilename)r   linenor   s      r   _coordzPLYParser._coord1   s'    Y'   	r   c                    |j         j         j                            dd|                    |                    }|dk     rd}|                    |          |z
  }|                     |                    |          |          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   s        r   _token_coordzPLYParser._token_coord7   sr    
 '-'--dAqxx	7J7JKKQ;;G((9%%1{{188I..777r   c                 *    t          |d|          )Nz: )r   )r   msgcoords      r   _parse_errorzPLYParser._parse_errorB   s    UUUCC0111r   r
   )r   r   r   r(   r-   r7   r;   r   r   r   r   r   "   sU        ; ; ;   	8 	8 	82 2 2 2 2r   r   c                        f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 r
   )_params)	rule_funcparamss    r   decoratezparameterized.<locals>.decorateP   s    "	r   r   )r@   rA   s   ` r   parameterizedrB   F   s#         Or   c                 (   d}t          |           D ]}|                    d          rht          | |          }t          |d          rHt	          | |           |j        t          | |           _|st          j        dt          d           d}| S )	z Class decorator to generate rules from parameterized rule templates.

    See `parameterized` for more information on parameterized rules.
    Fp_r>   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methods       r   templaterT   V   s    
 !XX 0 0	%% 	0S),,Fvy)) 0Y''' >-'V4444- 0MZ&#$& & & & ,0(Jr   c                     j         D ]t\  }}fd}j                            d|                              d|          |_        j                            d|          |_        t	          | |j        |           ud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                       | |           d S r
   r   )r   r"   funcs     r   
param_rulez'_create_param_rules.<locals>.param_rule}   s    DqMMMMMr   xxxyyyN)r>   r   replacer   r$   )rP   rW   rY   rZ   rX   s    `   r   rL   rL   t   s     L 
6 
6S	 	 	 	 	 "\11%==EEeSQQ
"m33E3??
 	Z(*5555
6 
6r   )	rM   objectr   	Exceptionr   r   rB   rT   rL   r   r   r   <module>r^      s        F   $ " ! ! ! ! ! ! !!2 !2 !2 !2 !2 !2 !2 !2H     <6 6 6 6 6r   