
    hq                     ^    S r SSKr " S S5      rSS jr " S S5      r " S S	\5      rS
 rg)zJsLex: a lexer for JavaScript    Nc                   &    \ rS rSrSrSrSS jrSrg)Tok   z$
A specification for a token class.
r   Nc                     [         R                  U l        [         =R                  S-  sl        Xl        X l        X0l        g )N   )r   numidnameregexnext)selfr
   r   r   s       D/var/www/html/env/lib/python3.13/site-packages/django/utils/jslex.py__init__Tok.__init__   s)    ''1	
	    )r	   r
   r   r   N)__name__
__module____qualname____firstlineno____doc__r   r   __static_attributes__ r   r   r   r      s     Cr   r   c                 Z   ^^ SR                  UU4S jU R                  5        5       5      $ )z
Create a regex from a space-separated list of literal `choices`.

If provided, `prefix` and `suffix` will be attached to each choice
individually.
|c              3   \   >#    U  H!  nT[         R                  " U5      -   T-   v   M#     g 7fr   )reescape).0cprefixsuffixs     r   	<genexpr>literals.<locals>.<genexpr>   s#     LOqFRYYq\)F2Os   ),)joinsplit)choicesr!   r"   s    ``r   literalsr(      s      88LGMMOLLLr   c                   $    \ rS rSrSrS rS rSrg)Lexer    z*
A generic multi-state regex-based lexer.
c           	         0 U l         0 U l        UR                  5        H  u  p4/ nU HD  nSUR                  -  nX`R                  U'   UR	                  SU< SUR
                  < S35        MF     [        R                  " SR                  U5      [        R                  [        R                  -  5      U R                   U'   M     X l        g )Nzt%dz(?P<>)r   )regexestoksitemsr	   appendr   r   compiler%   	MULTILINEVERBOSEstate)r   statesfirstr6   rulespartstokgroupids           r   r   Lexer.__init__%   s    	"LLNLEE#&&.%(		'"Wcii@A  #%**SXXe_bllRZZ>W"XDLL + 
r   c              #   h  #    [        U5      nU R                  nU R                  nU R                  nSnXb:  ar  XC   R	                  X5       HT  nUR
                  nXX   n	Xx   n
U[        U
5      -  nU	R                  U
4v   U	R                  (       d  MH  U	R                  n  O   Xb:  a  Mr  X0l        g7f)z?
Lexically analyze `text`.

Yield pairs (`name`, `tokentext`).
r   N)lenr6   r/   r0   finditer	lastgroupr
   r   )r   textendr6   r/   r0   startmatchr
   r;   toktexts              r   lex	Lexer.lex3   s      $i

,,yyk 00=j+W%xx))888HHE > k 
s   BB2B2+B2)r/   r6   r0   N)r   r   r   r   r   r   rG   r   r   r   r   r*   r*       s    r   r*   c                     ^  \ rS rSrSr\" SS5      \" SS5      \" SS5      \" S	\" S
SS9SS9\" S\" SSS9SS9\" SSSS9\" SSSS9\" SS5      \" SSSS9\" S\" S5      SS9\" S\" S5      SS9\" S\" S5      SS9\" SSSS9\" SS SS9/r\" S!S"5      /r\\" S\" S#5      SS9/-   \-   \\" S$S%SS9/-   \-   S&.r	U 4S' jr
S(rU =r$ ))JsLexerN   z
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.
commentz/\*(.|\n)*?\*/linecommentz//.*?$wsz\s+keywordal  
                           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
                           z\b)r"   reg)r   reservedznull true falsedivr	   z
                  ([a-zA-Z_$   ]|\\u[0-9a-fA-Z]{4})   # first char
                  ([a-zA-Z_$0-9]|\\u[0-9a-fA-F]{4})*  # rest chars
                  hnumz0[xX][0-9a-fA-F]+onumz0[0-7]+dnuma|  
                    (   (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
                    )
                    punctz
                         >>>= === !== >>> <<= >>= <= >= == != << >> &&
                         || += -= *= %= &= |= ^=
                         z	++ -- ) ]z){ } ( [ . ; , < > + - * % & | ^ ! ~ ? : =stringz"([^"\\]|(\\(.|\n)))*?"z'([^'\\]|(\\(.|\n)))*?'other.z/= /r   a  
                    /                       # 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
                )rR   rP   c                 :   > [         TU ]  U R                  S5        g )NrP   )superr   r7   )r   	__class__s    r   r   JsLexer.__init__   s    e,r   r   )r   r   r   r   r   r   r(   both_before
both_afterr7   r   r   __classcell__)r\   s   @r   rJ   rJ   N   s   0 	I()M9%D& 	 	
 	J!25AN 	
 	F(u5FJ !	
$ 	 		
 	GXk*7GXIJQVWH0u=H0u=y=K@ 	GTJ &)6

 	 . 3

< ='FR- -r   rJ   c                 X   S n[        5       n/ nUR                  U 5       Hv  u  pEUS:X  a  SnOWUS:X  a9  UR                  S5      (       a"  [        R                  " SXSS 5      nS	U-   S	-   nOUS
:X  a  UR                  SS5      nUR                  U5        Mx     SR                  U5      $ )z
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                     U S   nUS:X  a  gU$ )z1Used in a regex to properly escape double quotes.r   "z\"r   )mss     r   escape_quotes-prepare_js_for_gettext.<locals>.escape_quotes   s    aD8Hr   r   z"REGEX"rW   'z\\.|.r   rc   r	   \U )rJ   rG   
startswithr   subreplacer2   r%   )jsrf   lexerr    r
   r;   gutss          r   prepare_js_for_gettextrs      s     IE
AYYr]	7? CX ~~c""vvh1RyADj3&T\ ++dC(C	! #" 771:r   )rl   rl   )r   r   r   r(   r*   rJ   rs   r   r   r   <module>rt      s<    # 
 M+ +\E-e E-P$r   