
    F	h&                     f   d Z ddlmZ ddlZddlmZmZ ddlZ ej                  d      Z	 e
d      ZdZ G d d	ej                        Zej                  d
        Zej                  d        ZdZdZdZdZ ed      Zej                  d        Zd Z	 	 ddZ ej6                   e       d       y)z
Pure-python parsing backend.
    
scanstringN)commonutilsz[a-z0-9eE\.\+-]+|\Sz[]{},)Nc                        e Zd Z fdZ xZS )UnexpectedSymbolc                 6    t         t        |   d||fz         y )NzUnexpected symbol %r at %d)superr	   __init__)selfsymbolpos	__class__s      P/var/www/html/backend/venv/lib/python3.12/site-packages/ijson/backends/python.pyr   zUnexpectedSymbol.__init__   s    .(FC=8	
    )__name__
__module____qualname__r   __classcell__)r   s   @r   r	   r	      s    
 
r   r	   c              #   t  K    t        j                  d             }|j                  }| j                  }	 	 d}d }	  |||      }|r	 ||       n|s| j                          y 0# t        $ r d}d}Y 8w xY w# t
        $ r3}	 | j                          n#  Y nxY wt        j                  |      d }~ww xY ww)Nzutf-8TFr   )	codecsgetincrementaldecoderdecodesendGeneratorExitUnicodeDecodeErrorcloser   IncompleteJSONError)targetdecoderr   r   finalbdatasdataes           r   utf8_encoderr&      s     3f**735G^^F;;D
	EE	05%(E KLLN'   	EE	
 " 	0,,Q//	0sW   4B8A& 	A9 B8&A63B85A66B89	B5BB0BB00B55B8c              #   >  K   	 d}|}d}d}| j                  }	 t        j                  ||      }|r.|j	                         }|dk(  rq|j                         }|dz   }	 	 |j                  d|      }	|	dz
  }
||
   dk(  r|
dz  }
||
   dk(  r|	|
z
  dz  dk(  r|	dz   }nn	 B |||z   |||	dz    f       |	dz   }n|t        vrt|j                         t        |      k(  rX	 d}|snP||z  }t        j                  ||      }|j	                         }|t        vr|j                         t        |      k(  rX |||j                         z   |f       |j                         }n2|r	 d}|s	 | j                  t               y|t        |      z  }|}d}{# t         $ r d}Y w xY w# t        $ r7 	 d}n# t         $ r d}Y nw xY w|st        j                  d      ||z  }Y Gw xY w# t         $ r d}Y w xY w# t         $ r d}Y w xY w# t        $ r Y yw xY ww)	z
    Parses lexemes out of the incoming content, and sends them to parse_value.
    A special EOF result is sent when the data source has been exhausted to
    give parse_value the possibility of raising custom exceptions due to missing
    content.
    N r   "   \   zIncomplete string lexeme)r   r   	LEXEME_REsearchgroupstartindex
ValueErrorr   r   UNARY_LEXEMESendlenEOFStopIteration)r    databufr   	discardedr   matchlexemer0   r4   escposs              r   Lexerr>   1   st     C
CI;;D
  c*[[]F}kkma$!iiU3!$q!&kT1"aKF "&kT1&LA-2$'!GE! " $ i#os3sQw'789AgM1eiikSX6M" %  4KC%,,S#6E"[[]F M1eiikSX6M i%++-/89iik !D KK$ S!ICCs   . & $&$)D, &#%D&#"("<"<=W"XXt$ ) "!" % D % s   HF AH ,F( F( A HG+ #AH6.H%G= )H,H HF%!H$F%%H(	G(2F76G(7GG(GG($H'G((H+G:6H9G::H=HH
HH	HHHHr*   r,      infc              #   :  K   t         g}|j                  }|j                  }| j                  }d\  }}|rt        j
                  nt        j                  }		 |*d\  }
}|
|ft        k(  r!|rt	        j                  d      y||}}
d\  }}	 |d   }|sJ |t         k(  r|dk(  r |d        |        n|dk(  r |d	        |        n|d
k(  r |d        |        n|d   dk(  r |dt        |      f        |        n|dk(  rc |d       d\  }
}|
|ft        k(  rt	        j                  d      |dk(  r |d        |        n;|
|}} |t                |t                n|dk(  rW |d       d\  }
}|
|ft        k(  rt	        j                  d      |dk(  r |d        |        n|
|}} |t               nt        |      dkD  r|d   dk(  r|d   dvst        |      dkD  r'|dd dk(  r|d   dvrt	        j                  d|      |d   dk(  s|d   dk(  rt	        j                  d|      	  |	|      }|t        k(  rt	        j                  d|      	  |d|f        |        n	|t        k(  ru|d   dk7  rt#        ||
       |d t        |      f       d\  }
}|
|ft        k(  rt	        j                  d      |d!k7  rt#        ||
      t$        |d<    |t                n|t$        k(  r7|d"k(  r
t        |d<   ns|dk7  rt#        ||
       |d        |         |        nK|t        k(  rB|d"k(  rt        |d<    |t                n'|dk7  rt#        ||
       |d        |         |        6# t        $ r* |rt         } ||       nt	        j                  d      Y -w xY w#  dj!                  |      s"d
j!                  |      sdj!                  |      rt	        j                  d      t#        ||
      xY ww)#a  
    Parses results coming out of the Lexer into ijson events, which are sent to
    `target`. A stack keeps track of the type of object being parsed at the time
    (a value, and object or array -- the last two being values themselves).

    A special EOF result coming from the Lexer indicates that no more content is
    expected. This is used to check for incomplete content and raise the
    appropriate exception, which wouldn't be possible if the Lexer simply closed
    this co-routine (either explicitly via .close(), or implicitly by itself
    finishing and decreasing the only reference to the co-routine) since that
    causes a GeneratorExit exception that cannot be replaced with a custom one.
    )NNNzIncomplete JSON contentr   zAdditional data foundnull)rB   Ntrue)booleanTfalse)rD   Fr   r)   string[)start_arrayN])	end_arrayN{)	start_mapN})end_mapNr*   0)r%   E.r,   z-0zInvalid JSON number: rQ   zfloat overflow: numbermap_key:,)_PARSE_VALUEpopappendr   r   integer_or_floatinteger_or_decimalr6   r   
IndexError	JSONErrorparse_string_PARSE_ARRAY_ELEMENT_END_PARSE_OBJECT_KEYr5   r@   
startswithr	   _PARSE_OBJECT_END)r    
multivalue	use_floatstate_stackrW   pushr   prev_posprev_symbol	to_numberr   r   staterR   s                 r   parse_valuerj      s<      .K
//CD;;D&Hk+4''&:S:SI
 KCV}# 445NOO"KC$.!Hk	@OE {L ^$6!&'7"'(c!hV 4563*+$V=C' 445NOOS=,-E,/kH12&3()$V=C' 445NOOS=*+E,/kH*+ [1_c)9fQi>^[1_!)<RaAa **+PQQ!9#vbzS'8 **+PQQ
&v.F}$..v/OPP % (F+,E''ayC&vs33)\&123 KCV}#001JKK}&vs33/KO''}"3B3&vs33&'..}":B\"3&vs33()a   	@$U&&'>?? 	@x8((0G4F4Fv4NRXRcRcdjRk$889RSS*6377sE   B	PN F2P)O .DP/N?;P>N??PAPPc                      t        | d      d   S )Nr*   r   r   )r   s    r   r]   r]     s    fa ##r   Fc           	      Z    |rt        d      t        t        t        | ||                  S )zx
    Iterator yielding unprefixed events.

    Parameters:

    - file: a readable file-like object with JSON input
    z0Comments are not supported by the python backend)r2   r&   r>   rj   )r    multiple_valuesallow_commentsrc   s       r   basic_parse_basecororo     s,     KLLk&/9MNOOr   )
c_comments)FFF)__doc__json.decoderr   reijsonr   r   r   compiler-   setr3   r6   r\   r	   	coroutiner&   r>   rV   r^   r_   ra   floatr@   rj   r]   ro   enrich_backendglobals r   r   <module>r|      s    $ 	   BJJ-.	G
v'' 
  2 H HX     ElD DN$ HM#(P   giE 2r   