o
    V\                     @   s  d Z ddlmZ ddlZddlmZ eg deddZdd	d
dddZ	e
dejZe
dejZe
dZe
dejZe
dZe
dej Ze
dZeddZde
dejfde
dfde
dfde
dejejB fdefdefde
d ejfd!e
d"ejfd#e
d$d%eeje fd&e
d'ejfd(e
d)ejejB fgZd*d+ Zd,d- Zd.d/ Zd2d0d1ZdS )3z
    babel.messages.jslexer
    ~~~~~~~~~~~~~~~~~~~~~~

    A simple JavaScript 1.5 lexer which is used for the JavaScript
    extractor.

    :copyright: (c) 2013-2019 by the Babel Team.
    :license: BSD, see LICENSE for more details.
    )
namedtupleN)unichr)++-*%z!=z==<>z<=z>==z+=z-=z*=z%=z<<z>>z>>>z<<=z>>=z>>>=&z&=|z|=z&&z||^z^=()[]{}!--++~,;.:T)keyreverse
	)bfnrtz[\w$_][\w\d$_]*z[\w$_][\w\d$_.]*[\w\d$_.]z/=?z%/(?:[^/\\]*(?:\\.[^/\\]*)*)/[a-zA-Z]*z(\r\n|\n|\r)z\\z[a-fA-F0-9]{1,4}Tokenztype value linenoz\s+z<!--.*Zlinecommentz//.*Zmultilinecommentz	/\*.*?\*/dotted_namenamenumberzb(
        (?:0|[1-9]\d*)
        (\.\d+)?
        ([eE][-+]?\d+)? |
        (0x[a-fA-F0-9]+)
    )Zjsx_tagz(?:</?[^>\s]+|/>)operatorz(%s)r   template_stringz`(?:[^`\\]*(?:\\.[^`\\]*)*)`stringzT(
        '(?:[^'\\]*(?:\\.[^'\\]*)*)'  |
        "(?:[^"\\]*(?:\\.[^"\\]*)*)"
    )c                 C   sV   g }t D ]$\}}| s|rd|v rq|s|dkrq|dkr!|sqd}|||f q|S )ze
    Get a tokenization rule list given the passed syntax options.

    Internal to this module.
    jsxr-   r)   r*   )_rulesappend)r/   dottedr-   rules
token_typerule r6   8/usr/lib/python3/dist-packages/babel/messages/jslexer.py	get_rules:   s   r8   c                 C   s   | j dkr
| jdv S | j dv S )zzA helper function that helps the tokenizer to decide if the current
    token may be followed by a division operator.
    r,   )r   r   r   r   r   )r*   r+   r.   regexp)typevalue)tokenr6   r6   r7   indicates_divisionN   s   


r=   c                 C   sT  | r| d | d kr| d dv sJ dt d| dd } g }|j}d}	 | d|}|dk r1nf|| ||  | |d  }|tv rJ|t|  nH|dv rt| |d	 }|d
ur| }t|dkr~z|t	t
|d W n	 tyx   Y nw |d }q%|||  | }q%|| n|| |d	 }q&|t| k r|| |d
  d|S )zUnquote a string with JavaScript rules.  The string has to start with
    string delimiters (``'``, ``"`` or the back-tick/grave accent (for template strings).)
    r   z"'`z)string provided is not properly delimitedz\1   \ZuU   N          )line_join_resubr1   findescapesuni_escape_rematchgrouplenr   int
ValueErrorendjoin)r.   resultaddposZ
escape_posZ	next_charZescapedZescaped_valuer6   r6   r7   unquote_stringW   sJ   "
'
rU   c                 c   s    d}d}d}t | }t|||d}||k rm|D ]\}	}
|
| |}|dur( nq|r4t| |}d}	nt| |}d}	|du rE|d7 }q| }|	durZt|	||}t|}|V  |t t	|7 }|
 }||k sdS dS )z
    Tokenize JavaScript/JSX source.  Returns a generator of tokens.

    :param jsx: Enable (limited) JSX parsing.
    :param dotted: Read dotted names as single name token.
    :param template_string: Support ES6 template strings
    Fr   r?   )r/   r2   r-   Nr,   r9   )rM   r8   rK   division_reregex_rerL   r(   r=   line_refindallrP   )sourcer/   r2   r-   Z
may_dividerT   linenorP   r3   r4   r5   rK   Ztoken_valuer<   r6   r6   r7   tokenize   s8   r\   )TTT) __doc__collectionsr   reZbabel._compatr   sortedrM   Z	operatorsrI   compileUNICODEZname_reZdotted_name_rerV   DOTALLrW   rX   patternrF   rJ   r(   VERBOSEIrQ   mapescaper0   r8   r=   rU   r\   r6   r6   r6   r7   <module>   sH   





	8