� K�gq��^�ddlmZmZddlZddlZddlZddlZddlZddlZddl Z ddl m Z m Z m Z mZmZmZmZmZmZmZmZmZmZmZmZer0ddlmZddlmZddlmZej dkrdd l m!Z!ndd l"m!Z!dd l#m$Z$dd l%m&Z&m'Z'm(Z(dd l)m*Z*m+Z+m,Z,m-Z-m.Z.dd l/m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4ddlm5Z5ddl6m7Z7m8Z8m9Z9m:Z:ddl;m<Z<m=Z=m>Z>m?Z?m@Z@ddlAmBZBddl#mCZCmDZDmEZEmFZFddlGmHZH ddlIZIdZJn #eK$rdZJYnwxYwGd�de��ZLGd�de*��ZMhd�ZNdZOdZPe dd���ZQGd �de*��ZRdS)!�)�ABC�abstractmethodN)�TypeVar�Type�List�Dict�Iterator�Callable�Union�Optional�Sequence�Tuple�Iterable�IO�Any� TYPE_CHECKING� Collection�)�InteractiveParser)� ParseTree)� Transformer)��)�Literal)�ParsingFrontend)�ConfigurationError� assert_config�UnexpectedInput)� Serialize�SerializeMemoizer�FS�isascii�logger)� load_grammar�FromPackageLoader�Grammar�verify_used_files�PackageResource� sha256_digest)�Tree)� LexerConf� ParserConf�_ParserArgType� _LexerArgType)�Lexer� BasicLexer� TerminalDef� LexerThread�Token)�ParseTreeBuilder)�_validate_frontend_args�_get_lexer_callbacks�_deserialize_parsing_frontend�_construct_parsing_frontend)�RuleTFc�b�eZdZUedeedeefd���ZdZee e d<dS)�PostLex�stream�returnc��|S�N�)�selfr<s �Y/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/lark/lark.py�processzPostLex.process,s��� �r@� always_acceptN) �__name__� __module__� __qualname__rr r3rCrEr�str�__annotations__r@rDrBr;r;+s\���������h�u�o��(�5�/�����^��$&�M�8�C�=�%�%�%�%�%rDr;c ���eZdZUdZeeed<eed<eed<ded<eeefed<eed<eeefed <eed <e ed <eed <e e eege fed <e ed<eed<ded<e eed<ded<eee egeffed<eed<eed<e e egefed<ded<e eed<dZereez Zidd�dd�d d�d d�d d�dd�dd�dd �dd�dd�dd �dd �d d�dd�di�dd!�dd�d"dd!gdid#��Zeee fed$<d%eee fd&dfd'�Zd(ed&e fd)�Zd(ed*ed&dfd+�Zd0d&eee ffd,�Zed-eee fd.ee eeeffd&dfd/���ZdS)1� LarkOptionsz$Specifies the options for Lark �start�debug�strictzOptional[Transformer]� transformer�propagate_positions�maybe_placeholders�cache�regex� g_regex_flags�keep_all_tokens� tree_class�parser�lexerz0Literal["auto", "resolve", "explicit", "forest"]� ambiguity�postlexz-Optional[Literal["auto", "normal", "invert"]]�priority�lexer_callbacks� use_bytes� ordered_sets�edit_terminalszUList[Union[str, Callable[[Union[None, str, PackageResource], str], Tuple[str, str]]]]� import_paths� source_patha7 **=== General Options ===** start The start symbol. Either a string, or a list of strings for multiple possible starts (Default: "start") debug Display debug information and extra warnings. Use only when debugging (Default: ``False``) When used with Earley, it generates a forest graph as "sppf.png", if 'dot' is installed. strict Throw an exception on any potential ambiguity, including shift/reduce conflicts, and regex collisions. transformer Applies the transformer to every parse tree (equivalent to applying it after the parse, but faster) propagate_positions Propagates positional attributes into the 'meta' attribute of all tree branches. Sets attributes: (line, column, end_line, end_column, start_pos, end_pos, container_line, container_column, container_end_line, container_end_column) Accepts ``False``, ``True``, or a callable, which will filter which nodes to ignore when propagating. maybe_placeholders When ``True``, the ``[]`` operator returns ``None`` when not matched. When ``False``, ``[]`` behaves like the ``?`` operator, and returns no value at all. (default= ``True``) cache Cache the results of the Lark grammar analysis, for x2 to x3 faster loading. LALR only for now. - When ``False``, does nothing (default) - When ``True``, caches to a temporary file in the local directory - When given a string, caches to the path pointed by the string regex When True, uses the ``regex`` module instead of the stdlib ``re``. g_regex_flags Flags that are applied to all terminals (both regex and strings) keep_all_tokens Prevent the tree builder from automagically removing "punctuation" tokens (Default: ``False``) tree_class Lark will produce trees comprised of instances of this class instead of the default ``lark.Tree``. **=== Algorithm Options ===** parser Decides which parser engine to use. Accepts "earley" or "lalr". (Default: "earley"). (there is also a "cyk" option for legacy) lexer Decides whether or not to use a lexer stage - "auto" (default): Choose for me based on the parser - "basic": Use a basic lexer - "contextual": Stronger lexer (only works with parser="lalr") - "dynamic": Flexible and powerful (only with parser="earley") - "dynamic_complete": Same as dynamic, but tries *every* variation of tokenizing possible. ambiguity Decides how to handle ambiguity in the parse. Only relevant if parser="earley" - "resolve": The parser will automatically choose the simplest derivation (it chooses consistently: greedy for tokens, non-greedy for rules) - "explicit": The parser will return all derivations wrapped in "_ambig" tree nodes (i.e. a forest). - "forest": The parser will return the root of the shared packed parse forest. **=== Misc. / Domain Specific Options ===** postlex Lexer post-processing (Default: ``None``) Only works with the basic and contextual lexers. priority How priorities should be evaluated - "auto", ``None``, "normal", "invert" (Default: "auto") lexer_callbacks Dictionary of callbacks for the lexer. May alter tokens during lexing. Use with caution. use_bytes Accept an input of type ``bytes`` instead of ``str``. ordered_sets Should Earley use ordered-sets to achieve stable output (~10% slower than regular sets. Default: True) edit_terminals A callback for editing the terminals before parse. import_paths A List of either paths or loader functions to specify from where grammars are imported source_path Override the source of from where the grammar was loaded. Useful for relative imports and unconventional grammar loading **=== End of Options ===** FN�earley�autoTr)rUr^r_rarb�_plugins� _defaults� options_dictr=c��t|��}i}|j���D]N\}}||vr>|�|��}t |t ��r|dvrt |��}n|}|||<�Ot |dt ��r |dg|d<||jd<t|j d��|j dkr|j rtd���|r$td|� ��z���dS)N)rSr^rQrM�options)rc�lalr�cykNrcz�Cannot specify an embedded transformer when using the Earley algorithm. Please use your transformer on the resulting parse tree, or use a different algorithm (i.e. LALR)zUnknown options: %s) �dictrf�items�pop� isinstance�boolrI�__dict__rrXrPr�keys)rArg�ori�name�default�values rB�__init__zLarkOptions.__init__�s3�� �� � ����!�^�1�1�3�3� "� "�M�D�'��q�y�y����d� � ���g�t�,�,�(��=j�1j�1j� ��K�K�E����!�G�D�M�M� �g�g�&�� ,� ,� 2� '�� 0�1�G�G� �#*�� �i� � �d�k�#B�C�C�C� �;�(� "� "�t�'7� "�$�&A�B�B� B� � G�$�%:�Q�V�V�X�X�%E�F�F� F� G� GrDrtc�l� |jd|S#t$r}t|���d}~wwxYw)Nri)rq�KeyError�AttributeError)rArt�es rB� __getattr__zLarkOptions.__getattr__�sF�� $��=��+�D�1� 1��� $� $� $� ��#�#� #����� $���s�� 3�.�3rvc�j�t||j���d��||j|<dS)Nz,%r isn't a valid option. Expected one of: %s)rrirr)rArtrvs rB� __setattr__zLarkOptions.__setattr__�s5���d�D�L�-�-�/�/�1_�`�`�`�"�� �T���rDc��|jSr?�ri)rA�memos rB� serializezLarkOptions.serialize�s ���|�rD�datar�c��||��Sr?r@)�clsr�r�s rB� deserializezLarkOptions.deserialize�s���s�4�y�y�rDr?)rFrGrH�__doc__rrIrJrpr �intr r rr-r.r;rr3r1� OPTIONS_DOCrfrwr|r~r�� classmethodr9r�r@rDrBrLrL2s���������� ��9���� �K�K�K� �L�L�L�(�(�(�(��t�S�y�)�)�)�)����� ��s�� ���� �K�K�K�����������3��+�s�"2�3�4�4�4�4� ���� ����A�A�A�A� �g� ����=�=�=�=��#�x�����7�7�8�8�8�8��O�O�O������X�{�m�[�&@�A�B�B�B�B�i�i�i�i��#�����L�K�Z���;���!���!��%�!� �5�!� �d� !� �� !� �4� !� �(�!� ��!� �t�!� ��!� �F�!� �V�!� ��!� �u�!� �2�!� �d�!!�" �$�#!�$������/!�!�!�I�t�C��H�~����4G�T�#�s�(�^�G��G�G�G�G�:$��$��$�$�$�$� #��#�C�#�D�#�#�#�#����S�#�X��������t�C��H�~��T�#�u�[�RV�EV�?W�:W�5X��]j�����[���rDrL> rNrTr[rer^rWrPrUr]rQ)rd�normal�invertN)rd�resolve�explicit�forest�_T�Lark)�boundc �z�eZdZUdZeed<eed<ded<eed<eed<ded <ee ed <d7d�Z er edej zz ZdZ d8de d efd�Zd9d�Zd:d�Zd;deed d fd�Zedeed efd���Zdeeefdeeee effded efd�Zdeded efd �Zed!���Zed<deed"ed#e ed efd$���Z!ed%gfdeed&ed'ed(d)d ef d*���Z"d+�Z#d8d,ede d e$e%fd-�Z&d.ed e fd/�Z'd=d,e ed0e ed d1fd2�Z(d=d,ed0e ed3d4d d5fd6�Z)d S)>r�a}Main interface for the library. It's mostly a thin wrapper for the many different parsers, and for the tree constructor. Parameters: grammar: a string or file-object containing the grammar spec (using Lark's ebnf syntax) options: a dictionary controlling various aspects of Lark. Example: >>> Lark(r'''start: "foo" ''') Lark(...) rb�source_grammarr&�grammarrirYrrX� terminals�Union[Grammar, str, IO[str]]r=Nc ����t|��|_|jj}|rtrt}nt d���t }|jj�% |j|_n(#t$r d|_YnwxYw|jj|_ |j }|��}n#t$rYnwxYwd}d}t|t���r�||_ |jj rt|��std���|jj�re|jjdkrtd���d�d��fd�|���D����}d d lm} ||z| ztt,jdd ���z} t1| ��}t|jjt��r |jj}nt|jjd urtd ��� t3j��} n#t6$rd} YnwxYwt9j��d| |gt,jdd ��Rzz}|j} t=j|d��5} tAj!d|��tE|��tFz D]}||=�| �$���%d��}tMj'| ��}||�(d��kr?tS|��r0tMj'| ��}|j*|fi|�� ddd��dSddd��n #1swxYwYn7#tV$rYn+t6$rtAj,d|��| |_YnwxYwt[||j|jj.|jj/��\|_0}nt|tb��sJ�||_0|jj2dkr�|jjdkr d|j_2n{|jjdkr:|jj3�!tAj4d��d|j_2n>d|j_2n1|jjdkr d|j_2nJ|jj���|jj2}t|tj��rtm|tn��sJ�n/tq|d��|jj3�d|vrtd���|jj9dkr|jjdkr d|j_9ntq|jjd d!��|jj:dkr d"|j_:|jj:tvvr$td#|jj:�d$tv�����|jj9txvr$td%|jj9�d$tx�����|jj�d&}n9|jj3�tE|jj3j=��}ntE��}|j0�>|jj?|��\|_@|_A|_B|jjCr$|j@D]}|j�C|���d'�|j@D��|_D|jj:d(krE|jAD]%}|jj:�|jj: |j_:�&|j@D]}|j: |_:�n?|jj:�3|jAD]}|jj:� d|j_:�|j@D] }d)|_:� t�|j@||jB|jj3|jjF|jjG|jj |jjH�*��|_I|jjr|�J��|_n|r|�K��|_2|r�tAj!d+|�� t=j|d,��5} |�J�| �L|�(d��dz��tMjM|| ��|�N| tF��ddd��dS#1swxYwYdS#t�$r!}tAj,d-||��Yd}~dSd}~wwxYwdS).Nz?`regex` module must be installed if calling `Lark(regex=True)`.z<string>z/Grammar must be ascii only, when use_bytes=Truerjz+cache only works with parser='lalr' for now)rPr[r]r`re�c3�J�K�|]\}}|�v� |t|��zV��dSr?)rI)�.0�k�v� unhashables �rB� <genexpr>z Lark.__init__.<locals>.<genexpr>:s<�����%b�%b�4�1�a�a�Wa�Na�Na�a��A���h�Na�Na�Na�Na�%b�%brDr)� __version__�Tz"cache argument must be bool or str�unknownz/.lark_cache_%s_%s_%s_%s.tmp�rbzLoading grammar from cache: %s� �utf8z<Failed to load Lark from cache: %r. We will try to carry on.rd� contextualrcz~postlex can't be used with the dynamic lexer, so we use 'basic' instead. Consider using lalr with contextual instead of earley�basic�dynamicrkF)r�r�r��dynamic_completezGCan't use postlex with a dynamic lexer. Use basic or contextual insteadr�)rcrkzG%r doesn't support disambiguation. Use one of these parsers instead: %sr�zinvalid priority option: z. Must be one of zinvalid ambiguity option: �*c��i|] }|j|�� Sr@�rt�r��ts rB� <dictcomp>z!Lark.__init__.<locals>.<dictcomp>����B�B�B�a����B�B�BrDr�r)r^rOzSaving grammar to cache: %s�wbz!Failed to save Lark to cache: %r.)PrLrirT� _has_regex� ImportError�rerbrtrz�readrorIr�r^r"rrSrX�joinrmr�r��sys� version_infor)�getpass�getuser� Exception�tempfile� gettempdirr!�openr#rN�set�_LOAD_ALLOWED_OPTIONS�readline�rstrip�pickle�load�encoder'�_load�FileNotFoundError� exceptionr$rarVr�r&rYr[�info�type� issubclassr/rrZr\�_VALID_PRIORITY_OPTIONS�_VALID_AMBIGUITY_OPTIONSrE�compilerMr��rules� ignore_tokensr`�_terminals_dictr+r]rUrO� lexer_conf� _build_parser� _build_lexer�write�dump�save�IOError)rAr�ri� use_regex� re_moduler��cache_fn� cache_sha256� options_strr��s�username� old_options�frt� file_sha256�cached_used_files�cached_parser_data� used_filesrY�terminals_to_keepr��rule�termr{r�s @rBrwz Lark.__init__s ���"�7�+�+�� ��L�&� � � �� e�!� � �!�"c�d�d�d��I� �<� #� +� .�#*�<�� � ��!� .� .� .�#-�� � � � .���� $�|�7�D� � ��<�D��d�f�f�G�G��� � � � �D� ���� ��� � �g�s� #� #�< #�")�D� ��|�%� `��w�'�'�`�,�-^�_�_�_��|�!�/ /��<�&�&�0�0�,�-Z�[�[�[�h� � �g�g�%b�%b�%b�%b�7�=�=�?�?�%b�%b�%b�b�b� �)�)�)�)�)�)��k�)�K�7�#�c�>N�r�PQ�r�>R�:S�:S�S��,�Q�/�/� ��d�l�0�#�6�6�H�#�|�1�H�H��|�)��5�5�0�1U�V�V�V�-�#*�?�#4�#4����$�-�-�-�$-���� -���� (�2�4�4�7U�Ya�co�YH�ru�sC�DF�EF�DF�sG�YH�YH�8H� H�H�"�l� �/����4�0�0� #�A�� �%E�x�P�P�P�%(��\�\�4I�%I�.�.�D� '�� � �&'�j�j�l�l�&9�&9�%�&@�&@� �,2�K��N�N�)�&�,�*=�*=�f�*E�*E�E�E�J[�\m�Jn�Jn�E�17��Q���.�&�D�J�'9�E�E�W�E�E�E�"� #� #� #� #� #� #� #� #� #� #� #� #� #� #� #� #� #� #� #���� #� #� #� #���)�����D� �/�/�/��$�%c�em�n�n�n�$/�D�L�L�L� /����(4�G�T�=M�t�|�Oh�jn�jv�kG�(H�(H� $�D�L�*�*��g�w�/�/� /� /�/�"�D�L� �<� �� '� '��|�"�f�,�,�%1�� �"�"���$��0�0��<�'�3��K�!X�Y�Y�Y�)0�D�L�&�&�)2�D�L�&�&���$��-�-�%,�� �"�"�1�d�l�1�1�1�u�� �"�� �e�T� "� "� t��e�U�+�+� +� +�+� +� �%�!W� X� X� X��|�#�/�I��4F�4F�(�)r�s�s�s� �<� !�V� +� +��|�"�h�.�.�)2�� �&�� �$�,�-�/@�CL� M� M� M� �<� �F� *� *�$,�D�L� !� �<� �(?� ?� ?�$�$�Y]�Ye�Yn�Yn�Yn�qH�qH�&I�J�J� J� �<� !�)A� A� A�$�$�Z^�Zf�Zp�Zp�Zp�sK�sK�&L�M�M� M� �<� � &� #� � � �\� !� -� #�D�L�$8�$F� G� G� � � #��� �:>��9M�9M�d�l�N`�bs�9t�9t�6���� �D�$6� �<� &� /��^� /� /��� �+�+�A�.�.�.�.�B�B�4�>�B�B�B��� �<� �H� ,� ,�� � C� C���<�(�4�-1�\�-B�,B�D�L�)���� /� /��!%���� � � /� �\� "� *�� � 1� 1���<�(�4�,0�D�L�)���� "� "�� !�� � �$��� �4�+=�t�|�?S�� �,�d�l�.H�TX�T`�Tj�sw�s�tG������ �<� � -��,�,�.�.�D�K�K� � -��*�*�,�,�D�J� � S� �L�6�� A� A� A� S��W�X�t�,�,�8��'�3�3�3��G�G�L�/�/��7�7�%�?�@�@�@��K� �A�.�.�.��I�I�a�!6�7�7�7� 8�8�8�8�8�8�8�8�8�8�8�8����8�8�8�8�8�8�� � S� S� S�� �!D�h�PQ�R�R�R�R�R�R�R�R�R����� S���� S� Ss�� A#�#A7�6A7� B� B+�*B+�#G7�7 H�H�L4�B9L(� L4� L4�(L,�,L4�/L,�0L4�4 M(�%M(�'M(�*`9�?A `,� `9�,`0�0`9�3`0�4`9�9 a$�a�a$z )rXr�riF� dont_ignorec�b�|j}|rddlm}||��}d|_t|��S)Nr)�copyr@)r�r��ignorer0)rAr�r�r�s rBr�zLark._build_lexer�sH���_� � � #� !� !� !� !� !� !���j�)�)�J� "�J� ��*�%�%�%rDc��i|_|jjdkr�t|j|jjpt |jj|jjdko|jjdk|jj ��|_ |j � |jj ��|_|j� t|jj |j����dS)Nr�rjr�)� _callbacksrirZr4r�rWr*rQrXrR�_parse_tree_builder�create_callbackrP�updater6r��rAs rB�_prepare_callbackszLark._prepare_callbacks�s������ �<� !�X� -� -�'7��J��L�+�3�t��L�4��L�'�6�1�Z�d�l�6L�PZ�6Z��L�3� (�(�D� $�#�6�F�F�t�|�G_�`�`�D�O� ����3�D�L�4L�d�n�]�]�^�^�^�^�^rDc� �|���t|jj|jj��t |j|j|jj��}t|jj|jj|j ||j���S)Nr�) r�r5rirXrYr,r�r�rMr8r�)rA� parser_confs rBr�zLark._build_parser�s|�� ���!�!�!��� � 3�T�\�5G�H�H�H� ���T�_�d�l�>P�Q�Q� �*� �L� � �L� � �O� ��L�  � � � rDr@�exclude_optionsc�,��|jjdkrtd���|�tt g��\}}�r)�fd�|d���D��|d<tj||d�|tj ���dS)zgSaves the instance into the given file object Useful for caching and multiprocessing. rjz7Lark.save() is only implemented for the LALR(1) parser.c�$��i|] \}}|�v� ||�� Sr@r@)r��nr�r�s �rBr�zLark.save.<locals>.<dictcomp>�s*���d�d�d���1�1�Tc�Kc�Kc�q�!�Kc�Kc�KcrDri�r�r�)�protocolN) rirX�NotImplementedError�memo_serializer1r9rmr�r��HIGHEST_PROTOCOL)rAr�r�r��ms ` rBr�z Lark.save�s���� �<� �&� (� (�%�&_�`�`� `��%�%�{�D�&9�:�:���a� � e�d�d�d�d��Y��0E�0E�0G�0G�d�d�d�D��O�� �T�1�-�-�q�6�;R�S�S�S�S�S�SrDr�c�V�|�|��}|�|��S)zfLoads an instance from the given file object Useful for caching and multiprocessing. ��__new__r�)r�r��insts rBr�z Lark.load�s%�� �{�{�3�����z�z�!�}�}�rDr�r�c���tj|d|��}|jpi|_|jrtnt |_|j|_|j|_d|_ |j |_ |S)Nr�T) r+r�r]� callbacksrTr�r�r^rU�skip_validationr[)rAr�r�rir�s rB�_deserialize_lexer_confzLark._deserialize_lexer_confsj���*�4� �+=�t�D�D� �&�6�<�"� ��(/� �=�u�u�2� ��&�0� ��#*�#8� � �%)� �"�$�_� ���rDrAr�c ����t|t��r|}ntj|��}|d}|d}|sJ�t j|t td�i���t|d��}t|��tz ttj ��zr7td� t|��tz �����|�|��t�|���|_�fd�|dD��|_d|_t%|jj|jj��|�|d �|j��|_|jj|_|���d �|jD��|_t5|d �|j|j|j��|_|S) Nr�r�)r9r1riz6Some options are not allowed when loading a Parser: {}c�:��g|]}tj|�����Sr@)r9r�)r��rr�s �rB� <listcomp>zLark._load.<locals>.<listcomp>s&���G�G�G�A�d�&�q�$�/�/�G�G�GrDr�z<deserialized>rXc��i|] }|j|�� Sr@r�r�s rBr�zLark._load.<locals>.<dictcomp>%r�rD)rorlr�r�r r�r9r1r�r�rLrfr�formatr�rir�rbr5rXrYrr�r�r�r�r7r�)rAr��kwargs�d� memo_jsonr�rir�s @rBr�z Lark._loads���� �a�� � � ��A�A�� �A���A��f�I� ���y�����y� �,�Y��Va�8b�8b�df�g�g���t�I��'�'�� ��K�K�/� /�3�{�7L�3M�3M� M� K�$�%]�$�f�S��[�[�3H�%H�I�I�K�K� K����v����"�.�.�w��=�=�� �G�G�G�G��g��G�G�G�� �+����� � 3�T�\�5G�H�H�H��6�6�t�H�~�t�T�\�Z�Z�����2��� ���!�!�!�B�B�4�>�B�B�B���3� ��N� � �O� �O� �L�  � �� �� rDc �N�|�|��}|j||d�fi|��S)Nr�r)r�r�r�rrs rB�_load_from_dictzLark._load_from_dict/s5���{�{�3�����t�z�4��6�6�A�A�&�A�A�ArD�grammar_filename�rel_toc ���|r?tj�|��}tj�||��}t |d���5}||fi|��cddd��S#1swxYwYdS)a&Create an instance of Lark with the grammar given by its filename If ``rel_to`` is provided, the function will find the grammar filename in relation to it. Example: >>> Lark.open("grammar_file.lark", rel_to=__file__, parser="lalr") Lark(...) r�)�encodingN)�os�path�dirnamer�r�)r�rrri�basepathr�s rBr�z Lark.open4s��� � H��w���v�.�.�H�!�w�|�|�H�6F�G�G� � �"�V� 4� 4� 4� %���3�q�$�$�G�$�$� %� %� %� %� %� %� %� %� %� %� %� %���� %� %� %� %� %� %s� A)�)A-�0A-r��package� grammar_path� search_pathsz Sequence[str]c ���t||��}|d|��\}}|�d|��|�dg��|d�|��||fi|��S)akCreate an instance of Lark with the grammar loaded from within the package `package`. This allows grammar loading from zipapps. Imports in the grammar will use the `package` and `search_paths` provided, through `FromPackageLoader` Example: Lark.open_from_package(__name__, "example.lark", ("grammars",), parser=...) Nrbra)r%� setdefault�append)r�rrrri�package_loader� full_path�texts rB�open_from_packagezLark.open_from_packageFs���+�7�L�A�A��(�.��|�<�<�� �4����=�)�4�4�4����>�2�.�.�.����&�&�~�6�6�6��s�4�#�#�7�#�#�#rDc�L�d|j�d|jj�d|jj�d�S)Nz Lark(open(z ), parser=z, lexer=z, ...))rbrirXrYr�s rB�__repr__z Lark.__repr__Xs2���=A�=M�=M�=M�t�|�Ob�Ob�Ob�dh�dp�dv�dv�dv�w�wrDr#c��t|d��r|r|�|��}n|j}tj||��}|�d��}|jjr|jj�|��S|S)aOnly lex (and postlex) the text, without parsing it. Only relevant when lexer='basic' When dont_ignore=True, the lexer will return all tokens, even those marked for %ignore. :raises UnexpectedCharacters: In case the lexer cannot find a suitable match. rYN) �hasattrr�rYr2� from_text�lexrir[rC)rAr#r�rY� lexer_threadr<s rBr*zLark.lex\s����t�W�%�%� �� ��%�%�k�2�2�E�E��J�E�"�,�U�D�9�9� ��!�!�$�'�'�� �<� � 8��<�'�/�/��7�7� 7�� rDrtc��|j|S)z Get information about a terminal)r�)rArts rB� get_terminalzLark.get_terminalns���#�D�)�)rDrMrc�:�|j�||���S)a-Start an interactive parsing session. Parameters: text (str, optional): Text to be parsed. Required for ``resume_parse()``. start (str, optional): Start symbol Returns: A new InteractiveParser instance. See Also: ``Lark.parse()`` )rM)rX�parse_interactive)rAr#rMs rBr/zLark.parse_interactivers���{�,�,�T��,�?�?�?rD�on_errorz+Optional[Callable[[UnexpectedInput], bool]]rc�<�|j�|||���S)a�Parse the given text, according to the options provided. Parameters: text (str): Text to be parsed. start (str, optional): Required if Lark was given multiple possible start symbols (using the start option). on_error (function, optional): if provided, will be called on UnexpectedToken error. Return true to resume parsing. LALR only. See examples/advanced/error_handling.py for an example of how to use on_error. Returns: If a transformer is supplied to ``__init__``, returns whatever is the result of the transformation. Otherwise, returns a Tree instance. :raises UnexpectedInput: On a parse error, one of these sub-exceptions will rise: ``UnexpectedCharacters``, ``UnexpectedToken``, or ``UnexpectedEOF``. For convenience, these sub-exceptions also inherit from ``ParserError`` and ``LexerError``. )rMr0)rX�parse)rAr#rMr0s rBr2z Lark.parse�s!��$�{� � ��U�X� �F�F�FrD)r�r�r=N)F)r=N)r=r)r@r?)NN)*rFrGrHr�rIrJrLr/rr1rwr��__serialize_fields__rpr0r�r�r�r�r�rr�r�rrr�r r9r+rr�rr r�r$r&r r3r*r-r/r2r@rDrBr�r��s�������� � ��������� ���� ���� �L�L�L� �����+�&�&�&�&�yS�yS�yS�yS�v�4��6�K�3�3�3��7��&�&��&�z�&�&�&�&� _� _� _� _�  �  �  �  � T� T�z�#�� T�� T� T� T� T���$�r�(��"�����[���D��c��N��$�s�E�R]�_c�Rc�Ld�Gd�Be��p{��AJ������B��3��R�����@�B�B��[�B��%�%�$�r�(�%�c�%�8�C�=�%�]_�%�%�%��[�%�"�ik�hl�$�$�t�B�x�$�#�$�S�$�Xg�$�|~�$�$�$��[�$�"x�x�x�����$���%������$*��*��*�*�*�*� @� @�h�s�m� @��#�� @�Xk� @� @� @� @�G�G�#�G�h�s�m�G�Dq�G�|G�G�G�G�G�G�GrD)S�abcrrr�r�rr�r��typesr��typingrrrrr r r r r rrrrrr�parsers.lalr_interactive_parserr�treer�visitorsrr�r�typing_extensions�parser_frontendsr� exceptionsrrr�utilsrr r!r"r#r$r%r&r'r(r)r*�commonr+r,r-r.rYr/r0r1r2r3�parse_tree_builderr4r5r6r7r8r�r9rTr�r�r;rLr�r�r�r�r�r@rDrB�<module>r@s���#�#�#�#�#�#�#�#��������������������� � � � � � � � ������������������������������������2�B�B�B�B�B�B�������%�%�%�%�%�%� ��6�!�!�"�"�"�"�"�"�"�-�-�-�-�-�-�1�1�1�1�1�1�J�J�J�J�J�J�J�J�J�J�D�D�D�D�D�D�D�D�D�D�D�D�D�D�u�u�u�u�u�u�u�u�u�u�u�u�u�u�u�u�������H�H�H�H�H�H�H�H�H�H�H�H�E�E�E�E�E�E�E�E�E�E�E�E�E�E�0�0�0�0�0�0�H�H�H�H�H�H�H�H�H�H�H�H���������L�L�L��J�J�������J�J�J�����&�&�&�&�&�c�&�&�&�y�y�y�y�y�)�y�y�y�|g�g�g��<��D�� �W�T�� � � ��ZG�ZG�ZG�ZG�ZG�9�ZG�ZG�ZG�ZG�ZGs�C!�!C+�*C+
Memory