o
    \hi                     @   s   d Z ddl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-2025 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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__ W/home/air/segue/gemini/backup/venv/lib/python3.10/site-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ZdgZddgZdgZdZ	d	d
 Z
dd ZdnddZdnddZdd Zdd Zdd Zdd Zi d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(defdejfd)ed*fgdd+eeed(fgd!d,eeejeejd(fgd-d.e
ed*fd/eefd0eejfd1eed2fgd#d3e
ed2fd4efd5eejeed%d6fed7ed8ed9d:e
ejd;fgd7d<ejfd=ejfd>ej fd?ejfgd8d@eejd%d6fdAejdBfgd9dCejdDfdEejdFfdGe!dHfdIe!dJfgdKd4efdefdejfdLejfed7ed9dMe
ejdNfgdDedKdOejd2fgdFdPeejefedKdQejd2fgdRd)efdSeeej"fdTeefdUej"fgdVdWeejd(fdXeejd(fgdYdZefd[efdefd4ejfgdHedYd\e!j#fd]e!fdGe!d2fgdJedYd^e!fd_e!j#fd`e!fdae!d2fgdSefdefdbe
ejdcfdTeed2fgdde
ed2fdeed2fd[efdedffd4e$j%j&fdge$j%j&fgdhe
ed2fdeed2fdZefd[efdefd4ejfdiejfgdjZ'do fdldm	Z(  Z)S )pr   zK
    Lexer for YAML, a human-friendly data serialization
    language.
    YAMLzhttp://yaml.org/yamlz*.yamlz*.ymlztext/x-yamlz0.11c                        fdd}|S )zDo not produce empty tokens.c                 3   s0    |  }|s	d S |  |fV  | |_d S N)groupstartendposlexermatchcontexttexttoken_classr"   r#   callback-   s   z%YamlLexer.something.<locals>.callbackr"   r7   r8   r"   r6   r#   	something+   s   zYamlLexer.somethingc                    r+   )zReset the indentation levels.c                 3   s@    |  }g |_d|_d|_d |_|  |fV  | |_d S r   )r-   r   r   r   r   r.   r/   r0   r1   r6   r"   r#   r8   7   s   z(YamlLexer.reset_indent.<locals>.callbackr"   r9   r"   r6   r#   reset_indent5   s   zYamlLexer.reset_indentFc                        fdd}|S )z"Save a possible indentation level.c                 3   s    |  }d} r;t||_|j|jk r:|j|jk r&|j |_|j|jk s|j|jkr:||jd  }|d |j }n	| jt|7  _|rN| |fV  |r]| t| j|fV  | |_	d S )N )
r-   lenr   r   r   popr.   r   r/   r0   )r2   r3   r4   r5   extrar.   r7   r"   r#   r8   C   s&   
z'YamlLexer.save_indent.<locals>.callbackr"   )r7   r.   r8   r"   rA   r#   save_indentA   s   zYamlLexer.save_indentc                    r<   )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/   r0   r1   implicitr7   r"   r#   r8   Y   s   z&YamlLexer.set_indent.<locals>.callbackr"   )r7   rE   r8   r"   rD   r#   
set_indentW   s   	zYamlLexer.set_indentc                    r+   )z5Set an explicit indentation level for a block scalar.c                 3   sj    |  }d |_|sd S | d}|r"t|jd}t|}|| |_|r3|  |fV  | |_d S d S )N   r   )r-   r   maxr   intr.   r/   r0   )r2   r3   r4   r5   	incrementcurrent_indentr6   r"   r#   r8   f   s   

z3YamlLexer.set_block_scalar_indent.<locals>.callbackr"   r9   r"   r6   r#   set_block_scalar_indentd   s   z!YamlLexer.set_block_scalar_indentc                    r<   )z(Process an empty line in a block scalar.c                 3   s    |  }|jd u st||jkr|r| |fV  n!|d |j }||jd  }| |fV  | |j  |fV  | |_d S r,   )r-   r   r>   r.   r/   r0   )r2   r3   r4   r5   indentationcontentcontent_token_classindent_token_classr"   r#   r8   w   s   
z9YamlLexer.parse_block_scalar_empty_line.<locals>.callbackr"   )rQ   rP   r8   r"   rO   r#   parse_block_scalar_empty_lineu   s   z'YamlLexer.parse_block_scalar_empty_linec                    r+   )z-Process indentation spaces in a block scalar.c                 3   s    |  }|jd u r&t|t|jdkr |j  |j  d S t||_nt||jk r9|j  |j  d S |rJ|  |fV  | |_	d S d S Nr   )
r-   r   r>   rH   r   stackr?   r.   r/   r0   r1   r6   r"   r#   r8      s    




z5YamlLexer.parse_block_scalar_indent.<locals>.callbackr"   r9   r"   r6   r#   parse_block_scalar_indent   s   z#YamlLexer.parse_block_scalar_indentc                    r+   )z-Process indentation spaces in a plain scalar.c                 3   sV    |  }t||jkr|j  |j  d S |r)|  |fV  | |_d S d S r,   )r-   r>   r   rT   r?   r.   r/   r0   r1   r6   r"   r#   r8      s   

z5YamlLexer.parse_plain_scalar_indent.<locals>.callbackr"   r9   r"   r6   r#   parse_plain_scalar_indent   s   	z#YamlLexer.parse_plain_scalar_indentrootz[ ]+(?=#|$)z\n+z#[^\n]*z^%YAML(?=[ ]|$)zyaml-directivez^%TAG(?=[ ]|$)ztag-directivez^(?:---|\.\.\.)(?=[ ]|$)
block-linez[ ]*(?!\s|$)T)r.   )rX   rM   zignored-linez\nz#pop:2z([ ]+)([0-9]+\.[0-9]+)z;([ ]+)(!|![\w-]*!)([ ]+)(!|!?[\w;/?:@&=+$,.!~*\'()\[\]%-]+)rM   z[ ]*$z[ ]+(?=[?:-](?:[ ]|$))z[?:-](?=[ ]|$)z[ ]*z#popz[ ]*(?=#|$)z[ ]+z([^#,?\[\]{}"'\n]+)(:)(?=[ ]|$))rE   descriptorszblock-nodesz
flow-nodesz'(?=[^\s?:,\[\]{}#&*!|>\'"%@`-]|[?:-]\S)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flow-collectionz[?:,]z(?=[^\s?:,\[\]{}#&*!|>\'"%@`])plain-scalar-in-flow-contextz\]z([^,:?\[\]{}"'\n]+)(:)(?=[ ]|$)z\}r[   z^[ ]+$z^[ ]*z[\S\t ]+r\   z([1-9])?[+-]?(?=[ ]|$)z[+-]?([1-9])?(?=[ ]|$)zquoted-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_   rZ   r]   Nc                    s    |d u r	t |d}t ||S rS   )r   r   get_tokens_unprocessed)r   r5   r4   r    r"   r#   r`     s   
z YamlLexer.get_tokens_unprocessed)F)NN)*r$   r%   r&   r'   nameurlaliases	filenames	mimetypesversion_addedr:   r;   rB   rF   rL   rR   rU   rV   r   r   Singler   Tag	Namespacer   r   r	   Typer   	Indicatorr   VariableLabelr   ConstantEscaper
   ScalarPlaintokensr`   r(   r"   r"   r    r#   r      s   



 
'0
<Q^g

s 
  

  

  (  4  ?  K  \

   	r   c                   @   sl   e Zd ZdZdZdZddgZg dZg dZdZ	e
d	Ze
d
Ze
dZe
dZe
dZh dZdd ZdS )r   a(  
    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.
    JSONzhttps://www.json.orgjsonzjson-object)z*.jsonz*.jsonlz*.ndjsonzPipfile.lock)zapplication/jsonzapplication/json-objectzapplication/x-ndjsonzapplication/jsonlzapplication/json-seqz1.5z-0123456789z.eE+truefalsenull0123456789abcdefABCDEFz{}[],>   
	 c              	   c   s   d}d}d}d}d}d}d}d}	d}
d}d}d}d}g }t |D ]\}}|rj|r=|| jv r8|d8 }|s7d}n1d}d}n,|rI|dkrFd}n#d}n |dkrPd}n|dkri||tj|||d  f d}d}d}q!|r|| jv rrq!|r||t||| f n
|t||| fV  d}n|r|| jv rq!|tj	||| fV  d}n|r|| j
v rq!|| jv rd}q!|r|tj||| fV  n|tj||| fV  d}d}n|	r|| jv rq!|t||| fV  d}	n|
r|d	krq!|r||tj||| f n|tj||| fV  d}
n`|rE|d
krd}n,|rDd}|dkrD|r5||tj|||d  f n|tj|||d  fV  d}q!|rmd}|dkrRd}
q!|d
krZd}q!|E dH  |  |t||| fV  |}|dkrwd}q!|| jv rd}q!|dv r|E dH  |  d}q!|| j
v r|E dH  |  d}q!|dkr|D ]\}}}|tju r|tj|fV  q|||fV  q|  d}	q!|| jv r|E dH  |  d}	q!|dkrd}q!|E dH  |  |t|fV  q!|E dH  |r|t||d fV  dS |r|tj||d fV  dS |r+|tj||d fV  dS |r;|tj	||d fV  dS |rJ|t||d fV  dS |	rY|t||d fV  dS |
ri|tj||d fV  dS |rx|t||d fV  dS |r|t||d fV  dS dS )zParse JSON data.Fr   rG   u   \Tr^   rw   */N>   fnt:)	enumeratehexadecimalsrC   r   Doublewhitespacesr   	constantsr	   rn   integersfloatsr   FloatIntegerpunctuationsr   r   rg   	Multilineclearr   r   rh   )r   r5   	in_string	in_escapein_unicode_escapein_whitespacein_constant	in_numberin_floatin_punctuationin_comment_singlein_comment_multilineexpecting_second_comment_openerexpecting_second_comment_closerr.   queuestop	character_start_token_textr"   r"   r#   r`     s  







 







	



z JsonLexer.get_tokens_unprocessedN)r$   r%   r&   r'   ra   rb   rc   rd   re   rf   setr   r   r   r   r   r   r`   r"   r"   r"   r#   r     s    

r   c                   @   s$   e Zd ZdZdZg Zg Zg ZdZdS )r   z
    For JSON data structures (with missing object curly braces).

    .. deprecated:: 2.8.0

       Behaves the same as `JsonLexer` now.
    JSONBareObjectz2.2N)	r$   r%   r&   r'   ra   rc   rd   re   rf   r"   r"   r"   r#   r     s    r   c                       sN   e Zd ZdZdZdZddgZdgZdgZdZ	d	d
 dD Z
 fddZ  ZS )r   z"
    For JSON-LD linked data.
    zJSON-LDzhttps://json-ld.org/jsonldzjson-ldz*.jsonldzapplication/ld+jsonz2.0c                 C   s   h | ]}d | dqS )z"@r^   r"   ).0keywordr"   r"   r#   	<setcomp>  s    
zJsonLdLexer.<setcomp>)base	containerr4   	directiongraphidimportincludedindexrt   languagelistnestnoneprefix	propagate	protectedreverser   typevalueversionvocabc                 #   sN    t  |D ]\}}}|tju r|| jv r|tj|fV  q|||fV  qd S r,   )r   r`   r   rh   json_ld_keywords	Decorator)r   r5   r.   tokenr   r    r"   r#   r`     s   z"JsonLdLexer.get_tokens_unprocessed)r$   r%   r&   r'   ra   rb   rc   rd   re   rf   r   r`   r(   r"   r"   r    r#   r     s    r   N)r'   pygments.lexerr   r   r   r   r   pygments.tokenr   r   r	   r
   r   r   r   r   r   __all__r   r   r   r   r   r"   r"   r"   r#   <module>   s    
,     