3

V'ícŒ=ã@s°dZddlZddlmZmZmZmZmZmZddl	m
Z
mZmZm
Z
mZmZmZmZmZdgZdddd	d
ddd
ddddddddddddddddddd d!d"gZGd#d„deƒZdS)$zÅ
    pygments.lexers.crystal
    ~~~~~~~~~~~~~~~~~~~~~~~

    Lexer for Crystal.

    :copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS.
    :license: BSD, see LICENSE for details.
éN)ÚExtendedRegexLexerÚincludeÚbygroupsÚdefaultÚwordsÚline_re)	ÚCommentÚOperatorÚKeywordÚNameÚStringÚNumberÚPunctuationÚErrorÚ
WhitespaceÚCrystalLexerz!=z!~ú!ú%z&&ú&z**Ú*ú+ú-ú/z<=>z<<z<=ú<z===z==z=~ú=z>=z>>ú>z[]=z[]?z[]ú^z||ú|ú~c.@sÎeZdZdZdZdZddgZdgZdgZe	j
e	jBZdd	„Z
d
d„Zdejfed
jƒddefedjƒdddejfdejfedddgddejfdeeeejƒfdeeeejƒdfdedfdeeeejƒdfedjƒdddejfdejjfedjƒdddejfd ejjfd!e
fd"e
fd#ejd$fd%eeejƒd&fd'ejd&fd(eeejƒd&fd)eejee ƒfd*eej!ee ƒfd+eej"ee ƒfd,eej#ee ƒfd-eej#ee ƒfd.eej#ee ƒfd/eej$ee ƒfd0ej%j&fd1ej%j'fd2ej%j(fd3ej%j(fd4ej%j(fd5e fe)d6ƒd7ej*fd8ejfd9ej+d:fd;ej+d<fd=ee eej,ƒd>fee-d?d@ee ej ƒfdAee eƒfdBefdCe fdDe fdEe.fdFefg-dGeej&e ej/ƒdHfe0dHƒgdIej&fdJee.eej&ee.ƒfe0dHƒgdKej+dLfdMej+dHfe)dNƒgdOej+dPfgdQej1fge)dRƒe)dSƒge)dRƒdTejfdUejfge)dRƒdTej2fdUej2fge)dRƒdVejfdWejfdTejfdXejfdYejdHfgdZejdHfgd9ej+dLfd[ej+dHfd\efe)dNƒgd;ej+dLfd]ej+dHfe)dNƒgd^e dLfd_e dHfe)dNƒgd`œZ3e3j4eƒƒdaS)brz=
    For Crystal source code.

    .. versionadded:: 2.2
    ZCrystalzhttp://crystal-lang.orgÚcrZcrystalz*.crztext/x-crystalccsî|jdƒ}|t|jdƒfV|jdƒtj|jdƒfV|jdƒtj|jdƒfV|jdƒtj|jdƒfV|jjdgƒ}t|ƒ}|j	|jdƒdk|jdƒfƒ|jdƒ|_
|jdƒ|_t|ƒdkrØ|j
|d	EdHn|j
tj|jdƒfV|jƒ|_
|rêxÔ|D]Ì\}}g}x¼tj|j|j
ƒD]„}|r:|jƒjƒ}	n|jƒjƒ}	|	|kršx$|D]}
|
jƒtj|
jƒfVqVW|jƒtj|jƒfV|jƒ|_
Pn
|j	|ƒq"Wx"|D]}
|
jƒt|
jƒfVq°WqWt|jƒ|_|dd…=dS)
NééééÚheredocstackz<<-ééd)Úcontext)Ústartr	ÚgrouprZHeredocZ	DelimiterÚ__dict__Ú
setdefaultÚboolÚappendÚposÚendÚlenZget_tokens_unprocessedrÚfinditerÚtextÚstripÚrstripr)ÚselfÚmatchÚctxr(r$Z	outermostZtolerantZhdnameÚlinesÚcheckZamatch©r:ú;/tmp/pip-build-gk9425m9/Pygments/pygments/lexers/crystal.pyÚheredoc_callback*s@






 zCrystalLexer.heredoc_callbackc
Csni}dtjfttddtjfdtjfdtjfdtjdfdttjtƒfd	tjd
fdtjdfg|d
<xfdtjd	fdtjd	fdtjdffD]@\}}}t	|dkrœdndƒd||fd|f||dfg|d|<q„Wxžd>D]”\}}}}d*|tj
fg||k|tj
d+fg|tj
dft	dƒd,|d-tj
fd.|d/tj
fg||d0<|d
jd1|tj
|d0fƒd2|d-tj
fg||k|tj
d+fg|tj
dfd,|d-tj
fd.|d/tj
fg||d3<|d
jd4|tj
|d3fƒd2|d-tjfg||k|tjd+fg|d5tjdft	d6ƒd,|d-tjfd.|d/tjfg||d7<|d
jd8|tj|d7fƒqÐW|S)?Nz
\:\w+[!?]?z\:)Úprefixz:'(\\\\|\\[^\\]|[^'\\])*'z'(\\\\|\\'|[^']|\\[^'\\]+)'z:"z
simple-symz([a-zA-Z_]\w*)(:)(?!:)ú"z
simple-stringz(?<!\.)`zsimple-backtickÚstringsÚstringÚsymZbacktickú`zstring-escapedzstring-intp-escapedz	[^\\%s#]+z[\\#]z#popzsimple-ú\{ú\}ú{}Úcbú\[ú\]ú\[\]Úsbú\(ú\)ú()Úparrú<>Úabú\|Úpiz\\z#pushz[\\#ú]z[^\\#z]+z-intp-stringz%Q?z\\[\\z-stringz%[qwi]z[imsx]*zstring-intpz-regexz%r©rCrDrErF©rGrHrIrJ©rKrLrMrN©rrrOrP©rQrQrQrR)rTrUrVrWrX)
rZSymbolrÚCRYSTAL_OPERATORSÚCharrrÚDoubleZBacktickrÚOtherr-ÚRegex)ZstatesÚnameZttyper/ZlbraceZrbraceZbraceccr:r:r;Úgen_crystalstrings_rulesYsV



$
(
(z%CrystalLexer.gen_crystalstrings_rulesz#.*?$zó
                abstract asm begin break case do else elsif end ensure extend if in
                include next of private protected require rescue return select self super
                then unless until when while with yield
            z\b)Úsuffixzz
                previous_def forall out uninitialized __DIR__ __FILE__ __LINE__
                __END_LINE__
            z(?<!\.))r=r`z(\.(is_a\?|nil\?|responds_to\?|as\?|as\b)ÚtrueÚfalseÚnilz2(module|lib)(\s+)([a-zA-Z_]\w*(?:::[a-zA-Z_]\w*)*)z)(def|fun|macro)(\s+)((?:[a-zA-Z_]\w*::)*)Úfuncnamezdef(?=[*%&^`~+-/\[<>=])zI(annotation|class|struct|union|type|alias|enum)(\s+)((?:[a-zA-Z_]\w*::)*)Ú	classnamezN
                instance_sizeof offsetof pointerof sizeof typeof
            z+(?<!\.)(debugger\b|p!|pp!|record\b|spawn\b)z
                abort at_exit caller exit gets loop main p pp print printf puts
                raise rand read_line sleep spawn sprintf system
            z(?<!\.)(((class_)?((getter|property)\b[!?]?|setter\b))|(def_(clone|equals|equals_and_hash|hash)|delegate|forward_missing_to)\b)z/(?<!\w)(<<-?)(["`\']?)([a-zA-Z_]\w*)(\2)(.*?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\})|\S)(?!\w)z[A-Z][A-Z_]+\b(?!::|\.)z\{%zin-macro-controlz\{\{z
in-macro-exprz!(@\[)(\s*)([A-Z]\w*(::[A-Z]\w*)*)zin-annotz(\.|::))r=z,(\.|::)([a-zA-Z_]\w*[!?]?|[*%&^`~+\-/\[<>=])z[a-zA-Z_]\w*(?:[!?](?!=))?z:(\[|\]\??|\*\*|<=>?|>=|<<?|>>?|=~|===|!~|&&?|\|\||\.{1,3})z[-+/*%=<>&!^|~]=?z
[(){};,/?:\\]z\s+z\(?:([a-zA-Z_]\w*)(\.))?([a-zA-Z_]\w*[!?]?|\*\*?|[-+]@?|[/%&|^`~]|\[\]=?|<<|>>|<=?>|>=?|===?)z#popz	[A-Z_]\w*z(\()(\s*)([A-Z_]\w*)(\s*)(\))z\{z#pushz\}Úrootz#\{zin-intpzR\\([\\abefnrtv#"\']|[0-7]{1,3}|x[a-fA-F0-9]{2}|u[a-fA-F0-9]{4}|u\{[a-fA-F0-9 ]+\})zstring-intpzstring-escapedz[\\#]z[^\\#]+z\\\\z\\/z[^\\/#]+z/[imsx]*z.+z%\}z(for|verbatim)\bz\}\}z\[z\])rfrdrezin-intpzstring-intpzstring-escapedzstring-intp-escapedzinterpolated-regexzinterpolated-stringzmultiline-regexzend-partzin-macro-controlz
in-macro-exprzin-annotN)5Ú__name__Ú
__module__Ú__qualname__Ú__doc__r^ÚurlÚaliasesÚ	filenamesÚ	mimetypesÚreÚDOTALLÚ	MULTILINEÚflagsr<r_rÚSinglerÚsplitr
ZPseudoÚConstantrrrÚ	NamespaceZBuiltinZPreprocrr]r
ÚOctr	ZHexZBinZFloatZIntegerÚVariableZClassZInstanceÚGlobalrrZZInterpolZ	DecoratorrYrZFunctionrZEscaper\ÚtokensÚupdater:r:r:r;rsè/J


	
















)rjroZpygments.lexerrrrrrrZpygments.tokenrr	r
rrr
rrrÚ__all__rYrr:r:r:r;Ú<module>	s ,