Your IP : 216.73.216.85
B
ͽ�\ � @ sl d Z ddlZddlmZ ddlmZ ddlmZ ddlmZ e� d�Z
ed�Zdd � Zd
d� Z
dd
d�ZdS )a
pygments.regexopt
~~~~~~~~~~~~~~~~~
An algorithm that generates optimized regexes for matching long lists of
literal strings.
:copyright: Copyright 2006-2019 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
� N)�escape)�commonprefix)�groupby)�
itemgetterz
[\^\\\-\]]c C s dt �dd� d�| �� d S )N�[c S s d| � � S )N�\)�group)�m� r
�B/opt/alt/python37/lib/python3.7/site-packages/pygments/regexopt.py�<lambda> � zmake_charset.<locals>.<lambda>� �])� CS_ESCAPE�sub�join)Zlettersr
r
r �make_charset s r c s� |rdp
d}| sdS | d � t | �dkr8|t� � | S � sZ|t| dd� d� d | S t � �dkr�g }g }x.| D ]&}t |�dkr�|�|� qt|�|� qtW t |�dkr�|r�|t|d� d t|� | S |t|� | S t| �}|�rt |��|t|� t�fd d
�| D �d� | S dd
� | D �}t|�}|�rtt |��|tt�fdd
�| D ��d� t|ddd� � | S |d�dd
� t| � fdd��D �� | S )zEReturn a regex that matches any string in the sorted list of strings.�)r r � Nz(?:�?�|c s g | ]}|� d � �qS )Nr
)�.0�s)�plenr
r �
<listcomp>@ s z#regex_opt_inner.<locals>.<listcomp>c S s g | ]}|d d d� �qS )N���r
)r r r
r
r r C s c 3 s | ]}|d � � V qd S )Nr
)r r )�slenr
r � <genexpr>I s z"regex_opt_inner.<locals>.<genexpr>r c s s | ]}t t|d �d�V qdS )r r N)�regex_opt_inner�list)r r r
r
r r N s c s | d � d kS )Nr r
)r )�firstr
r r O r
z!regex_opt_inner.<locals>.<lambda>) �lenr r �appendr r �sortedr r ) �stringsZ
open_parenZclose_parenZ oneletter�restr �prefixZstrings_rev�suffixr
)r! r r r r s:
(6r r c C s t | �} |t| d� | S )z�Return a compiled regex that matches any string in the given list.
The strings to match must be literal strings, not regexes. They will be
regex-escaped.
*prefix* and *suffix* are pre- and appended to the final regex.
�()r$ r )r% r'