o
    Ti                     @   s8   d Z ddlZdgZG dd deZdd Zd	ddZdS )
zJSON token scanner
    NHjsonDecodeErrorc                   @   s"   e Zd ZdZdddZdd ZdS )r   a  Subclass of ValueError with the following additional properties:

    msg: The unformatted error message
    doc: The JSON document being parsed
    pos: The start index of doc where parsing failed
    end: The end index of doc where parsing failed (may be None)
    lineno: The line corresponding to pos
    colno: The column corresponding to pos
    endlineno: The line corresponding to end (may be None)
    endcolno: The column corresponding to end (may be None)

    Nc              	   C   sp   t | t||||d || _|| _|| _|| _t||\| _| _	|d ur0t||\| _
| _d S d\| _
| _d S )N)end)NN)
ValueError__init__errmsgmsgdocposr   linecollinenocolno	endlinenoendcolno)selfr   r   r	   r    r   A/home/ubuntu/.local/lib/python3.10/site-packages/hjson/scanner.pyr      s   zHjsonDecodeError.__init__c                 C   s   | j | j| j| j| jffS N)	__class__r   r   r	   r   )r   r   r   r   
__reduce__!   s   zHjsonDecodeError.__reduce__r   )__name__
__module____qualname____doc__r   r   r   r   r   r   r      s    
c                 C   sD   |  dd|d }|dkr|d }||fS || dd| }||fS )N
r      )countrindex)r   r	   r   r   r   r   r   r
   %   s   r
   c           	      C   sn   t ||\}}| dt|||d  } |d u r#d}|| |||f S t ||\}}d}|| ||||||f S )Nz%rr   z%s: line %d column %d (char %d)z8%s: line %d column %d - line %d column %d (char %d - %d))r
   replacerepr)	r   r   r	   r   r   r   fmtr   r   r   r   r   r   .   s   r   r   )r   re__all__r   r   r
   r   r   r   r   r   <module>   s    	