U ʗRe @sldZddlZddlmZddlmZddlmZddlmZe dZ edZ dd Z d d Z dd dZdS)a pygments.regexopt ~~~~~~~~~~~~~~~~~ An algorithm that generates optimized regexes for matching long lists of literal strings. :copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details. N)escape) commonprefix)groupby) itemgetterz [\[\^\\\-\]]cCsdtddd|dS)N[cSs d|S)N\)group)mr /builddir/build/BUILDROOT/alt-python38-pip-22.2.1-2.el8.x86_64/opt/alt/python38/lib/python3.8/site-packages/pip/_vendor/pygments/regexopt.pyzmake_charset..]) CS_ESCAPEsubjoin)lettersr r r make_charsetsrc s|rdp d}|sdS|dt|dkr8|t|SsZ|t|dddd|Stdkrg}g}|D]&}t|dkr||qr||qrt|dkr|r|t|ddt||S|t||St|}|rt||t|tfd d |Dd|Sd d |D}t|}|rpt||ttfd d |Ddt|ddd|S|ddd t|fddD|S)zEReturn a regex that matches any string in the sorted list of strings.)rrNz(?:?|csg|]}|dqSNr .0s)plenr r ?sz#regex_opt_inner..cSsg|]}|dddqS)Nr rr r r rBsc3s|]}|d VqdSrr r)slenr r Hsz"regex_opt_inner..rcss |]}tt|ddVqdS)rrN)regex_opt_innerlist)rrr r r r!Mscs|ddkS)Nrr )r)firstr r r Nr z!regex_opt_inner..) lenrr"appendrrsortedrr) strings open_paren close_paren oneletterrestrprefix strings_revsuffixr )r$rr r r"sj         r"rcCst|}|t|d|S)zReturn 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-r/r r r regex_optRsr1)rr)__doc__reros.pathr itertoolsroperatorrcompiler FIRST_ELEMENTrr"r1r r r r s      8