관리-도구
편집 파일: plyparser.cpython-39.opt-1.pyc
a ������_^ ����������������������@���sT���d�dl�Z�G�dd��de�ZG�dd��de�ZG�dd��de�Zdd ��Zd d��Zdd ��ZdS�)�����Nc�������������������@���s&���e�Zd�ZdZdZddd�Zdd��ZdS�) �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 ����7/usr/lib/python3.9/site-packages/pycparser/plyparser.py�__init__���s����zCoord.__init__c�����������������C���s(���d|�j�|�jf�}|�jr$|d|�j�7�}|S�)Nz%s:%sz:%sr���)r ����strr ���r ���r����__str__���s����z Coord.__str__)N)�__name__� __module__�__qualname__�__doc__� __slots__r���r���r ���r ���r ���r���r��� ���s��� r���c�������������������@���s���e�Zd�ZdS�)� ParseErrorN)r���r���r���r ���r ���r ���r���r�����������r���c�������������������@���s.���e�Zd�Zdd��Zd dd�Zdd��Zdd ��ZdS�)� PLYParserc�����������������C���s<���|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_optc�����������������S���s���|d�|d<�d�S�)N����r���r ����r ����pr ���r ���r����optrule*���s����z+PLYParser._create_opt_rule.<locals>.optrulez%s : empty | %szp_%sN)r���r����setattr� __class__)r ���ZrulenameZoptnamer���r ���r ���r����_create_opt_rule#���s ���� zPLYParser._create_opt_ruleNc�����������������C���s���t�|�jj||d�S�)Nr���)r���Zclex�filename)r ����linenor���r ���r ���r����_coord1���s �����zPLYParser._coordc�����������������C���sF���|j�j�j�dd|�|��}|dk�r&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 ���r���Z token_idxZlast_crr���r ���r ���r����_token_coord7���s ����zPLYParser._token_coordc�����������������C���s���t�d||f���d�S�)Nz%s: %s)r���)r ����msgZcoordr ���r ���r����_parse_errorB���s����zPLYParser._parse_error)N)r���r���r���r���r ���r$���r&���r ���r ���r ���r���r���"���s��� r���c���������������������s�����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. c��������������������s �����|�_�|�S�r���)�_params)Z rule_func��paramsr ���r����decorateP���s����zparameterized.<locals>.decorater ���)r)���r*���r ���r(���r���� parameterizedF���s���� r+���c�����������������C���sl���d}t�|��D�]Z}|�d�rt|�|�}t|d�rt|�|��|jdurNt|�|��q|stjdt 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����templateV���s ���� �r9���c��������������������sV�����j�D�]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. c��������������������s�����|�|��d�S�r���r ���r�����funcr ���r���� param_rule}���s����z'_create_param_rules.<locals>.param_rule�xxx�yyyN)r'���r����replacer���r���)r7���r;���r=���r>���r<���r ���r:���r���r3���t���s ����r3���) r4����objectr���� Exceptionr���r���r+���r9���r3���r ���r ���r ���r����<module>���s���$