a
    1	c_J                     @   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 g d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-2020 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  j|i | g | _d| _d| _d | _d S Nr   )super__init__indent_stackindentnext_indentblock_scalar_indent)selfargskwds	__class__ 6/usr/lib/python3/dist-packages/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#d$f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d>fgd?ejd@fdAejdBfdCedDfdEedFfgd0efdefdejfdGejfed3ed5dHeejdIfgedJdKejd.fgdLeejefedJ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dCe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%dj fdfdg	Z&  Z'S )kr   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.   |  }|sd S |  |fV  | |_d S N)groupstartendposlexermatchcontexttexttoken_classr#   r$   callback0   s
    z%YamlLexer.something.<locals>.callbackr#   r5   r6   r#   r4   r$   	something.   s    zYamlLexer.somethingc                    s    fdd}|S )zReset the indentation levels.c                 3   s>   |  }g |_d|_d|_d |_|  |fV  | |_d S r   )r+   r   r   r   r   r,   r-   r.   r/   r4   r#   r$   r6   :   s    z(YamlLexer.reset_indent.<locals>.callbackr#   r7   r#   r4   r$   reset_indent8   s    zYamlLexer.reset_indentFc                    s    fdd}|S )z"Save a possible indentation level.c                 3   s   |  }d} rjt||_|j|jk r||j|jk r@|j |_q&|j|jkr|||jd  }|d |j }n| jt|7  _|r| |fV  |r| t| j|fV  | |_	d S )N )
r+   lenr   r   r   popr,   r   r-   r.   )r0   r1   r2   r3   Zextrar,   r5   r#   r$   r6   F   s     
z'YamlLexer.save_indent.<locals>.callbackr#   )r5   r,   r6   r#   r=   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k r*|j|j |j|_ s@| jt|7  _| |fV  | |_d S r*   )	r+   r   r   r   appendr;   r,   r-   r.   r/   implicitr5   r#   r$   r6   \   s    z&YamlLexer.set_indent.<locals>.callbackr#   )r5   rA   r6   r#   r@   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   |  }d |_|sd S | d}|rBt|jd}t|}|| |_|r`|  |fV  | |_d S )N   r   )r+   r   maxr   intr,   r-   r.   )r0   r1   r2   r3   Z	incrementZcurrent_indentr4   r#   r$   r6   i   s    

z3YamlLexer.set_block_scalar_indent.<locals>.callbackr#   r7   r#   r4   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d u s t||jkr6|rx| |fV  nB|d |j }||jd  }| |fV  | |j  |fV  | |_d S r*   )r+   r   r;   r,   r-   r.   )r0   r1   r2   r3   indentationZcontentcontent_token_classindent_token_classr#   r$   r6   z   s    
z9YamlLexer.parse_block_scalar_empty_line.<locals>.callbackr#   )rJ   rI   r6   r#   rH   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d u rJt|t|jdkr>|j  |j  d S t||_n&t||jk rp|j  |j  d S |r|  |fV  | |_	d S Nr   )
r+   r   r;   rD   r   stackr<   r,   r-   r.   r/   r4   r#   r$   r6      s    




z5YamlLexer.parse_block_scalar_indent.<locals>.callbackr#   r7   r#   r4   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   |  }t||jkr.|j  |j  d S |rL|  |fV  | |_d S r*   )r+   r;   r   rM   r<   r,   r-   r.   r/   r4   r#   r$   r6      s    

z5YamlLexer.parse_plain_scalar_indent.<locals>.callbackr#   r7   r#   r4   r$   parse_plain_scalar_indent   s    	z#YamlLexer.parse_plain_scalar_indentz[ ]+(?=#|$)z\n+z#[^\n]*z^%YAML(?=[ ]|$)yaml-directivez^%TAG(?=[ ]|$)tag-directivez^(?:---|\.\.\.)(?=[ ]|$)
block-linez[ ]*(?!\s|$)T)r,   )rR   rG   z\n#pop:2z([ ]+)([0-9]+\.[0-9]+)ignored-linez;([ ]+)(!|![\w-]*!)([ ]+)(!|!?[\w;/?:@&=+$,.!~*\'()\[\]%-]+)z[ ]*$z[ ]+(?=[?:-](?:[ ]|$))z[?:-](?=[ ]|$)z[ ]*#popz[ ]*(?=#|$)z[ ]+z ([^#,:?\[\]{}"'\n]+)(:)(?=[ ]|$))rA   descriptorsblock-nodes
flow-nodesz'(?=[^\s?:,\[\]{}#&*!|>\'"%@`-]|[?:-]\S)plain-scalar-in-block-contextz!!<[\w#;/?:@&=+$,.!~*\'()\[\]%-]+>z+!(?:[\w-]+!)?[\w#;/?:@&=+$,.!~*\'()\[\]%-]*z&[\w-]+z\*[\w-]+z
:(?=[ ]|$)z[|>])block-scalar-contentblock-scalar-header\[flow-sequence\{flow-mappingz\'single-quoted-scalarz\"double-quoted-scalarz[?:,]z(?=[^\s?:,\[\]{}#&*!|>\'"%@`])plain-scalar-in-flow-contextflow-collection\]z([^,:?\[\]{}"'\n]+)(:)(?=[ ]|$)\}z^[ ]+$z^[ ]*z[\S\t ]+z([1-9])?[+-]?(?=[ ]|$)z[+-]?([1-9])?(?=[ ]|$)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	[ ]+(?=#)&plain-scalar-in-block-context-new-linez(?::(?!\s)|[^\s:])+z[ ]*(?=[,:?\[\]{}])z[^\s,:?\[\]{}]+)rootrT   rP   rQ   rG   rR   rV   rW   rX   rc   r]   r_   rZ   r[   rf   r`   ra   rh   rY   rb   Nc                    s    |d u rt |d}t ||S rL   )r   r   get_tokens_unprocessed)r   r3   r2   r!   r#   r$   rj     s    
z YamlLexer.get_tokens_unprocessed)F)F)NN)(r%   r&   r'   r(   namealiases	filenames	mimetypesr8   r9   r>   rB   rF   rK   rN   rO   r   r	   Singler   TagZ	Namespacer   r   r
   Typer   Z	Indicatorr   ZVariableZLabelr   ConstantZEscaper   ZScalarZPlaintokensrj   r)   r#   r#   r!   r$   r   !   s0  




	










   	r   c                   @   s   e Zd ZdZdZdgZd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JSONZjsonz*.jsonzPipfile.lockz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+"(\\(["\\/bfnrt]|u[a-fA-F0-9]{4})|[^\\"])*"value:,rU   re   rS   
whitespaceobjectattributerd   simplevaluer^   objectvaluer\   
arrayvalue)rw   ry   rx   rz   r{   rt   ri   N)r%   r&   r'   r(   rk   rl   rm   rn   reDOTALLflagsZint_partZ	frac_partZexp_partr   r
   rr   varsr   ZFloatZIntegerr   Doubler   r   r   rp   rs   r#   r#   r#   r$   r     sT   
		r   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-objectre   rz   )ri   rx   N)r%   r&   r'   r(   rk   rl   rm   rn   r   r   r   rs   r#   r#   r#   r$   r     s   r   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+jsonrz   zU"@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)"rx   N)r%   r&   r'   r(   rk   rl   rm   rn   r   Z	Decoratorr   rs   r#   r#   r#   r$   r     s   r   )r(   r|   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