3
.ßL]ƒV  ã               @   sÀ   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 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 dddgZejd	ƒZ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.ruby
    ~~~~~~~~~~~~~~~~~~~~

    Lexers for Ruby and related languages.

    :copyright: Copyright 2006-2019 by the Pygments team, see AUTHORS.
    :license: BSD, see LICENSE for details.
é    N)	ÚLexerÚ
RegexLexerÚExtendedRegexLexerÚincludeÚbygroupsÚdefaultÚLexerContextÚdo_insertionsÚwords)
ÚTextÚCommentÚOperatorÚKeywordÚNameÚStringÚNumberÚPunctuationÚErrorÚGeneric)Úshebang_matchesÚ	RubyLexerÚRubyConsoleLexerÚ
FancyLexerz.*?
Ú*ú**ú-ú+ú-@ú+@ú/ú%ú&ú|ú^ú`ú~ú[]ú[]=ú<<ú>>ú<ú<>ú<=>ú>ú>=ú==ú===c            r   @   s@  e Zd ZdZdZdddgZdddd	d
dddgZddgZej	ej
B Zdd„ Zdd„ Zdejfdejfdejfedüd4d5�efd6eeeejƒfd7eeeƒd8fd9ed8fd:eeeƒd;fedýd4d5�ejfdNejfedþd_d5�ejfd`ejfedÿdÀd4dÁ�ejfdÂejj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j eeƒfdÌeej!eeƒfdÍeej"eeƒfdÎeej#eeƒfdÏej$j%fdÐej$j&fdÑej$j'fdÒej$j'fdÓej$j'fdÔefe(dÕƒdÖej)fd×ej*fee+dØdÙ�eeejƒfdÚeeeƒfdÛefdÜefdÝefdÞe,fdßefg(dàe,dáfdâeej%eej-ƒdãfe.dãƒgdàe,dáfdäedãfdåej%dãfe.dãƒgdæee,eƒdãfdàedçfe(dèƒgdéej/dçfdêej/dãfe(dèƒgdëej/dìfdíej/fdîej/fge(dïƒdðej0fge(dïƒdñejfdòejfge(dïƒdñej1fdòej1fge(dïƒdóejfdôejfdñejfdõejfdöejdãfgd÷ejdãfgdøœZ2e2j3eƒ ƒ dùdú„ Z4dûS (   r   z=
    For `Ruby <http://www.ruby-lang.org>`_ source code.
    ZRubyÚrbÚrubyZdubyz*.rbz*.rbwZRakefilez*.rakez	*.gemspecz*.rbxz*.dubyZGemfileztext/x-rubyzapplication/x-rubyc             c   sÞ  |j dƒ}|t|jdƒfV  |j dƒtj|jdƒfV  |j dƒtj|jdƒfV  |j dƒtj|jdƒfV  |jjdg ƒ}t|ƒ }|j	|jdƒdk|jdƒfƒ |j dƒ|_
|jdƒ|_x&| j|d�D ]\}}}|||fV  qÆW |jƒ |_
|�rÚxÒ|D ]Ê\}	}
g }x¼tj|j|j
ƒD ]„}|	�r,|jƒ jƒ }n|jƒ jƒ }||
k�rŒx$|D ]}|j ƒ tj|jƒ fV  �qHW |j ƒ tj|jƒ fV  |jƒ |_
P n
|j	|ƒ �qW x"|D ]}|j ƒ t|jƒ fV  �q¢W qöW t|jƒ|_|d d …= d S )	Né   é   é   é   Úheredocstackz<<-é   )Úcontext)Ústartr   Úgroupr   ZHeredocZ	DelimiterÚ__dict__Ú
setdefaultÚboolÚappendÚposÚendÚget_tokens_unprocessedÚline_reÚfinditerÚtextÚstripÚrstripr   Úlen)ÚselfÚmatchÚctxr:   r7   Z	outermostÚiÚtÚvZtolerantZhdnameÚlinesÚcheckZamatch© rQ   ú:/tmp/pip-install-5sebvq2j/pygments/pygments/lexers/ruby.pyÚheredoc_callback,   s>    






zRubyLexer.heredoc_callbackc        	      C   sŽ  dd„ } dd„ }i }dt jfttdd�t jf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g|d< xZdt jdfdt jdfdt jdffD ]4\}}}t	dƒd| |fd|f||dfg|d| < q”W �xpdCD �]f\}}}}d+| d, t j
f|t j
d-f|t j
dft	dƒd.| d, t j
fd/| d0 t j
fg||d1 < |d jd2| t j
|d1 fƒ d+| d, t j
f|t j
d-f|t j
dfd.| d, t j
fd/| d0 t j
fg||d3 < |d jd4| t j
|d3 fƒ d+| d, t jf|t jd-f|d5 t jdft	d6ƒd.| d, t jfd/| d0 t jfg||d7 < |d jd8| t j|d7 fƒ qÔW |d  d9| fd:t j
fd;|fd<ttt j
d ƒfd=ttt j
d ƒfd>|fg7  < |S )DNc             s   sˆ   |j dƒtj|jdƒfV  t|jdƒddgƒ}x0| j|d�D ] \}}}|j dƒ| ||fV  q<W |j dƒtj|jdƒfV  |jƒ |_d S )Nr3   r5   r   zinterpolated-regex)r9   r6   )r:   r   ÚRegexr;   r   rB   rA   r@   )rI   rJ   rK   ÚnctxrL   rM   rN   rQ   rQ   rR   Úintp_regex_callbackZ   s    z<RubyLexer.gen_rubystrings_rules.<locals>.intp_regex_callbackc             s   sˆ   |j dƒtj|jdƒfV  t|jdƒddgƒ}x0| j|d�D ] \}}}|j dƒ| ||fV  q<W |j dƒtj|jdƒfV  |jƒ |_d S )Nr3   r5   r   zinterpolated-string)r9   r6   )r:   r   ÚOtherr;   r   rB   rA   r@   )rI   rJ   rK   rU   rL   rM   rN   rQ   rQ   rR   Úintp_string_callbackb   s    z=RubyLexer.gen_rubystrings_rules.<locals>.intp_string_callbackz\:@{0,2}[a-zA-Z_]\w*[!?]?z\:@{0,2})Úprefixz:'(\\\\|\\'|[^'])*'z'(\\\\|\\'|[^'])*'z:"z
simple-symz([a-zA-Z_]\w*)(:)(?!:)ú"zsimple-stringz(?<!\.)`zsimple-backtickÚstringsÚstringÚsymZbacktickr$   zstring-intp-escapedz	[^\\%s#]+z[\\#]z#popzsimple-ú\{ú\}ú{}Úcbú\[ú\]ú\[\]Úsbú\(ú\)ú()Úpar*   r-   ú<>Úabz\\[\\ú]z#pushz[\\#z[^\\#z]+z-intp-stringz%[QWx]?z-stringz%[qsw]z[mixounse]*z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^   r_   r`   ra   ©rb   rc   rd   re   ©rf   rg   rh   ri   ©r*   r-   rj   rk   )rm   rn   ro   rp   )r   ÚSymbolr
   ÚRUBY_OPERATORSÚSingler   r   ÚDoubleZBacktickr   rW   r?   rT   r   )	rV   rX   ZstatesÚnameZttyperA   ZlbraceÚrbraceZbraceccrQ   rQ   rR   Úgen_rubystrings_rulesY   sx    



   




zRubyLexer.gen_rubystrings_rulesz\A#!.+?$z#.*?$z=begin\s.*?\n=end.*?$ÚBEGINÚENDÚaliasÚbeginÚbreakÚcaseúdefined?ÚdoÚelseÚelsifrA   ÚensureÚforÚifÚinÚnextÚredoÚrescueÚraiseÚretryÚreturnÚsuperÚthenÚundefÚunlessÚuntilÚwhenÚwhileÚyieldz\b)Úsuffixz.(module)(\s+)([a-zA-Z_]\w*(?:::[a-zA-Z_]\w*)*)z
(def)(\s+)Úfuncnamezdef(?=[*%&^`~+-/\[<>=])z(class)(\s+)Ú	classnameÚ
initializeÚnewÚloopr   ÚextendÚ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ÚfrozenÚinstance_ofÚis_aÚiteratorÚkind_ofÚmethod_definedÚprivate_method_definedÚprotected_method_definedÚpublic_method_definedÚ
respond_toÚtaintedz\?z(chomp|chop|exit|gsub|sub)!ÚArrayÚFloatÚIntegerr   Ú__id__Ú__send__ÚabortÚ	ancestorsÚat_exitÚbindingÚcallccÚcallerÚchompÚchopÚ
class_evalÚclass_variablesÚcloneúconst_defined?Ú	const_getÚconst_missingÚ	const_setÚ	constantsÚdisplayÚdupÚevalÚexecÚexitÚ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_variablesÚmethodÚmethod_missingÚmethodsÚmodule_evalru   Ú	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ÚputsÚrandÚreadlineÚ	readlinesÚrequireÚscanÚselectrI   ÚsendÚset_trace_funcÚsingleton_methodsÚsleepÚsplitÚsprintfÚsrandÚsubÚsyscallÚsystemÚtaintÚtestÚto_aÚto_sÚ	trace_varÚtrapÚuntaintÚuntrace_varÚwarnz(?<!\.))rY   r”   z__(FILE|LINE)__\bz/(?<!\w)(<<-?)(["`\']?)([a-zA-Z_]\w*)(\2)(.*?\n)z(<<-?)("|\')()(\2)(.*?\n)Z__END__z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*)(/)z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*)([/?])?z([\d]+(?:_\d+)*)(\s*)([/?])?z@@[a-zA-Z_]\w*z@[a-zA-Z_]\w*z\$\w+z\$[!@&`\'+~=/\\,;.<>_*$?:"^-]z\$-[0adFiIlpvw]z::r[   zI\?(\\[MC]-)*(\\([\\abefnrstv#"\']|x[a-fA-F0-9]{1,2}|[0-7]{1,3})|\S)(?!\w)z[A-Z]\w+z(\.|::))rY   z,(\.|::)([a-zA-Z_]\w*[!?]?|[*%&^`~+\-/\[<>=])z[a-zA-Z_]\w*[!?]?z:(\[|\]|\*\*|<<?|>>?|>=|<=|<=>|=~|={3}|!~|&&?|\|\||\.{1,3})z[-+/*%=<>&!^|~]=?z[(){};,/?:\\]z\s+z\(Údefexprz\(?:([a-zA-Z_]\w*)(\.))?([a-zA-Z_]\w*[!?]?|\*\*?|[-+]@?|[/%&|^`~]|\[\]=?|<<|>>|<=?>|>=?|===?)z#popz<<z	[A-Z_]\w*z(\))(\.|::)?z#pushÚrootz\{z\}z#\{zin-intpz#@@?[a-zA-Z_]\w*z#\$[a-zA-Z_]\w*zstring-intpz2\\([\\abefnrstv#"\']|x[a-fA-F0-9]{1,2}|[0-7]{1,3})z[\\#]z[^\\#]+z\\\\z\\/z[^\\/#]+z/[mixounse]*z.+)r  r•   r–   r  zin-intpzstring-intpzstring-intp-escapedzinterpolated-regexzinterpolated-stringzmultiline-regexzend-partc             C   s
   t | dƒS )Nzruby(1\.\d)?)r   )rE   rQ   rQ   rR   Úanalyse_text‚  s    zRubyLexer.analyse_textN)rx   ry   rz   r{   r|   r}   r~   r   r€   r�   rA   r‚   rƒ   r„   r…   r†   r‡   rˆ   r‰   rŠ   r‹   rŒ   r�   rŽ   r�   r�   r‘   r’   r“   )r—   r˜   r™   r   rš   r‰   r›   rœ   r�   rž   rŸ   r    r¡   r¢   r£   r¤   r¥   r¦   r§   )r¨   r©   rª   r«   r¬   r­   r   r®   r¯   r°   r±   r²   r§   r³   r´   rµ   r¶   r·   )er¸   r¹   rº   r   r»   r¼   r½   r¾   r¿   r¨   rÀ   rÁ   rÂ   rŸ   rÃ   rÄ   rÅ   rÆ   rÇ   rÈ   rÉ   rÊ   rË   rÌ   rÍ   rÎ   rÏ   rÐ   rÑ   rš   rÒ   rÓ   rÔ   rÕ   rÖ   r×   rØ   rÙ   rÚ   rÛ   rÜ   rÝ   rÞ   rß   rà   rá   râ   rã   rä   rå   ræ   r™   rç   rè   ré   rê   ru   rë   rì   rí   rî   rï   rð   rñ   rò   ró   rô   rõ   rö   r÷   rø   rù   rú   r‰   rû   rü   rý   rþ   rÿ   r   rI   r  r  r  r  r  r  r  r  r	  r
  r  r  r    r  r  r  r  r  r  r  )5Ú__name__Ú
__module__Ú__qualname__Ú__doc__ru   ÚaliasesÚ	filenamesÚ	mimetypesÚreÚDOTALLÚ	MULTILINEÚflagsrS   rw   r   ZHashbangrs   Z	Multiliner
   r   r   r   r   Ú	NamespaceZPseudor   ÚWordÚBuiltinZPreprocr   rT   r   ÚOctÚHexÚBinrº   ÚVariableÚClassÚInstanceÚGlobalr   ÚCharÚConstantrr   r   ÚFunctionr   ZInterpolZEscaperW   ÚtokensÚupdater  rQ   rQ   rQ   rR   r      s
  


-h                            



	













c               @   s4   e Zd ZdZdZddgZdgZejdƒZ	dd„ Z
d	S )
r   z¾
    For Ruby interactive console (**irb**) output like:

    .. sourcecode:: rbcon

        irb(main):001:0> a = 1
        => 1
        irb(main):002:0> puts a
        1
        => nil
    zRuby irb sessionZrbconZirbztext/x-ruby-shellsessionz.irb\([a-zA-Z_]\w*\):\d{3}:\d+[>*"\'] |>> |\?> c       
      c   sè   t f | jŽ}d}g }xªtj|ƒD ]œ}|jƒ }| jj|ƒ}|d k	r~|jƒ }|jt	|ƒdt
j|d |… fgfƒ |||d … 7 }q |rªxt||j|ƒƒD ]
}	|	V  q”W d}g }|jƒ t
j|fV  q W |räxt||j|ƒƒD ]
}	|	V  qÖW d S )NÚ r   )r   ÚoptionsrC   rD   r;   Ú
_prompt_rerJ   rA   r?   rH   r   ZPromptr	   rB   r:   ZOutput)
rI   rE   ZrblexerZcurcodeZ
insertionsrJ   ÚlineÚmrA   ÚitemrQ   rQ   rR   rB   ™  s,    

z'RubyConsoleLexer.get_tokens_unprocessedN)r  r  r  r  ru   r  r  r  Úcompiler3  rB   rQ   rQ   rQ   rR   r   †  s   
c            &   @   sž  e 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dId8d9�ejfd:ejfd;efd<ejfd=ejjfd>ejjfd?efd@efdAeeje
eƒfdBeeje
eƒfdCeeje
eƒfdDeeje
eƒfdEejfdFejfgdGœZ dHS )Jr   a  
    Pygments Lexer For `Fancy <http://www.fancy-lang.org/>`_.

    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
    ZFancyz*.fyz*.fancypackZfancyZfyztext/x-fancysrcz/(\\\\|\\/|[^/])*/[egimosx]*z#popz!(\\\\|\\!|[^!])*![egimosx]*z\\(\\\\|[^\\])*\\[egimosx]*z\{(\\\\|\\\}|[^}])*\}[egimosx]*z<(\\\\|\\>|[^>])*>[egimosx]*z \[(\\\\|\\\]|[^\]])*\][egimosx]*z\((\\\\|\\\)|[^)])*\)[egimosx]*z@(\\\\|\\@|[^@])*@[egimosx]*z%(\\\\|\\%|[^%])*%[egimosx]*z\$(\\\\|\\\$|[^$])*\$[egimosx]*z\s+zs\{(\\\\|\\\}|[^}])*\}\s*z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ÚFiler)  r   r   Ú
EnumerableÚFancyEnumerableÚBlockÚ	TrueClassÚNilClassÚ
FalseClassÚTuplerq   ÚStackÚSetÚ	FancySpecÚMethodÚPackageÚRangez\b)r”   z[a-zA-Z](\w|[-+?!=*/^><%])*:z[-+*/~,<>=&!?%^\[\].$]+z[A-Z]\w*z@[a-zA-Z_]\w*z@@[a-zA-Z_]\w*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*)([/?])?z([\d]+(?:_\d+)*)(\s*)([/?])?z/\d+([eE][+-]?[0-9]+)|\d+\.\d+([eE][+-]?[0-9]+)?z\d+)zbalanced-regexr  N)r8  r¸   r9  r:  r;  r)  r   r   r<  r=  r>  r?  r@  rA  rB  rq   rC  rD  rE  rF  rG  rH  )!r  r  r  r  ru   r  r  r  r   rT   r   r   rs   rq   r   r   r-  r   r
   r$  r.  r   r(  r*  r)  r   r   r%  r&  r'  rº   r¹   r/  rQ   rQ   rQ   rR   r   ´  sj   	













   

)r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   ) r  r  Zpygments.lexerr   r   r   r   r   r   r   r	   r
   Zpygments.tokenr   r   r   r   r   r   r   r   r   r   Zpygments.utilr   Ú__all__r7  rC   rr   r   r   r   rQ   rQ   rQ   rR   Ú<module>
   s   ,0

   i.