ó
i4Vdc           @  s   d  Z  d d l m Z d d l Z d e f d     YZ d d d  Z d e f d	     YZ d
 e f d     YZ d   Z	 d S(   u   JsLex: a lexer for Javascripti’’’’(   t   unicode_literalsNt   Tokc           B  s    e  Z d  Z d Z d d  Z RS(   u,   
    A specification for a token class.
    i    c         C  s:   t  j |  _ t  j d 7_ | |  _ | |  _ | |  _ d  S(   Ni   (   R   t   numt   idt   namet   regext   next(   t   selfR   R   R   (    (    s`   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/utils/jslex.pyt   __init__   s
    		N(   t   __name__t
   __module__t   __doc__R   t   NoneR   (    (    (    s`   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/utils/jslex.pyR      s   u    c           s&   d j     f d   |  j   D  S(   u¤   
    Create a regex from a space-separated list of literal `choices`.

    If provided, `prefix` and `suffix` will be attached to each choice
    individually.
    u   |c         3  s&   |  ] }   t  j |   Vq d  S(   N(   t   ret   escape(   t   .0t   c(   t   prefixt   suffix(    s`   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/utils/jslex.pys	   <genexpr>   s    (   t   joint   split(   t   choicesR   R   (    (   R   R   s`   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/utils/jslex.pyt   literals   s    t   Lexerc           B  s    e  Z d  Z d   Z d   Z RS(   u2   
    A generic multi-state regex-based lexer.
    c         C  s³   i  |  _  i  |  _ x | j   D] \ } } g  } xB | D]: } d | j } | |  j | <| j d | | j f  q8 Wt j d j |  t j	 t j
 B |  j  | <q W| |  _ d  S(   Nu   t%du
   (?P<%s>%s)u   |(   t   regexest   tokst   itemsR   t   appendR   R   t   compileR   t	   MULTILINEt   VERBOSEt   state(   R   t   statest   firstR   t   rulest   partst   tokt   groupid(    (    s`   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/utils/jslex.pyR   %   s    		0c         c  sÄ   t  |  } |  j } |  j } |  j } d } x | | k  r¶ xt | | j | |  D]\ } | j } | | }	 | j |  }
 | t  |
  7} |	 j |
 f V|	 j rS |	 j } PqS qS Wq0 W| |  _ d S(   uX   
        Lexically analyze `text`.

        Yields pairs (`name`, `tokentext`).
        i    N(	   t   lenR   R   R   t   finditert	   lastgroupt   groupR   R   (   R   t   textt   endR   R   R   t   startt   matchR   R$   t   toktext(    (    s`   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/utils/jslex.pyt   lex3   s     				
		(   R	   R
   R   R   R/   (    (    (    s`   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/utils/jslex.pyR       s   	t   JsLexerc           B  s  e  Z d  Z e d d  e d d  e d d  e d e d d	 d
 d d e d e d d	 d
 d d e d d d d e d d d d e d d  e d d d d e d e d  d d e d e d  d d e d e d  d d e d d d d e d d d d g Z e d d   g Z i e e d e d!  d d g e d 6e e d" d# d d g e d 6Z d$   Z RS(%   uō   
    A Javascript lexer

    >>> lexer = JsLexer()
    >>> list(lexer.lex("a = 1"))
    [('id', 'a'), ('ws', ' '), ('punct', '='), ('ws', ' '), ('dnum', '1')]

    This doesn't properly handle non-ASCII characters in the Javascript source.
    u   commentu   /\*(.|\n)*?\*/u   linecommentu   //.*?$u   wsu   \s+u   keywordul  
                           break case catch class const continue debugger
                           default delete do else enum export extends
                           finally for function if import in instanceof
                           new return super switch this throw try typeof
                           var void while with
                           R   u   \bR   u   regu   reservedu   null true falseu   divu   idu   
                  ([a-zA-Z_$   ]|\\u[0-9a-fA-Z]{4})   # first char
                  ([a-zA-Z_$0-9]|\\u[0-9a-fA-F]{4})*  # rest chars
                  u   hnumu   0[xX][0-9a-fA-F]+u   onumu   0[0-7]+u   dnumu|  
                    (   (0|[1-9][0-9]*)     # DecimalIntegerLiteral
                        \.                  # dot
                        [0-9]*              # DecimalDigits-opt
                        ([eE][-+]?[0-9]+)?  # ExponentPart-opt
                    |
                        \.                  # dot
                        [0-9]+              # DecimalDigits
                        ([eE][-+]?[0-9]+)?  # ExponentPart-opt
                    |
                        (0|[1-9][0-9]*)     # DecimalIntegerLiteral
                        ([eE][-+]?[0-9]+)?  # ExponentPart-opt
                    )
                    u   punctu   
                         >>>= === !== >>> <<= >>= <= >= == != << >> &&
                         || += -= *= %= &= |= ^=
                         u	   ++ -- ) ]u)   { } ( [ . ; , < > + - * % & | ^ ! ~ ? : =u   stringu   "([^"\\]|(\\(.|\n)))*?"u   '([^'\\]|(\\(.|\n)))*?'u   otheru   .u   /= /u   regexuė  
                    /                       # opening slash
                    # First character is..
                    (   [^*\\/[]            # anything but * \ / or [
                    |   \\.                 # or an escape sequence
                    |   \[                  # or a class, which has
                            (   [^\]\\]     #   anything but \ or ]
                            |   \\.         #   or an escape sequence
                            )*              #   many times
                        \]
                    )
                    # Following characters are same, except for excluding a star
                    (   [^\\/[]             # anything but \ / or [
                    |   \\.                 # or an escape sequence
                    |   \[                  # or a class, which has
                            (   [^\]\\]     #   anything but \ or ]
                            |   \\.         #   or an escape sequence
                            )*              #   many times
                        \]
                    )*                      # many times
                    /                       # closing slash
                    [a-zA-Z0-9]*            # trailing flags
                c         C  s    t  t |   j |  j d  d  S(   Nu   reg(   t   superR0   R   R    (   R   (    (    s`   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/utils/jslex.pyR   ·   s    (	   R	   R
   R   R   R   t   both_beforet
   both_afterR    R   (    (    (    s`   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/utils/jslex.pyR0   N   s0   			'$c         C  sÓ   d   } t    } g  } x« | j |   D] \ } } | d k rI d } nl | d k r | j d  rµ t j d | | d d ! } d	 | d	 } qµ n! | d
 k rµ | j d d  } n  | j |  q( Wd j |  S(   u³   
    Convert the Javascript source `js` into something resembling C for
    xgettext.

    What actually happens is that all the regex literals are replaced with
    "REGEX".
    c         S  s'   |  j  d  } | d k r d S| Sd S(   u1   Used in a regex to properly escape double quotes.i    u   "u   \"N(   R)   (   t   mt   s(    (    s`   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/utils/jslex.pyt   escape_quotesĆ   s    u   regexu   "REGEX"u   stringu   'u   \\.|.i   i’’’’u   "u   idu   \u   Uu    (   R0   R/   t
   startswithR   t   subt   replaceR   R   (   t   jsR6   t   lexerR   R   R$   t   guts(    (    s`   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/utils/jslex.pyt   prepare_js_for_gettext»   s    			(
   R   t
   __future__R    R   t   objectR   R   R   R0   R=   (    (    (    s`   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/utils/jslex.pyt   <module>   s   
.m