
    |e)                         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mZ g dZ ej&                  d      Z G d de      Z G d	 d
e      Z G d de      Zy)z
    pygments.lexers.r
    ~~~~~~~~~~~~~~~~~

    Lexers for the R/S languages.

    :copyright: Copyright 2006-2023 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
Whitespace)RConsoleLexerSLexerRdLexerz.*?
c                   (    e Zd ZdZdZddgZdgZd Zy)r   z@
    For R console transcripts or R CMD BATCH output files.
    RConsolerconsoleroutz*.Routc           	   #   6  K   t        di | j                  }d}g }t        j                  |      D ]  }|j	                         }|j                  d      s|j                  d      r:|j                  t        |      dt        j                  |d d fgf       ||dd  z  }o|r't        ||j                  |            E d {    d}g }|j                         t        j                  |f  |r$t        ||j                  |            E d {    y y 7 T7 w)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lines          3/usr/lib/python3/dist-packages/pygments/lexers/r.pyr&   z$RConsoleLexer.get_tokens_unprocessed    s1    '$,,'
%%d+ 	:E;;=Ds#ts'; !!3'9#:%&Ra$A#B#D E"d12h." &,"F$A$ABT$U W W W *,&!#JkkmW^^T99'	:0 $F99:LMO O O WOs%   B>D DADDDDN)__name__
__module____qualname____doc__namealiases	filenamesr&   r       r0   r   r      s%     D6"G
I Or8   r   c                      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z  ej0                  f ed      defdefgd ed!fgd"ed!fgd#Zd$ Zy%)&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([^"\\]|\\.)*")r>   rB   rE   rD   rF   rA   rC   rG   rootr?   r@   c                 2    t        j                  d|       ryy )Nz[a-z0-9_\])\s]<-(?!-)g)\(?)research)r*   s    r0   analyse_textzSLexer.analyse_text   s    99-t4 5r8   N)r1   r2   r3   r4   r5   r6   r7   	mimetypesrB   r   Singler   r   r
   Reservedr	   ConstantBuiltinPseudor   Hexr   r   r   Functionr   tokensrM   r   r8   r0   r   r   C   s    D!GEIEI PJ gnn%
 
 *;7

 9(C4h?

  ,,-
 4VZZ@K	
 JZ FO,FO,%&L!IJM"K 
 
*DMM:L!{#4L
 !&&1
 /
BFHr8   r   c            
           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y)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-docrI   z	\\[\\{}%]z%.*$z\\(?:cr|l?dots|R|tab)\bz\\[a-zA-Z]+\bz^\s*#(?:ifn?def|endif).*\bz[{}]z[^\\%\n{}]+rH   N)r1   r2   r3   r4   r5   r6   r7   rN   r   Escaper   r
   rQ   Preprocr   rR   r   rV   r   r8   r0   r   r      s    	 DfGI I
 	6==)g')9)9:w'*GOO<dll#T"4L
Fr8   r   )r4   rK   pygments.lexerr   r   r   r   pygments.tokenr   r   r	   r
   r   r   r   r   r   r   __all__compiler   r   r   r   r   r8   r0   <module>r`      sg    
 D D- - - 1 2::g)OE )OXTZ Tn$j $r8   