3

V'íc<iã@s¬dZddlmZmZmZmZmZddlmZm	Z	m
Z
mZmZm
Z
mZmZmZddddgZGdd	„d	eƒZGd
d„deƒZGdd„deƒZGdd„deƒZGd
d„deƒZdS)zÉ
    pygments.lexers.data
    ~~~~~~~~~~~~~~~~~~~~

    Lexers for data file format.

    :copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS.
    :license: BSD, see LICENSE for details.
é)ÚLexerÚExtendedRegexLexerÚLexerContextÚincludeÚbygroups)	ÚCommentÚErrorÚKeywordÚLiteralÚNameÚNumberÚPunctuationÚStringÚ
WhitespaceÚ	YamlLexerÚ	JsonLexerÚJsonBareObjectLexerÚJsonLdLexercs eZdZdZ‡fdd„Z‡ZS)ÚYamlLexerContextz'Indentation context for the YAML lexer.cs*tƒj||Žg|_d|_d|_d|_dS)Néréÿÿÿÿ)ÚsuperÚ__init__Úindent_stackÚindentÚnext_indentÚblock_scalar_indent)ÚselfÚargsÚkwds)Ú	__class__©ú8/tmp/pip-build-gk9425m9/Pygments/pygments/lexers/data.pyrs
zYamlLexerContext.__init__)Ú__name__Ú
__module__Ú__qualname__Ú__doc__rÚ
__classcell__r!r!)r r"rsrcsœeZdZdZdZdZdgZddgZdgZdd	„Z	d
d„Z
djd
d„Zdkdd„Zdd„Z
dd„Zdd„Zdd„Zdefdefdejfde
ejƒdfde
ejƒdfd e
ejƒd!fd"eed#d$dlfgdefdejfd&ed'fgd(eeeƒd)fgd*eeejeejƒd)fgd+e	eƒd'fd,eeƒfd-eejƒfd.eeƒd/fgd0e	eƒd/fd1efd2eejeed#d3ƒfed4ƒed5ƒed6ƒd7e	ejƒd8fgd9ejfd:ejfd;ejfd<ejfgd=eejd#d3fd>ejdmfgdAejdBfdCejdDfdEe dFfdGe dHfgd1efdefdejfdIejfed4ƒed6ƒdJe	ejƒdKfgedLƒdMejd/fgdNeejeƒfedLƒdOejd/fgd&efdPeeej!ƒfdQeeƒfdRej!fgdSe
ejƒd)fdTe
ejƒd)fgdUefdVefdefd1ejfgedWƒdXe j"fdYe fdEe d/fgedWƒdZe fd[e j"fd\e fd]e d/fgdPefdefd^e	ejƒd_fdQeeƒd/fgd`e	eƒd/fdaed/fdVefdedbfd1e#j$j%fdce#j$j%fgdde	eƒd/fdaed/fdUefdVefdefd1ejfdeejfgdfœZ&dn‡fdhdi„	Z'‡Z(S)orzg
    Lexer for YAML, a human-friendly data serialization
    language.

    .. versionadded:: 0.11
    ZYAMLzhttp://yaml.org/Zyamlz*.yamlz*.ymlztext/x-yamlcs‡fdd„}|S)zDo not produce empty tokens.c3s.|jƒ}|sdS|jƒˆ|fV|jƒ|_dS)N)ÚgroupÚstartÚendÚpos)ÚlexerÚmatchÚcontextÚtext)Útoken_classr!r"Úcallback.s
z%YamlLexer.something.<locals>.callbackr!)r0r1r!)r0r"Ú	something,szYamlLexer.somethingcs‡fdd„}|S)zReset the indentation levels.c3s>|jƒ}g|_d|_d|_d|_|jƒˆ|fV|jƒ|_dS)Nrrr)r(rrrrr)r*r+)r,r-r.r/)r0r!r"r18sz(YamlLexer.reset_indent.<locals>.callbackr!)r0r1r!)r0r"Úreset_indent6szYamlLexer.reset_indentFcs‡‡fdd„}|S)z"Save a possible indentation level.c3sÀ|jƒ}d}ˆrnt|ƒ|_|j|jkr€x|j|jkrB|jjƒ|_q(W|j|jkr€||jd…}|d|j…}n|jt|ƒ7_|r”|jƒˆ|fV|r²|jƒt|ƒˆj|fV|jƒ|_	dS)NÚ)
r(ÚlenrrrÚpopr)rr*r+)r,r-r.r/Úextra)r)r0r!r"r1Ds 
z'YamlLexer.save_indent.<locals>.callbackr!)r0r)r1r!)r)r0r"Úsave_indentBszYamlLexer.save_indentcs‡‡fdd„}|S)z+Set the previously saved indentation level.c3s^|jƒ}|j|jkr*|jj|jƒ|j|_ˆs@|jt|ƒ7_|jƒˆ|fV|jƒ|_dS)N)	r(rrrÚappendr5r)r*r+)r,r-r.r/)Úimplicitr0r!r"r1Zsz&YamlLexer.set_indent.<locals>.callbackr!)r0r:r1r!)r:r0r"Ú
set_indentXs	zYamlLexer.set_indentcs‡fdd„}|S)z5Set an explicit indentation level for a block scalar.c3sd|jƒ}d|_|sdS|jdƒ}|rBt|jdƒ}t|ƒ}|||_|r`|jƒˆ|fV|jƒ|_dS)Nrr)r(rÚmaxrÚintr)r*r+)r,r-r.r/Ú	incrementÚcurrent_indent)r0r!r"r1gs

z3YamlLexer.set_block_scalar_indent.<locals>.callbackr!)r0r1r!)r0r"Úset_block_scalar_indentes
z!YamlLexer.set_block_scalar_indentcs‡‡fdd„}|S)z(Process an empty line in a block scalar.c3s†|jƒ}|jdks t|ƒ|jkr6|rx|jƒˆ|fVnB|d|j…}||jd…}|jƒˆ|fV|jƒ|jˆ|fV|jƒ|_dS)N)r(rr5r)r*r+)r,r-r.r/ÚindentationÚcontent)Úcontent_token_classÚindent_token_classr!r"r1xs

z9YamlLexer.parse_block_scalar_empty_line.<locals>.callbackr!)rDrCr1r!)rCrDr"Úparse_block_scalar_empty_linevs
z'YamlLexer.parse_block_scalar_empty_linecs‡fdd„}|S)z-Process indentation spaces in a block scalar.c3s’|jƒ}|jdkrJt|ƒt|jdƒkr>|jjƒ|jjƒdSt|ƒ|_n&t|ƒ|jkrp|jjƒ|jjƒdS|rŽ|jƒˆ|fV|jƒ|_	dS)Nr)
r(rr5r<rÚstackr6r)r*r+)r,r-r.r/)r0r!r"r1‰s




z5YamlLexer.parse_block_scalar_indent.<locals>.callbackr!)r0r1r!)r0r"Úparse_block_scalar_indent‡sz#YamlLexer.parse_block_scalar_indentcs‡fdd„}|S)z-Process indentation spaces in a plain scalar.c3sP|jƒ}t|ƒ|jkr.|jjƒ|jjƒdS|rL|jƒˆ|fV|jƒ|_dS)N)r(r5rrFr6r)r*r+)r,r-r.r/)r0r!r"r1s

z5YamlLexer.parse_plain_scalar_indent.<locals>.callbackr!)r0r1r!)r0r"Úparse_plain_scalar_indent›s	z#YamlLexer.parse_plain_scalar_indentz[ ]+(?=#|$)z\n+z#[^\n]*z^%YAML(?=[ ]|$)zyaml-directivez^%TAG(?=[ ]|$)z
tag-directivez^(?:---|\.\.\.)(?=[ ]|$)ú
block-linez[ ]*(?!\s|$)T)r)rAz\nz#pop:2z([ ]+)([0-9]+\.[0-9]+)zignored-linez;([ ]+)(!|![\w-]*!)([ ]+)(!|!?[\w;/?:@&=+$,.!~*\'()\[\]%-]+)z[ ]*$z[ ]+(?=[?:-](?:[ ]|$))z[?:-](?=[ ]|$)z[ ]*z#popz[ ]*(?=#|$)z[ ]+z([^#,?\[\]{}"'\n]+)(:)(?=[ ]|$))r:Údescriptorszblock-nodesz
flow-nodesz'(?=[^\s?:,\[\]{}#&*!|>\'"%@`-]|[?:-]\S)zplain-scalar-in-block-contextz!!<[\w#;/?:@&=+$,.!~*\'()\[\]%-]+>z+!(?:[\w-]+!)?[\w#;/?:@&=+$,.!~*\'()\[\]%-]*z&[\w-]+z\*[\w-]+z
:(?=[ ]|$)z[|>]úblock-scalar-contentúblock-scalar-headerz\[z
flow-sequencez\{zflow-mappingz\'zsingle-quoted-scalarz\"zdouble-quoted-scalarz[?:,]z(?=[^\s?:,\[\]{}#&*!|>\'"%@`])zplain-scalar-in-flow-contextzflow-collectionz\]z([^,:?\[\]{}"'\n]+)(:)(?=[ ]|$)z\}z^[ ]+$z^[ ]*z[\S\t ]+z([1-9])?[+-]?(?=[ ]|$)z[+-]?([1-9])?(?=[ ]|$)z^[ ]+z[ ]+$zquoted-scalar-whitespacesz\'\'z[^\s\']+z\\[0abt\tn\nvfre "\\N_LP]z5\\(?:x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})z	[^\s"\\]+ú"z^(?=---|\.\.\.)z#pop:3z[ ]*(?=:[ ]|:$)z	[ ]+(?=#)z&plain-scalar-in-block-context-new-linez(?::(?!\s)|[^\s:])+z[ ]*(?=[,:?\[\]{}])z[^\s,:?\[\]{}]+)Úrootzignored-linezyaml-directivez
tag-directiverAz
block-linerJzblock-nodesz
flow-nodeszflow-collectionz
flow-sequencezflow-mappingzblock-scalar-contentzblock-scalar-headerzquoted-scalar-whitespaceszsingle-quoted-scalarzdouble-quoted-scalarz&plain-scalar-in-block-context-new-linezplain-scalar-in-block-contextzplain-scalar-in-flow-contextNcs |dkrt|dƒ}tƒj||ƒS)Nr)rrÚget_tokens_unprocessed)rr/r.)r r!r"rO¯s
z YamlLexer.get_tokens_unprocessed)F)F)rIrA)rKrL)NN))r#r$r%r&ÚnameÚurlÚaliasesÚ	filenamesÚ	mimetypesr2r3r8r;r@rErGrHrrÚSinglerÚTagÚ	Namespacerrr	ÚTyper
Z	IndicatorrÚVariableZLabelrÚConstantZEscaper
ZScalarZPlainÚtokensrOr'r!r!)r r"rsæ
















c@sleZdZdZdZdZddgZddgZdd	gZe	d
ƒZ
e	dƒZe	dƒZe	d
ƒZ
e	dƒZddddhZdd„ZdS)raC
    For JSON data structures.

    Javascript-style comments are supported (like ``/* */`` and ``//``),
    though comments are not part of the JSON specification.
    This allows users to highlight JSON as it is used in the wild.

    No validation is performed on the input JSON document.

    .. versionadded:: 1.5
    ZJSONzhttps://www.json.orgÚjsonzjson-objectz*.jsonzPipfile.lockzapplication/jsonzapplication/json-objectz-0123456789z.eE+Z
truefalsenullZ0123456789abcdefABCDEFz{}[],ú Ú
ú
ú	ccs*d}d}d}d}d}d}d}d}	d}
d}d}d}
d}g}xÞt|ƒD]Ð\}}|rÚ|r|||jkrr|d8}|szd}qÔd}d}qD|r”|dkrŽd}qÔd}qD|dkr¢d}qD|dkrD|j|tj|||d…fƒd}d}d}qDn(|r(||jkrìqD|r|j|t|||…fƒn|t|||…fVd}nÚ|rZ||jkr<qD|tj	|||…fVd}n¨|rÂ||j
krpqDn||jkr‚d}qD|r |tj
|||…fVn|tj|||…fVd}d}n@|	rò||jkrÖqD|t|||…fVd}	n|
rB|d	krqD|r&|j|tj|||…fƒn|tj|||…fVd}
nÀ|r°|d
krXd}
qD|
rDd}
|dkrD|rŽ|j|tj|||d…fƒn|tj|||d…fVd}qDnR|rd}|dkrÌd}
qDn|d
krÜd}qD|EdH|jƒ|t|||…fV|}|dkrd}qD||jkr(d}qD|dkrJ|EdH|jƒd}qD||j
krn|EdH|jƒd}qD|dkrÄx<|D]4\}}}|tjkr¤|tj|fVn|||fVq~W|jƒd}	qD||jkrè|EdH|jƒd}	qD|dkrød}qD|EdH|jƒ|t|fVqDW|EdH|r@|t||d…fVnæ|r^|tj
||d…fVnÈ|r||tj||d…fVnª|rš|tj	||d…fVnŒ|r¶|t||d…fVnp|	rÒ|t||d…fVnT|
rð|tj||d…fVn6|r|t||d…fVn|r&|t||d…fVdS)zParse JSON data.FrrÚuéú\TrMr^Ú*ú/NÚfÚnÚtú:>rhrfrg)Ú	enumerateÚhexadecimalsr9rÚDoubleÚwhitespacesrÚ	constantsr	rZÚintegersÚfloatsrZFloatZIntegerÚpunctuationsr
rrUZ	MultilineÚclearrrrV)rr/Z	in_stringZ	in_escapeZin_unicode_escapeZ
in_whitespaceZin_constantZ	in_numberZin_floatZin_punctuationZin_comment_singleZin_comment_multilineZexpecting_second_comment_openerZexpecting_second_comment_closerr)ÚqueueÚstopÚ	characterZ_startÚ_tokenZ_textr!r!r"rO×s



 







	



z JsonLexer.get_tokens_unprocessedN)r#r$r%r&rPrQrRrSrTÚsetrorprnrkrqrmrOr!r!r!r"rµs
c@s eZdZdZdZgZgZgZdS)rz©
    For JSON data structures (with missing object curly braces).

    .. versionadded:: 2.2

    .. deprecated:: 2.8.0

       Behaves the same as `JsonLexer` now.
    ZJSONBareObjectN)r#r$r%r&rPrRrSrTr!r!r!r"r¿s
	csJeZdZdZdZdZddgZdgZdgZdd	„d#DƒZ	‡fd!d"„Z
‡ZS)$rz=
    For JSON-LD linked data.

    .. versionadded:: 2.0
    zJSON-LDzhttps://json-ld.org/Zjsonldzjson-ldz*.jsonldzapplication/ld+jsoncCsh|]}d|’qS)z"@%s"r!)Ú.0Úkeywordr!r!r"ú	<setcomp>ÝszJsonLdLexer.<setcomp>ÚbaseÚ	containerr.Ú	directionÚgraphÚidÚimportÚincludedÚindexr\ÚlanguageÚlistÚnestÚnoneÚprefixÚ	propagateÚ	protectedÚreverserwÚtypeÚvalueÚversionÚvocabc#sPxJtƒj|ƒD]:\}}}|tjkr<||jkr<|tj|fVq|||fVqWdS)N)rrOrrVÚjson_ld_keywordsZ	Decorator)rr/r)ÚtokenrŒ)r r!r"rOúsz"JsonLdLexer.get_tokens_unprocessed)r{r|r.r}r~rr€rr‚r\rƒr„r…r†r‡rˆr‰rŠrwr‹rŒrrŽ)r#r$r%r&rPrQrRrSrTrrOr'r!r!)r r"rÐs>N)r&Zpygments.lexerrrrrrZpygments.tokenrrr	r
rrr
rrÚ__all__rrrrrr!r!r!r"Ú<module>	s,