� K�g�`��,�ddlmZmZddlZddlmZddlmZmZm Z m Z m Z m Z m Z mZmZmZmZmZddlmZddlZ ddlZn #e$rYnwxYwer ddlmZddlmZdd lmZmZmZm Z dd l!m"Z"m#Z#m$Z$dd l%m&Z&dd l'm'Z' e(e��Z)n #e*$rd Z)YnwxYwGd�dee��Z+Gd�de+��Z,Gd�de+��Z-Gd�de��Z.edd���Z/Gd�de0��Z1Gd�d��Z2Gd�d��Z3Gd�d��Z4d �Z5d!�Z6Gd"�d#��Z7d$e0fd%�Z8Gd&�d'��Z9Gd(�d)��Z:e e1ge1fZ;Gd*�d+e��Z<d5d-e e.e0ffd.�Z=Gd/�d0e<��Z>Gd1�d2e>��Z?Gd3�d4e<��Z@dS)6�)�abstractmethod�ABCN)�suppress) �TypeVar�Type�Dict�Iterator� Collection�Callable�Optional� FrozenSet�Any�ClassVar� TYPE_CHECKING�overload)� ModuleType�)� LexerConf)� ParserState)�classify�get_regexp_width� Serialize�logger)�UnexpectedCharacters�LexError�UnexpectedToken)�TOKEN_DEFAULT_PRIORITY)�copyFc ��eZdZUdZeed<eeed<eeed<eeed<ddedeedeeddfd �Z d �Z d �Z d �Z e defd ���Zee defd�����Zee defd�����Zd�ZdS)�Patternz(An abstraction over regular expressions.�value�flags�raw�type�N�returnc�J�||_t|��|_||_dS�N)r!� frozensetr"r#)�selfr!r"r#s �Z/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/lark/lexer.py�__init__zPattern.__init__)s#���� ��u�%�%�� ������c�D�t|�����Sr()�repr� to_regexp�r*s r+�__repr__zPattern.__repr__.s���D�N�N�$�$�%�%�%r-c�T�tt|��|j|jf��Sr()�hashr$r!r"r1s r+�__hash__zPattern.__hash__2s!���T�$�Z�Z���T�Z�8�9�9�9r-c��t|��t|��ko|j|jko|j|jkSr()r$r!r"�r*�others r+�__eq__zPattern.__eq__5s7���D�z�z�T�%�[�[�(�d�T�Z�5�;�-F�d�4�:�Y^�Yd�Kd�dr-c��t���r(��NotImplementedErrorr1s r+r0zPattern.to_regexp8s��!�#�#�#r-c��t���r(r;r1s r+� min_widthzPattern.min_width<���"�#�#�#r-c��t���r(r;r1s r+� max_widthzPattern.max_widthAr?r-c�,�|jD] }d|�d|�d�}� |S)Nz(?�:�))r")r*r!�fs r+� _get_flagszPattern._get_flagsFs.���� .� .�A�A�#$�1�1�e�e�e�,�E�E�� r-)r%N)�__name__� __module__� __qualname__�__doc__�str�__annotations__r r rr,r2r5r9rr0�property�intr>rArFr%r-r+r r !s[�������.�.� �J�J�J� �c�?���� �#����� �3�-������c��*�S�/��X�c�]��^b����� &�&�&�:�:�:�e�e�e��$�3�$�$�$��^�$���$�3�$�$�$��^��X�$���$�3�$�$�$��^��X�$�����r-r c�r�eZdZUdZdZeeed<defd�Ze de fd���Z e de fd���Z dS) � PatternStr)r!r"r#rKr$r&c�Z�|�tj|j����Sr()rF�re�escaper!r1s r+r0zPatternStr.to_regexpQs �����r�y���4�4�5�5�5r-c�*�t|j��Sr(��lenr!r1s r+r>zPatternStr.min_widthT����4�:���r-c�*�t|j��Sr(rUr1s r+rAzPatternStr.max_widthXrWr-N) rGrHrI�__serialize_fields__r$rrKrLr0rMrNr>rAr%r-r+rPrPLs��������2���D�(�3�-����6�3�6�6�6�6���3�����X����3�����X���r-rPc�|�eZdZUdZdZeeed<defd�ZdZ d�Z e de fd���Z e de fd ���ZdS) � PatternRE)r!r"r#�_widthrRr$r&c�6�|�|j��Sr()rFr!r1s r+r0zPatternRE.to_regexpbs�����t�z�*�*�*r-Nc�j�|j�&t|�����|_|jSr()r\rr0r1s r+� _get_widthzPatternRE._get_widthfs+�� �;� �*�4�>�>�+;�+;�<�<�D�K��{�r-c�6�|���dS�Nr�r_r1s r+r>zPatternRE.min_widthk������ � ��#�#r-c�6�|���dS)Nrrbr1s r+rAzPatternRE.max_widthorcr-)rGrHrIrYr$rrKrLr0r\r_rMrNr>rAr%r-r+r[r[]s��������<���D�(�3�-����+�3�+�+�+�+��F���� �$�3�$�$�$��X�$��$�3�$�$�$��X�$�$�$r-r[c �l�eZdZUdZdZeefZee d<e e d<e e d<e fdede de ddfd�Z d �Zdefd �ZdS) � TerminalDefzA definition of a terminal)�name�pattern�priorityrgrhrir&Nc�n�t|t��s J|���||_||_||_dSr()� isinstancer rgrhri)r*rgrhris r+r,zTerminalDef.__init__}s9���'�7�+�+�4�4�W�4�4�+��� ��� � �� � � r-c�P�t|��j�d|j�d|j�d�S)N�(�, rD)r$rGrgrhr1s r+r2zTerminalDef.__repr__�s*��#�D�z�z�2�2�2�D�I�I�I�t�|�|�|�L�Lr-c�j�|j�d��r|jjp|jS|jS)N�__)rg� startswithrhr#r1s r+� user_reprzTerminalDef.user_repr�s4�� �9� � �� %� %� ��<�#�0�t�y� 0��9� r-)rGrHrIrJrYrPr[�__serialize_namespace__rKrLr rNrr,r2rrr%r-r+rfrfts�������� � �8��(�)�3�� �I�I�I� �����M�M�M�DZ�!�!�S�!�7�!�c�!�_c�!�!�!�!� M�M�M��3������r-rf�_T�Token)�boundc���eZdZUdZdZdZeed<ee ed<e ed<ee ed<ee ed<ee ed <ee ed <ee ed <e ddede dee dee dee d ee d ee d ee d dfd���Z e ddede dee dee dee d ee d ee d ee d dfd���Z d�Z e d�fd� ��Ze ddeedee d dfd���Ze ddeedee d dfd���Zd�Zddeedee d dfd�Ze deedede ddd ef d���Zd�Zd�Zd�Zd�ZejZ�xZS) rua�A string with meta-information, that is produced by the lexer. When parsing text, the resulting chunks of the input that haven't been discarded, will end up in the tree as Token instances. The Token class inherits from Python's ``str``, so normal string comparisons and operations will work as expected. Attributes: type: Name of the token (as specified in grammar) value: Value of the token (redundant, as ``token.value == token`` will always be true) start_pos: The index of the token in the text line: The line of the token in the text (starting with 1) column: The column of the token in the text (starting with 1) end_line: The line where the token ends end_column: The next column after the end of the token. For example, if the token is a single character with a column value of 4, end_column will be 5. end_pos: the index where the token ends (basically ``start_pos + len(token)``) )r$� start_posr!�line�column�end_line� end_column�end_pos�r$r!r$rxr!ryrzr{r|r}Nr&c ��dSr(r%) �clsr$r!rxryrzr{r|r}s r+�__new__z Token.__new__�s �� �r-�type_c ��dSr(r%) r�r�r!rxryrzr{r|r}s r+r�z Token.__new__�s ���r-c��d|vrEtjdt��d|vrtd���|�d��|d<|j|i|��S�Nr�z(`type_` is deprecated use `type` insteadr$zAError: using both 'type' and the deprecated 'type_' as arguments.)�warnings�warn�DeprecationWarning� TypeError�pop� _future_new)r��args�kwargss r+r�z Token.__new__�sg�� �f� � � �M�D�FX� Y� Y� Y������ c�d�d�d�#�Z�Z��0�0�F�6�N��s���/��/�/�/r-c ����tt|���||��} || _|| _|| _|| _|| _|| _|| _ || _ | Sr() �superrur�r$rxr!ryrzr{r|r}) r�r$r!rxryrzr{r|r}�inst� __class__s �r+r�zToken._future_new�s_����U�C� � �(�(��e�4�4���� �"����� ��� ��� � �� �$����� �� r-c��dSr(r%�r*r$r!s r+�updatez Token.update���� �r-c��dSr(r%)r*r�r!s r+r�z Token.update�r�r-c��d|vrEtjdt��d|vrtd���|�d��|d<|j|i|��Sr�)r�r�r�r�r��_future_update)r*r�r�s r+r�z Token.update�sh�� �f� � � �M�D�FX� Y� Y� Y������ c�d�d�d�#�Z�Z��0�0�F�6�N�"�t�"�D�3�F�3�3�3r-c�^�t�|�|n|j|�|n|j|��Sr()ru�new_borrow_posr$r!r�s r+r�zToken._future_update�s9���#�#��$�D�D�$�)��&�E�E�D�J� � � � r-r��borrow_tc �b�||||j|j|j|j|j|j��Sr()rxryrzr{r|r})r�r�r!r�s r+r�zToken.new_borrow_pos�sD���s�5�%��!3�X�]�H�O�U]�Uf�hp�h{�~F�~N�O�O� Or-c�P�|j|j|j|j|j|jffSr()r�r$r!rxryrzr1s r+� __reduce__zToken.__reduce__s&������D�J���� �SW�S^� _�`�`r-c�(�d|j�d|j�d�S)NzToken(rnrDr~r1s r+r2zToken.__repr__s���"&�)�)�)�T�Z�Z�Z�8�8r-c�Z�t|j|j|j|j|j��Sr()rur$r!rxryrz)r*�memos r+� __deepcopy__zToken.__deepcopy__s"���T�Y�� �D�N�D�I�t�{�S�S�Sr-c��t|t��r|j|jkrdSt�||��S)NF)rkrur$rKr9r7s r+r9z Token.__eq__ s;�� �e�U� #� #� �� �U�Z�(?�(?��5��z�z�$��&�&�&r-)NNNNNN�NN)rGrHrIrJ� __slots__�__match_args__rKrLr rNrrr�� classmethodr�r�r�rrtr�r�r2r�r9r5� __classcell__)r�s@r+ruru�s�����������$f�I�&�N� �I�I�I���}���� �J�J�J� �3�-���� �S�M�����s�m������ ���� �c�]����� (,�"&�$(�&*�(,�%)�  �  ��  ��  � ��}�  � �3�-�  � �S�M�  ��s�m�  �!�� �  ��c�]�  � �  �  �  ��X�  �� (,�"&�$(�&*�(,�%)� � �� �� � ��}� � �3�-� � �S�M� ��s�m� �!�� � ��c�]� � � � � ��X� �0�0�0�� � � � � ��[� �� � �8�C�=� ��� � �QX� � � ��X� �� � �H�S�M� ��#�� �RY� � � ��X� �4�4�4� � �8�C�=� ��� � �Y`� � � � ��O�D��H�O�S�O��O��O�TV�O�O�O��[�O�a�a�a�9�9�9�T�T�T�'�'�'� �|�H�H�H�H�Hr-c�0�eZdZdZdZd�Zd�Zd defd�ZdS) � LineCounterz>A utility class for keeping track of line & column information)�char_posryrz�line_start_pos� newline_charc�L�||_d|_d|_d|_d|_dS)Nrr)r�r�ryrzr�)r*r�s r+r,zLineCounter.__init__s-��(����� ��� ��� �����r-c�z�t|t��stS|j|jko|j|jkSr()rkr��NotImplementedr�r�r7s r+r9zLineCounter.__eq__s9���%��-�-� "�!� !��}���.�Z�4�3D��HZ�3Z�Zr-T�tokenc��|rV|�|j��}|r:|xj|z c_|j|�|j��zdz|_|xjt |��z c_|j|jz dz|_dS)z�Consume a token and calculate the new line & column. As an optional optimization, set test_newline=False if token doesn't contain a newline. rN)�countr�ryr��rindexr�rVrz)r*r�� test_newline�newliness r+�feedzLineCounter.feed$s��� � Z��{�{�4�#4�5�5�H�� Z�� � �X�%� � �&*�m�e�l�l�4�CT�6U�6U�&U�XY�&Y��#� � � ��U���#� � ��m�d�&9�9�A�=�� � � r-N)T) rGrHrIrJr�r,r9rur�r%r-r+r�r�s`������D�D�N�I� � � �[�[�[� >� >�%� >� >� >� >� >� >r-r�c��eZdZd�Zd�ZdS)�UnlessCallbackc��||_dSr()�scanner)r*r�s r+r,zUnlessCallback.__init__4s ���� � � r-c�^�|j�|jd��}|r |\}|_|Sra)r��matchr!r$)r*�t�res�_values r+�__call__zUnlessCallback.__call__7s3���l� � ���!�,�,�� � !� �N�F�A�F��r-N�rGrHrIr,r�r%r-r+r�r�3s2�������������r-r�c��eZdZd�Zd�ZdS)� CallChainc�0�||_||_||_dSr()� callback1� callback2�cond)r*r�r�r�s r+r,zCallChain.__init__?s��"���"����� � � r-c��|�|��}|�|��r|�|��n|Sr()r�r�r�)r*r��t2s r+r�zCallChain.__call__Ds9�� �^�^�A� � ��$(�I�I�b�M�M�9�t�~�~�a� � � �r�9r-Nr�r%r-r+r�r�>s2��������� :�:�:�:�:r-r�c�b�|�|||��}|r|�d��SdSra)r��group)�re_�regexp�sr"�ms r+� _get_matchr�Is9�� � � �&�!�U�#�#�A����w�w�q�z�z���r-c �� �t|d���}t|��dksJ|������t��� i}|�t g��D]�}g}|�t g��D]�}|j|jkr�|jj } | t||j� ��| |��krD|� |��|jj |jj kr� �|����|r)tt!|||d|�����||j<�܈ fd�|D��} | |fS)Nc�*�t|j��Sr()r$rh�r�s r+�<lambda>z _create_unless.<locals>.<lambda>Os��4�� �?�?�r-�T)� match_whole� use_bytesc���g|]}|�v�|�� Sr%r%)�.0r�� embedded_strss �r+� <listcomp>z"_create_unless.<locals>.<listcomp>`s#���D�D�D�1�Q�m�-C�-C�Q�-C�-C�-Cr-)rrV�keys�set�getr[rPrirhr!r�r0�appendr"�addr��Scannerrg) � terminals� g_regex_flagsr�r��tokens_by_type�callback�retok�unless�strtokr�� new_terminalsr�s @r+�_create_unlessr�Nsm����i�)B�)B�C�C�N� �~� � �!� #� #� #�^�%8�%8�%:�%:� #� #� #��E�E�M��H��#�#�I�r�2�2� ~� ~����$�(�(��R�8�8� .� .�F���%�.�0�0����$�A��J�s�E�M�$;�$;�$=�$=�q�-�P�P�P�P�� � �f�%�%�%��>�'�5�=�+>�>�>�!�%�%�f�-�-�-�� � ~�#1�'�&�-�QT�bf�r{�2|�2|�2|�#}�#}�H�U�Z� ��D�D�D�D� �D�D�D�M� �(� "�"r-c�"�eZdZdd�Zd�Zd�ZdS)r�Fc���||_||_||_||_||_d�|jD��|_|�|t|����|_dS)Nc��h|] }|j�� Sr%�rg�r�r�s r+� <setcomp>z#Scanner.__init__.<locals>.<setcomp>ls��=�=�=��a�f�=�=�=r-) r�r�r�r�r�� allowed_types� _build_mresrV�_mres)r*r�r�r�r�r�s r+r,zScanner.__init__es`��"���*������"���&���=�=�d�n�=�=�=����%�%�i��Y���@�@�� � � r-c���|jrdnd�g}|r�d��fd�|d|�D����}|jr|�d��} |j�||j��}n)#t$r|�||dz��cYSwxYw|� |��||d�}|��|S)N�$��|c3�h�K�|],}d|j�d|j����z�d�V��-dS)z(?P<�>rDN)rgrhr0)r�r��postfixs �r+� <genexpr>z&Scanner._build_mres.<locals>.<genexpr>wsL�����x�x�^_�^_�������9L�9L�9N�9N�QX�9X�9X�9X� Y�x�x�x�x�x�xr-zlatin-1r�) r��joinr��encoder��compiler��AssertionErrorr�r�)r*r��max_size�mresrh�mrer�s @r+r�zScanner._build_mresps����)�1�#�#�r����� -��i�i�x�x�x�x�cl�mv�nv�mv�cw�x�x�x�x�x�G��~� 4�!�.�.��3�3�� B��h�&�&�w��0B�C�C����!� B� B� B��'�'� �8�q�=�A�A�A�A�A� B���� �K�K�� � � �!�(�)�)�,�I�� -�� s� A8�8#B�Bc��|jD]8}|�||��}|r|�d��|jfcS�9dSra)r�r�r�� lastgroup)r*�text�posrr�s r+r�z Scanner.match�sZ���:� /� /�C�� � �$��$�$�A�� /��w�w�q�z�z�1�;�.�.�.�.� /� /� /r-N)F)rGrHrIr,r�r�r%r-r+r�r�dsJ������ A� A� A� A����&/�/�/�/�/r-r��rc�2�d|vpd|vpd|vp d|vpd|vod|vS)z�Expressions that may indicate newlines in a regexp: - newlines (\n) - escaped newline (\\n) - anything but ([^...]) - any-char (.) when the flag (?s) exists - spaces (\s) � z\nz\sz[^z(?s�.r%)rs r+�_regexp_has_newliner �s>�� �1�9� Z��� � Z�e�q�j� Z�D�A�I� Z�%�1�*�BY�QT�XY�QY�Zr-c�|�eZdZUdZdZeed<eed<ee ed<d dedeedee fd�Z d�Z d �Z dS) � LexerStatez�Represents the current state of the lexer as it scans the text (Lexer objects are only instantiated per grammar, not per text) )r�line_ctr� last_tokenrrrNc�|�||_|p%tt|t��rdnd��|_||_dS)N� r )rr�rk�bytesrr)r*rrrs r+r,zLexerState.__init__�s<���� � �[�K��D�%�9P�9P�0Z���VZ�$[�$[�� �$����r-c��t|t��stS|j|juo|j|jko|j|jkSr()rkrr�rrrr7s r+r9zLexerState.__eq__�sG���%��,�,� "�!� !��y�E�J�&�r�4�=�E�N�+J�r�t��bg�br�Or�rr-c�n�t|��|jt|j��|j��Sr()r$rrrrr1s r+�__copy__zLexerState.__copy__�s*���t�D�z�z�$�)�T�$�-�%8�%8�$�/�J�J�Jr-r�) rGrHrIrJr�rKrLr�r rur,r9rr%r-r+rr�s����������1�I� �I�I�I�����������%�%�S�%�H�[�,A�%�T\�]b�Tc�%�%�%�%� s�s�s� K�K�K�K�Kr-rc�V�eZdZdZdddefd�Zedddeddfd���Zd �Z d �Z e Z d S) � LexerThreadzTA thread that ties a lexer instance and a lexer state, to be used by the parser �lexer�Lexer� lexer_statec�"�||_||_dSr()r�state)r*rrs r+r,zLexerThread.__init__�s���� � �� � � r-rr&c�4�||t|����Sr(�r)r�rrs r+� from_textzLexerThread.from_text�s���s�5�*�T�*�*�+�+�+r-c�B�|j�|j|��Sr()r�lexr)r*� parser_states r+r"zLexerThread.lex�s���z�~�~�d�j�,�7�7�7r-c�b�t|��|jt|j����Sr()r$rrrr1s r+rzLexerThread.__copy__�s&���t�D�z�z�$�*�d�4�:�&6�&6�7�7�7r-N) rGrHrIrJrr,r�rKr r"rru�_Tokenr%r-r+rr�s���������!�g�!�J�!�!�!�!��,�g�,�S�,�]�,�,�,��[�,�8�8�8�8�8�8��F�F�Fr-rc�H�eZdZdZedededeefd���Z d�Z dS)rzlLexer interface Method Signatures: lex(self, lexer_state, parser_state) -> Iterator[Token] rr#r&c��tSr()r�)r*rr#s r+r"z Lexer.lex�s���r-c� �t|��S)� Deprecatedr)r*rs r+�make_lexer_statezLexer.make_lexer_state�s���$���r-N) rGrHrIrJrrrr rur"r*r%r-r+rr�sf�������� ��z�����%������^�� � � � � r-r��terminal_to_regexpc��|stj�|��}|rdnd}|���|krdSt |d������D]�}|�|d���D]�\}}|j|jksJ�|�||��d|j �d|j �d�} |� |||��� ��} n#t$rd } YnwxYw|rt|�d | �����tjd || ��|���|krtjd ��dS�ڌ�dS) Nr�g�������?c��|jSr()rir�s r+r�z)_check_regex_collisions.<locals>.<lambda>�s��� �r-T)� skip_markedzCollision between Terminals z and z. zONo example could be found fast enough. However, the collision does still existsr z5%s The lexer will choose between them arbitrarily. %sz2Found 8 regex collisions, will not check for more.)� interegular� Comparator� from_regexes�count_marked_pairsr�values�checkri�markrg�get_example_overlap�format_multiline� ValueErrorrr�warning) r,� comparator� strict_mode�max_collisions_to_show�max_timer��a�b�message�examples r+�_check_regex_collisionsrC�s��� �M� �+�8�8�9K�L�L� � �(�q�q�S�H��$�$�&�&�*@�@�@����,�.B�.B�C�C�J�J�L�L�����$�$�U��$�=�=� � �D�A�q��:���+�+�+�+� �O�O�A�q� !� !� !�M�Q�V�L�L�!�&�L�L�L�G� l�$�8�8��A�x�H�H�Y�Y�[�[����� l� l� l�k���� l����� 8��'�6�6�W�6�6�7�7�7� �N�S�U\�^e� f� f� f��,�,�.�.�2H�H�H���S�T�T�T�����I� ��s�?)C)�) C8�7C8c��eZdZUeeefed<ed d d���Zed de de de fd ���Z d e de de e fd �ZdS)�AbstractBasicLexer�terminals_by_nameN�confrr&c��dSr(r%)r*rGr;s r+r,zAbstractBasicLexer.__init__�r�r-� lex_stater#c��dSr(r%)r*rIr#s r+� next_tokenzAbstractBasicLexer.next_token�r�r-rc#�~K�tt��5 |�||��V��#1swxYwYdSr()r�EOFErrorrK)r*rr#s r+r"zAbstractBasicLexer.lexst���� �h� � � ;� ;� ;��o�o�e�\�:�:�:�:�:� ;� ;� ;� ;� ;���� ;� ;� ;� ;� ;� ;s �2�6�6r(�rGrr&N)rGrHrIrrKrfrLrr,rrrurKr r"r%r-r+rErE�s���������C��,�-�-�-�-�� � � � ��^� �� � �J� �c� �U� � � ��^� �;��;�3�;�8�E�?�;�;�;�;�;�;r-rEc���eZdZUeeed<eeed<eeed<eee fed<eee fed<e ed<ddd �Z d �Z e d ���Zd�Zddeded efd�ZdS)� BasicLexerr�� ignore_types� newline_types�user_callbacksr�rRNrGrr&c�4�t|j��}td�|D����s J|���|j|_|j�s@i}|D]�}|j���} |j�||j ��n2#|jj $r td|j �d|j�����wxYw|jj dkr td|j �d|j�d����|jjdkr|||<��t|j��d�|D��ks1td t|j��d �|D��z z���t"rt%|||j��n|jrtd ���t)d �|D����|_t)|j��|_|�d ����||_|j|_|j |_ |j|_|j|_d|_dS)Nc3�@K�|]}t|t��V��dSr()rkrfr�s r+r�z&BasicLexer.__init__.<locals>.<genexpr>s,����A�A�!�:�a��-�-�A�A�A�A�A�Ar-zCannot compile token z: rz,Lexer does not allow zero-width terminals. (rDrRc��h|] }|j�� Sr%r�r�s r+r�z&BasicLexer.__init__.<locals>.<setcomp>#s��(C�(C�(C�A���(C�(C�(Cr-z$Ignore terminals are not defined: %sc��h|] }|j�� Sr%r�r�s r+r�z&BasicLexer.__init__.<locals>.<setcomp>$s��\w�\w�\w�hi�]^�]c�\w�\w�\wr-zUinteregular must be installed for strict mode. Use `pip install 'lark[interegular]'`.c3�pK�|]1}t|j������(|jV��2dSr()r rhr0rgr�s r+r�z&BasicLexer.__init__.<locals>.<genexpr>,sB����&o�&o�!�DW�XY�Xa�Xk�Xk�Xm�Xm�Dn�Dn�&o�q�v�&o�&o�&o�&o�&o�&or-c�j�|j |jj t|jj�� |jfSr()rirhrArVr!rg)�xs r+r�z%BasicLexer.__init__.<locals>.<lambda>/s.��q�z�k�A�I�4G�3G�#�a�i�o�J^�J^�I^�`a�`f�%g�r-)�key)�listr��all� re_modulerR�skip_validationrhr0r�r��errorrrgr>r$r��ignore�has_interegularrC�strictr)rRrQ�sort� callbacksrSr�rF�_scanner)r*rGr;r�r,r�r�s r+r,zBasicLexer.__init__sK�����(�(� ��A�A�y�A�A�A�A�A�L�L�9�L�L�A��.����#� x�!#� �� 3� 3����,�,�.�.��X��G�O�O�F�D�,>�?�?�?�?���w�}�X�X�X�"�(�A�F�F�F�A�I�I�#V�W�W�W�X�����9�&�!�+�+�"�(�\]�\b�\b�\b�de�dm�dm�dm�#n�o�o�o��9�>�T�)�)�,2�&�q�)���� �$�$�(C�(C��(C�(C�(C�C�C��E��T�[�IY�IY�\w�\w�mv�\w�\w�\w�Iw�x�y�y�y�� x�'�(:�J�� �T�T�T�T��� x��v�w�w�w�'�&o�&o�y�&o�&o�&o�o�o���%�d�k�2�2������g�g��h�h�h�"���"�n���!�/�������!%�!7����� � � s �, B � /B<c���t|j|j|j|j��\}|_t |j�����sJ�|j� ��D]@\�}�|jvr(t|j�|�fd���|j�<�6||j�<�At||j|j|j��|_ dS)Nc���|j�kSr()r$)r�r�s �r+r�z+BasicLexer._build_scanner.<locals>.<lambda>?s���TU�TZ�^c�Tc�r-) r�r�r�rRr�r�r]r4rS�itemsr�r�rf)r*r�rEr�s @r+�_build_scannerzBasicLexer._build_scanner8s����#1�$�.�$�BT�VZ�V]�_c�_m�#n�#n� � �4�=��4�=�'�'�)�)�*�*�*�*�*��+�1�1�3�3� )� )�H�E�1��� �%�%�'0���u�1E�q�Jc�Jc�Jc�Jc�'d�'d�� �e�$�$�'(�� �e�$�$�� �4�+=�t�w���W�W�� � � r-c�F�|j�|���|jSr()rfrjr1s r+r�zBasicLexer.scannerEs$�� �=� � � � � !� !� !��}�r-c�8�|j�||��Sr()r�r�)r*rrs r+r�zBasicLexer.matchKs���|�!�!�$��,�,�,r-rIr#c �L�|j}|jt|j��k�rq|�|j|j��}|sV|jj|jz }|sdh}t|j|j|j |j ||j o|j g||j ����|\}}||jv}d} |r ||j vr"t|||j|j |j ��} |�|||jv��| �|j | _|j | _|j| _| j|j vr|j | j| ��} |s0t+| t��st-d| z���| |_ | S|jt|j��k��qt/|���)Nz <END-OF-FILE>)�allowed� token_historyrrFz+Callbacks must return a token (returned %r))rr�rVrr�r�r�rQrryrzrrFr�rur�rRr{r|r}r$rkrrM) r*rIr#rr�rnr!r��ignoredr�s r+rKzBasicLexer.next_tokenNs����%����#�i�n�"5�"5�5�5��*�*�Y�^�X�->�?�?�C�� i��,�4�t�7H�H���0�.�/�G�*�9�>�8�;L�h�m�]e�]l�3:�)�J^�Jy�dm�dx�cy�1=�QU�Qg�i�i�i�i��L�E�5��t�0�0�G��A�� [�e�t�}�4�4��%���(9�8�=�(�/�Z�Z�� �M�M�%��$�*<�!<� =� =� =��}�%�]�� �'��� �$�-�� ��6�T�]�*�*�-�� �a�f�-�a�0�0�A���%�a��/�/�Z�&�'T�WX�'X�Y�Y�Y�+,�I�(��H�7��#�i�n�"5�"5�5�5�<�t�n�n�r-r(rN)rGrHrIr rfrLr rKr� _Callbackrr,rjrMr�r�rrrurKr%r-r+rPrPs���������+�&�&�&�&��C�.� � � ��S�>�!�!�!���i��(�(�(�(��3� �>�"�"�"�"��N�N�N�(�(�(�(�(�T X� X� X�����X�� -�-�-� � �J� �c� �U� � � � � � r-rPc ��eZdZUeeefed<eed<eZeeed<ddddeee e fde e d d fd �Z d e d dd e efd�Zd S)�ContextualLexer�lexers� root_lexerrPr%rGr�states� always_acceptr&Nc��� �t|j��}|j� t|��}||_tr1|js*t j�d�|D����}nd}i}i|_ |� ��D]�\}} t| ��} || } n�#t$rtt| ��t|j��zt|��z} t|��} � fd�| D��| _|�| |��} | || <YnwxYw| |j |<��|j|usJ�d|_|�||��|_dS)Nc�B�i|]}||j�����Sr%)rhr0r�s r+� <dictcomp>z,ContextualLexer.__init__.<locals>.<dictcomp>s)��=j�=j�=j�[\�a���AT�AT�AV�AV�=j�=j�=jr-c�(��g|]}|�v��|��Sr%r%)r��nrFs �r+r�z,ContextualLexer.__init__.<locals>.<listcomp>�s+���'h�'h�'h��QR�Vg�Qg�Qg�(9�!�(<�Qg�Qg�Qgr-T)r\r�rFrrbr_r0r1r2rtrir)�KeyErrorr�rarPru)r*rGrvrwr�� trad_confr;�lexer_by_tokensr�acceptsr[r� lexer_confrFs @r+r,zContextualLexer.__init__ws�������(�(� � �2����J�J� �'� �� � �4�#7� �$�/�<�<�=j�=j�`i�=j�=j�=j�k�k�J�J��J�DF���� �$�l�l�n�n� '� '�N�E�7��G�$�$�C� -�'��,����� -� -� -��g�,�,��T�[�)9�)9�9�C� �<N�<N�N��!�)�_�_� �'h�'h�'h�'h�g�'h�'h�'h� �$���� �J�?�?��',���$�$�$�  -����"'�D�K�� � ��"�i�/�/�/�/�$(� �!��/�/�)�Z�@�@����s�B(�(A;D&�%D&rr#rc#�JK� |j|j}|�||��V��+#t$rYdSt$r\} |j}|j�||��}t||j||g|jj ����#t$r|�wxYwd}~wwxYw)NT)rrorF) rt�positionrKrMrrrurrnrF)r*rr#r�err�s r+r"zContextualLexer.lex�s����� � B�� �L�$9�:���&�&�{�L�A�A�A�A�A� B��� � � � �D�D�#� � � � �(�3� ���2�2�;� �M�M��%�e�Q�Y�l�[e�Zf�z~�{J�{\�]�]�]�]��'� � � ��� �������� ���s'�,0� B"� B"�AB � B�B�B")r%)rGrHrIrrNrErLrPrr rKr,rr rur"r%r-r+rsrsqs�������� ��(�(� )�)�)�)�"�"�"�"�+5�J��'�(�5�5�5�A�A�[�A�$�s�J�s�O�7K�2L�A�]g�hk�]l�A�tx�A�A�A�A�<�z����8�TY�?������r-rs)r+)A�abcrrrR� contextlibr�typingrrrr r r r r rrrr�typesrr�r0� ImportError�commonr�parsers.lalr_parser_stater�utilsrrrr� exceptionsrrr�grammarrr�boolrb� NameErrorr rPr[rfrtrKrur�r�r�r�r�r�r rrrqrrCrErPrsr%r-r+�<module>r�s ��$�#�#�#�#�#�#�#� � � � ��������������������������������������������� �������� � � ��D� �����7�!�!�!�!�!�!�6�6�6�6�6�6�@�@�@�@�@�@�@�@�@�@�@�@�G�G�G�G�G�G�G�G�G�G�+�+�+�+�+�+���������d�;�'�'�O�O�������O�O�O�����(�(�(�(�(�i��(�(�(�V���������"$�$�$�$�$��$�$�$�.�����)����0 �W�T��!�!�!��A�A�A�A�A�C�A�A�A�H>�>�>�>�>�>�>�>�B��������:�:�:�:�:�:�:�:���� #�#�#�,#/�#/�#/�#/�#/�#/�#/�#/�L[�3�[�[�[�[�K�K�K�K�K�K�K�K�4��������* �e�W�e�^� $� �  �  �  �  �  �C�  �  �  ����[�#�5E�0F�����@;�;�;�;�;��;�;�;�"h�h�h�h�h�#�h�h�h�V3�3�3�3�3�e�3�3�3�3�3s!�?�A�A�; B�B�B
Memory