
xi\c           @   sZ  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
 d d d d d d d d d d d d d d d d d d d d d d  d! f Z d e f d"     YZ d e f d#     YZ d e f d$     YZ d S(%   s   
    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.
iN(	   t   Lexert
   RegexLexert   ExtendedRegexLexert   includet   bygroupst   defaultt   LexerContextt   do_insertionst   words(
   t   Textt   Commentt   Operatort   Keywordt   Namet   Stringt   Numbert   Punctuationt   Errort   Generic(   t   shebang_matchest	   RubyLexert   RubyConsoleLexert
   FancyLexers   .*?
t   *s   **t   -t   +s   -@s   +@t   /t   %t   &t   |t   ^t   `t   ~s   []s   []=s   <<s   >>t   <s   <>s   <=>t   >s   >=s   ==s   ===c        s   B   s  e  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	 BZ
 d   Z d   Z i d e j f d e j f d e j f e d d1 d2 e f d3 e e e e j  f d4 e e e  d5 f d6 e d5 f d7 e e e  d8 f e d d1 d2 e j f dK e j f e d d1 d\ e j f d] e j f e d d d d1 d2 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 6d e+ d f d e e j$ e e j,  d f e- d  g d5 6d e+ d f d e d f d e j$ d f e- d  g d8 6d e e+ e  d f d e d f e' d  g d 6d e j. d f d e j. d f e' d  g d 6d e j. d f d e j. f d e j. f g d 6e' d  d e j/ f g d 6e' d  d e j f d e j f g d 6e' d  d e j0 f d e j0 f g d 6e' d  d e j f d e j f d e j f d e j f d e j d f g d 6d e j d f g d 6Z1 e1 j2 e    d   Z3 RS(   s=   
    For `Ruby <http://www.ruby-lang.org>`_ source code.
    t   Rubyt   rbt   rubyt   dubys   *.rbs   *.rbwt   Rakefiles   *.rakes	   *.gemspecs   *.rbxs   *.dubyt   Gemfiles   text/x-rubys   application/x-rubyc         c   su  | 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  | _ x1 |  j d |  D] \ } } } | | | f VqW| j   | _
 | rq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qW| j    t j | j   f V| j   | _
 Pq{| j	 |  q{Wx( | D]  } | j    t | j   f Vq0WqPWt | j  | _ | 2n  d  S(	   Ni   i   i   i   t   heredocstacks   <<-i   t   context(   t   startR   t   groupR   t   Heredoct	   Delimitert   __dict__t
   setdefaultt   boolt   appendt   post   endt   get_tokens_unprocessedt   line_ret   finditert   textt   stript   rstripR   t   len(   t   selft   matcht   ctxR+   R)   t	   outermostt   it   tt   vt   tolerantt   hdnamet   linest   checkt   amatch(    (    s3   lib/python2.7/site-packages/pygments/lexers/ruby.pyt   heredoc_callback,   s>    ###+"!"c    	      C   sq  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 <x} d t  j d f d t  j d f d t  j d f f D]H \ } } } t	 d  d | | f d | f | | d f g | d | <q Wxd= d> d? d@ f D]\ } } } } d) | d* t  j
 f | t  j
 d+ f | t  j
 d f t	 d  d, | d* t  j
 f d- | d. t  j
 f g | | d/ <| d j d0 | t  j
 | d/ f  d) | d* t  j
 f | t  j
 d+ f | t  j
 d f d, | d* t  j
 f d- | d. t  j
 f g | | d1 <| d j d2 | t  j
 | d1 f  d) | d* t  j f | t  j d+ f | d3 t  j d f t	 d4  d, | d* t  j f d- | d. t  j f g | | d5 <| d j d6 | t  j | d5 f  q3W| d c d7 |  f d8 t  j
 f d9 | f d: t t t  j
 d   f d; t t t  j
 d   f d< | f g 7<| S(A   Nc         s   s   | j  d  t j | j d  f Vt | j d  d d g  } x> |  j d |  D]* \ } } } | j  d  | | | f VqT W| j  d  t j | j d  f V| j   | _ d  S(   Ni   i   i    s   interpolated-regexR*   i   (   R+   R   t   RegexR,   R   R5   R4   R3   (   R<   R=   R>   t   nctxR@   RA   RB   (    (    s3   lib/python2.7/site-packages/pygments/lexers/ruby.pyt   intp_regex_callbackZ   s    #"#c         s   s   | j  d  t j | j d  f Vt | j d  d d g  } x> |  j d |  D]* \ } } } | j  d  | | | f VqT W| j  d  t j | j d  f V| j   | _ d  S(   Ni   i   i    s   interpolated-stringR*   i   (   R+   R   t   OtherR,   R   R5   R4   R3   (   R<   R=   R>   RJ   R@   RA   RB   (    (    s3   lib/python2.7/site-packages/pygments/lexers/ruby.pyt   intp_string_callbackb   s    #"#s   \:@{0,2}[a-zA-Z_]\w*[!?]?t   prefixs   \:@{0,2}s   :'(\\\\|\\'|[^'])*'s   '(\\\\|\\'|[^'])*'s   :"s
   simple-syms   ([a-zA-Z_]\w*)(:)(?!:)t   "s   simple-strings   (?<!\.)`s   simple-backtickt   stringst   stringt   symt   backtickR   s   string-intp-escapeds	   [^\\%s#]+s   [\\#]s   #pops   simple-s   \{s   \}s   {}t   cbs   \[s   \]s   \[\]t   sbs   \(s   \)s   ()t   paR!   R"   s   <>t   abs   \\[\\t   ]s   #pushs   [\\#s   [^\\#s   ]+s   -intp-strings   %[QWx]?s   -strings   %[qsw]s   [mixounse]*s   string-intps   -regexs   %rs-   (%r([\W_]))((?:\\\2|(?!\2).)*)(\2[mixounse]*)s"   %[qsw]([\W_])((?:\\\1|(?!\1).)*)\1s&   (%[QWx]([\W_]))((?:\\\2|(?!\2).)*)(\2)s<   (?<=[-+/*%=<>&!^|~,(])(\s*)(%([\t ])(?:(?:\\\3|(?!\3).)*)\3)s'   ^(\s*)(%([\t ])(?:(?:\\\3|(?!\3).)*)\3)s*   (%([^a-zA-Z0-9\s]))((?:\\\2|(?!\2).)*)(\2)(   s   \{s   \}s   {}RT   (   s   \[s   \]s   \[\]RU   (   s   \(s   \)s   ()RV   (   R!   R"   s   <>RW   (   R   t   SymbolR   t   RUBY_OPERATORSt   SingleR   R   t   Doublet   BacktickR   RL   R2   RI   R	   t   None(	   RK   RM   t   statest   namet   ttypeR4   t   lbracet   rbracet   bracecc(    (    s3   lib/python2.7/site-packages/pygments/lexers/ruby.pyt   gen_rubystrings_rulesY   sx    		"			""	"
s   \A#!.+?$s   #.*?$s   =begin\s.*?\n=end.*?$t   BEGINt   ENDt   aliast   begint   breakt   cases   defined?t   dot   elset   elsifR4   t   ensuret   fort   ift   int   nextt   redot   rescuet   raiset   retryt   returnt   supert   thent   undeft   unlesst   untilt   whent   whilet   yieldt   suffixs   \bs.   (module)(\s+)([a-zA-Z_]\w*(?:::[a-zA-Z_]\w*)*)s
   (def)(\s+)t   funcnames   def(?=[*%&^`~+-/\[<>=])s   (class)(\s+)t	   classnamet
   initializet   newt   loopR   t   extendt   attr_readert   attr_writert   attr_accessort   attrt   catcht   throwt   privatet   module_functiont   publict	   protectedt   truet   falset   nils   (not|and|or)\bt   autoloadt   block_givent   const_definedt   eqlt   equalt   frozent   instance_oft   is_at   iteratort   kind_oft   method_definedt   private_method_definedt   protected_method_definedt   public_method_definedt
   respond_tot   tainteds   \?s   (chomp|chop|exit|gsub|sub)!t   Arrayt   Floatt   IntegerR   t   __id__t   __send__t   abortt	   ancestorst   at_exitt   bindingt   callcct   callert   chompt   chopt
   class_evalt   class_variablest   clones   const_defined?t	   const_gett   const_missingt	   const_sett	   constantst   displayt   dupt   evalt   exect   exitt   failt   forkt   formatt   freezet   getct   getst   global_variablest   gsubt   hasht   idt   included_modulest   inspectt   instance_evalt   instance_methodt   instance_methodst   instance_variable_gett   instance_variable_sett   instance_variablest   lambdat   loadt   local_variablest   methodt   method_missingt   methodst   module_evalR`   t	   object_idt   opent   pt   printt   printft   private_class_methodt   private_instance_methodst   private_methodst   proct   protected_instance_methodst   protected_methodst   public_class_methodt   public_instance_methodst   public_methodst   putct   putst   randt   readlinet	   readlinest   requiret   scant   selectR<   t   sendt   set_trace_funct   singleton_methodst   sleept   splitt   sprintft   srandt   subt   syscallt   systemt   taintt   testt   to_at   to_st	   trace_vart   trapt   untaintt   untrace_vart   warnRN   s   (?<!\.)s   __(FILE|LINE)__\bs/   (?<!\w)(<<-?)(["`\']?)([a-zA-Z_]\w*)(\2)(.*?\n)s   (<<-?)("|\')()(\2)(.*?\n)t   __END__s   end-partsb  (?:^|(?<=[=<>~!:])|(?<=(?:\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*)(/)s   multiline-regexs   (?<=\(|,|\[)/s   (\s+)(/)(?![\s=])s#   (0_?[0-7]+(?:_[0-7]+)*)(\s*)([/?])?s.   (0x[0-9A-Fa-f]+(?:_[0-9A-Fa-f]+)*)(\s*)([/?])?s    (0b[01]+(?:_[01]+)*)(\s*)([/?])?s   ([\d]+(?:_\d+)*)(\s*)([/?])?s   @@[a-zA-Z_]\w*s   @[a-zA-Z_]\w*s   \$\w+s   \$[!@&`\'+~=/\\,;.<>_*$?:"^-]s   \$-[0adFiIlpvw]s   ::RP   sI   \?(\\[MC]-)*(\\([\\abefnrstv#"\']|x[a-fA-F0-9]{1,2}|[0-7]{1,3})|\S)(?!\w)s   [A-Z]\w+s   (\.|::)s,   (\.|::)([a-zA-Z_]\w*[!?]?|[*%&^`~+\-/\[<>=])s   [a-zA-Z_]\w*[!?]?s:   (\[|\]|\*\*|<<?|>>?|>=|<=|<=>|=~|={3}|!~|&&?|\|\||\.{1,3})s   [-+/*%=<>&!^|~]=?s   [(){};,/?:\\]s   \s+t   roots   \(t   defexprs\   (?:([a-zA-Z_]\w*)(\.))?([a-zA-Z_]\w*[!?]?|\*\*?|[-+]@?|[/%&|^`~]|\[\]=?|<<|>>|<=?>|>=?|===?)s   #pops   <<s	   [A-Z_]\w*s   (\))(\.|::)?s   #pushs   \{s   \}s   in-intps   #\{s   #@@?[a-zA-Z_]\w*s   #\$[a-zA-Z_]\w*s   string-intps2   \\([\\abefnrstv#"\']|x[a-fA-F0-9]{1,2}|[0-7]{1,3})s   string-intp-escapeds   [\\#]s   [^\\#]+s   interpolated-regexs   interpolated-strings   \\\\s   \\/s   [^\\/#]+s   /[mixounse]*s   .+c         C   s   t  |  d  S(   Ns   ruby(1\.\d)?(   R   (   R8   (    (    s3   lib/python2.7/site-packages/pygments/lexers/ruby.pyt   analyse_text  s    (   Rf   Rg   Rh   Ri   Rj   Rk   s   defined?Rl   Rm   Rn   R4   Ro   Rp   Rq   Rr   Rs   Rt   Ru   Rv   Rw   Rx   Ry   Rz   R{   R|   R}   R~   R   R   (   R   R   R   R   R   Rv   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   (e   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   s   const_defined?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   Rv   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   (4   t   __name__t
   __module__t   __doc__R`   t   aliasest	   filenamest	   mimetypest   ret   DOTALLt	   MULTILINEt   flagsRH   Re   R
   t   HashbangR[   t	   MultilineR   R   R   R	   R   t	   Namespacet   PseudoR   t   Wordt   Builtint   PreprocR   RI   R   t   Octt   Hext   BinR   t   Variablet   Classt   Instancet   GlobalR   t   Chart   ConstantRZ   R   t   FunctionR   t   Interpolt   EscapeRL   t   tokenst   updateR  (    (    (    s3   lib/python2.7/site-packages/pygments/lexers/ruby.pyR      s  	-	f     	   	                    													c           B   sA   e  Z d  Z d Z d d g Z d g Z e j d  Z d   Z	 RS(   s   
    For Ruby interactive console (**irb**) output like:

    .. sourcecode:: rbcon

        irb(main):001:0> a = 1
        => 1
        irb(main):002:0> puts a
        1
        => nil
    s   Ruby irb sessiont   rbcont   irbs   text/x-ruby-shellsessions.   irb\([a-zA-Z_]\w*\):\d{3}:\d+[>*"\'] |>> |\?> c   
      c   s1  t  |  j   } d } g  } x t j |  D] } | j   } |  j j |  } | d  k	 r | j   } | j	 t
 |  d t j | |  f g f  | | | 7} q+ | r x% t | | j |   D] }	 |	 Vq Wd } g  } n  | j   t j | f Vq+ W| r-x( t | | j |   D] }	 |	 VqWn  d  S(   Nt    i    (   R   t   optionsR6   R7   R,   t
   _prompt_reR=   R^   R4   R2   R;   R   t   PromptR   R5   R+   t   Output(
   R<   R8   t   rblexert   curcodet
   insertionsR=   t   linet   mR4   t   item(    (    s3   lib/python2.7/site-packages/pygments/lexers/ruby.pyR5     s,    		(
   R  R  R  R`   R  R	  R
  t   compileR'  R5   (    (    (    s3   lib/python2.7/site-packages/pygments/lexers/ruby.pyR     s   	c        &   B   sh  e  Z d  Z d Z d d g Z d d g Z d g Z i 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 6d 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 dG d7 d8 e j f d9 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 d@ e e j e	 e  f dA e e j e	 e  f dB e e j e	 e  f dC e e j e	 e  f dD e j f dE e j f g dF 6Z RS(H   s  
    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
    t   Fancys   *.fys   *.fancypackt   fancyt   fys   text/x-fancysrcs   /(\\\\|\\/|[^/])*/[egimosx]*s   #pops   !(\\\\|\\!|[^!])*![egimosx]*s   \\(\\\\|[^\\])*\\[egimosx]*s   \{(\\\\|\\\}|[^}])*\}[egimosx]*s   <(\\\\|\\>|[^>])*>[egimosx]*s    \[(\\\\|\\\]|[^\]])*\][egimosx]*s   \((\\\\|\\\)|[^)])*\)[egimosx]*s   @(\\\\|\\@|[^@])*@[egimosx]*s   %(\\\\|\\%|[^%])*%[egimosx]*s   \$(\\\\|\\\$|[^$])*\$[egimosx]*s   balanced-regexs   \s+s   s\{(\\\\|\\\}|[^}])*\}\s*s   s<(\\\\|\\>|[^>])*>\s*s   s\[(\\\\|\\\]|[^\]])*\]\s*s   s\((\\\\|\\\)|[^)])*\)\s*s    m?/(\\\\|\\/|[^/\n])*/[gcimosx]*s   m(?=[/!\\{<\[(@%$])s   #(.*?)\ns   \'([^\'\s\[\](){}]+|\[\])s   """(\\\\|\\"|[^"])*"""s   "(\\\\|\\"|[^"])*"sJ   (def|class|try|catch|finally|retry|return|return_local|match|case|->|=>)\bs   (self|super|nil|false|true)\bs   [(){};,/?|:\\]t   ObjectR   t   Hasht	   Directoryt   FileR  R   R   t
   Enumerablet   FancyEnumerablet   Blockt	   TrueClasst   NilClasst
   FalseClasst   TupleRY   t   Stackt   Sett	   FancySpect   Methodt   Packaget   RangeR   s   \bs   [a-zA-Z](\w|[-+?!=*/^><%])*:s   [-+*/~,<>=&!?%^\[\].$]+s   [A-Z]\w*s   @[a-zA-Z_]\w*s   @@[a-zA-Z_]\w*s   @@?s   [a-zA-Z_]\w*s&   (0[oO]?[0-7]+(?:_[0-7]+)*)(\s*)([/?])?s1   (0[xX][0-9A-Fa-f]+(?:_[0-9A-Fa-f]+)*)(\s*)([/?])?s#   (0[bB][01]+(?:_[01]+)*)(\s*)([/?])?s   ([\d]+(?:_\d+)*)(\s*)([/?])?s/   \d+([eE][+-]?[0-9]+)|\d+\.\d+([eE][+-]?[0-9]+)?s   \d+R  (   R4  R   R5  R6  R7  R  R   R   R8  R9  R:  R;  R<  R=  R>  RY   R?  R@  RA  RB  RC  RD  (    R  R  R  R`   R  R  R	  R   RI   R	   R
   R[   RY   R   R   R  R   R   R  R  R   R  R  R  R   R   R  R  R  R   R   R!  (    (    (    s3   lib/python2.7/site-packages/pygments/lexers/ruby.pyR     sl   						   				(    R  R
  t   pygments.lexerR    R   R   R   R   R   R   R   R   t   pygments.tokenR	   R
   R   R   R   R   R   R   R   R   t   pygments.utilR   t   __all__R0  R6   RZ   R   R   R   (    (    (    s3   lib/python2.7/site-packages/pygments/lexers/ruby.pyt   <module>
   s   @F'' h.