r2u2_cli 4.1.0

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

���h�
�@s�ddlZddlmZddlZddlmZmZdZeje	e
eeejfd�dd�Z
ejeejd�d	d
�Zejdd�dd
�Zejdd�dd�ZdS)�N)�Optional)�types�logZPRSO)�
trace_path�map_file_provided�returnc
	Cs�td|���t|d��}|��}W5QRX|��}t|�dkrDdSd}i}|dddkr�|ddd�}|r|t�td�d	d
�|�d�D�D]<}||kr�t�td|�d
�t�	|j
d��|||<|d7}q�t|�d}	|	|fSt|�dfS)zrGiven `trace_path`, return the inferred length of the trace and, if `return_mapping` is enabled, a signal mapping.zTrace: �r�)�����Nr�#NzHMap file given and header included in trace file; header will be ignoredcSsg|]}|���qS�)�strip)�.0�srr�o/Users/aaurandt/Desktop/IowaState/R2U2Research/Dissertation/Comparison/r2u2-modify/compiler/c2po/parse_utils.py�
<listcomp>#sz$parse_trace_file.<locals>.<listcomp>�,�Signal ID 'z5' found multiple times in csv, using right-most value)�print�open�read�
splitlines�lenr�warning�MODULE_CODE�split�FileLocation�name)
rr�f�content�linesZcnt�signal_mapping�header�id�trace_lengthrrr�parse_trace_file	s6�
�
r%)�map_pathrc	Cs�t|d��}|��}W5QRXi}|��}|D]�}t�d|�r�|�d�}|d}t|d�}||kr�t�t	d|�d�t�
|j|�|�d��|||<q.t�
t	d|�d	�t�
|j|�|���d
Sq.|S)z*Return the signal mapping from `map_path`.rz[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 ':' NUMERALN)rrr�re�matchr�intrrrrr�index�error)	r&rr�mappingr �lineZstrsr#Zsidrrr�parse_map_file5s.

�

�r/)�bounds_pathrcCsdS�Nr�r0rrr�parse_bounds_cWsr3cCsdSr1rr2rrr�parse_bounds_rust[sr4)�pathlib�typingrr(�c2porrr�Path�bool�tupler*�
SignalMappingr%r/r3r4rrrr�<module>s�,"