ó
·W[Tc           @   s9  d  Z  d d l Z d d l 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 d d l m Z d d d d	 d
 d g Z e j d ƒ Z d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d	 e f d „  ƒ  YZ d e f d „  ƒ  YZ d
 e f d „  ƒ  YZ d S(   sÉ   
    pygments.lexers.shell
    ~~~~~~~~~~~~~~~~~~~~~

    Lexers for various shells.

    :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS.
    :license: BSD, see LICENSE for details.
iÿÿÿÿN(   t   Lexert
   RegexLexert   do_insertionst   bygroupst   include(	   t   Punctuationt   Textt   Commentt   Operatort   Keywordt   Namet   Stringt   Numbert   Generic(   t   shebang_matchest	   BashLexert   BashSessionLexert	   TcshLexert
   BatchLexert   PowerShellLexert   ShellSessionLexers   .*?
c           B   s«  e  Z d  Z d Z d d d d g Z d d d d	 d
 d d d d d g
 Z d d g Z i	 e d ƒ d e j	 d f e d ƒ e d ƒ g d 6d e
 d f d e
 d f d e j d f d e j f g d 6d e e
 e ƒ f d  e j f d! e f d" e j f d# e e j e e ƒ f d$ e f d% e f d& e f d' e f g	 d 6d( 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 d0 e f d1 e f d2 e f d3 e f g d 6d) e j d4 f d5 e j f e d ƒ g d* 6d6 e j d4 f d7 e
 f d8 e j f d9 e f d: e f e d ƒ g d 6d; e
 d4 f e d ƒ g d 6d< e
 d4 f d= e f d> e f d? e f d@ e f e d ƒ g d 6d e j	 d4 f e d ƒ g d 6Z dA „  Z RS(B   sG   
    Lexer for (ba|k|)sh shell scripts.

    .. versionadded:: 0.6
    t   Basht   basht   sht   ksht   shells   *.shs   *.kshs   *.bashs   *.ebuilds   *.eclasss   .bashrct   bashrcs   .bash_*s   bash_*t   PKGBUILDs   application/x-shs   application/x-shellscriptt   basict   `t	   backtickst   datat   interpt   roots   \$\(\(t   maths   \$\(t   parens   \$\{#?t   curlys   \$#?(\w+|.)sa   \b(if|fi|else|while|do|done|for|then|return|function|case|select|continue|until|esac|elif)(\s*)\bsN  \b(alias|bg|bind|break|builtin|caller|cd|command|compgen|complete|declare|dirs|disown|echo|enable|eval|exec|exit|export|false|fc|fg|getopts|hash|help|history|jobs|kill|let|local|logout|popd|printf|pushd|pwd|read|readonly|set|shift|shopt|source|suspend|test|time|times|trap|true|type|typeset|ulimit|umask|unalias|unset|wait)\s*\b(?!\.)s   #.*\ns   \\[\w\W]s   (\b\w+)(\s*)(=)s   [\[\]{}()=]s   <<<s   <<-?\s*(\'?)\\?(\w+)[\w\W]+?\2s   &&|\|\|s%   (?s)\$?"(\\\\|\\[0-7]+|\\.|[^"\\$])*"t   "t   strings#   (?s)\$'(\\\\|\\[0-7]+|\\.|[^'\\])*'s	   (?s)'.*?'t   ;t   &s   \|s   \s+s   \d+(?= |\Z)s   [^=\s\[\]{}()$"\'`\\<&|;]+t   <s   #pops    (?s)(\\\\|\\[0-7]+|\\.|[^"\\$])+s   \}s   :-s   \w+s   [^}:"\'`$\\]+t   :s   \)s   \)\)s   [-+*/%^|&]|\*\*|\|\|s   \d+#\d+s	   \d+#(?! )s   \d+c         C   s*   t  |  d ƒ r d S|  j d ƒ r& d Sd  S(   Ns	   (ba|z|)shi   s   $ gš™™™™™É?(   R   t
   startswith(   t   text(    (    s9   /usr/lib/python2.7/dist-packages/pygments/lexers/shell.pyt   analyse_texts   s    (   t   __name__t
   __module__t   __doc__t   namet   aliasest	   filenamest	   mimetypesR   R   t   BacktickR	   t   InterpolR
   t   VariableR   R   t   BuiltinR   t   EscapeR   t   Doublet   SingleR   R   t   tokensR-   (    (    (    s9   /usr/lib/python2.7/dist-packages/pygments/lexers/shell.pyR      sr   																				c           B   s8   e  Z d  Z d Z d g Z d g Z d g Z d „  Z RS(   sI   
    Lexer for simplistic shell sessions.

    .. versionadded:: 1.1
    s   Bash Sessiont   consoles   *.sh-sessions   application/x-shell-sessionc         c   sÂ  t  |  j   } d } d } g  } xSt j | ƒ D]B} | j ƒ  } t j d | ƒ } | r· | sp | j ƒ  } n  | j t	 | ƒ d t
 j | j d ƒ f g f ƒ | | j d ƒ 7} q1 | j d ƒ r| j t	 | ƒ d t
 j | d  f g f ƒ | | d 7} q1 | rP| j | ƒ }	 x5 t | |	 ƒ D]! \ }
 } } | |
 | | f Vq(Wn  | j ƒ  t
 j | f Vg  } d } q1 W| r¾x> t | | j | ƒ ƒ D]! \ }
 } } | |
 | | f Vq–Wn  d  S(   Ni    t    sS   ^((?:\(\S+\))?(?:|sh\S*?|\w+\S+[@:]\S+(?:\s+\S+)?|\[\S+[@:][^\n]+\].+)[$#%])(.*\n?)i   i   t   >(   R   t   optionst   line_ret   finditert   groupt   ret   matcht   startt   appendt   lenR   t   PromptR+   t   get_tokens_unprocessedR   t   Output(   t   selfR,   t	   bashlexert   post   curcodet
   insertionsRE   t   linet   mt   tokst   it   tt   v(    (    s9   /usr/lib/python2.7/dist-packages/pygments/lexers/shell.pyRJ   †   s:    		"
	(   R.   R/   R0   R1   R2   R3   R4   RJ   (    (    (    s9   /usr/lib/python2.7/dist-packages/pygments/lexers/shell.pyR   z   s   			c           B   s8   e  Z d  Z d Z d g Z d g Z d g Z d „  Z RS(   sg   
    Lexer for shell sessions that works with different command prompts

    .. versionadded:: 1.6
    s   Shell Sessions   shell-sessions   *.shell-sessions   application/x-sh-sessionc         c   sv  t  |  j   } d } d } g  } xt j | ƒ D]ö } | j ƒ  } t j d | ƒ } | r· | sp | j ƒ  } n  | j t	 | ƒ d t
 j | j d ƒ f g f ƒ | | j d ƒ 7} q1 | r| j | ƒ }	 x5 t | |	 ƒ D]! \ }
 } } | |
 | | f VqÜ Wn  | j ƒ  t
 j | f Vg  } d } q1 W| rrx> t | | j | ƒ ƒ D]! \ }
 } } | |
 | | f VqJWn  d  S(   Ni    R>   s'   ^((?:\[?\S+@[^$#%]+\]?\s*)[$#%])(.*\n?)i   i   (   R   R@   RA   RB   RC   RD   RE   RF   RG   RH   R   RI   RJ   R   RK   (   RL   R,   RM   RN   RO   RP   RE   RQ   RR   RS   RT   RU   RV   (    (    s9   /usr/lib/python2.7/dist-packages/pygments/lexers/shell.pyRJ   ¹   s0    "
	(   R.   R/   R0   R1   R2   R3   R4   RJ   (    (    (    s9   /usr/lib/python2.7/dist-packages/pygments/lexers/shell.pyR   ­   s   			c           B   s¶  e  Z d  Z d Z d d d d g Z d d g Z d g Z e j e j	 BZ
 i d	 e f d
 e e e ƒ f d e j f d e j f d e j f d e f d e e e e j ƒ f d e e e e j ƒ f d e e e e j ƒ f d e f d e f e d ƒ d e f g d 6d e j f d e d f e d ƒ d e f g d 6d e j f d e j f d e j f d e f d e f d e f d  e f d! e j f d" e f d# e e e e ƒ f g
 d 6Z RS($   sQ   
    Lexer for the DOS/Windows Batch file format.

    .. versionadded:: 0.7
    t	   Batchfilet   batt   batcht   dosbatcht   winbatchs   *.bats   *.cmds   application/x-dos-batchs   ^\s*@s   ^(\s*)(rem\s.*)$s   ".*?"s   '.*?'s   %%?[~$:\w]+%?s   ::.*s   \b(set)(\s+)(\w+)s   \b(call)(\s+)(:\w+)s   \b(goto)(\s+)(\w+)s›   \b(set|call|echo|on|off|endlocal|for|do|goto|if|pause|setlocal|shift|errorlevel|exist|defined|cmdextversion|errorlevel|else|cd|md|del|deltree|cls|choice)\bs   \b(equ|neq|lss|leq|gtr|geq)\bR   t   .R!   s   \^\^|\^<|\^>|\^\|s   \ns   #pops   [^\'"^]+t   echos   `.*?`s   -?\d+t   ,t   =s   /\S+s   :\w+s   \w:\w+s   ([<>|])(\s*)(\w+)(   R.   R/   R0   R1   R2   R3   R4   RD   t	   MULTILINEt
   IGNORECASEt   flagsR   R   R   R   R   R:   R;   R
   R7   R	   t   LabelR   R   R9   R5   R   R<   (    (    (    s9   /usr/lib/python2.7/dist-packages/pygments/lexers/shell.pyR   Û   sF   											c        
   B   s£  e  Z d  Z d Z d d g Z d d g Z d g Z i e d ƒ d e d	 f d
 e d f d e	 j
 d f e d ƒ g d 6d e f d e j f d e f d e	 j f d e e j e e ƒ f d e f d e	 f d e f g d 6d e	 j f d e	 j f d e f d e f d e f d e j f g d 6d e d f d  e f d! e j f d" e f d# e f e d ƒ g d 6d$ e d f e d ƒ g d	 6d e	 j
 d f e d ƒ g d 6Z RS(%   s=   
    Lexer for tcsh scripts.

    .. versionadded:: 0.10
    t   Tcsht   tcsht   cshs   *.tcshs   *.cshs   application/x-cshR   s   \$\(R#   s   \$\{#?R$   R   R   R   R!   s]   \b(if|endif|else|while|then|foreach|case|default|continue|goto|breaksw|end|switch|endsw)\s*\bsù  \b(alias|alloc|bg|bindkey|break|builtins|bye|caller|cd|chdir|complete|dirs|echo|echotc|eval|exec|exit|fg|filetest|getxvers|glob|getspath|hashstat|history|hup|inlib|jobs|kill|limit|log|login|logout|ls-F|migrate|newgrp|nice|nohup|notify|onintr|popd|printenv|pushd|rehash|repeat|rootnode|popd|pushd|set|shift|sched|setenv|setpath|settc|setty|setxvers|shift|source|stop|suspend|source|suspend|telltc|time|umask|unalias|uncomplete|unhash|universe|unlimit|unset|unsetenv|ver|wait|warp|watchlog|where|which)\s*\bs   #.*s   \\[\w\W]s   (\b\w+)(\s*)(=)s   [\[\]{}()=]+s   <<\s*(\'?)\\?(\w+)[\w\W]+?\2R'   s!   (?s)"(\\\\|\\[0-7]+|\\.|[^"\\])*"s!   (?s)'(\\\\|\\[0-7]+|\\.|[^'\\])*'s   \s+s   [^=\s\[\]{}()$"\'`\\;#]+s   \d+(?= |\Z)s   \$#?(\w+|.)s   \}s   #pops   :-s   \w+s   [^}:"\'`$]+R*   s   \)(   R.   R/   R0   R1   R2   R3   R4   R   R	   R   R5   R
   R8   R   R9   R   R7   R   R   R   R:   R;   R   R<   (    (    (    s9   /usr/lib/python2.7/dist-packages/pygments/lexers/shell.pyR     sJ   													c           B   s‡  e  Z d  Z d Z d d d d g Z d d g Z d g Z e j e j	 Be j
 BZ d	 j ƒ  Z d
 j ƒ  Z d j ƒ  Z d j ƒ  Z i d e d f d e f d d j e ƒ e e e j e ƒ f d e f d e j d f d e j d f d e j f d e f d e j d f d e j f d e j f d d j e ƒ e f d d j e ƒ e f d d j e ƒ e j  f d  e j! f d! e f d" e f d# e f g d$ 6d% e d& f e" d$ ƒ g d 6d' e j f d( e j d& f d) d j e ƒ e j f d* e j f g d 6d+ e j# f d, e j f d- e d f d. e j f d/ e j f d e j d& f g d 6d0 e j d& f d- e d f d1 e j f d2 e j f g d 6Z$ RS(3   sA   
    For Windows PowerShell code.

    .. versionadded:: 1.5
    t
   PowerShellt
   powershellt   posht   ps1t   psm1s   *.ps1s   *.psm1s   text/x-powershells·  while validateset validaterange validatepattern validatelength validatecount until trap switch return ref process param parameter in if global: function foreach for finally filter end elseif else dynamicparam do default continue cmdletbinding break begin alias \? % #script #private #local #global mandatory parametersetname position valuefrompipeline valuefrompipelinebypropertyname valuefromremainingarguments helpmessage try catch throwsN  and as band bnot bor bxor casesensitive ccontains ceq cge cgt cle clike clt cmatch cne cnotcontains cnotlike cnotmatch contains creplace eq exact f file ge gt icontains ieq ige igt ile ilike ilt imatch ine inotcontains inotlike inotmatch ireplace is isnot le like lt match ne not notcontains notlike notmatch or regex replace wildcards½  write where wait use update unregister undo trace test tee take suspend stop start split sort skip show set send select scroll resume restore restart resolve resize reset rename remove register receive read push pop ping out new move measure limit join invoke import group get format foreach export expand exit enter enable disconnect disable debug cxnew copy convertto convertfrom convert connect complete compare clear checkpoint aggregate adds§   component description example externalhelp forwardhelpcategory forwardhelptargetname functionality inputs link notes outputs parameter remotehelprunspace role synopsiss   \(t   childs   \s+s    ^(\s*#[#\s]*)(\.(?:%s))([^\n]*$)t   |s	   #[^\n]*?$s	   (&lt;|<)#t   multlines   @"\ns   heredoc-doubles   @'\n.*?\n'@s	   `[\'"$@-]R%   R&   s   '([^']|'')*'s+   (\$|@@|@)((global|script|private|env):)?\w+s   (%s)\bs   -(%s)\bs   (%s)-[a-z_]\w*\bs   \[[a-z_\[][\w. `,\[\]]*\]s
   -[a-z_]\w*s   \w+s#   [.,;@{}\[\]$()=+*/\\&%!~?^`|<>-]|::R!   s   \)s   #pops   [^#&.]+s	   #(>|&gt;)s   \.(%s)s   [#&.]s   `[0abfnrtv'\"$`]s   [^$`"]+s   \$\(s   ""s   [`$]s   \n"@s	   [^@\n]+"]R\   (%   R.   R/   R0   R1   R2   R3   R4   RD   t   DOTALLRa   R`   Rb   t   splitt   keywordst	   operatorst   verbst   commenthelpR   R   t   joinR   R   R   t   Doct	   Multilinet   HeredocR:   R;   R
   R7   R	   R   R8   t   ConstantR   R9   R<   (    (    (    s9   /usr/lib/python2.7/dist-packages/pygments/lexers/shell.pyR   W  s^   									(   R0   RD   t   pygments.lexerR    R   R   R   R   t   pygments.tokenR   R   R   R   R	   R
   R   R   R   t   pygments.utilR   t   __all__t   compileRA   R   R   R   R   R   R   (    (    (    s9   /usr/lib/python2.7/dist-packages/pygments/lexers/shell.pyt   <module>
   s   (@`3.8D