3
.ßL]oJ  ã               @   s¸   d Z ddlZddlmZmZmZmZmZmZ ddl	m
Z
mZmZmZmZmZmZmZmZ ddddgZG d	d
„ d
eƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZdS )zÉ
    pygments.lexers.data
    ~~~~~~~~~~~~~~~~~~~~

    Lexers for data file format.

    :copyright: Copyright 2006-2019 by the Pygments team, see AUTHORS.
    :license: BSD, see LICENSE for details.
é    N)Ú
RegexLexerÚExtendedRegexLexerÚLexerContextÚincludeÚbygroupsÚinherit)	ÚTextÚCommentÚKeywordÚNameÚStringÚNumberÚPunctuationÚLiteralÚErrorÚ	YamlLexerÚ	JsonLexerÚJsonBareObjectLexerÚJsonLdLexerc                   s    e Zd ZdZ‡ fdd„Z‡  ZS )ÚYamlLexerContextz'Indentation context for the YAML lexer.c                s.   t t| ƒj||Ž g | _d| _d| _d | _d S )Né   r   éÿÿÿÿ)Úsuperr   Ú__init__Úindent_stackÚindentÚnext_indentÚblock_scalar_indent)ÚselfÚargsÚkwds)Ú	__class__© ú:/tmp/pip-install-5sebvq2j/pygments/pygments/lexers/data.pyr      s
    zYamlLexerContext.__init__)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Ú__classcell__r"   r"   )r!   r#   r      s   r   c                   s˜  e Zd ZdZdZdgZddgZdgZdd„ Zd	d
„ Z	dhdd„Z
didd„Zdd„ Zdd„ Zdd„ Zdd„ Zdefdefdejfde	ejƒdfde	ejƒdfde	ejƒd fd!e
ed"d#�djfgdefdejfd%ed&fgd'eeeƒd(fgd)eeejeejƒd(fgd*eeƒd&fd+e
eƒfd,eejƒfd-e
eƒd.fgd/eeƒd.fd0efd1eejeed"d2�ƒfed3ƒed4ƒed5ƒd6eejƒd7fgd8ejfd9ejfd:ejfd;ejfgd<eejd"d2�fd=ejdkfgd@ejdAfdBejdCfdDedEfdFedGfgd0efdefdejfdHejfed3ƒed5ƒdIeejƒdJfgedKƒdLejd.fgd1eejeƒfedKƒdMejd.fgd%efdNeeej ƒfdOeeƒfdPej fgdQeejƒd(fdReejƒd(fgdSefdTefdefd0ejfgedUƒdVej!fdWefdDed.fgedUƒdXefdYej!fdZefd[ed.fgdNefdefd\eejƒd]fdOeeƒd.fgd^eeƒd.fd_ed.fdTefded`fd0e"j#j$fdae"j#j$fgdbeeƒd.fd_ed.fdSefdTefdefd0ejfdcejfgddœZ%dl‡ fdfdg„	Z&‡  Z'S )mr   z}
    Lexer for `YAML <http://yaml.org/>`_, a human-friendly data serialization
    language.

    .. versionadded:: 0.11
    ZYAMLZyamlz*.yamlz*.ymlztext/x-yamlc                s   ‡ fdd„}|S )zDo not produce empty tokens.c             3   s.   |j ƒ }|sd S |jƒ ˆ |fV  |jƒ |_d S )N)ÚgroupÚstartÚendÚpos)ÚlexerÚmatchÚcontextÚtext)Útoken_classr"   r#   Úcallback0   s
    z%YamlLexer.something.<locals>.callbackr"   )r1   r2   r"   )r1   r#   Ú	something.   s    zYamlLexer.somethingc                s   ‡ fdd„}|S )zReset the indentation levels.c             3   s>   |j ƒ }g |_d|_d|_d |_|jƒ ˆ |fV  |jƒ |_d S )Nr   r   r   )r)   r   r   r   r   r*   r+   r,   )r-   r.   r/   r0   )r1   r"   r#   r2   :   s    z(YamlLexer.reset_indent.<locals>.callbackr"   )r1   r2   r"   )r1   r#   Úreset_indent8   s    zYamlLexer.reset_indentFc                s   ‡ ‡fdd„}|S )z"Save a possible indentation level.c             3   sÀ   |j ƒ }d}ˆ rnt|ƒ|_|j|jk r€x|j|jk rB|jjƒ |_q(W |j|jkr€||jd … }|d |j… }n| jt|ƒ7  _|r”|jƒ ˆ|fV  |r²|jƒ t|ƒ ˆj|fV  |jƒ |_	d S )NÚ )
r)   Úlenr   r   r   Úpopr*   r   r+   r,   )r-   r.   r/   r0   Úextra)r*   r1   r"   r#   r2   F   s     
z'YamlLexer.save_indent.<locals>.callbackr"   )r1   r*   r2   r"   )r*   r1   r#   Úsave_indentD   s    zYamlLexer.save_indentc                s   ‡ ‡fdd„}|S )z+Set the previously saved indentation level.c             3   s^   |j ƒ }|j|jk r*|jj|jƒ |j|_ˆ s@| jt|ƒ7  _|jƒ ˆ|fV  |jƒ |_d S )N)	r)   r   r   r   Úappendr6   r*   r+   r,   )r-   r.   r/   r0   )Úimplicitr1   r"   r#   r2   \   s    z&YamlLexer.set_indent.<locals>.callbackr"   )r1   r;   r2   r"   )r;   r1   r#   Ú
set_indentZ   s    	zYamlLexer.set_indentc                s   ‡ fdd„}|S )z5Set an explicit indentation level for a block scalar.c             3   sd   |j ƒ }d |_|sd S |j dƒ}|rBt|jdƒ}t|ƒ}|| |_|r`|jƒ ˆ |fV  |jƒ |_d S )Nr   r   )r)   r   Úmaxr   Úintr*   r+   r,   )r-   r.   r/   r0   Ú	incrementÚcurrent_indent)r1   r"   r#   r2   i   s    

z3YamlLexer.set_block_scalar_indent.<locals>.callbackr"   )r1   r2   r"   )r1   r#   Úset_block_scalar_indentg   s    z!YamlLexer.set_block_scalar_indentc                s   ‡ ‡fdd„}|S )z(Process an empty line in a block scalar.c             3   s†   |j ƒ }|jd ks t|ƒ|jkr6|rx|jƒ ˆ|fV  nB|d |j… }||jd … }|jƒ ˆ|fV  |jƒ |j ˆ |fV  |jƒ |_d S )N)r)   r   r6   r*   r+   r,   )r-   r.   r/   r0   ÚindentationÚcontent)Úcontent_token_classÚindent_token_classr"   r#   r2   z   s    

z9YamlLexer.parse_block_scalar_empty_line.<locals>.callbackr"   )rE   rD   r2   r"   )rD   rE   r#   Úparse_block_scalar_empty_linex   s    z'YamlLexer.parse_block_scalar_empty_linec                s   ‡ fdd„}|S )z-Process indentation spaces in a block scalar.c             3   s’   |j ƒ }|jd krJt|ƒt|jdƒkr>|jjƒ  |jjƒ  d S t|ƒ|_n&t|ƒ|jk rp|jjƒ  |jjƒ  d S |rŽ|jƒ ˆ |fV  |jƒ |_	d S )Nr   )
r)   r   r6   r=   r   Ústackr7   r*   r+   r,   )r-   r.   r/   r0   )r1   r"   r#   r2   ‹   s    




z5YamlLexer.parse_block_scalar_indent.<locals>.callbackr"   )r1   r2   r"   )r1   r#   Úparse_block_scalar_indent‰   s    z#YamlLexer.parse_block_scalar_indentc                s   ‡ fdd„}|S )z-Process indentation spaces in a plain scalar.c             3   sP   |j ƒ }t|ƒ|jkr.|jjƒ  |jjƒ  d S |rL|jƒ ˆ |fV  |jƒ |_d S )N)r)   r6   r   rG   r7   r*   r+   r,   )r-   r.   r/   r0   )r1   r"   r#   r2   Ÿ   s    

z5YamlLexer.parse_plain_scalar_indent.<locals>.callbackr"   )r1   r2   r"   )r1   r#   Úparse_plain_scalar_indent�   s    	z#YamlLexer.parse_plain_scalar_indentz[ ]+(?=#|$)z\n+z#[^\n]*z^%YAML(?=[ ]|$)zyaml-directivez^%TAG(?=[ ]|$)ztag-directivez^(?:---|\.\.\.)(?=[ ]|$)ú
block-linez[ ]*(?!\s|$)T)r*   rB   z\nz#pop:2z([ ]+)([0-9]+\.[0-9]+)zignored-linez;([ ]+)(!|![\w-]*!)([ ]+)(!|!?[\w;/?:@&=+$,.!~*\'()\[\]%-]+)z[ ]*$z[ ]+(?=[?:-](?:[ ]|$))z[?:-](?=[ ]|$)z[ ]*z#popz[ ]*(?=#|$)z[ ]+z([^,:?\[\]{}"'\n]+)(:)(?=[ ]|$))r;   Údescriptorszblock-nodesz
flow-nodesz'(?=[^\s?:,\[\]{}#&*!|>\'"%@`-]|[?:-]\S)zplain-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\'zsingle-quoted-scalarz\"zdouble-quoted-scalarz[?:,]z(?=[^\s?:,\[\]{}#&*!|>\'"%@`])zplain-scalar-in-flow-contextzflow-collectionz\]z\}z^[ ]+$z^[ ]*z[\S\t ]+z([1-9])?[+-]?(?=[ ]|$)z[+-]?([1-9])?(?=[ ]|$)z^[ ]+z[ ]+$zquoted-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-linezyaml-directiveztag-directiverB   z
block-linerK   zblock-nodesz
flow-nodeszflow-collectionzflow-sequencezflow-mappingzblock-scalar-contentzblock-scalar-headerzquoted-scalar-whitespaceszsingle-quoted-scalarzdouble-quoted-scalarz&plain-scalar-in-block-context-new-linezplain-scalar-in-block-contextzplain-scalar-in-flow-contextNc                s$   |d krt |dƒ}tt| ƒj||ƒS )Nr   )r   r   r   Úget_tokens_unprocessed)r   r0   r/   )r!   r"   r#   rP   ±  s    
z YamlLexer.get_tokens_unprocessed)F)F)rJ   rB   )rL   rM   )NN)(r$   r%   r&   r'   ÚnameÚaliasesÚ	filenamesÚ	mimetypesr3   r4   r9   r<   rA   rF   rH   rI   r   r	   ÚSingler   ÚTagÚ	Namespacer   r   r
   ÚTyper   Z	Indicatorr   ÚVariableZLabelr   ÚConstantZEscaper   ZScalarZPlainÚtokensrP   r(   r"   r"   )r!   r#   r   !   sä   















c               @   sè   e Zd ZdZdZdgZdgZdgZej	Z
dZdZdZd	efgd
ejfdeƒ  ejfeejfdejfgedƒdefdedfdedfgedƒdejdfdedfgedƒedƒdefdedfgedƒedƒdedfdedfgedƒgdœZdS )r   z>
    For JSON data structures.

    .. versionadded:: 1.5
    ZJSONÚjsonz*.jsonzapplication/jsonz-?(0|[1-9]\d*)z\.\d+z[eE](\+|-)?\d+z\s+z(true|false|null)\bzB%(int_part)s(%(frac_part)s%(exp_part)s|%(exp_part)s|%(frac_part)s)z"(\\\\|\\"|[^"])*"Úvalueú:ú,z#popz\}z#pop:2Ú
whitespaceÚobjectattributez\]Úsimplevaluez\{Úobjectvaluez\[Ú
arrayvalue)r`   rb   ra   rc   rd   r]   rO   N)r$   r%   r&   r'   rQ   rR   rS   rT   ÚreÚDOTALLÚflagsZint_partZ	frac_partZexp_partr   r
   rZ   Úvarsr   ZFloatZIntegerr   ÚDoubler   r   r   rV   r[   r"   r"   r"   r#   r   ·  s@   





c               @   sB   e Zd ZdZdZdgZg ZdgZdefe	dƒgdefe
gdœZdS )	r   za
    For JSON data structures (with missing object curly braces).

    .. versionadded:: 2.2
    ZJSONBareObjectzjson-objectzapplication/json-objectz\}rc   )rO   ra   N)r$   r%   r&   r'   rQ   rR   rS   rT   r   r   r   r[   r"   r"   r"   r#   r     s   c               @   s<   e Zd ZdZdZddgZdgZdgZddej	d	fe
giZd
S )r   zV
    For `JSON-LD <http://json-ld.org/>`_ linked data.

    .. versionadded:: 2.0
    zJSON-LDZjsonldzjson-ldz*.jsonldzapplication/ld+jsonrc   zU"@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)"ra   N)r$   r%   r&   r'   rQ   rR   rS   rT   r   Z	Decoratorr   r[   r"   r"   r"   r#   r     s   )r'   re   Zpygments.lexerr   r   r   r   r   r   Zpygments.tokenr   r	   r
   r   r   r   r   r   r   Ú__all__r   r   r   r   r   r"   r"   r"   r#   Ú<module>
   s    ,   O