a *eg @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-2024 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 G/usr/local/lib/python3.9/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 ?r z#regex_opt_inner..cSsg|]}|dddqS)Nr rr r r rBr c3s|]}|d VqdSrr r)slenr r Hr z"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) stringsZ open_parenZ close_parenZ oneletterrestrprefixZ 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_optRsr-)rr)__doc__reros.pathr itertoolsroperatorrcompilerZ FIRST_ELEMENTrr"r-r r r r s      8