
    
`in                     6   d dl mZmZ d dlZd dlZd dlZd dlZd dlZd dlZd dl	Z	d dl
mZmZmZmZmZmZmZmZmZmZmZmZmZmZmZ erddlmZ ddlmZ ddlmZ d dl
m Z  dd	l!m"Z" dd
l#m$Z$m%Z%m&Z& ddl'm(Z(m)Z)m*Z*m+Z+ ddl,m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1 ddlm2Z2 ddl3m4Z4m5Z5m6Z6m7Z7 ddl8m9Z9m:Z:m;Z;m<Z<m=Z= ddl>m?Z? ddl!m@Z@mAZAmBZBmCZC ddlDmEZE 	 d dlFZFdZGn# eH$ r dZGY nw xY w G d de          ZI G d de(          ZJh dZKdZLdZM edd          ZN G d de(          ZOdS )     )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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    e Zd ZU edee         dee         fd            ZdZee	         e
d<   dS )PostLexstreamreturnc                     |S N )selfr9   s     ]/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/lark/lark.pyprocesszPostLex.process)   s        r=   always_acceptN)__name__
__module____qualname__r   r	   r0   r@   rB   r   str__annotations__r=   rA   r?   r8   r8   (   s\         huo (5/    ^ $&M8C=%%%%%rA   r8   c            	          e Zd ZU dZee         ed<   eed<   eed<   ded<   eeef         ed<   eed<   eeef         ed	<   eed
<   e	ed<   eed<   e
eeegef                  ed<   eed<   eed<   ded<   e
e         ed<   ded<   eeeegef         f         ed<   eed<   eed<   e
eegef                  ed<   ded<   e
e         ed<   dZereez  Zi ddddddddd	ddddddd dddddd dd d
ddddi dd!ddd"dd!g di d#Zeeef         ed$<   d%eeef         d&dfd'Zd(ed&efd)Zd(ed*ed&dfd+Zd0d&eeef         fd,Zed-eeef         d.ee	eeef         f         d&d fd/            ZdS )1LarkOptionsz$Specifies the options for Lark

    startdebugstrictzOptional[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   )rR   r[   r\   r^   r_   _plugins	_defaultsoptions_dictr:   c                    t          |          }i }| j                                        D ]N\  }}||v r>|                    |          }t	          |t
                    r|dvrt          |          }n|}|||<   Ot	          |d         t                    r|d         g|d<   || j        d<   t          | j	        d           | j	        dk    r| j
        rt          d          |r$t          d|                                z            d S )N)rP   r[   rN   rJ   options)r`   lalrcykNr`   zCannot 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)zUnknown options: %s)dictrc   itemspop
isinstanceboolrF   __dict__r   rU   rM   r   keys)r>   rd   orf   namedefaultvalues          r?   __init__zLarkOptions.__init__   s3   !^1133 	" 	"MD'qyydgt,, (=j1j1j KKE!GDMMgg&,, 	2 ' 01GG#*i  	dk#BCCC;(""t'7"$ &A B B B  	G$%:QVVXX%EFFF	G 	GrA   rq   c                 l    	 | j         d         |         S # t          $ r}t          |          d }~ww xY w)Nrf   )rn   KeyErrorAttributeError)r>   rq   es      r?   __getattr__zLarkOptions.__getattr__   sF    	$=+D11 	$ 	$ 	$ ###	$s    
3.3rs   c                 j    t          || j                                        d           || j        |<   d S )Nz,%r isn't a valid option. Expected one of: %s)r   rf   ro   )r>   rq   rs   s      r?   __setattr__zLarkOptions.__setattr__   s5    dDL--//1_```"TrA   c                     | j         S r<   rf   )r>   memos     r?   	serializezLarkOptions.serialize   s
    |rA   datar~   c                      | |          S r<   r=   )clsr   r~   s      r?   deserializezLarkOptions.deserialize   s    s4yyrA   r<   )rC   rD   rE   __doc__r   rF   rG   rm   r   intr   r
   r   r*   r+   r8   r   r0   r.   OPTIONS_DOCrc   rt   ry   r{   r   classmethodr6   r   r=   rA   r?   rI   rI   /   s          9KKKLLL((((tSy))))sKKK3+s"234444AAAAg====#x778888OOOX{m[&@ABBBBiiii#LKZ  ;!!%! 	5! 	d	!
 	! 	4! 	(! 	! 	t! 	! 	F! 	V! 	! 	u! 	2!  	d!!" 	$#!$ /! ! !ItCH~   4GT#s(^ G G G G G:$ $ $ $ $ $# #C #D # # # # S#X     tCH~ T#u[RVEV?W:W5X ]j    [  rA   rI   >
   rK   rQ   rX   rb   r[   rT   rM   rR   rZ   rN   )ra   normalinvertN)ra   resolveexplicitforest_TLark)boundc                   z   e Zd ZU dZeed<   eed<   ded<   eed<   eed<   ded	<   ee	         ed
<   d7dZ
eredej        z   z  ZdZd8dedefdZd9dZd:dZd;dee         ddfdZedee         defd            Zdeeef         deeee	ef         f         dedefdZdededefd Zed!             Zed<dee         d"ed#e e         defd$            Z!ed%gfdee         d&ed'ed(d)def
d*            Z"d+ Z#d8d,edede$e%         fd-Z&d.ede	fd/Z'd=d,e e         d0e e         dd1fd2Z(d=d,ed0e e         d3d4dd5fd6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(...)
    r_   source_grammarr#   grammarrf   rV   r   rU   	terminalsUnion[Grammar, str, IO[str]]r:   Nc           
         t          |          | _        | j        j        }|rt          rt          }nt	          d          t
          }| j        j        %	 |j        | _        n(# t          $ r
 d| _        Y nw xY w| j        j        | _        	 |j	        } |            }n# t          $ r Y nw xY wd }d }t          |t                    r|| _        | j        j        r#|                                st          d          | j        j        re| j        j        dk    rt          d          dd                    fd|                                D                       }d	d
lm}	 ||z   |	z   t          t,          j        d d                   z   }
t1          |
          }t          | j        j        t                    r| j        j        }nt| j        j        durt          d          	 t3          j                    }n# t6          $ r d}Y nw xY wt9          j                    d||gt,          j        d d         R z  z   }| j        }	 t=          j        |d          5 }tA          j!        d|           tE          |          tF          z
  D ]}||= |$                                %                    d          }tM          j'        |          }||(                    d          k    r?tS          |          r0tM          j'        |          } | j*        |fi | 	 d d d            d S d d d            n# 1 swxY w Y   n7# tV          $ r Y n+t6          $ r tA          j,        d|           || _        Y nw xY wt[          || j        | j        j.        | j        j/                  \  | _0        }nt          |tb                    sJ || _0        | j        j2        dk    r| j        j        dk    rd| j        _2        n{| j        j        dk    r:| j        j3        !tA          j4        d           d| j        _2        n>d| j        _2        n1| j        j        dk    rd| j        _2        nJ | j        j                    | j        j2        }t          |tj                    rtm          |tn                    sJ n/tq          |d           | j        j3        d|v rt          d          | j        j9        dk    r| j        j        dk    rd| j        _9        ntq          | j        j        d d!           | j        j:        dk    rd"| j        _:        | j        j:        tv          vr$t          d#| j        j:        d$tv                    | j        j9        tx          vr$t          d%| j        j9        d$tx                    | j        j        d&}n9| j        j3        tE          | j        j3        j=                  }ntE                      }| j0        >                    | j        j?        |          \  | _@        | _A        | _B        | j        jC        r$| j@        D ]}| j        C                    |           d' | j@        D             | _D        | j        j:        d(k    rE| jA        D ]%}|j        j:        |j        j:         |j        _:        &| j@        D ]}|j:         |_:        n?| j        j:        3| jA        D ]}|j        j:        d |j        _:        | j@        D ]	}d)|_:        
t          | j@        || jB        | j        j3        | j        jF        | j        jG        | j        j        | j        jH        *          | _I        | j        j        r| J                                | _        n|r| K                                | _2        |rtA          j!        d+|           	 t=          j        |d,          5 }|J |L                    |(                    d          dz              tM          jM        ||           | N                    |tF                     d d d            d S # 1 swxY w Y   d S # t          $ r!}tA          j,        d-||           Y d }~d S d }~ww xY wd S ).Nz?`regex` module must be installed if calling `Lark(regex=True)`.z<string>z/Grammar must be ascii only, when use_bytes=Truerg   z+cache only works with parser='lalr' for now)rM   rX   rZ   r]   rb    c              3   J   K   | ]\  }}|v	|t          |          z   V  d S r<   )rF   ).0kv
unhashables      r?   	<genexpr>z Lark.__init__.<locals>.<genexpr>7  s<      %b%b41aaWaNaNaaAhNaNaNaNa%b%brA   r   )__version__   Tz"cache argument must be bool or strunknownz/.lark_cache_%s_%s_%s_%s.tmprbzLoading grammar from cache: %s   
utf8z<Failed to load Lark from cache: %r. We will try to carry on.ra   
contextualr`   z~postlex can't be used with the dynamic lexer, so we use 'basic' instead. Consider using lalr with contextual instead of earleybasicdynamicrh   F)r   r   r   dynamic_completezGCan't use postlex with a dynamic lexer. Use basic or contextual insteadr   )r`   rh   zG%r doesn't support disambiguation. Use one of these parsers instead: %sr   zinvalid priority option: z. Must be one of zinvalid ambiguity option: *c                     i | ]
}|j         |S r=   rq   r   ts     r?   
<dictcomp>z!Lark.__init__.<locals>.<dictcomp>      BBBaBBBrA   r   r   )r[   rL   zSaving grammar to cache: %swbz!Failed to save Lark to cache: %r.)PrI   rf   rQ   
_has_regexImportErrorrer_   rq   rw   readrl   rF   r   r[   isasciir   rP   rU   joinrj   r   r   sysversion_infor&   getpassgetuser	Exceptiontempfile
gettempdirr   openr    rK   set_LOAD_ALLOWED_OPTIONSreadlinerstrippickleloadencoder$   _loadFileNotFoundError	exceptionr!   r^   rS   r   r#   rV   rX   infotype
issubclassr,   r   rW   rY   _VALID_PRIORITY_OPTIONS_VALID_AMBIGUITY_OPTIONSrB   compilerJ   r   rulesignore_tokensr]   _terminals_dictr(   rZ   rR   rL   
lexer_conf_build_parser_build_lexerwritedumpsaveIOError)r>   r   rf   	use_regex	re_moduler   cache_fncache_sha256options_strr   susernameold_optionsfrq   file_sha256cached_used_filescached_parser_data
used_filesrV   terminals_to_keepr   ruletermrx   r   s                            @r?   rt   zLark.__init__  s
   "7++ L&	 	 e!		!"cdddI <#+.#*<  ! . . .#-   .  $|7D	<D dffGG  	 	 	D	
 gs## <	#")D|% `(( `,-^___|! //<&&00,-Z[[[h
 gg%b%b%b%b7==??%b%b%bbb))))))k)K7#c>NrPQr>R:S:SS,Q//dl0#66 H#|1HH|)5501UVVV-#*?#4#4$ - - - $-	-  (2447UYaco  YHru  sC  DF  EF  DF  sG  YH  YH  8H   HH"l/400 
#A%ExPPP%(\\4I%I . .D '&'jjll&9&9%&@&@,2KNN)&,*=*=f*E*EEEJ[\mJnJnE17Q.&DJ'9EEWEEE"
# 
# 
# 
# 
# 
# 
# 
# 
# 
# 
# 
# 
# 
# 
# 
# 
# 
# 
# 
# 
# 
# 
# )   D  / / /$%cemnnn $/DLLL/ (4GT=Mt|Ohjnjv  kG  (H  (H$DL**gw/////"DL <''|"f,,%1""$00<'3K !X Y Y Y)0DL&&)2DL&&$--%,""1dl111u"eT"" 	teU++++++%!WXXX|#/I4F4F()rsss<!V++|"h..)2&$,-/@  CL  M  M  M< F**$,DL!< (???$$Y]YeYnYnYn  qH  qH  &I  J  J  J<!)AAA$$Z^ZfZpZpZp  sK  sK  &L  M  M  M<& #\!- #DL$8$F G G # :>9M9MdlN`bs9t9t6
D$6<& 	/^ / /++A....BB4>BBB < H,,
 C C<(4-1\-B,BDL) / /!%/
 \"*
 1 1<(4,0DL) " " ! $	4+=t|?S,dl.HTXT`Tjsws  tG  
 < 	-,,..DKK 	-**,,DJ 		SL6AAASWXt,, 8'333GGL//77%?@@@K
A...IIa!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 !DhPQRRRRRRRRRS		S 		Ss   A# #A76A7B 
B+*B+(G< <H
HL9 B9L-L9 !L9 -L11L9 4L15L9 9
M-%M-,M-/`> A `1$`> 1`55`> 8`59`> >
a)a$$a)z

)rU   r   rf   Fdont_ignorec                 b    | j         }|rddlm}  ||          }d|_        t          |          S )Nr   )copyr=   )r   r   ignorer-   )r>   r   r   r   s       r?   r   zLark._build_lexer  sH    _
 	#!!!!!!j))J "J*%%%rA   c                    i | _         | j        j        dk    rt          | j        | j        j        pt          | j        j        | j        j        dk    o| j        j        dk    | j        j	                  | _
        | j
                            | j        j                  | _         | j                             t          | j        j        | j                             d S )Nr   rg   r   )
_callbacksrf   rW   r1   r   rT   r'   rN   rU   rO   _parse_tree_buildercreate_callbackrM   updater3   r   r>   s    r?   _prepare_callbackszLark._prepare_callbacks  s    <!X--'7JL+3tL4L'61Zdl6LPZ6ZL3( (D$ #6FFt|G_``DO3DL4Ldn]]^^^^^rA   c                     |                                   t          | j        j        | j        j                   t          | j        | j        | j        j                  }t          | j        j        | j        j        | j
        || j                  S )Nr}   )r   r2   rf   rU   rV   r)   r   r   rJ   r5   r   )r>   parser_confs     r?   r   zLark._build_parser  s|    !!! 3T\5GHHH T_dl>PQQ*LLOL
 
 
 	
rA   r=   exclude_optionsc                 ,   | j         j        dk    rt          d          |                     t          t
          g          \  }}r)fd|d                                         D             |d<   t          j        ||d|t          j	                   dS )zgSaves the instance into the given file object

        Useful for caching and multiprocessing.
        rg   z7Lark.save() is only implemented for the LALR(1) parser.c                 $    i | ]\  }}|v	||S r=   r=   )r   nr   r   s      r?   r   zLark.save.<locals>.<dictcomp>  s*    ddd11TcKcKcq!KcKcKcrA   rf   r   r~   )protocolN)
rf   rU   NotImplementedErrormemo_serializer.   r6   rj   r   r   HIGHEST_PROTOCOL)r>   r   r   r   ms     `  r?   r   z	Lark.save  s    
 <&((%&_```%%{D&9::a 	eddddY0E0E0G0GdddDOT1--q6;RSSSSSSrA   r   c                 V    |                      |           }|                    |          S )zfLoads an instance from the given file object

        Useful for caching and multiprocessing.
        __new__r   )r   r   insts      r?   r   z	Lark.load  s%     {{3zz!}}rA   r   r~   c                     t          j        |d         |          }|j        pi |_        |j        rt          nt
          |_        |j        |_        |j        |_        d|_	        |j
        |_
        |S )Nr   T)r(   r   rZ   	callbacksrQ   r   r   r[   rR   skip_validationrX   )r>   r   r~   rf   r   s        r?   _deserialize_lexer_confzLark._deserialize_lexer_conf  sj    *4+=tDD
&6<"
(/=uu2
&0
#*#8
 %)
"$_
rA   r>   r   c                    t          |t                    r|}nt          j        |          }|d         }|d         }|sJ t	          j        |t          t          di           t          |d                   }t          |          t          z
  t          t          j                  z  r7t          d                    t          |          t          z
                      |                    |           t                              |          | _        fd|d         D             | _        d| _        t%          | j        j        | j        j                   |                     |d	         | j                  | _        | j        j        | _        |                                  d
 | j        D             | _        t5          |d	         | j        | j        | j                  | _        | S )Nr~   r   )r6   r.   rf   z6Some options are not allowed when loading a Parser: {}c                 :    g | ]}t          j        |          S r=   )r6   r   )r   rr~   s     r?   
<listcomp>zLark._load.<locals>.<listcomp>  s&    GGGAd&q$//GGGrA   r   z<deserialized>rU   c                     i | ]
}|j         |S r=   r   r   s     r?   r   zLark._load.<locals>.<dictcomp>"  r   rA   )rl   ri   r   r   r   r   r6   r.   r   r   rI   rc   r   formatr   rf   r   r_   r2   rU   rV   r  r   r   r   r   r4   r   )r>   r   kwargsd	memo_jsonr   rf   r~   s          @r?   r   z
Lark._load  s   a 	AAAAfI	yy ,YVa8b8bdfggtI''KK//3{7L3M3MM 	K$%]$fS[[3H%HIIK K Kv"..w==GGGGgGGG
+ 3T\5GHHH66tH~tT\ZZ2!!!BB4>BBB3NOOL
 
 rA   c                 N    |                      |           } |j        ||dfi |S )Nr   r   )r   r   r~   r  r  s        r?   _load_from_dictzLark._load_from_dict,  s5    {{3tz466AA&AAArA   grammar_filenamerel_toc                     |r?t           j                            |          }t           j                            ||          }t	          |d          5 } | |fi |cddd           S # 1 swxY w Y   dS )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   r  r  rf   basepathr   s         r?   r   z	Lark.open1  s      	Hwv..H!w||H6FGG"V444 	%3q$$G$$	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	%s   	A))A-0A-r   packagegrammar_pathsearch_pathszSequence[str]c                     t          ||          } |d|          \  }}|                    d|           |                    dg            |d                             |            | |fi |S )ak  Create 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=...)
        Nr_   r^   )r"   
setdefaultappend)r   r  r  r  rf   package_loader	full_pathtexts           r?   open_from_packagezLark.open_from_packageC  s     +7LAA(.|<<	4=)444>2...&&~666s4##7###rA   c                 L    d| j         d| j        j        d| j        j        dS )Nz
Lark(open(z
), parser=z, lexer=z, ...))r_   rf   rU   rV   r   s    r?   __repr__zLark.__repr__U  s2     =A=M=M=Mt|ObObObdhdpdvdvdvwwrA   r!  c                    t          | d          r|r|                     |          }n| j        }t          j        ||          }|                    d          }| j        j        r| j        j                            |          S |S )a  Only 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.
        rV   N)	hasattrr   rV   r/   	from_textlexrf   rX   r@   )r>   r!  r   rV   lexer_threadr9   s         r?   r(  zLark.lexY  s     tW%% 	 	%%k22EEJE",UD99!!$''< 	8<'//777rA   rq   c                     | j         |         S )z Get information about a terminal)r   )r>   rq   s     r?   get_terminalzLark.get_terminalk  s    #D))rA   rJ   r   c                 :    | 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()``
        )rJ   )rU   parse_interactive)r>   r!  rJ   s      r?   r-  zLark.parse_interactiveo  s     {,,T,???rA   on_errorz+Optional[Callable[[UnexpectedInput], bool]]r   c                 <    | 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``.

        )rJ   r.  )rU   parse)r>   r!  rJ   r.  s       r?   r0  z
Lark.parse}  s!    $ {  UX FFFrA   )r   r   r:   N)F)r:   N)r:   r   )r=   r<   )NN)*rC   rD   rE   r   rF   rG   rI   r,   r   r.   rt   r   __serialize_fields__rm   r-   r   r   r   r   r   r   r   r   r   r   r   r   r6   r(   r  r   r  r   r   r"  r$  r	   r0   r(  r+  r-  r0  r=   rA   r?   r   r      s          LLL+&&&&yS yS yS ySv  46K3337& & &z & & & &_ _ _ _

 

 

 


T 
Tz# 
T 
T 
T 
T 
T $r( "    [DcN $sER]_cRcLdGdBe p{   AJ    B 3 R    @ B B [B % %$r( %c %8C= %]_ % % % [%" ikhl $ $tBx $# $S $Xg $|~ $ $ $ [$"x x x  $ %    $* * * * * *@ @hsm @# @Xk @ @ @ @G G# Ghsm GDq G  |G G G G G G GrA   )Pabcr   r   r   r   r  r   r   typesr   typingr   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   parsers.lalr_interactive_parserr   treer   visitorsr   r   parser_frontendsr   
exceptionsr   r   r   utilsr   r   r   r    r!   r"   r#   r$   r%   r&   r'   commonr(   r)   r*   r+   rV   r,   r-   r.   r/   r0   parse_tree_builderr1   r2   r3   r4   r5   r   r6   rQ   r   r   r8   rI   r   r   r   r   r   r=   rA   r?   <module>r=     s   # # # # # # # #                				                                   2BBBBBB%%%%%%111111 J J J J J J J J J J ; ; ; ; ; ; ; ; ; ; ; ; 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      LLLJJ   JJJ& & & & &c & & &y y y y y) y y y| g  g  g < D  WT   ZG ZG ZG ZG ZG9 ZG ZG ZG ZG ZGs   C CC