| Server IP : 217.160.0.135 / Your IP : 216.73.216.115 Web Server : Apache System : Linux www 6.18.52-i1-ampere #1203 SMP Mon Sep 14 18:29:59 CEST 2026 aarch64 User : sws1074145052 ( 1074145052) PHP Version : 8.3.32 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /lib/python3/dist-packages/parso/python/__pycache__/ |
Upload File : |
�
̑�a�� � � � d Z ddlZddlZddlmZ ddlZddlmZ ddlm Z ddl
mZ ddlm
Z
mZ ddlmZ ej e� � Zd Zd
Zej Zej Zej Zej Zej Zd� Zd� Zd
� Zd� Zd� Zd� Z d� Z!d� Z"d� Z#d� Z$d$d�Z%d� Z&d� Z'd� Z(d� Z) G d� de*� � Z+d� Z, G d� d� � Z- G d � d!� � Z. G d"� d#� � Z/dS )%aa
The diff parser is trying to be a faster version of the normal parser by trying
to reuse the nodes of a previous pass over the same file. This is also called
incremental parsing in parser literature. The difference is mostly that with
incremental parsing you get a range that needs to be reparsed. Here we
calculate that range ourselves by using difflib. After that it's essentially
incremental parsing.
The biggest issue of this approach is that we reuse nodes in a mutable way. The
intial design and idea is quite problematic for this parser, but it is also
pretty fast. Measurements showed that just copying nodes in Python is simply
quite a bit slower (especially for big files >3 kLOC). Therefore we did not
want to get rid of the mutable nodes, since this is usually not an issue.
This is by far the hardest software I ever wrote, exactly because the initial
design is crappy. When you have to account for a lot of mutable state, it
creates a ton of issues that you would otherwise not have. This file took
probably 3-6 months to write, which is insane for a parser.
There is a fuzzer in that helps test this whole thing. Please use it if you
make changes here. If you run the fuzzer like::
test/fuzz_diff_parser.py random -n 100000
you can be pretty sure that everything is still fine. I sometimes run the
fuzzer up to 24h to make sure everything is still ok.
� N)�
namedtuple)�split_lines)�Parser)� EndMarker)�PythonToken�BOM_UTF8_STRING)�PythonTokenTypesF)�INDENT�ERROR_DEDENT�DEDENTc �4 � | j dk o
| j t v S )N�
error_leaf)�type�
token_type�_INDENTATION_TOKENS��nodes �3/usr/lib/python3/dist-packages/parso/python/diff.py�_is_indentation_error_leafr 3 s � ��9��$�O���<O�)O�O� c �r � | r4t | � � r%| � � � } | rt | � � �%| S �N)r �get_previous_leaf��leafs r �!_get_previous_leaf_if_indentationr 7 sJ � �
� (�-�d�3�3� (��%�%�'�'�� � (�-�d�3�3� (��Kr c �r � | r4t | � � r%| � � � } | rt | � � �%| S r )r �
get_next_leafr s r �_get_next_leaf_if_indentationr = sJ � �
� $�-�d�3�3� $��!�!�#�#�� � $�-�d�3�3� $��Kr c �6 � t | j d � � S �N� )�_get_indentation�children�� tree_nodes r �_get_suite_indentationr'