o a_@sdZddlmZmZmZmZmZddlmZm Z m Z m Z m Z m Z mZmZmZmZgdZGdddeZGdddeZGd d d eZGd d d eZGd ddeZdS)z pygments.lexers.data ~~~~~~~~~~~~~~~~~~~~ Lexers for data file format. :copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details. )LexerExtendedRegexLexer LexerContextincludebygroups) TextCommentKeywordNameStringNumber PunctuationLiteralError Whitespace) YamlLexer JsonLexerJsonBareObjectLexer JsonLdLexercs eZdZdZfddZZS)YamlLexerContextz'Indentation context for the YAML lexer.cs.tj|i|g|_d|_d|_d|_dSNr)super__init__ indent_stackindent next_indentblock_scalar_indent)selfargskwds __class__6/usr/lib/python3/dist-packages/pygments/lexers/data.pyrs  zYamlLexerContext.__init__)__name__ __module__ __qualname____doc__r __classcell__r#r#r!r$rsrc seZdZdZdZdgZddgZdgZddZd d Z dld d Z dlddZ ddZ ddZ ddZddZiddefdefdejfde ejdfde ejdfd e ejd!fd"e ed#d$d%fgd&defdejfd'ed(fgdd)eeed&fgdd*eeejeejd&fgd+d,eed(fd-e efd.e ejfd/e ed0fgd!d1eed0fd2efd3eeje ed#d4fed5ed6ed7d8eejd9fgd5d:ejfd;ejfde ejd#d4fd?ejd@fgd7dAejdBfdCejdDfdEedFfdGedHfgdId2efdefdejfdJejfed5ed7dKeejdLfgdBedIdMejd0fgdDdNeejefedIdOejd0fgdPd'efdQe eej fdReefdSej fgdTdUe ejd&fdVe ejd&fgdWdXefdYefdefd2ejfgdFedWdZej!fd[efdEed0fgdHedWd\efd]ej!fd^efd_ed0fgdQefdefd`eejdafdReed0fgdbeed0fdced0fdYefdeddfd2e"j#j$fdee"j#j$fgdfeed0fdced0fdXefdYefdefd2ejfdgejfgdhZ%dmfdjdk Z&Z'S)nrz} Lexer for `YAML `_, a human-friendly data serialization language. .. versionadded:: 0.11 YAMLyamlz*.yamlz*.ymlz text/x-yamlcfdd}|S)zDo not produce empty tokens.c3s0|}|s dS||fV||_dSN)groupstartendposlexermatchcontexttext token_classr#r$callback-s z%YamlLexer.something..callbackr#r8r9r#r7r$ something+s zYamlLexer.somethingcr,)zReset the indentation levels.c3s@|}g|_d|_d|_d|_||fV||_dSr)r.rrrrr/r0r1r2r7r#r$r97sz(YamlLexer.reset_indent..callbackr#r:r#r7r$ reset_indent5s zYamlLexer.reset_indentFcfdd}|S)z"Save a possible indentation level.c3s|}d}r;t||_|j|jkr:|j|jkr&|j|_|j|jks|j|jkr:||jd}|d|j}n |jt|7_|rN||fV|r]|t|j|fV||_ dS)N) r.lenrrrpopr/rr0r1)r3r4r5r6extrar/r8r#r$r9Cs&     z'YamlLexer.save_indent..callbackr#)r8r/r9r#rBr$ save_indentAszYamlLexer.save_indentcr=)z+Set the previously saved indentation level.c3s`|}|j|jkr|j|j|j|_s!|jt|7_||fV||_dSr-) r.rrrappendr?r/r0r1r2implicitr8r#r$r9Ys z&YamlLexer.set_indent..callbackr#)r8rFr9r#rEr$ set_indentWs zYamlLexer.set_indentcr,)z5Set an explicit indentation level for a block scalar.c3sj|}d|_|s dS|d}|r"t|jd}t|}|||_|r3||fV||_dSdS)Nr)r.rmaxrintr/r0r1)r3r4r5r6 incrementcurrent_indentr7r#r$r9fs   z3YamlLexer.set_block_scalar_indent..callbackr#r:r#r7r$set_block_scalar_indentds  z!YamlLexer.set_block_scalar_indentcr=)z(Process an empty line in a block scalar.c3s|}|jdust||jkr|r||fVn!|d|j}||jd}||fV||j|fV||_dSr-)r.rr?r/r0r1)r3r4r5r6 indentationcontentcontent_token_classindent_token_classr#r$r9ws  z9YamlLexer.parse_block_scalar_empty_line..callbackr#)rRrQr9r#rPr$parse_block_scalar_empty_lineus z'YamlLexer.parse_block_scalar_empty_linecr,)z-Process indentation spaces in a block scalar.c3s|}|jdur&t|t|jdkr |j|jdSt||_nt||jkr9|j|jdS|rJ||fV||_ dSdSNr) r.rr?rIrstackr@r/r0r1r2r7r#r$r9s       z5YamlLexer.parse_block_scalar_indent..callbackr#r:r#r7r$parse_block_scalar_indents z#YamlLexer.parse_block_scalar_indentcr,)z-Process indentation spaces in a plain scalar.c3sV|}t||jkr|j|jdS|r)||fV||_dSdSr-)r.r?rrUr@r/r0r1r2r7r#r$r9s  z5YamlLexer.parse_plain_scalar_indent..callbackr#r:r#r7r$parse_plain_scalar_indents  z#YamlLexer.parse_plain_scalar_indentrootz [ ]+(?=#|$)z\n+z#[^\n]*z^%YAML(?=[ ]|$)zyaml-directivez^%TAG(?=[ ]|$)z tag-directivez^(?:---|\.\.\.)(?=[ ]|$) block-linez [ ]*(?!\s|$)T)r/)rYrNz ignored-linez\nz#pop:2z([ ]+)([0-9]+\.[0-9]+)z;([ ]+)(!|![\w-]*!)([ ]+)(!|!?[\w;/?:@&=+$,.!~*\'()\[\]%-]+)rNz[ ]*$z[ ]+(?=[?:-](?:[ ]|$))z[?:-](?=[ ]|$)z[ ]*z#popz [ ]*(?=#|$)z[ ]+z ([^#,:?\[\]{}"'\n]+)(:)(?=[ ]|$))rF descriptorsz block-nodesz flow-nodesz'(?=[^\s?:,\[\]{}#&*!|>\'"%@`-]|[?:-]\S)plain-scalar-in-block-contextz!!<[\w#;/?:@&=+$,.!~*\'()\[\]%-]+>z+!(?:[\w-]+!)?[\w#;/?:@&=+$,.!~*\'()\[\]%-]*z&[\w-]+z\*[\w-]+z :(?=[ ]|$)z[|>])block-scalar-contentblock-scalar-headerz\[z flow-sequencez\{z flow-mappingz\'zsingle-quoted-scalarz\"zdouble-quoted-scalarzflow-collectionz[?:,]z(?=[^\s?:,\[\]{}#&*!|>\'"%@`])plain-scalar-in-flow-contextz\]z([^,:?\[\]{}"'\n]+)(:)(?=[ ]|$)z\}r\z^[ ]+$z^[ ]*z[\S\t ]+r]z([1-9])?[+-]?(?=[ ]|$)z[+-]?([1-9])?(?=[ ]|$)zquoted-scalar-whitespacesz^[ ]+z[ ]+$z\'\'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 [ ]+(?=#)&plain-scalar-in-block-context-new-linez(?::(?!\s)|[^\s:])+z[ ]*(?=[,:?\[\]{}])z[^\s,:?\[\]{}]+)r`r[r^Ncs |dur t|d}t||SrT)rrget_tokens_unprocessed)rr6r5r!r#r$ras z YamlLexer.get_tokens_unprocessed)F)NN)(r%r&r'r(namealiases filenames mimetypesr;r<rCrGrMrSrVrWrrSingler Tag Namespacerr r Typer IndicatorrVariableLabelr ConstantEscaperScalarPlaintokensrar)r#r#r!r$rs       '0    < Q^g  s     (4?K\      rc@sdeZdZdZdZddgZddgZddgZed Z ed Z ed Z ed Z ed Z hdZddZdS)rz> For JSON data structures. .. versionadded:: 1.5 JSONjsonz json-objectz*.jsonz Pipfile.lockzapplication/jsonzapplication/json-objectz -0123456789z.eE+ truefalsenull0123456789abcdefABCDEFz{}[],>    c csd}d}d}d}d}d}d}d} d} g} t|D]O\} } |rb|r5| |jvr0|d8}|s/d}n1d}d}n,|rA| dkr>d}n#d}n | dkrHd}n| dkra| | tj|| | dfd}d}d}q|r| |jvrjq| ry| | t|| | fn | t|| | fVd}nX|r| |jvrq| tj || | fVd}nB|r| |j vrq| |j vrd}q|r| t j || | fVn | t j|| | fVd}d}n| r| |jvrq| t|| | fVd} | } | dkrd}q| |jvrd}q| d vr| Ed H| d}q| |j vr| Ed H| d}q| d krH| D](\}}}|tur*|||fVq|tjur9|tj|fVq|t|fVq| d} q| |jvrZ| Ed H| d} q| Ed H| | t| fVq| Ed H|r~| t|| d fVd S|r| t j || d fVd S|r| t j|| d fVd S|r| tj || d fVd S|r| t|| d fVd S| r| t|| d fVd Sd S) zParse JSON data.FrrHu\Tr_>fntN:) enumerate hexadecimalsrDr Double whitespacesr constantsr rmintegersfloatsr FloatInteger punctuationsr clearr rgr)rr6 in_string in_escapein_unicode_escape in_whitespace in_constant in_numberin_floatin_punctuationr/queuestop character_start_token_textr#r#r$ras                 z JsonLexer.get_tokens_unprocessedN)r%r&r'r(rbrcrdresetrrrrrrrar#r#r#r$rs  rc@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. JSONBareObjectN)r%r&r'r(rbrcrdrer#r#r#r$r~s  rcsFeZdZdZdZddgZdgZdgZddd DZfd d Z Z S) rzW For `JSON-LD `_ linked data. .. versionadded:: 2.0 zJSON-LDjsonldzjson-ldz*.jsonldzapplication/ld+jsoncCsh|]}d|qS)z"@%s"r#).0keywordr#r#r$ szJsonLdLexer.)base containerr5 directiongraphidimportincludedindexrslanguagelistnestnoneprefix propagate protectedreversertypevalueversionvocabc#sNt|D]\}}}|tjur||jvr|tj|fVq|||fVqdSr-)rrar rgjson_ld_keywords Decorator)rr6r/tokenrr!r#r$ras z"JsonLdLexer.get_tokens_unprocessed) r%r&r'r(rbrcrdrerrar)r#r#r!r$rsrN)r(pygments.lexerrrrrrpygments.tokenrrr r r r r rrr__all__rrrrrr#r#r#r$s 0 K