
-V[Tc           @   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-2014 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        r   B   s  e  Z d  Z d Z d d d g Z 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 e d d/ d0 e f d1 e e e e j  f d2 e e e  d3 f d4 e d3 f d5 e e e  d6 f e d d/ d0 e j f dI e j f e d d/ dZ e j f d[ e j f e d d d d/ d0 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 d3 6d e* d f d e d f d e j# d f e, d  g d6 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 j/ f d e j/ 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 6Z0 e0 j1 e    d   Z2 RS(   s=   
    For `Ruby <http://www.ruby-lang.org>`_ source code.
    t   Rubyt   rbt   rubyt   dubys   *.rbs   *.rbwt   Rakefiles   *.rakes	   *.gemspecs   *.rbxs   *.dubys   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   HeredocR   t   Constantt   __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(    (    s8   /usr/lib/python2.7/dist-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   R4   R3   R2   (   R;   R<   R=   t   nctxR?   R@   RA   (    (    s8   /usr/lib/python2.7/dist-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   R4   R3   R2   (   R;   R<   R=   RI   R?   R@   RA   (    (    s8   /usr/lib/python2.7/dist-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   {}RS   (   s   \[s   \]s   \[\]RT   (   s   \(s   \)s   ()RU   (   R!   R"   s   <>RV   (   R   t   SymbolR   t   RUBY_OPERATORSt   SingleR   R   t   Doublet   BacktickR   RK   R1   RH   R	   t   None(	   RJ   RL   t   statest   namet   ttypeR3   t   lbracet   rbracet   bracecc(    (    s8   /usr/lib/python2.7/dist-packages/pygments/lexers/ruby.pyt   gen_rubystrings_rulesY   sx    		"			""	"
s   #.*?$s   =begin\s.*?\n=end.*?$t   BEGINt   ENDt   aliast   begint   breakt   cases   defined?t   dot   elset   elsifR3   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   warnRM   s   (?<!\.)s   __(FILE|LINE)__\bs/   (?<!\w)(<<-?)(["`\']?)([a-zA-Z_]\w*)(\2)(.*?\n)s   (<<-?)("|\')()(\2)(.*?\n)t   __END__s   end-parts  (?:^|(?<=[=<>~!:])|(?<=(?:\s|;)when\s)|(?<=(?:\s|;)or\s)|(?<=(?:\s|;)and\s)|(?<=(?:\s|;|\.)index\s)|(?<=(?:\s|;|\.)scan\s)|(?<=(?:\s|;|\.)sub\s)|(?<=(?:\s|;|\.)sub!\s)|(?<=(?:\s|;|\.)gsub\s)|(?<=(?:\s|;|\.)gsub!\s)|(?<=(?:\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   ::RO   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   (   R7   (    (    s8   /usr/lib/python2.7/dist-packages/pygments/lexers/ruby.pyt   analyse_text  s    (   Re   Rf   s   aliasRh   Ri   Rj   s   defined?Rk   s   elseRm   s   endRn   Ro   Rp   s   ins   nextRs   Rt   Ru   Rv   Rw   s   superRy   Rz   R{   R|   R}   R~   R   (   R   s   newR   s   includes   extendRu   R   R   R   s   attrR   s   throwR   R   R   R   R   R   R   (   R   R   R   R   R   R   s   includeR   R   s   iteratorR   R   R   R   R   R   R   R   (e   R   s   Floats   Integers   StringR   R   s   abortR   R   R   R   R   R   R   R   R   R   R   R   s   const_defined?R   R   R   R   R   s   dups   evals   execs   exits   extendR   s   forks   formatR   R   R   R   R   s   hashs   idR   s   inspectR   R   R   R   R   R   R   s   loadR   R   R   R   R   R   s   nameR   s   openR   s   printR   R   R   R   R   R   R   R   R   R   R   R   Ru   R   s   readlines	   readlinesR   s   scanR   s   selfs   sendR   R   R   s   splitR   R   s   subR   s   systemR   R   s   throwR   R   R   R   R   R   s   warn(3   t   __name__t
   __module__t   __doc__R_   t   aliasest	   filenamest	   mimetypest   ret   DOTALLt	   MULTILINEt   flagsRG   Rd   R
   RZ   t	   MultilineR   R   R   R	   R   t	   Namespacet   PseudoR   t   Wordt   Builtint   PreprocR   RH   R   t   Octt   Hext   BinR   t   Variablet   Classt   Instancet   GlobalR   t   CharR-   RY   R   t   FunctionR   t   Interpolt   EscapeRK   t   tokenst   updateR  (    (    (    s8   /usr/lib/python2.7/dist-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   optionsR5   R6   R+   t
   _prompt_reR<   R]   R3   R1   R:   R   t   PromptR   R4   R*   t   Output(
   R;   R7   t   rblexert   curcodet
   insertionsR<   t   linet   mR3   t   item(    (    s8   /usr/lib/python2.7/dist-packages/pygments/lexers/ruby.pyR4     s,    		(
   R  R  R  R_   R  R  R	  t   compileR$  R4   (    (    (    s8   /usr/lib/python2.7/dist-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   TupleRX   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   (   R1  s   ArrayR2  R3  R4  s   Classs   Strings   NumberR5  R6  R7  R8  R9  R:  R;  s   SymbolR<  s   SetR>  R?  R@  RA  (    R  R  R  R_   R  R  R  R   RH   R	   R
   RZ   RX   R   R   R-   R   R   R  R  R   R  R  R  R   R   R  R  R  R   R   R  (    (    (    s8   /usr/lib/python2.7/dist-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__R-  R5   RY   R   R   R   (    (    (    s8   /usr/lib/python2.7/dist-packages/pygments/lexers/ruby.pyt   <module>
   s   @F'' g.