Файловый менеджер - Редактировать - /opt/imh-python/lib/python3.9/site-packages/parso/python/__pycache__/parser.cpython-39.pyc
Ðазад
a e�h� � @ sJ d dl mZ d dlmZ d dlmZ ejZejZejZG dd� de�Z dS )� )�tree)�PythonTokenTypes)� BaseParserc s e Zd ZdZejejejejej ej ejejejejej ejejejejejejejejejejejejejejejejd�ZejZejejejej ej!ej"ej#ej$ej%ej&ej'ej(ej)ej*iZ+d� fdd� Z,� fdd�Z-d d � Z.dd� Z/� fd d�Z0dd� Z1dd� Z2� Z3S )�Parserz� This class is used to parse a Python file, it then divides them into a class structure of different scopes. :param pgen_grammar: The grammar object of pgen2. Loaded by load_grammar. )Z expr_stmtZclassdefZfuncdef� file_input�import_nameZimport_fromZ break_stmtZ continue_stmtZreturn_stmtZ raise_stmtZ yield_exprZdel_stmtZ pass_stmtZglobal_stmtZ nonlocal_stmtZ print_stmtZassert_stmtZif_stmtZ with_stmtZfor_stmtZ while_stmtZtry_stmtZ sync_comp_for� decoratorZlambdefZlambdef_nocondZnamedexpr_testTr c s( t � j|||d� g | _g | _d| _d S )N)�error_recoveryr )�super�__init__Z syntax_errors�_omit_dedent_list�_indent_counter)�selfZpgen_grammarr Zstart_nonterminal�� __class__� ��/root/rpmbuild/BUILDROOT/imh-python39-modules-3.9.7-92.el8.x86_64/opt/imh-python/lib/python3.9/site-packages/parso/python/parser.pyr @ s �zParser.__init__c s* | j r| jdkrt�| �|�}t� �|�S )Nr )�_error_recovery�_start_nonterminal�NotImplementedError�_recovery_tokenizer �parse)r �tokensr r r r H s zParser.parsec C sT z| j | |�}W n< tyN |dkr>|d g|dd� }| �||�}Y n0 |S )a Convert raw node information to a PythonBaseNode instance. This is passed to the parser driver which calls it whenever a reduction of a grammar rule produces a new complete node, so that the tree is build strictly bottom-up. �suiter � ���)�node_map�KeyError�default_node)r �nonterminal�children�noder r r �convert_nodeQ s zParser.convert_nodec C sH |t kr0|| jjv r"t�|||�S t�|||�S | j�|tj�|||�S )N) �NAMEZ _pgen_grammarZreserved_syntax_stringsr �Keyword�Name� _leaf_map�get�Operator)r �type�value�prefix� start_posr r r �convert_leafe s zParser.convert_leafc s� | j d j}|r|d �� }nd }| jdkr�|jtjksZ|jtkr�|j� d�s�|j� d�s�| j d j jdkr�z| j d j jtj }W n ty� Y n,0 |jjr�|js�|j| j d _ | �|� d S | js�t� �|�S dd� }|| j �}| �|d ��r| �|� nH|\}}} } |tk�r&| j�| j� t�|j|| | �}| j d j�|� | j d }|jd k�r�z|j jd |_ W n t�y� Y n0 d S )Nr r � � Zsimple_stmtc S sJ t tt| ���D ]4\}}|jdkr( qFq|jdkrt|j�dkr qFq|S )Nr r � )�reversed�list� enumerater �len�nodes)�stack�until_index� stack_noder r r � current_suite� s z,Parser.error_recovery.<locals>.current_suiter0 r �stmt) r6 r5 Z get_last_leafr r) r � ENDMARKER�DEDENTr* �endswithZdfaZ from_ruleZtransitions�NEWLINEr Znext_dfaZis_finalZ dfa_pushesZ _add_tokenr r r �_stack_removal�INDENTr �appendr r ZPythonErrorLeaf�namer Zarcs) r �tokenZ tos_nodesZ last_leafZplanr9 r7 �typr* r, r+ Z error_leafZtosr r r r o sN �� � � zParser.error_recoveryc C sR dd� | j |d � D �}|r<t�|�}| j |d j�|� g | j |d �<