
    |eX                         d Z ddlZddlmZmZmZmZ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mZmZ ddlmZ g dZdZ G d d	e      Z G d
 de      Z G d de      Zy)z
    pygments.lexers.ruby
    ~~~~~~~~~~~~~~~~~~~~

    Lexers for Ruby and related languages.

    :copyright: Copyright 2006-2023 by the Pygments team, see AUTHORS.
    :license: BSD, see LICENSE for details.
    N)
Lexer
RegexLexerExtendedRegexLexerincludebygroupsdefaultLexerContextdo_insertionswordsline_re)TextCommentOperatorKeywordNameStringNumberPunctuationErrorGeneric
Whitespaceshebang_matches)	RubyLexerRubyConsoleLexer
FancyLexer)*z**-+z-@z+@/%&|^`~z[]z[]=<<z>><<>z<=>>z>=z==z===c                   4   e Zd ZdZdZdZg dZg dZddgZe	j                  e	j                  z  Zd Zd	 Zg d
ej                   fdej"                  fdej$                  f edd      efd eeeej0                        fd eee      dfdedfd eee      df edd      ej2                  fdej6                  f edd      ej8                  fdej8                  f eddd      ej8                  fdej8                  j2                  fdefd efd!ej:                  d"fd# eeej@                        d$fd%ej@                  d$fd& eeej@                        d$fd' ee!jD                  ee      fd( ee!jF                  ee      fd) ee!jH                  ee      fd* ee!jJ                  ee      fd+ejL                  jN                  fd,ejL                  jP                  fd-ejL                  jR                  fd.ejL                  jR                  fd/ejL                  jR                  fd0ef e*d1      d2ejV                  fd3ejX                  f ee-d45       eeej4                        fd6 eee      fd7efd8efd9efd:e.fd;efd<e.d=fd> eejN                  eej^                        d?f e0d?      gd<e.d=fd@ed?fdAejN                  d?f e0d?      gdB ee.e      d?fd<edCf e*dD      gdEejb                  dCfdFejb                  d?f e*dD      gdGejb                  dHfdIejb                  fdJejb                  fg e*dK      dLejd                  fg e*dK      dMej@                  fdNej@                  fg e*dK      dMejf                  fdNejf                  fg e*dK      dOej@                  fdPej@                  fdMej@                  fdQej@                  fdRej@                  d?fgdSej:                  d?fgdTZ4e4jk                   e              dU Z6yV)Wr   z
    For Ruby source code.
    Rubyzhttp://www.ruby-lang.org)rubyrbduby)	z*.rbz*.rbwRakefilez*.rakez	*.gemspecz*.rbxz*.dubyGemfileVagrantfileztext/x-rubyzapplication/x-rubyc              #   F  K   |j                  d      }|t        |j                  d      f |j                  d      t        j                  |j                  d      f |j                  d      t        j
                  |j                  d      f |j                  d      t        j                  |j                  d      f |j                  j                  dg       }t        |       }|j                  |j                  d      dv |j                  d      f       |j                  d      |_
        |j                  d      |_        t        |      dk  r| j                  |	      E d {    n.|j                  t        j                  |j                  d      f |j                         |_
        |r`|D ]:  \  }}g }t        j                  |j                   |j                        D ]  }|r|j                         j#                         }	n|j                         j%                         }	|	|k(  r|D ]3  }
|
j                         t        j                  |
j                         f 5 |j                         t        j
                  |j                         f |j                         |_
         |j                  |        |D ])  }
|
j                         t&        |
j                         f + = t        |j                         |_        |d d = y y 7 w)
N            heredocstack)z<<-z<<~   d   context)startr   groupr   Heredoc	Delimiter__dict__
setdefaultboolappendposendlenget_tokens_unprocessedr   finditertextstriprstripr   )selfmatchctxr=   r8   	outermosttoleranthdnamelinescheckamatchs              6/usr/lib/python3/dist-packages/pygments/lexers/ruby.pyheredoc_callbackzRubyLexer.heredoc_callback*   st     AXu{{1~--kk!nfnnekk!n<<kk!nf..A>>kk!nfnnekk!n<<||..~rB\**	U[[^~=u{{1~NO++a.))A,|s"2232???''6>>5;;q>99))+$0 D &$--chh@ DE % 3 3 5 % 4 4 6&+ QF"(,,.&..&,,."PPQ#kkmV-=-=u{{}LL"'))+U+D #( D$llneV\\^CCD#D& #((mCGQ-  @s   E/L!1L2F-L!c                     d } d }i }dt         j                  ft        t        d      t         j                  fdt         j                  fdt         j                  dfd	t	        t         j                  t
              fd
t         j                  dfdt         j                  dfdt         j                  dfg|d<   dt         j                  d
fdt         j                  dfdt         j                  d
fdt         j                  dffD ]%  \  }}}t        d      d|z  |fd|f||dfg|d|z   <   ' dD ]  \  }}}}d|z   dz   t         j                  f|t         j                  df|t         j                  dft        d      d|z   dz   t         j                  fd |z   d!z   t         j                  fg||d"z   <   |d   j                  d#|z   t         j                  |d"z   f       d|z   dz   t         j                  f|t         j                  df|t         j                  dfd|z   dz   t         j                  fd |z   d!z   t         j                  fg||d$z   <   |d   j                  d%|z   t         j                  |d$z   f       d|z   dz   t         j                  f|t         j                  df|d&z   t         j                  dft        d'      d|z   dz   t         j                  fd |z   d!z   t         j                  fg||d(z   <   |d   j                  d)|z   t         j                  |d(z   f        |dxx   d*| fd+t         j                  fd,|fd-t	        t        t         j                  d       fd.t	        t        t         j                  d       fd/|fgz  cc<   |S )0Nc              3     K   |j                  d      t        j                  |j                  d      f t	        |j                  d      ddg      }| j                  |      D ]  \  }}}|j                  d      |z   ||f ! |j                  d      t        j                  |j                  d      f |j                         |_        y w)Nr4   r6   r   interpolated-regexr;   r7   )r=   r   Regexr>   r	   rH   rF   rE   rM   rN   rO   nctxitvs          rV   intp_regex_callbackz<RubyLexer.gen_rubystrings_rules.<locals>.intp_regex_callbackZ   s     ++a.&,,A>>A4H3IJD66t6D -1akk!nQ&1,,-++a.&,,A>>iikCG   CCc              3     K   |j                  d      t        j                  |j                  d      f t	        |j                  d      ddg      }| j                  |      D ]  \  }}}|j                  d      |z   ||f ! |j                  d      t        j                  |j                  d      f |j                         |_        y w)Nr4   r6   r   interpolated-stringr;   r7   )r=   r   Otherr>   r	   rH   rF   rE   r\   s          rV   intp_string_callbackz=RubyLexer.gen_rubystrings_rules.<locals>.intp_string_callbackb   s     ++a.&,,A>>A4I3JKD66t6D -1akk!nQ&1,,-++a.&,,A>>iikCGrb   z\:@{0,2}[a-zA-Z_]\w*[!?]?z\:@{0,2}prefixz:'(\\\\|\\[^\\]|[^'\\])*'z:"z
simple-symz([a-zA-Z_]\w*)(:)(?!:)"zsimple-string-double'zsimple-string-singlez(?<!\.)`zsimple-backtickstringszstring-doublezstring-singlesymbacktickr%   string-intp-escapedz	[^\\%s#]+[\\#]#popzsimple-))\{\}z{}cb)z\[z\]z\[\]sb)\(z\)z()pa)r(   r*   r)   abz\\[\\]#pushz[\\#z[^\\#z]+z-intp-stringz%[QWx]?z-stringz%[qsw]z[mixounse]*string-intpz-regexz%rz-(%r([\W_]))((?:\\\2|(?!\2).)*)(\2[mixounse]*)z"%[qsw]([\W_])((?:\\\1|(?!\1).)*)\1z&(%[QWx]([\W_]))((?:\\\2|(?!\2).)*)(\2)z<(?<=[-+/*%=<>&!^|~,(])(\s*)(%([\t ])(?:(?:\\\3|(?!\3).)*)\3)z'^(\s*)(%([\t ])(?:(?:\\\3|(?!\3).)*)\3)z*(%([^a-zA-Z0-9\s]))((?:\\\2|(?!\2).)*)(\2))r   Symbolr   RUBY_OPERATORSr   r   DoubleSingleBacktickr   re   rD   r[   r   )	ra   rf   statesnamettyperF   lbracerbracebraceccs	            rV   gen_rubystrings_ruleszRubyLexer.gen_rubystrings_rulesY   s   	"	"  *6==9>+6F)6==9FMM<0&fmm[136=="896=="89&//+<=
y "1&-- E!0&-- E!&s ;!+V__c B!C 		D%
 -.#U+5!eV$	&F9T>"			'!	6)FFGT G#c)6<<8w/v.-.7"S(&,,7G#d*FLL9+F4&' 9$$j6&96<<&*>&9&; < G#c)6<<8w/v.7"S(&,,7G#d*FLL9&F4	>" 9$$i&&8&,,&*9n&6 7 G#c)6<<8w/-'v>&7"S(&,,7G#d*FLL9%F4=! 9$$efnfll&*8m&5 6A!	6H 	y= " 3FLLA6!# Mj&,,57 8j&,,57 ;!##
 	
*     z\A#!.+?$z#.*?$z=begin\s.*?\n=end.*?$)BEGINENDaliasbeginbreakcasezdefined?doelseelsifrF   ensureforifinnextredorescueraiseretryreturnsuperthenundefunlessuntilwhenwhileyield\bsuffixz.(module)(\s+)([a-zA-Z_]\w*(?:::[a-zA-Z_]\w*)*)z
(def)(\s+)funcnamezdef(?=[*%&^`~+-/\[<>=])z(class)(\s+)	classname)
initializenewloopr   extendr   attr_readerattr_writerattr_accessorattrcatchthrowprivatemodule_functionpublic	protectedtruefalsenilz(not|and|or)\b)autoloadblock_givenconst_definedeqlequalfrozenr   instance_ofis_aiteratorkind_ofmethod_definedr   private_method_definedprotected_method_definedpublic_method_defined
respond_totaintedz\?z(chomp|chop|exit|gsub|sub)!)eArrayFloatIntegerr   __id____send__abort	ancestorsat_exitr   bindingcallcccallerr   chompchop
class_evalclass_variablesclonezconst_defined?	const_getconst_missing	const_set	constantsdisplaydupevalexecexitr   failforkformatfreezegetcgetsglobal_variablesgsubhashidincluded_modulesinspectinstance_evalinstance_methodinstance_methodsinstance_variable_getinstance_variable_setinstance_variableslambdaloadlocal_variablesr   methodmethod_missingmethodsmodule_evalr   	object_idopenpprintprintfprivate_class_methodprivate_instance_methodsprivate_methodsprocprotected_instance_methodsprotected_methodspublic_class_methodpublic_instance_methodspublic_methodsputcputsr   randreadline	readlinesrequirescanselectrM   sendset_trace_funcsingleton_methodssleepsplitsprintfsrandsubsyscallsystemtainttestr   to_ato_s	trace_vartrapuntaintuntrace_varwarnz(?<!\.))rh   r   z__(FILE|LINE)__\bz2(?<!\w)(<<[-~]?)(["`\']?)([a-zA-Z_]\w*)(\2)(.*?\n)z(<<[-~]?)("|\')()(\2)(.*?\n)__END__end-partab  (?:^|(?<=[=<>~!:])|(?<=(?:\s|;)when\s)|(?<=(?:\s|;)or\s)|(?<=(?:\s|;)and\s)|(?<=\.index\s)|(?<=\.scan\s)|(?<=\.sub\s)|(?<=\.sub!\s)|(?<=\.gsub\s)|(?<=\.gsub!\s)|(?<=\.match\s)|(?<=(?:\s|;)if\s)|(?<=(?:\s|;)elsif\s)|(?<=^when\s)|(?<=^index\s)|(?<=^scan\s)|(?<=^sub\s)|(?<=^gsub\s)|(?<=^sub!\s)|(?<=^gsub!\s)|(?<=^match\s)|(?<=^if\s)|(?<=^elsif\s))(\s*)(/)multiline-regexz(?<=\(|,|\[)/z(\s+)(/)(?![\s=])z#(0_?[0-7]+(?:_[0-7]+)*)(\s*)([/?])?z.(0x[0-9A-Fa-f]+(?:_[0-9A-Fa-f]+)*)(\s*)([/?])?z (0b[01]+(?:_[01]+)*)(\s*)([/?])?([\d]+(?:_\d+)*)(\s*)([/?])?@@[a-zA-Z_]\w*@[a-zA-Z_]\w*z\$\w+z\$[!@&`\'+~=/\\,;.<>_*$?:"^-]z\$-[0adFiIlpvw]z::rk   zI\?(\\[MC]-)*(\\([\\abefnrstv#"\']|x[a-fA-F0-9]{1,2}|[0-7]{1,3})|\S)(?!\w)z[A-Z]\w+z(\.|::)rg   z,(\.|::)([a-zA-Z_]\w*[!?]?|[*%&^`~+\-/\[<>=])z[a-zA-Z_]\w*[!?]?z:(\[|\]|\*\*|<<?|>>?|>=|<=|<=>|=~|={3}|!~|&&?|\|\||\.{1,3})z[-+/*%=<>&!^|~]=?z[(){};,/?:\\]\s+ru   defexprz(?:([a-zA-Z_]\w*)(\.))?([a-zA-Z\u0080-\uffff][a-zA-Z0-9_\u0080-\uffff]*[!?=]?|!=|!~|=~|\*\*?|[-+!~]@?|[/%&|^]|<=>|<[<=]?|>[>=]?|===?|\[\]=?|`)rp   r'   z	[A-Z_]\w*z(\))(\.|::)?ry   rootrq   rr   z#\{in-intpz#@@?[a-zA-Z_]\w*z#\$[a-zA-Z_]\w*rz   z2\\([\\abefnrstv#"\']|x[a-fA-F0-9]{1,2}|[0-7]{1,3})ro   z[^\\#]+z\\\\z\\/z[^\\/#]+z/[mixounse]*z.+)r,  r   r   r+  r-  rz   rn   rZ   rd   r&  r%  c                     t        | d      S )Nzruby(1\.\d)?r   )rJ   s    rV   analyse_textzRubyLexer.analyse_text  s    t_55r   N)7__name__
__module____qualname____doc__r   urlaliases	filenames	mimetypesreDOTALL	MULTILINEflagsrW   r   r   Hashbangr~   	Multiliner   r   r   r   r   	NamespacePseudor   WordBuiltinPreprocr   r   r[   r   OctHexBinr   VariableClassInstanceGlobalr   CharConstantr|   r   Functionr   InterpolEscapere   tokensupdater/   r   rV   r   r      sf    D
$C$G>I 45III$E- ^ePG
'**+G
w~~&G
 &w'8'89G

  = FK	L
 G
%gz4>>:<G
 HWj9:FG
  (*=!G
" hw
;[I#G
&  R 	
 ^^'G
2 .3G
4  B KP	Q
 \\5G
@ ,T\\:AG
B  '* 0:%+I, \\-CG
p "4<<#6#67qG
t CuG
z -.>?{G
| *5}G
@. $D&,,79J/LAG
r v||->?sG
v "8J#E wG
J 4fjj*h79KG
N ?fjj*h79OG
R 1fjj*h79SG
V -fnnj(;=WG
\  3 34]G
^ t}}556_G
` t}}++,aG
b .t}}/C/CDcG
d  !5!56eG
f HgG
h IiG
l [[mG
t $--(uG
z >*5h.0{G
~ =h%'G
B "4(CG
D%&.0EG
H "8,IG
J {+KG
L Z MG
R K+ djj(DMM:FD FO
 K+Hf%4::v.FO	
 h{H=vFHg&FO
 FOOW-FOOV,FO
 V__i0 &//21
 M"B]] 
 M"v||$&
 M"v||$& 
 M"fll#V\\"v||$&,,'fllF3
 GOOV,
CDFJ MM')*6r   r   c                   P    e Zd ZdZdZddgZdgZdZ ej                  d      Z
d Zy	)
r   z8
    For Ruby interactive console (**irb**) output.
    zRuby irb sessionrbconirbztext/x-ruby-shellsessionzrbcon/consolez.irb\([a-zA-Z_]\w*\):\d{3}:\d+[>*"\'] |>> |\?> c           	   #   L  K   t        di | j                  }d}g }t        j                  |      D ]  }|j	                         }| j
                  j                  |      }|J|j                         }|j                  t        |      dt        j                  |d | fgf       |||d  z  }z|r't        ||j                  |            E d {    d}g }|j                         t        j                  |f  |r$t        ||j                  |            E d {    y y 7 T7 w)N r   rQ  )r   optionsr   rI   r>   
_prompt_rerN   rF   rD   rG   r   Promptr
   rH   r=   Output)	rM   rJ   rblexercurcode
insertionsrN   linemrF   s	            rV   rH   z'RubyConsoleLexer.get_tokens_unprocessed  s1    +dll+
%%d+ 	:E;;=D%%d+A}eeg!!3w<%&Tc
$C#D#F G4:%,"G$B$B7$K M M M G!#JkkmW^^T99	: $G::7CE E E MEs%   C	D$D AD$D"D$"D$N)r0  r1  r2  r3  r   r5  r7  _exampler8  compilerX  rH   rQ  r   rV   r   r     s@     DG+,IH ) *JEr   r   c                    
   e Zd ZdZdZdZddgZddgZdgZd	e	j                  d
fde	j                  d
fde	j                  d
fde	j                  d
fde	j                  d
fde	j                  d
fde	j                  d
fde	j                  d
fde	j                  d
fde	j                  d
fg
defde	j                  dfde	j                  dfde	j                  dfde	j                  dfde	j                  fde	j                  dfdej                  fde	j                  fde	fde	fd efd!ej"                  fd"ef ed#d$%      ej(                  fd&ej*                  fd'efd(ej"                  fd)ej.                  j0                  fd*ej.                  j2                  fd+efd,efd- eej8                  ee      fd. eej:                  ee      fd/ eej<                  ee      fd0 eej>                  ee      fd1ej@                  fd2ej>                  fgd3Z!y4)5r   z
    Pygments Lexer For Fancy.

    Fancy is a self-hosted, pure object-oriented, dynamic,
    class-based, concurrent general-purpose programming language
    running on Rubinius, the Ruby VM.

    .. versionadded:: 1.5
    Fancyz!https://github.com/bakkdoor/fancyz*.fyz*.fancypackfancyfyztext/x-fancysrcz"/(\\\\|\\[^\\]|[^/\\])*/[egimosx]*rp   z"!(\\\\|\\[^\\]|[^!\\])*![egimosx]*z\\(\\\\|[^\\])*\\[egimosx]*z$\{(\\\\|\\[^\\]|[^}\\])*\}[egimosx]*z"<(\\\\|\\[^\\]|[^>\\])*>[egimosx]*z%\[(\\\\|\\[^\\]|[^\]\\])*\][egimosx]*z$\((\\\\|\\[^\\]|[^)\\])*\)[egimosx]*z"@(\\\\|\\[^\\]|[^@\\])*@[egimosx]*z"%(\\\\|\\[^\\]|[^%\\])*%[egimosx]*z$\$(\\\\|\\[^\\]|[^$\\])*\$[egimosx]*r*  zs\{(\\\\|\\[^\\]|[^}\\])*\}\s*balanced-regexzs<(\\\\|\\[^\\]|[^>\\])*>\s*zs\[(\\\\|\\[^\\]|[^\]\\])*\]\s*zs\((\\\\|\\[^\\]|[^)\\])*\)\s*z&m?/(\\\\|\\[^\\]|[^///\n])*/[gcimosx]*zm(?=[/!\\{<\[(@%$])z#(.*?)\nz\'([^\'\s\[\](){}]+|\[\])z"""(\\\\|\\[^\\]|[^\\])*?"""z"(\\\\|\\[^\\]|[^"\\])*"zJ(def|class|try|catch|finally|retry|return|return_local|match|case|->|=>)\bz(self|super|nil|false|true)\bz[(){};,/?|:\\])Objectr   Hash	DirectoryFilerG  r   r   
EnumerableFancyEnumerableBlock	TrueClassNilClass
FalseClassTupler{   StackSet	FancySpecMethodPackageRanger   r   z[a-zA-Z](\w|[-+?!=*/^><%])*:z[-+*/~,<>=&!?%^\[\].$]+z[A-Z]\w*r)  r(  z@@?z[a-zA-Z_]\w*z&(0[oO]?[0-7]+(?:_[0-7]+)*)(\s*)([/?])?z1(0[xX][0-9A-Fa-f]+(?:_[0-9A-Fa-f]+)*)(\s*)([/?])?z#(0[bB][01]+(?:_[01]+)*)(\s*)([/?])?r'  z/\d+([eE][+-]?[0-9]+)|\d+\.\d+([eE][+-]?[0-9]+)?z\d+)rf  r,  N)"r0  r1  r2  r3  r   r4  r6  r5  r7  r   r[   r   r   r~   r{   r   r   rK  r   r   rA  rL  r   rF  rH  rG  r   r   rC  rD  rE  r   r   rO  rQ  r   rV   r   r     sr    D
-C'IoG"#I
 3FLL&I2FLL&I+V\\6B4fllFK2FLL&I5v||VL4fllFK2FLL&I2FLL&I4fllFK
 Z  />NO,fll<LM/?OP.>NO6E#V\\3CD '..))6==9,f5(&1&( .t}}=, ; DI	J
 \\ -dmm<'2$--(t}}556 3 34Hd# 7fjj*h79Afjj*h793fjj*h79,fnnj(;=?NV^^$i5
DFr   r   ) r3  r8  pygments.lexerr   r   r   r   r   r   r	   r
   r   r   pygments.tokenr   r   r   r   r   r   r   r   r   r   r   pygments.utilr   __all__r|   r   r   r   rQ  r   rV   <module>r|     sq    
C C C4 4 4 4 )
9l6" l6^"Eu "EJT Tr   