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<!--.*linecommentz//.*multilinecommentz	/\*.*?\*/dotted_namenamenumberzb(
        (?:0|[1-9]\d*)
        (\.\d+)?
        ([eE][-+]?\d+)? |
        (0x[a-fA-F0-9]+)
    )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.
    jsxr0   r+   r,   )_rulesappend)r2   dottedr0   rules
token_typerule r9   8/usr/lib/python3/dist-packages/babel/messages/jslexer.py	get_rules:   s   r;   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-   r1   regexp)typevalue)tokenr9   r9   r:   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   \uU   N          )line_join_resubr4   findescapesuni_escape_rematchgrouplenr   int
ValueErrorendjoin)r1   resultaddpos
escape_pos	next_charescapedescaped_valuer9   r9   r:   unquote_stringW   sJ   "
'
r]   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   rB   )r2   r5   r0   Nr/   r<   )rQ   r;   rO   division_reregex_rerP   r(   r@   line_refindallrT   )sourcer2   r5   r0   
may_dividerX   linenorT   r6   r7   r8   rO   token_valuer?   r9   r9   r:   tokenize   s8   rf   )TTT) __doc__collectionsr   rebabel._compatr   sortedrQ   	operatorsrM   compileUNICODEname_redotted_name_rer^   DOTALLr_   r`   patternrJ   rN   r(   VERBOSEIrU   mapescaper3   r;   r@   r]   rf   r9   r9   r9   r:   <module>   sH   





	8