o
    ‡ÎÖa  ã                   @   s–   d Z ddlZddl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e d¡ZG dd„ deƒZG d	d
„ d
eƒZG dd„ deƒZdS )zÄ
    pygments.lexers.r
    ~~~~~~~~~~~~~~~~~

    Lexers for the R/S languages.

    :copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS.
    :license: BSD, see LICENSE for details.
é    N)ÚLexerÚ
RegexLexerÚincludeÚdo_insertions)	ÚTextÚCommentÚOperatorÚKeywordÚNameÚStringÚNumberÚPunctuationÚGeneric)ÚRConsoleLexerÚSLexerÚRdLexerz.*?
c                   @   s*   e Zd ZdZdZddgZdgZdd„ ZdS )	r   z@
    For R console transcripts or R CMD BATCH output files.
    ÚRConsoleÚrconsoleÚroutz*.Routc              	   c   sÒ   � t di | j¤Ž}d}g }t |¡D ]E}| ¡ }| d¡s"| d¡r=| t|ƒdtj	|d d… fgf¡ ||dd … 7 }q|rNt
|| |¡ƒE d H  d}g }| ¡ tj|fV  q|rgt
|| |¡ƒE d H  d S d S )NÚ ú>ú+r   é   © )r   ÚoptionsÚline_reÚfinditerÚgroupÚ
startswithÚappendÚlenr   ÚPromptr   Úget_tokens_unprocessedÚstartÚOutput)ÚselfÚtextÚslexerÚcurrent_code_blockÚ
insertionsÚmatchÚliner   r   ú3/usr/lib/python3/dist-packages/pygments/lexers/r.pyr"       s.   €
ÿ

ÿ
ÿÿz$RConsoleLexer.get_tokens_unprocessedN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚnameÚaliasesÚ	filenamesr"   r   r   r   r,   r      s    r   c                   @   s
  e Zd ZdZdZg d¢Zg d¢Zg d¢ZdZde	j
fgeefgdefgd	ejfgd
efdefgdejfdejjfgdejfdefgedƒdefdedfdedfedƒedƒedƒedƒedƒedƒg
de ejfedƒdefdefgd ed!fgd"ed!fgd#œZd$d%„ Zd&S )'r   zG
    For S, S-plus, and R source code.

    .. versionadded:: 0.10
    ÚS)ÚsplusÚsÚr)z*.Sz*.Rz	.Rhistoryz	.Rprofilez	.Renviron)ztext/S-plusztext/Sztext/x-r-sourceztext/x-rztext/x-Rztext/x-r-historyztext/x-r-profilez;`[^`\\]*(?:\\.[^`\\]*)*`|(?:[a-zA-Z]|\.[A-Za-z_.])[\w.]*|\.z#.*$z\[{1,2}|\]{1,2}|\(|\)|;|,zH(if|else|for|while|repeat|in|next|break|return|switch|function)(?![\w.])z(<<?-|->>?|-|==|<=|>=|<|>|&&?|!=|\|\|?|\?z$\*|\+|\^|/|!|%[^%]*%|=|~|\$|@|:{1,3}zm(NULL|NA(_(integer|real|complex|character)_)?|letters|LETTERS|Inf|TRUE|FALSE|NaN|pi|\.\.(\.|[0-9]+))(?![\w.])z(T|F)\bz#0[xX][a-fA-F0-9]+([pP][0-9]+)?[Li]?z;[+-]?([0-9]+(\.[0-9]+)?|\.[0-9]+|\.)([eE][+-]?[0-9]+)?[Li]?Úcommentsz\s+z\'Ústring_squotez\"Ústring_dquoteÚbuiltin_symbolsÚ
valid_nameÚnumbersÚkeywordsÚpunctuationÚ	operatorsz(%s)\s*(?=\()Ú
statementsz\{|\}Ú.z([^\'\\]|\\.)*\'z#popz([^"\\]|\\.)*")r8   r<   r?   r>   r@   r;   r=   rA   Úrootr9   r:   c                 C   s   t  d| ¡rdS d S )Nz[a-z0-9_\])\s]<-(?!-)g)\�Âõ(¼?)ÚreÚsearch)r&   r   r   r,   Úanalyse_text•   s   ÿzSLexer.analyse_textN)r-   r.   r/   r0   r1   r2   r3   Ú	mimetypesr<   r   ÚSingler
   r   r	   ÚReservedr   ÚConstantÚBuiltinÚPseudor   ÚHexr   r   r   ÚFunctionÚtokensrF   r   r   r   r,   r   C   sh    ÿÿÿþÿþý
û	ÿüõùÿÿÁDr   c                
   @   sf   e Zd ZdZdZdgZdgZdgZddej	fde
fd	ejfd
efde
jfdejfdefdefgiZdS )r   am  
    Pygments Lexer for R documentation (Rd) files

    This is a very minimal implementation, highlighting little more
    than the macros. A description of Rd syntax is found in `Writing R
    Extensions <http://cran.r-project.org/doc/manuals/R-exts.html>`_
    and `Parsing Rd files <http://developer.r-project.org/parseRd.pdf>`_.

    .. versionadded:: 1.6
    ÚRdÚrdz*.Rdztext/x-r-docrC   z	\\[\\{}%]z%.*$z\\(?:cr|l?dots|R|tab)\bz\\[a-zA-Z]+\bz^\s*#(?:ifn?def|endif).*\bz[{}]z[^\\%\n{}]+rB   N)r-   r.   r/   r0   r1   r2   r3   rG   r   ÚEscaper   r	   rJ   ÚPreprocr
   rK   r   rO   r   r   r   r,   r   š   s"    
ñÿr   )r0   rD   Úpygments.lexerr   r   r   r   Úpygments.tokenr   r   r   r	   r
   r   r   r   r   Ú__all__Úcompiler   r   r   r   r   r   r   r,   Ú<module>   s    
,
,W