Files
intellecton/venv/lib/python3.12/site-packages/pygments/__pycache__/lexer.cpython-312.pyc
T

329 lines
38 KiB
Plaintext
Raw Normal View History

Ë
jR䋗XdZddlZddlZddlZddlmZmZddlmZddl m
Z
m Z m Z m
Z
mZddlmZmZmZmZmZmZddlmZgd¢Zej2d «Zgd
¢Zed «ZGd d
e«ZGdde¬«Z Gdde «Z!Gdde"«Z#Gdd«Z$e$«Z%Gdde&«Z'Gdd«Z(dZ)Gdd«Z*e*«Z+dZ,Gdd «Z-Gd!„d"e«Z.Gd#„d$e«Z/Gd%„d&e e/¬«Z0Gd'„d(«Z1Gd)„d*e0«Z2d+„Z3Gd,„d-e/«Z4Gd.„d/e0e4¬«Z5y)0z·
pygments.lexer
~~~~~~~~~~~~~~
Base lexer classes.
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
éN)Ú
apply_filtersÚFilter)Úget_filter_by_name)ÚErrorÚTextÚOtherÚ
WhitespaceÚ
_TokenType)Ú get_bool_optÚ get_int_optÚ get_list_optÚmake_analysatorÚFutureÚ guess_decode)Ú regex_opt)
ÚLexerÚ
RegexLexerÚExtendedRegexLexerÚDelegatingLexerÚ LexerContextÚincludeÚinheritÚbygroupsÚusingÚthisÚdefaultÚwordsÚline_rez.*?
))súutf-8)sÿþzutf-32)sþÿzutf-32be)sÿþzutf-16)sþÿzutf-16becóy)©)Úxs úQ/home/antigravity/intellecton/venv/lib/python3.12/site-packages/pygments/lexer.pyú<lambda>r%"óócóeZdZdZdZy)Ú LexerMetaz
This metaclass automagically converts ``analyse_text`` methods into
static methods which always return float values.
có\d|vrt|d«|d<tj||||«S) analyse_text)rÚtypeÚ__new__)ÚmcsÚnameÚbasesÚds r$r-zLexerMeta.__new__+s3Ø ˜ Ü /°°.Ñ0AÓ BˆAˆnÑ Ü|‰|˜C  u¨aÓ0r'N)Ú__name__Ú
__module__Ú __qualname__Ú__doc__r-r"r'r$r)r)%s ñó
1r'r)có`eZdZdZdZgZgZgZgZdZ dZ
dZ dZ dZ
dZdZdZdZd d „Zd
Zy) ra"
Lexer for a specific language.
See also :doc:`lexerdevelopment`, a high-level guide to writing
lexers.
Lexer classes have attributes used for choosing the most appropriate
lexer based on various criteria.
.. autoattribute:: name
:no-value:
.. autoattribute:: aliases
:no-value:
.. autoattribute:: filenames
:no-value:
.. autoattribute:: alias_filenames
.. autoattribute:: mimetypes
:no-value:
.. autoattribute:: priority
Lexers included in Pygments should have two additional attributes:
.. autoattribute:: url
:no-value:
.. autoattribute:: version_added
:no-value:
Lexers included in Pygments may have additional attributes:
.. autoattribute:: _example
:no-value:
You can pass options to the constructor. The basic options recognized
by all lexers and processed by the base `Lexer` class are:
``stripnl``
Strip leading and trailing newlines from the input (default: True).
``stripall``
Strip all leading and trailing whitespace from the input
(default: False).
``ensurenl``
Make sure that the input ends with a newline (default: True). This
is required for some lexers that consume input linewise.
.. versionadded:: 1.3
``tabsize``
If given and greater than 0, expand tabs in the input (default: 0).
``encoding``
If given, must be an encoding name. This encoding will be used to
convert the input string to Unicode, if it is not already a Unicode
string (default: ``'guess'``, which uses a simple UTF-8 / Locale /
Latin1 detection. Can also be ``'chardet'`` to use the chardet
library, if it is installed.
``inencoding``
Overrides the ``encoding`` if given.
Nrc ól||_t|dd«|_t|dd«|_t|dd«|_t |dd«|_|jdd «|_|jd
«xs |j|_g|_ t|d d «D]}|j|«Œy
)a
This constructor takes arbitrary options as keyword arguments.
Every subclass must first process its own options and then call
the `Lexer` constructor, since it processes the basic
options like `stripnl`.
An example looks like this:
.. sourcecode:: python
def __init__(self, **options):
self.compress = options.get('compress', '')
Lexer.__init__(self, **options)
As these options must all be specifiable as strings (due to the
command line usage), there are various utility functions
available to help with that, see `Utilities`_.
ÚstripnlTÚstripallFÚensurenlÚtabsizerÚencodingÚguessÚ
inencodingÚfiltersr"N) Úoptionsr r8r9r:r r;Úgetr<r?r
Ú
add_filter)Úselfr@Úfilter_s r$Ú__init__zLexer.__init__ð&ˆŒ Ü# G¨Y¸ÓŒ Ü$ W¨j¸%ÓŒ
Ü$ W¨j¸?ˆŒ
Ü" 7¨I°qÓŒ ØŸ  J°ÓŒ
ØŸ  LÓB°T·]±]ˆŒ
؈Œ Ü# G¨Y¸Ó %ˆ O‰O˜  %r'cóœ|jr'd|jjd|jdSd|jjdS)Nz<pygments.lexers.z with ú>)r@Ú __class__r2©rCs r$Ú__repr__zLexer.__repr__¯sIØ <Š<Ø& t§~¡~×'>Ñ'>Ð&?¸vÀdÇlÁlÐEUÐUVÐ & t§~¡~×'>Ñ'>Ð&?¸ Ar'c órt|t«s t|fi|¤Ž}|jj |«y)z8
Add a new stream filter to this lexer.
N)Ú
isinstancerrr?Úappend)rCrDr@s r$rBzLexer.add_filterµs/ô˜'¤6ÔÑ<°GÑ<ˆ ×ј$r'cóy)
A static method which is called for lexer guessing.
It should analyse the text and return a float in the range
from ``0.0`` to ``1.0``. If it returns ``0.0``, the lexer
will not be selected as the most probable one, if it returns
``1.0``, it will be selected immediately. This is used by
`guess_lexer`.
The `LexerMeta` metaclass automatically wraps this function so
that it works like a static method (no ``self`` or ``cls``
parameter) and the return value is automatically converted to
`float`. If the return value is an object that is boolean `False`
it's the same as if the return values was ``0.0``.
Nr")Útexts r$r+zLexer.analyse_text½r&r'cóÊt|t«sì|jdk(rt|«\}}ní|jdk(r„ ddl}d}t D]6\}}|j|«sŒ|t|«dj|d«}n|€9|j|dd«}|j|jd«xsd d«}|}nZ|j|j«}|jd
«r.|td
«d}n|jd
«r|td
«d}|jd d «}|jd
d «}|jr|j«}n|jr|jd «}|j dkDr|j#|j «}|j$r|j'd «s|d z
}|S#t
$r}t d«|d}~wwxYw)zVApply preprocessing such as decoding the input, removing BOM and normalizing newlines.r=ÚchardetrNzkTo enable chardet encoding guessing, please install the chardet library from http://chardet.feedparser.org/Úreplaceir<ruz
ú
ú
)rLÚstrr<rrQÚ ImportErrorÚ
_encoding_mapÚ
startswithÚlenÚdecodeÚdetectrArRr9Ústripr8r;Ú
expandtabsr:Úendswith) rCrOÚ_rQÚdecodedÚbomr<Úencs r$Ú_preprocess_lexer_inputzLexer._preprocess_lexer_inputÎô˜Ô}‰} Ò& , TÛ Ü%2òMC˜Ø +Ø"&¤s¨3£x y /×"8Ñ"8¸À9Ó"M˜Ùðð
!Ÿ.™.¨¨e¨t¨Ó5"Ÿk™k¨#¯'©'°*Ó*=Ò*HÀØ*3ó5à—{‘{ 4§=¡=Ó1Ø—?‘? 8Ô¤ H£
 Ð/‘Dà˜xÔœC ›M˜NÐ+ð|‰|˜F DÓ)ˆØ|‰|˜D 'ˆØ =Š=Ø—::“<‰DØ
\Š\Ø—::˜#ˆ <‰<˜ Ø—?? 4§<¡<Ó0ˆ =Š= §¡¨tÔ!4Ø D‰LˆDàˆ øôITÜ'LóMàRSðTûðTús¿GÇ G"Ç GÇG"cóxj«Šˆˆfd}|«}|st|j«}|S)ae
This method is the basic interface of a lexer. It is called by
the `highlight()` function. It must process the text and return an
iterable of ``(tokentype, value)`` pairs from `text`.
Normally, you don't need to override this method. The default
implementation processes the options recognized by all lexers
(`stripnl`, `stripall` and so on), and then yields all tokens
from `get_tokens_unprocessed()`, with the ``index`` dropped.
If `unfiltered` is set to `True`, the filtering mechanism is
bypassed even if filters are defined.
c3óNKj«D] \}}}||fŒy­w©N)Úget_tokens_unprocessed)r_ÚvrCrOs €€r$Ústreamerz"Lexer.get_tokens.<locals>.streamer
s0øèø€Ø×6°tÓ
1˜d“
ñ
ùsƒ"%)rdrr?)rCrOÚ
unfilteredrkÚstreams`` r$Ú
get_tokenszLexer.get_tokensýs=ù€ð×+¨DÓõ ñˆÙÜ" 6¨4¯<©<¸Ó>ˆˆ
r'cót)aS
This method should process the text and return an iterable of
``(index, tokentype, value)`` tuples where ``index`` is the starting
position of the token within the input text.
It must be overridden by subclasses. It is recommended to
implement it as a generator to maximize effectiveness.
)ÚNotImplementedError)rCrOs r$rhzLexer.get_tokens_unprocesseds
ô!r')F)r2r3r4r5r/ÚaliasesÚ filenamesÚalias_filenamesÚ mimetypesÚpriorityÚurlÚ
version_addedÚ_examplerErJrBr+rdrnrhr"r'r$rr1slñ8ðv €Dð€Gð
€Ið€Oð€Ið€Hð €Cð€Mð€Hò%ò<Bò  ò"-ó^ó0 "r'r)Ú metaclasscó eZdZdZefdZdZy)ra 
This lexer takes two lexer as arguments. A root lexer and
a language lexer. First everything is scanned using the language
lexer, afterwards all ``Other`` tokens are lexed using the root
lexer.
The lexers from the ``template`` lexer package use this base lexer.
c ór|di|¤Ž|_|di|¤Ž|_||_tj|fi|¤Žy©Nr")Ú
root_lexerÚlanguage_lexerÚneedlerrE)rCÚ _root_lexerÚ_language_lexerÚ_needler@s r$rEzDelegatingLexer.__init__+s9ÙÑŒÙÑÔØˆŒ Ü
'˜'r'cóld}g}g}|jj|«D]N\}}}||jur&|r|jt |«|f«g}||z
}Œ;|j|||f«ŒP|r|jt |«|f«t ||j j|««S))r~rhrrMrYÚ
do_insertionsr})rCrOÚbufferedÚ
insertionsÚ
lng_bufferÚirirjs r$rhz&DelegatingLexer.get_tokens_unprocessed1؈؈
؈
Ø×AÀ$Ó -‰GˆAˆqD—K‘KÑÙØ×%¤s¨8£}°jÐ&AÔBØ!#˜A
à×! 1 a¨ )Õ Ø × Ñ œs 8›}¨jÐ ˜ZØ!Ÿ_™_×CÀHÓOð Or'N)r2r3r4r5rrErhr"r'r$rr!sñð>Có Or'rcóeZdZdZy)rzI
Indicates that a state should include rules from another state.
r2r3r4r5r"r'r$rrHs ñð r'rcóeZdZdZdZy)Ú_inheritzC
Indicates the a state should inherit from its superclass.
cóy)Nrr"rIs r$rJz_inherit.__repr__SsØr'N)r2r3r4r5rJr"r'r$rrOs ñór'rcóeZdZdZdZdZy)Úcombinedz:
Indicates a state combined from multiple states.
có.tj||«Srg)Útupler-)ÚclsÚargss r$r-zcombined.__new__^sÜ}‰}˜S 'r'cóyrgr")rCr”s r$rEzcombined.__init__asà r'N)r2r3r4r5r-rEr"r'r$rrYsñò
r'rcó:eZdZdZdZd dZd dZd dZdZdZ y)
Ú _PseudoMatchz:
A pseudo match object constructed from a string.
có ||_||_yrg)Ú_textÚ_start)rCÚstartrOs r$rEz_PseudoMatch.__init__ks؈Œ
؈ r'Ncó|jSrg)©rCÚargs r$rz_PseudoMatch.startos Ø{‰{Ðr'cóF|jt|j«zSrg)rYr™rs r$Úendz_PseudoMatch.endrsØ{‰{œS §¡,r'có4|r td«|jS)Nz
No such group)Ú
IndexErrorr™rs r$Úgroupz_PseudoMatch.groupus٠ܘ z‰zÐr'có|jfSrg)r™rIs r$Úgroupsz_PseudoMatch.groupszsØ
ˆr'cóiSrgr"rIs r$Ú groupdictz_PseudoMatch.groupdict}s؈ r'rg)
r2r3r4r5rErr r"r'r$r—r—fs%ñòóóò
ór'r—códˆfd„ }|S)zL
Callback that yields multiple actions for each group in the match.
c
3ó¶Kt«D\}}|Œ t|«tur1|j|dz«}|sŒ1|j |dz«||fŒK|j|dz«}|Œb|r|j |dz«|_||t
|j |dz«|«|«D] }|sŒ|Œ Œ°|r|j«|_yy­w))Ú enumerater,r
rÚposr—r )ÚlexerÚmatchÚctxr‰ÚactionÚdataÚitemr”s €r$Úcallbackzbygroups.<locals>.callback…øèø€Ü" 4ò '‰IˆAˆˆ~ØÜf“¤Ñ—{‘{ 1 q¡5Ó)ÚØŸ+™+ a¨!¡eÓ,¨f°dЗ{‘{ 1 q¡5Ó)ØÑØ"'§+¡+¨a°!©eÓ"4˜œÙ & uÜ'3°E·K±KÀÀAÁÓ4FÈÓ'MÈsó!Tò'˜âØ"& Ø—ii“kˆC ùsƒ<CÁ0CÁ1ACÂ8!Crgr")r”s` r$rrsø€õ"ð& €Or'cóeZdZdZy)Ú_ThiszX
Special singleton used for indicating the caller class.
Used by ``using``.
Nrr"r'r$sòr'c ó²iŠdvr4‰jd«}t|ttf«r|d<nd|fd<tur dˆˆfd„ }|Sdˆˆˆfd„ }|S)
Callback that processes the match with a different lexer.
The keyword arguments are forwarded to the lexer, except `state` which
is handled separately.
`state` specifies the state that the new lexer will start in, and can
be an enumerable such as ('root', 'inline', 'string') or a simple
string which is assumed to be on top of the root state.
Note: For that to work, `_other` must not be an `ExtendedRegexLexer`.
ÚstateÚstackÚrootc3ó@K
r9t|j«}|j
«|jdi|¤Ž}n|}|j «}|j
|j
«fi‰ ¤ŽD]\}}}||z||fŒ|r|j«|_yy­wr|) Údictr@ÚupdaterHrrhr ) r­r1ÚlxÚsr‰rirjÚ gt_kwargsÚkwargss €€r$zusing.<locals>.callbackºsøèø€ñ䘟Ó'Ø˜Ô Ø$U—_‘_Ñ) qÑ)‘àØ
ˆAØ4˜2×4°U·[±[³]ÑPÀiÑ
"1˜!e˜Q 
ØŸ)™)+ðùsƒBBc3ó"Kt|j«}|j «‰ di|¤Ž}|j«}|j|j «fi
¤ŽD]\}}}||z||fŒ|r|j
«|_yy­wr|)r@rrhr ) r­r1r‰rirjÚ_otherr¿s €€€r$zusing.<locals>.callbackÊs‰øèø€äU—]‘]Ó#ˆAØ
H‰H Ù˜!‘ˆBà
ˆAØ4˜2×4°U·[±[³]ÑPÀiÑ
"1˜!e˜Q 
ØŸ)™)+ðùsƒB Brg)ÚpoprLÚlistrr)r¿s`` @r$rr¤seú€ð€IØØ J‰J ˆÜ aœ$¤˜Ô 'Ø!"ˆI à"(¨! ˆI à
 &ð6 €O÷
 €Or'cóeZdZdZdZy)r
Indicates a state or state action (e.g. #pop) to apply.
For example default('#pop') is equivalent to ('', Token, '#pop')
Note that state tuples may be used as well.
.. versionadded:: 2.0
có||_yrg))rCs r$rEzdefault.__init__às ؈
r'N)r2r3r4r5rEr"r'r$rrØs ñór'rcóeZdZdZddZdZy)rz•
Indicates a list of literal words that is transformed into an optimized
regex that matches any of the words.
.. versionadded:: 2.0
có.||_||_||_yrg)rÚprefixÚsuffix)rCrs r$rEzwords.__init__ës؈Œ
؈Œ ؈ r'cóZt|j|j|j¬«S))rrrIs r$rAz words.getðsܘŸ¨D¯K©KÀÇ Á ÔLr'N)r„r„)r2r3r4r5rErAr"r'r$rräsñó ó
Mr'rcó<eZdZdZdZdZdZdZd
dZdZ d „Z
y) ÚRegexLexerMetazw
Metaclass for RegexLexer, creates the self._tokens attribute from
self.tokens on the first instantiation.
có‚t|t«r|j«}tj||«j
S)zBPreprocess the regular expression component of a token definition.)rLrrAÚreÚcompiler®)r“ÚregexÚrflagsr·s r$Ú_process_regexzRegexLexerMeta._process_regexús.ä eœVÔ —I‘I“KˆEÜz‰z˜% Ó(×.r'cóRt|«tust|«s
Jd|«|S)z5Preprocess the token component of a token definition.z0token type must be simple type or callable, not )r,r
Úcallable)r“Útokens r$Ú_process_tokenzRegexLexerMeta._process_tokens2äE{œjÑ(¬H°U¬Oð IØ>¸u¸  IЈ r'cóät|t«r5|dk(ry||vr|fS|dk(r|S|dddk(rt|dd« SJd|«t|t«rfd|jz}|xjd z
c_g}|D]3}||k7s
Jd
|«|j |j
|||««Œ5|||<|fSt|t«r|D]}||vrŒ|d vrŒ
Jd|z«|SJd |«)
z=Preprocess the state transition action of a token definition.ú#popéÿÿÿÿú#pushNéz#pop:zunknown new state z_tmp_%drªzcircular state ref )zunknown new state def )rLrUÚintrÚ_tmpnameÚextendÚ_process_stater)r“Ú new_stateÚ unprocessedÚ processedÚ tmp_stateÚitokensÚistates r$Ú_process_new_statez!RegexLexerMeta._process_new_statesQä Ô ˜Ø˜!˜gÒ Ð Ø˜2˜A ˜I a b˜@Ð 2°9°-Ð@
˜ ¤8Ô
! C§L¡LÑ0ˆIØ LŠL˜ ˆGØ
FØ ÒLÐ.AÀ&ÀÐ,LÓ˜s×1°+Ø2;¸Vó EõFð
Fð$+ˆI Ø Ü
˜ ¤5Ô

2Ø Ð"3Ò(¨6Ñ
Ð à 2°9°-Ð @5r'c ó~t|t«s
Jd|«|ddk7s
Jd|«||vr||Sgx}||<|j}||D]?}t|t«r;||k7s
Jd|«|j |j ||t|«««ŒOt|t «rŒ`t|t«rO|j|j||«}|jtjd«jd|f«Œ¿t|«tus
Jd|« |j!|d||«}|j'|d
«}
t)|«dk(rd}n|j|d||«}|j||
|f«ŒB|S#t"$r } t%d |dd
|d |d | «| d} ~ wwxYw)z%Preprocess a single state definition.zwrong state name rú#zinvalid state name zcircular state reference r„Nzwrong rule def zuncompilable regex z
in state z of z: rªé)rLrUÚflagsrrrrMr,rÚ ExceptionÚ
ValueErrorrØrY) r“ÚtokensrÓÚtdefrâÚrexÚerrr×s r$zRegexLexerMeta._process_state)ä˜ÔDÐ):¸5¸)Ð'DÓQ‰x˜Ð?Ð"5°e°YÐ ?Ó?ˆØ  ؘ #Ø$&Ð&ˆ˜ˆØ Ñ 3ˆDܘԘuKÐ(AÀ%ÀÐ&KÓK
˜c׸iÜ14°T³óܘ$¤Ôܘ$¤Ô×2°4·:±:¸{ÈIÓV Ø
œrŸz™z¨"~×3°T¸9Ð䘓:¤Ñ B¨/¸$¸Ð(BÓ 
rØ×¨a©°&¸@ð×& t¨A¡wÓ/ˆ4y˜AŠ~Ø ‘ à×2°4¸±7Ø3>À óK ð
M‰M˜3   2ðA 3ðBˆ
øôò
rÜ Ð#6°t¸A±w°kÀÈEÈ9ÐTXÐY\ÐX_Ð_aÐbeÐafÐ!gÓhÐnqÐqûð
rúsÄ)FÆ F<ÆF7Æ7F<Ncó”ix}|j|<|xs|j|}t|«D]}|j|||«Œ|S)z-Preprocess a dictionary of token definitions.)Ú _all_tokensrï)r“r/Ú tokendefsräs r$Úprocess_tokendefzRegexLexerMeta.process_tokendefTsSà,.Ð.ˆ C—O‘O DÑÒ§¡¨DÑ!1ˆ ܘ)“_ò <ˆ × Ñ ˜y¨)°UÕ Ðr'có²i}i}|jD}|jjdi«}|j«D]t\}}|j|«}|€!|||< |j t
«}|||<Œ:|j|d«}|ŒO||||dz |j t
«} || z||<ŒvŒ§|S#t $rYŒ†wxYw#t $rYŒ•wxYw)a
Merge tokens from superclasses in MRO order, returning a single tokendef
dictionary.
Any state that is not defined by a subclass will be inherited
automatically. States that *are* defined by subclasses will, by
default, override that state in the superclass. If a subclass wishes to
inherit definitions from a superclass, it can use the special value
"inherit", which will cause the superclass' state definition to be
included at that point in the state.
Nrª)Ú__mro__Ú__dict__rAÚitemsÚindexr)
r“Ú inheritableÚtoksr·ÚcuritemsÚ inherit_ndxÚ new_inh_ndxs
r$Ú
get_tokendefszRegexLexerMeta.get_tokendefs\sðˆØˆ Øò CˆAØ—::—>> (¨BÓ/ˆDà $§
¡
£ ò
C !Ÿ:™: ,ØÐ
%*F˜5!Ø&+§k¡k´'Ó&:˜ ð*5K Ñà)Ÿo™o¨e°TÓ: ØÐð7<˜ ¡]ÐCð#(§+¡+¬gÓ"6*5°{Ñ)BK Ò&ñ9
Cð CðBˆ
øô) ð!ûôÙðús$ÁB;ÂC
Â; CÃCÃ
CÃCcóèd|jvrLi|_d|_t|d«r
|jrn%|j d|j
««|_tj|g|¢­i|¤ŽS)z:Instantiate cls after preprocessing its token definitions.Ú_tokensrÚtoken_variantsr„)
Úhasattrrrrr,Ú__call__)r“r”Úkwdss r$rzRegexLexerMeta.__call__shà ˜CŸL™LÑ  ˆCŒO؈CŒLÜ-°#×2DÒ2Dàà!×2°2°s×7HÑ7HÓ7JÓK ä}‰}˜0 0¨4Ñ0r'rg) r2r3r4r5rrr"r'r$ôs.ñò
 ò !AòF)óVò/ób 1r'có4eZdZdZej
ZiZddZy)r
Base for simple stateful regular expression-based lexers.
Simplifies the lexing process so that you need only
provide a list of states and regular expressions.
c#ó:Kd}|j}t|«}||d} |D]&\}}} |||«}
|