]i dZddlZddlmZddlmZddlmZejdZedZ dZ dZ d Z d d Z dS) a pygments.regexopt ~~~~~~~~~~~~~~~~~ An algorithm that generates optimized regexes for matching long lists of literal strings. :copyright: Copyright 2006-present by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details. N)escape)groupby) itemgetterz [\[\^\\\-\]]c|sdSt|}t|}t|D]\}}|||kr |d|cS|S)zJGiven an iterable of strings, returns the longest common leading substringN)minmax enumerate)ms1s2ics a/home/jenkins/workspace/simtester-sanitize/venv/lib/python3.11/site-packages/pygments/regexopt.py commonprefixrsf r QB QB" 1 1::bqb6MMM  Icldtdd|zdzS)N[c0d|zS)N\)group)r s rzmake_charset.."s )9rr]) CS_ESCAPEsubjoin)letterss r make_charsetr!s0 992777;K;KLL Ls RRrc  |rdpd}|sdS|d t|dkr|t z|zS s!|t|dddzdz|zSt dkrg}g}|D]@}t|dkr||+||At|dkr@|r)|t|dzdzt |z|zS|t |z|zSt |}|rAt| |t|zt fd |Ddz|zSd |D}t |}|rWt| |tt fd |Ddzt|ddd z|zS|dd t| fdDz|zS)zEReturn a regex that matches any string in the sorted list of strings.)rrNz(?:?|c$g|] }|d SN).0splens r z#regex_opt_inner..Js!999Aqx999rc$g|] }|dddS)Nr&)r'r(s rr*z#regex_opt_inner..Ms",,,q1TTrT7,,,rc3.K|]}|d VdSr%r&)r'r(slens r z"regex_opt_inner..Ss-$@$@1QvvY$@$@$@$@$@$@rr,c3\K|]'}tt|ddV(dS)r!rN)regex_opt_innerlist)r'rs rr/z"regex_opt_inner..XsRLL!eAh44LLLLLLrc(|ddkS)Nrr&)r(firsts rrz!regex_opt_inner..Ys1q9Ir) lenrr1appendrrsortedrr) strings open_paren close_paren oneletterrestr(prefix strings_revsuffixr4r)r.s @@@rr1r1%s$*K r AJE 7||qF5MM)K77  OGABBK???   5zzQ   A1vv{{  #### A y>>A   <!OD"$=$==C"9--.0;<< Y 7 77+E E ' " "F 6{{F6NN*99999995AAB -,G,,,K + & &F 16{{f$@$@$@$@$@$@$@@@%HHIVDDbD\""#%01 1  LL%g/I/I/I/IJJLLL L L L  rrcLt|}|t|dz|zS)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. ()r7r1)r8r=r?s r regex_optrB]s)WooG OGS11 1F ::r)rr)__doc__rer itertoolsroperatorrcompiler FIRST_ELEMENTrrr1rBr&rrrIs    BJ ' '  1    SSS555p ; ; ; ; ; ;r