|e dZddlZddlmZddlmZddlmZddlmZejdZ edZ dZ d Z d d Zy) a pygments.regexopt ~~~~~~~~~~~~~~~~~ An algorithm that generates optimized regexes for matching long lists of literal strings. :copyright: Copyright 2006-2023 by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details. N)escape) commonprefix)groupby) itemgetterz [\[\^\\\-\]]cZdtjddj|zdzS)N[c(d|jzS)N\)group)ms 3/usr/lib/python3/dist-packages/pygments/regexopt.pyzmake_charset..s )9]) CS_ESCAPEsubjoin)letterss r make_charsetrs' 92777;KL Ls RRrc r |xrdxsd}|sy|d t|dk(r|t z|zS s|t|dddzdz|zSt dk(r~g}g}|D]3}t|dk(r|j|#|j|5t|dkDr4|r!|t|dzdzt |z|zS|t |z|zSt |}|r:t|}|t|zt|Dcgc]}||d c}dz|zS|Dcgc] }|ddd  }}t |} | rAt|  |tt fd |Ddzt| ddd z|zS|djd t| fd Dz|zScc}wcc}w) zEReturn a regex that matches any string in the sorted list of strings.)rrNz(?:?|c3*K|] }|d  yw)N).0sslens r z"regex_opt_inner..Hs$@1QvY$@sc3LK|]}tt|ddyw)rrN)regex_opt_innerlist)rr s r r"z"regex_opt_inner..Ms)L!eAh4Ls"$c|ddk(S)Nrr)r firsts r rz!regex_opt_inner..Ns1q9Ir) lenrr$appendrrsortedrr) strings open_paren close_paren oneletterrestr prefixplen strings_revsuffixr'r!s @@r r$r$s$*K  AJE 7|qF5M)K77 OGABK??   5zQ  A1v{  # A   y>A !OD"$==C"9-.0;<< Y 77+E E ' "F 6{F6N*9Aqx95AB %,,q1TrT7,K, + &F 6{f$@$@@%HIVDbD\"#%01 1  L%g/IJL L L  :-s  F/ %F4c<t|}|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. ()r*r$)r+r0r3s r regex_optr6Rs$WoG OGS1 1F ::r)rr)__doc__reros.pathr itertoolsroperatorrcompiler FIRST_ELEMENTrr$r6rrr r>sE    BJJ ' 1 S5p ;r