403Webshell
Server IP : 3.96.16.70  /  Your IP : 216.73.216.15
Web Server : Apache
System : Linux ip-172-31-26-103.ca-central-1.compute.internal 6.1.163-186.299.amzn2023.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Feb 24 16:35:42 UTC 2026 x86_64
User : ec2-user ( 1000)
PHP Version : 8.4.18
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /usr/lib/python3.9/site-packages/jmespath/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/python3.9/site-packages/jmespath/__pycache__/parser.cpython-39.pyc
a

��^�J�@spdZddlZddlmZddlmZddlmZddlmZddlmZGdd	�d	e	�Z
eGd
d�de	��ZdS)a�Top down operator precedence parser.

This is an implementation of Vaughan R. Pratt's
"Top Down Operator Precedence" parser.
(http://dl.acm.org/citation.cfm?doid=512927.512931).

These are some additional resources that help explain the
general idea behind a Pratt parser:

* http://effbot.org/zone/simple-top-down-parsing.htm
* http://javascript.crockford.com/tdop/tdop.html

A few notes on the implementation.

* All the nud/led tokens are on the Parser class itself, and are dispatched
  using getattr().  This keeps all the parsing logic contained to a single
  class.
* We use two passes through the data.  One to create a list of token,
  then one pass through the tokens to create the AST.  While the lexer actually
  yields tokens, we convert it to a list so we can easily implement two tokens
  of lookahead.  A previous implementation used a fixed circular buffer, but it
  was significantly slower.  Also, the average jmespath expression typically
  does not have a large amount of token so this is not an issue.  And
  interestingly enough, creating a token list first is actually faster than
  consuming from the token iterator one token at a time.

�N)�lexer)�with_repr_method)�ast)�
exceptions)�visitorc@s�eZdZddddddddddddddddddddddddd	d
ddd
d�ZdZiZdZdxdd�Zdd�Zdd�Z	dd�Z
dydd�Zdd�Zdd�Z
dd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Zd;d<�Zd=d>�Zd?d@�ZdAdB�ZdCdD�Z dEdF�Z!dGdH�Z"dIdJ�Z#dKdL�Z$dMdN�Z%dOdP�Z&dQdR�Z'dSdT�Z(dUdV�Z)dWdX�Z*dYdZ�Z+d[d\�Z,d]d^�Z-d_d`�Z.dadb�Z/dzddde�Z0dfdg�Z1dhdi�Z2djdk�Z3dldm�Z4dndo�Z5dpdq�Z6drds�Z7dtdu�Z8e9dvdw��Z:dcS){�Parserr�����	���(�-�2�7�<)�eof�unquoted_identifier�quoted_identifier�literal�rbracket�rparen�comma�rbrace�numberZcurrent�expref�colon�pipe�or�and�eq�gt�lt�gte�lte�ne�flatten�star�filter�dot�not�lbrace�lbracket�lparen�
�cCs"d|_dg||_||_d|_dS�Nr)�	tokenizer�_tokensZ_buffer_size�_index)�self�	lookahead�r8�3/usr/lib/python3.9/site-packages/jmespath/parser.py�__init__NszParser.__init__cCsH|j�|�}|dur|S|�|�}||j|<t|j�|jkrD|��|S�N)�_CACHE�get�	_do_parse�len�	_MAX_SIZE�_free_cache_entries)r6�
expression�cached�
parsed_resultr8r8r9�parseTs

zParser.parsec
Cs�z|�|�WStjy:}z||_�WYd}~nfd}~0tjyj}z|�|��WYd}~n6d}~0tjy�}z||_�WYd}~n
d}~00dSr;)�_parserZ
LexerErrorrB�IncompleteExpressionErrorZset_expression�
ParseError)r6rB�er8r8r9r>^s
zParser._do_parsecCsrt���|�|_t|j�|_d|_|jdd�}|��dksh|�	d�}t
�|d|d|dd|d��t||�S)Nr)�
binding_powerr�start�value�typezUnexpected token: %s)
rZLexer�tokenizer3�listr4r5�_expression�_current_token�_lookahead_tokenrrH�ParsedResult)r6rB�parsed�tr8r8r9rFks

�z
Parser._parsecCs�|�d�}|��t|d|d|j�}||�}|��}||j|kr�t|d|d�}|durt|�d�}|�|�q8|��||�}|��}q8|S)Nrz
_token_nud_%srMz
_token_led_%s)rR�_advance�getattr�_error_nud_tokenrQ�
BINDING_POWER�_error_led_token)r6rJZ
left_tokenZnud_function�left�
current_tokenZledZerror_tokenr8r8r9rPvs"
�

zParser._expressioncCst�|d�S�NrL)rr�r6�tokenr8r8r9�_token_nud_literal�szParser._token_nud_literalcCst�|d�Sr])r�fieldr^r8r8r9�_token_nud_unquoted_identifier�sz%Parser._token_nud_unquoted_identifiercCs@t�|d�}|��dkr<|�d�}t�d|d|dd��|S)NrLr/rrMz1Quoted identifier not allowed for function names.)rrarQrRrrH)r6r_rarUr8r8r9�_token_nud_quoted_identifier�s
�z#Parser._token_nud_quoted_identifiercCs:t��}|��dkrt��}n|�|jd�}t�||�S)Nrr))r�identityrQ�_parse_projection_rhsrY�value_projection�r6r_r[�rightr8r8r9�_token_nud_star�s

zParser._token_nud_starcCs|�t���Sr;)�_token_led_filterrrdr^r8r8r9�_token_nud_filter�szParser._token_nud_filtercCs|��Sr;)�_parse_multi_select_hashr^r8r8r9�_token_nud_lbrace�szParser._token_nud_lbracecCs|��}|�d�|S)Nr)rP�_match�r6r_rBr8r8r9�_token_nud_lparen�s
zParser._token_nud_lparencCs*t�t���}|�|jd�}t�||�S�Nr()rr(rdrerY�
projectionrgr8r8r9�_token_nud_flatten�s
�zParser._token_nud_flattencCs|�|jd�}t�|�S)Nr,)rPrYrZnot_expression)r6r_�exprr8r8r9�_token_nud_not�szParser._token_nud_notcCsz|��dvr$|��}|�t��|�S|��dkrn|�d�dkrn|��|��|�|jd�}t�	t��|�S|�
�SdS)N�rrr)rr)rQ�_parse_index_expression�_project_if_slicerrd�
_lookaheadrVrerYrr�_parse_multi_select_list)r6r_rhr8r8r9�_token_nud_lbracket�s�zParser._token_nud_lbracketcCsR|�d�dks|�d�dkr$|��St�|�d�d�}|��|�d�|SdS)NrrrrLr)ry�_parse_slice_expressionr�indexrRrVrn)r6�noder8r8r9rw�s�
zParser._parse_index_expressioncCs�gd�}d}|��}|dks�|dkr�|dkrX|d7}|dkrN|�|�d�d�|��n6|dkr||�d�d	||<|��n|�|�d�d�|��}q|�d�tj|�S)
N)NNNrrr
rr�syntax errorrrL)rQ�_raise_parse_error_for_tokenrRrVrnr�slice)r6�partsr}r\r8r8r9r|�s(
�


�

zParser._parse_slice_expressioncCst��Sr;)rZcurrent_noder^r8r8r9�_token_nud_current�szParser._token_nud_currentcCs|�|jd�}t�|�S)Nr)rPrYrrror8r8r9�_token_nud_expref�szParser._token_nud_exprefcCsr|��dksJ|�|jd�}|ddkr:|d�|�|St�||g�Sn$|��|�|jd�}t�||�SdS)Nr)r+rM�
subexpression�children)	rQ�_parse_dot_rhsrY�appendrr�rVrerf�r6r[rhr8r8r9�_token_led_dot�s�zParser._token_led_dotcCs|�|jd�}t�||�S)Nr)rPrYrrr�r8r8r9�_token_led_pipeszParser._token_led_pipecCs|�|jd�}t�||�S)Nr )rPrYrZ
or_expressionr�r8r8r9�
_token_led_or	szParser._token_led_orcCs|�|jd�}t�||�S)Nr!)rPrYrZand_expressionr�r8r8r9�_token_led_and
szParser._token_led_andcCs�|ddkr:|�d�}t�|d|d|dd|d��|d}g}|��dks||��}|��dkrp|�d�|�|�qF|�d�t�||�}|S)	NrMra���rKrLzInvalid function name '%s'rr)	rRrrHrQrPrnr�rZfunction_expression)r6r[Zprev_t�name�argsrBZ
function_noder8r8r9�_token_led_lparens 

�

zParser._token_led_lparencCsH|�d�}|�d�|��dkr*t��}n|�|jd�}t�|||�S)Nrrr(r*)rPrnrQrrdrerYZfilter_projection)r6r[Z	conditionrhr8r8r9rj%s


zParser._token_led_filtercCs|�|d�S)Nr"��_parse_comparator�r6r[r8r8r9�
_token_led_eq/szParser._token_led_eqcCs|�|d�S)Nr'r�r�r8r8r9�
_token_led_ne2szParser._token_led_necCs|�|d�S)Nr#r�r�r8r8r9�
_token_led_gt5szParser._token_led_gtcCs|�|d�S)Nr%r�r�r8r8r9�_token_led_gte8szParser._token_led_gtecCs|�|d�S)Nr$r�r�r8r8r9�
_token_led_lt;szParser._token_led_ltcCs|�|d�S)Nr&r�r�r8r8r9�_token_led_lte>szParser._token_led_ltecCs&t�|�}|�|jd�}t�||�Srq)rr(rerYrrr�r8r8r9�_token_led_flattenAs

�zParser._token_led_flattencCs~|�d�}|ddvrJ|��}|ddkr<|d�|�|S|�||�Sn0|�d�|�d�|�|jd�}t�||�SdS)NrrMrv�index_expressionr�r)r)	rRrwr�rxrnrerYrrr)r6r[r_rhr8r8r9�_token_led_lbracketGs


zParser._token_led_lbracketcCs:t�||g�}|ddkr2t�||�|jd��S|SdS)NrMr�r))rr�rrrerY)r6r[rhZ
index_exprr8r8r9rxZs�zParser._project_if_slicecCs|�|j|�}t�|||�Sr;)rPrYr�
comparator)r6r[r�rhr8r8r9r�cszParser._parse_comparatorcCsFg}|��}|�|�|��dkr&q2q|�d�q|�d�t�|�S)Nrr)rPr�rQrnrZmulti_select_list)r6ZexpressionsrBr8r8r9rzgs

zParser._parse_multi_select_listcCs�g}|�d�}|jddgd�|d}|�d�|�d�}tj||d�}|�|�|��dkrj|�d�q|��d	kr|�d	�q�qtj|d
�S)Nrrr)�token_typesrLr)�key_namer~rr)Znodes)	rR�_match_multiple_tokensrnrPrZkey_val_pairr�rQZmulti_select_dict)r6�pairsZ	key_tokenr�rLr~r8r8r9rlss 
�



zParser._parse_multi_select_hashcCs�|j|��|jkrt��}nd|��dkr6|�|�}nL|��dkrN|�|�}n4|��dkrp|�d�|�|�}n|�|�	d�d�|S)Nr.r*r+rr)
rYrQ�_PROJECTION_STOPrrdrPrnr�r�rR)r6rJrhr8r8r9re�s

�zParser._parse_projection_rhscCs�|��}|dvr|�|�S|dkr4|�d�|��S|dkrN|�d�|��S|�d�}gd�}d||df}|�||�dS)N)rrr)r.r-r)rrr.r-�Expecting: %s, got: %srM)rQrPrnrzrlrRr�)r6rJr7rUZallowed�msgr8r8r9r��s	



�zParser._parse_dot_rhscCs6|ddkr&t�|d|d|d��|�|d�dS)NrMrrKrL�
invalid token)rrGr�r^r8r8r9rX�s
�zParser._error_nud_tokencCs|�|d�dS)Nr�)r�r^r8r8r9rZ�szParser._error_led_tokenNcCs,|��|kr|��n|�||�d��dSr2)rQrV�_raise_parse_error_maybe_eofrR)r6�
token_typer8r8r9rn�s


�z
Parser._matchcCs*|��|vr|�||�d��|��dSr2)rQr�rRrV)r6r�r8r8r9r��s

�zParser._match_multiple_tokenscCs|jd7_dS)Nr)r5�r6r8r8r9rV�szParser._advancecCs|j|jdS�NrM�r4r5r�r8r8r9rQ�szParser._current_tokencCs|j|j|dSr�r��r6rr8r8r9ry�szParser._lookaheadcCs|j|j|Sr;r�r�r8r8r9rR�szParser._lookahead_tokencCs,|d}|d}|d}t�||||��dS)NrKrLrM)rrH)r6r_�reason�lex_position�actual_value�actual_typer8r8r9r��s�z#Parser._raise_parse_error_for_tokencCsN|d}|d}|d}|dkr.t�|||��d||f}t�||||��dS)NrKrLrMrr�)rrGrH)r6Z
expected_typer_r�r�r��messager8r8r9r��s���z#Parser._raise_parse_error_maybe_eofcCs4t�|j��t|jd��D]}|j�|d�qdS)Nr	)�randomZsampler<�keys�intr@�pop)r6�keyr8r8r9rA�s zParser._free_cache_entriescCs|j��dS)z'Clear the expression compilation cache.N)r<�clear)�clsr8r8r9�purge�szParser.purge)r	)r)N);�__name__�
__module__�__qualname__rYr�r<r@r:rEr>rFrPr`rbrcrirkrmrprsrur{rwr|r�r�r�r�r�r�r�rjr�r�r�r�r�r�r�r�rxr�rzrlrer�rXrZrnr�rVrQryrRr�r�rA�classmethodr�r8r8r8r9r%s��"




	
	rc@s.eZdZdd�Zd
dd�Zdd�Zdd	�ZdS)rScCs||_||_dSr;)rBrT)r6rBrTr8r8r9r:�szParsedResult.__init__NcCst�|�}|�|j|�}|Sr;)rZTreeInterpreter�visitrT)r6rL�optionsZinterpreter�resultr8r8r9�search�s
zParsedResult.searchcCst��}|�|j�}|S)afRender the parsed AST as a dot file.

        Note that this is marked as an internal method because
        the AST is an implementation detail and is subject
        to change.  This method can be used to help troubleshoot
        or for development purposes, but is not considered part
        of the public supported API.  Use at your own risk.

        )rZGraphvizVisitorr�rT)r6Zrenderer�contentsr8r8r9�_render_dot_files
zParsedResult._render_dot_filecCs
t|j�Sr;)�reprrTr�r8r8r9�__repr__szParsedResult.__repr__)N)r�r�r�r:r�r�r�r8r8r8r9rS�s
rS)�__doc__r�ZjmespathrZjmespath.compatrrrr�objectrrSr8r8r8r9�<module>sS

Youez - 2016 - github.com/yon3zu
LinuXploit