r2u2_cli 4.1.0

R2U2 CLI: A stream-based runtime monitor command-line interface
�

`ɭho
�	��ddlZddlmZddlZddlmZmZdZdejde	de
eeejffd�Z
d	ejdeejfd
�Zdejddfd�Zdejddfd
�Zy)�N)�Optional)�types�log�PRSO�
trace_path�map_file_provided�returnc	�J�t|d�5}|j�}ddd�j�}t|�dkryd}i}|dddk(r�|ddd}|rt	j
td�|jd�D�cgc]}|j���c}D]M}	|	|vr=t	j
td	|	�d
�t	j|jd��|||	<|dz
}�Ot|�dz
}
|
|fSt|�dfS#1swY��xYwcc}w)zrGiven `trace_path`, return the inferred length of the trace and, if `return_mapping` is enabled, a signal mapping.�rN�)�����Nr�#zHMap file given and header included in trace file; header will be ignored�,�Signal ID 'z5' found multiple times in csv, using right-most value)�open�read�
splitlines�lenr�warning�MODULE_CODE�split�strip�FileLocation�name)rr�f�content�lines�cnt�signal_mapping�header�s�id�trace_lengths           �F/home/Dissertation/Comparison/r2u2-modify/compiler/c2po/parse_utils.py�parse_trace_filer%	s4��
�j�#�	� �!��v�v�x�� ��)�)�+�E�
�5�z�A�~���C�*,�N��Q�x��{�c���q��!�"�����K�K��Z�
�
'-�l�l�3�&7�8��1�7�7�9�8�	�B��^�#�����!�"��%Z�[��$�$�Z�_�_�a�8��
"%�N�2���1�H�C�	��5�z�A�~���n�-�-�
��J����I � ��*9s�D�D �D�map_pathc�\�t|d�5}|j�}ddd�i}j�}|D]�}tjd|�r}|jd�}|d}t
|d�}||vrOtjtd|�d�tj|j|j|�dz��|||<��tjtd	|�d
�tj|j|j|���y|S#1swY��xYw)z*Return the signal mapping from `map_path`.rNz[a-zA-Z_][a-zA-Z0-9_\[\]]*:\d+�:rrrz6' found multiple times in map file, using latest valuez#Invalid format for map line (found z,)
	 Should be of the form SYMBOL ':' NUMERAL)rrr�re�matchr�intrrrrr�index�error)	r&rr�mappingr�line�strsr"�sids	         r$�parse_map_filer24s��	
�h��	� ���v�v�x�� �$&�G���� �E����
�8�8�5�t�<��:�:�c�?�D��a��B��d�1�g�,�C��W�}�����!�"��%[�\��$�$�X�]�]�E�K�K��4E��4I�J���G�B�K��I�I��5�d�V�<@�@�� � �������D�0A�B�	
��+�.�N�; � �s�D!�!D+�bounds_pathc��y�N��r3s r$�parse_bounds_cr8V����c��yr5r6r7s r$�parse_bounds_rustr<Zr9r:)�pathlib�typingrr)�c2porrr�Path�bool�tupler+�
SignalMappingr%r2r8r<r6r:r$�<module>rDs�����	����(����(�15�(�
�3���,�,�-�-�.�(�V�W�\�\��h�u�7J�7J�.K��D	����	��	�	�7�<�<�	�D�	r: