
    ^h5s                     $   S SK JrJr  S SKrS SKrS SKrS SKrS SKrS SKrS SK	r	S SK
JrJrJrJrJrJrJrJrJrJrJrJrJrJrJr  \(       a  SSKJr  SSKJr  SSKJr  S SK
J r   SS	K!J"r"  SS
K#J$r$J%r%J&r&  SSK'J(r(J)r)J*r*J+r+J,r,  SSK-J-r-J.r.J/r/J0r0J1r1J2r2  SSKJ3r3  SSK4J5r5J6r6J7r7J8r8  SSK9J:r:J;r;J<r<J=r=J>r>  SSK?J@r@  SSK!JArAJBrBJCrCJDrD  SSKEJFrF   S SKGrGSrH " S S\5      rJ " S S\(5      rK1 SkrLSrMSrN\" SSS9rO " S S\(5      rPg! \I a    SrH N;f = f)     )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TextOrSlice)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                   R    \ rS rSr% \S\\   S\\   4S j5       rSr\	\
   \S'   Srg)PostLex(   streamreturnc                     U$ N )selfr;   s     C/home/james-whalen/.local/lib/python3.13/site-packages/lark/lark.pyprocessPostLex.process)   s        r?   always_acceptN)__name__
__module____qualname____firstlineno__r   r	   r1   rB   rE   r   str__annotations____static_attributes__r?   rD   rA   r9   r9   (   s:    huo (5/   $&M8C=%rD   r9   c            	          \ rS rSr% Sr\\   \S'   \\S'   \\S'   S\S'   \	\\4   \S'   \\S	'   \	\\4   \S
'   \\S'   \\S'   \
\S'   \\S'   \\\\/\4      \S'   \\S'   \\S'   S\S'   \\   \S'   S\S'   \\\\/\4   4   \S'   \\S'   \\S'   \\\/\4      \S'   S\S'   \\   \S'   Sr\(       a  \\-  r0 SS_SS_SS_SS _S
S_SS_SS _SS!_SS"_SS _SS_SS"_SS"_SS_SS_S0 _S	S#_S S$SS#/ S 0 S%.Er\\\4   \S&'   S'\\\4   S(S 4S) jrS*\S(\4S+ jrS*\S,\S(S 4S- jrS3S(\\\4   4S. jjr\S/\\\4   S0\\
\	\\4   4   S(S 4S1 j5       rS2rg )4LarkOptions/   z$Specifies the options for Lark

    startdebugstrictzOptional[Transformer]transformerpropagate_positionsmaybe_placeholderscachecache_grammar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_patha?  
    **===  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
    cache_grammar
            For use with ``cache`` option. When ``True``, the unanalyzed grammar is also included in the cache.
            Useful for classes that require the ``Lark.grammar`` to be present (e.g. Reconstructor).
            (default= ``False``)
    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   )rd   rY   rb   rc   re   rf   _plugins	_defaultsoptions_dictr<   c                 l   [        U5      n0 nU R                  R                  5        HH  u  pEXB;   a8  UR                  U5      n[	        U[
        5      (       a  US;  a  [        U5      nOUnXcU'   MJ     [	        US   [        5      (       a	  US   /US'   X0R                  S'   [        U R                  S5        U R                  S:X  a  U R                  (       a  [        S5      eU R                  (       a  U R                  (       d  [        S5      eU(       a  [        SUR                  5       -  5      eg )	N)rV   rb   rT   rP   options)rg   lalrcykNrg   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)z2cache_grammar cannot be set when cache is disabledzUnknown options: %s)dictrj   itemspop
isinstanceboolrJ   __dict__r   r\   rS   r   rW   rV   keys)r@   rk   orm   namedefaultvalues          rA   __init__LarkOptions.__init__   s   !^^113MDydgt,,=j1j KE!DM 4 gg&,, ' 01GG#*i  	dkk#BC;;("t'7'7$ &A B B djj$%YZZ$%:QVVX%EFF rD   rx   c                 b     U R                   S   U   $ ! [         a  n[        U5      eS nAff = f)Nrm   )ru   KeyErrorAttributeError)r@   rx   es      rA   __getattr__LarkOptions.__getattr__   s6    	$==+D11 	$ ##	$s    
.).rz   c                 h    [        XR                  R                  5       S5        X R                  U'   g )Nz,%r isn't a valid option. Expected one of: %s)r   rm   rv   )r@   rx   rz   s      rA   __setattr__LarkOptions.__setattr__   s&    dLL--/1_`"TrD   c                     U R                   $ r>   rm   )r@   memos     rA   	serializeLarkOptions.serialize   s    ||rD   datar   c                     U " U5      $ r>   r?   )clsr   r   s      rA   deserializeLarkOptions.deserialize   s    4yrD   r?   r>   )rF   rG   rH   rI   __doc__r   rJ   rK   rt   r   intr   r
   r   r+   r,   r9   r   r1   r/   OPTIONS_DOCrj   r{   r   r   r   classmethodr7   r   rL   r?   rD   rA   rN   rN   /   s    9KL((tSy))sK3+s"2344AAg==#x7788OX{m[&@ABBii#PKb ;!!%! 	5! 	d	!
 	! 	! 	4! 	(! 	! 	t! 	! 	F! 	V! 	! 	u!  	2!!" 	d#!$ 1!ItCH~ 6GT#s(^ G G@$ $ $# #C #D #S#X  tCH~ T#u[RVEV?W:W5X ]j  rD   rN   >
   rQ   rX   r_   ri   rb   r[   rS   rY   ra   rT   )rh   normalinvertN)rh   resolveexplicitforest_TLark)boundc                   \   \ rS rSr% Sr\\S'   \\S'   S\S'   \\S'   \\S'   S	\S
'   \	\
   \S'   / SQrS6S jr\(       a  \S\R                  -   -  rS7S\S\4S jjrS8S jrS9S jrS:S\	\   SS4S jjr\S\\   S\4S j5       rS\\\4   S\\\\
\4   4   S\S\4S jrS\S\S\4S jr\S 5       r \S;S\\   S \S!\!\   S\4S" jj5       r"\S#/4S\\   S$\S%\S&S'S\4
S( jj5       r#S) r$S7S*\%S\S\&\'   4S+ jjr(S,\S\
4S- jr)S<S*\!\%   S.\!\   SS/4S0 jjr*S<S*\%S.\!\   S1S2SS34S4 jjr+S5r,g)=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(...)
rf   source_grammarr$   grammarrm   r]   r   r\   	terminals)r\   rulesrm   r<   Nc                   ^ [        U5      U l        U R                  R                  (       a  U R                  S/-   U l        U R                  R                  nU(       a  [
        (       a  [        nO[        S5      e[        nU R                  R                  c   UR                  U l        OU R                  R                  U l         UR                  nU" 5       nS nS n[        U[        5      (       Ga  Xl        U R                  R                  (       a   UR!                  5       (       d  [#        S5      eU R                  R$                  (       Ga8  U R                  R&                  S:w  a  [#        S5      eSmSR)                  U4S	 jUR+                  5        5       5      nS
SKJn	  X-   U	-   [        [0        R2                  S S 5      -   n
[5        U
5      n[        U R                  R$                  [        5      (       a  U R                  R$                  nOU R                  R$                  SLa  [#        S5      e [6        R8                  " 5       n[<        R>                  " 5       SU R                  R                  (       a  SOSX/[0        R2                  S S Q7-  -   nU R                  n [@        RB                  " US5       n[D        RF                  " SU5        [I        U5      [J        -
   H  nX.	 M     URM                  5       RO                  S5      n[P        RR                  " U5      nXRU                  S5      :X  aC  [W        U5      (       a3  [P        RR                  " U5      nU RX                  " U40 UD6   S S S 5        g S S S 5        [_        XR                  U R                  R`                  U R                  Rb                  5      u  U l2        nO[        U[f        5      (       d   eXl2        U R                  Rh                  S:X  a  U R                  R&                  S:X  a  SU R                  l4        OU R                  R&                  S:X  aQ  U R                  Rj                  b(  [D        Rl                  " S5        SU R                  l4        OYSU R                  l4        OGU R                  R&                  S:X  a  SU R                  l4        O U R                  R&                  5       eU R                  Rh                  n[        U[n        5      (       a  [q        U[r        5      (       d   eO4[u        US5        U R                  Rj                  b  SU;   a  [#        S 5      eU R                  Rv                  S:X  a,  U R                  R&                  S:X  a  S!U R                  l;        O![u        U R                  R&                  S"S#5        U R                  Rx                  S:X  a  S$U R                  l<        U R                  Rx                  [z        ;  a+  [#        S%U R                  Rx                  < S&[z        < 35      eU R                  Rv                  [|        ;  a+  [#        S'U R                  Rv                  < S&[|        < 35      eU R                  R&                  c  S(nOKU R                  Rj                  b*  [I        U R                  Rj                  R~                  5      nO
[I        5       nU Rd                  R                  U R                  R                  U5      u  U lB        U lC        U lD        U R                  R                  (       a.  U R                   H  nU R                  R                  U5        M      U R                   Vs0 s H  nUR                  U_M     snU lF        U R                  Rx                  S):X  ax  U R                   HB  nUR                  Rx                  c  M  UR                  Rx                  * UR                  l<        MD     U R                   H  nURx                  * Ul<        M     OnU R                  Rx                  cW  U R                   H-  nUR                  Rx                  c  M  S UR                  l<        M/     U R                   H
  nS*Ul<        M     [        U R                  X@R                  U R                  Rj                  U R                  R                  U R                  R                  U R                  R                  U R                  R                  S+9U lK        U R                  R&                  (       a  U R                  5       U l        OU(       a  U R                  5       U l4        U(       a  [D        RF                  " S,U5         [@        RB                  " US-5       nUc   eUR                  URU                  S5      S-   5        [P        R                  " WU5        U R                  U[J        5        S S S 5        g g ! [         a    SU l         G	N\f = f! [         a     G	NYf = f! [:         a    Sn GNf = f! , (       d  f       GN= f! [Z         a     GN[:         a!    [D        R\                  " SU5        Xl         GN	f = fs  snf ! , (       d  f       g = f! [         a"  n[D        R\                  " S.UU5         S nAg S nAff = f)/Nr   z?`regex` module must be installed if calling `Lark(regex=True)`.z<string>z/Grammar must be ascii only, when use_bytes=Truern   z+cache only works with parser='lalr' for now)rS   r_   ra   rd   ri    c              3   T   >#    U  H  u  pUT;  d  M  U[        U5      -   v   M     g 7fr>   )rJ   ).0kv
unhashables      rA   	<genexpr> Lark.__init__.<locals>.<genexpr>F  s%     %b?41aWaNahaAh?s   ((r   )__version__   Tz"cache argument must be bool or strunknownz/.lark_%s_%s_%s_%s_%s.tmprW   rV   rbzLoading grammar from cache: %s   
utf8z<Failed to load Lark from cache: %r. We will try to carry on.rh   
contextualrg   z~postlex can't be used with the dynamic lexer, so we use 'basic' instead. Consider using lalr with contextual instead of earleybasicdynamicro   )r   r   r   dynamic_completezGCan't use postlex with a dynamic lexer. Use basic or contextual insteadr   )rg   ro   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: *r   r   )rb   rR   zSaving grammar to cache: %swbz!Failed to save Lark to cache: %r.)RrN   rm   rW   __serialize_fields__rX   
_has_regexImportErrorrerf   rx   r   readrs   rJ   r   rb   isasciir   rV   r\   joinrq   r   r   sysversion_infor'   getpassgetuser	Exceptiontempfile
gettempdirr   openr    rQ   set_LOAD_ALLOWED_OPTIONSreadlinerstrippickleloadencoder%   _loadFileNotFoundError	exceptionr"   re   rZ   r   r$   r]   r_   infotype
issubclassr-   r   r^   r`   _VALID_PRIORITY_OPTIONS_VALID_AMBIGUITY_OPTIONSrE   compilerP   r   r   ignore_tokensrd   _terminals_dictr)   ra   rY   rR   
lexer_conf_build_parser_build_lexerwritedumpsaveIOError)r@   r   rm   	use_regex	re_moduler   cache_fncache_sha256options_strr   susernameold_optionsfrx   file_sha256cached_used_filescached_parser_data
used_filesr]   terminals_to_keeptruletermr   r   s                            @rA   r{   Lark.__init__  s   "7+ <<%%(,(A(AYK(OD% LL&&	z!	!"cddI <<##+.#*<<   $||77D	<<D fGgs##")||%%((,-^__||!!!<<&&&0,-Z[[h
 gg%b7==?%bb))K7#c>N>NrPQ>R:SS,Q/dll00#66#||11H||))501UVV-#*??#4  (2247R+/<<+E+E7T\VCmpm}m}  A  @A  nBVC 8C  CH #ll/40A%ExP%(\4I%ID ' &J&'jjl&9&9%&@,2KKN)&*=*=f*EEJ[\mJnJn17Q. JJ'9EWE" 100. (4G=M=Mt||OhOhjnjvjv  kG  kG  (H$DL*gw////"L <<'||""f,%1"$$0<<''3KK !X Y)0DLL&)2DLL&$$-%,"1dll111u""eT""eU++++%!WX||##/I4F()rss<<!!V+||""h.)2&$,,--/@  CL  M<<  F*$,DLL!<<  (??$Y]YeYeYnYn  qH  &I  J  J<<!!)AA$Z^ZfZfZpZp  sK  &L  M  M<<& #\\!!- #DLL$8$8$F$F G # :>9M9MdllN`N`bs9t6
D$6<<&&^^++A. $ 48>>B>a	>B <<  H,

<<((4-1\\-B-B,BDLL) # !% '
 \\""*

<<((4,0DLL) #  ! ' $	+=+=t||?S?S,,dll.H.HTXT`T`TjTjswss  tG  tG
 <<,,.DK**,DJLL6ASWWXt,'333GGL//7%?@KK
A.IIa!67	 -, A " .#- .  		> % - $-	- 10 )   /$$%cemn $/L/B  CB -,
  S  !DhPQRRSs   h h' <h8 ,i B6i9i i jj- /Ajj- h$#h$'
h54h58ii
ii i 
j*&jj
j*&j- *j- -
k7kkz

dont_ignorec                 h    U R                   nU(       a  SSKJn  U" U5      nSUl        [        U5      $ )Nr   )copyr?   )r   r   ignorer.   )r@   r   r   r   s       rA   r   Lark._build_lexer  s.    __
!j)J "J*%%rD   c                 p   0 U l         U R                  R                  S:w  a  [        U R                  U R                  R
                  =(       d    [        U R                  R                  U R                  R                  S:g  =(       a    U R                  R                  S:H  U R                  R                  5      U l
        U R                  R                  U R                  R                  5      U l         U R                   R                  [        U R                  R                  U R                  5      5        g )Nr   rn   r   )
_callbacksrm   r^   r2   r   r[   r(   rT   r\   rU   _parse_tree_buildercreate_callbackrS   updater4   r   r@   s    rA   _prepare_callbacksLark._prepare_callbacks  s    <<!!X-'7JJLL++3tLL44LL''61Zdll6L6LPZ6ZLL33(D$ #66FFt||G_G_`DO3DLL4L4Ldnn]^rD   c                    U R                  5         [        U R                  R                  U R                  R                  5        [        U R                  U R                  U R                  R                  5      n[        U R                  R                  U R                  R                  U R                  UU R                  S9$ )Nr   )r   r3   rm   r\   r]   r*   r   r   rP   r6   r   )r@   parser_confs     rA   r   Lark._build_parser  s    ! 3 3T\\5G5GH T__dll>P>PQ*LLLLOOLL
 	
rD   exclude_optionsc                 R   U R                   R                  S:w  a  [        S5      eU R                  [        [
        /5      u  p4U(       a2  US   R                  5        VVs0 s H  u  pVXR;  d  M  XV_M     snnUS'   [        R                  " X4S.U[        R                  S9  gs  snnf )zWSaves the instance into the given file object

Useful for caching and multiprocessing.
rn   z7Lark.save() is only implemented for the LALR(1) parser.rm   r   r   )protocolN)
rm   r\   NotImplementedErrormemo_serializer/   r7   rq   r   r   HIGHEST_PROTOCOL)r@   r   r  r   mnr   s          rA   r   	Lark.save  s    
 <<&(%&_``%%{D&9:04Y0E0E0Gd0G1Kctqt0GdDOT-q6;R;RS es    B#/B#r   c                 F    U R                  U 5      nUR                  U5      $ )zVLoads an instance from the given file object

Useful for caching and multiprocessing.
__new__r   )r   r   insts      rA   r   	Lark.load  s      {{3zz!}rD   r   r   c                 &   [         R                  " US   U5      nUR                  =(       d    0 Ul        UR                  (       a  [        O[
        Ul        UR                  Ul        UR                  Ul        SUl	        UR                  Ul
        U$ )Nr   T)r)   r   ra   	callbacksrX   r   r   rb   rY   skip_validationr_   )r@   r   r   rm   r   s        rA   _deserialize_lexer_confLark._deserialize_lexer_conf  sr    **4+=tD
&66<"
(/u2
&00
#*#8#8
 %)
"$__
rD   r@   r   c                    [        U[        5      (       a  UnO[        R                  " U5      nUS   nUS   nU(       d   e[        R
                  " U[        [        S.0 5      nSU;   a  [        R
                  " US   U5      U l	        [        US   5      n[        U5      [        -
  [        [        R                  5      -  (       a*  [        SR                  [        U5      [        -
  5      5      eUR!                  U5        [        R                  Xv5      U l        US    Vs/ s H  n[        R
                  " X5      PM     snU l        SU l        [)        U R"                  R*                  U R"                  R,                  5        U R/                  US	   X`R"                  5      U l        U R0                  R2                  U l        U R5                  5         U R2                   V	s0 s H  oR6                  U	_M     sn	U l        [;        US	   UU R0                  U R<                  U R"                  5      U l        U $ s  snf s  sn	f )
Nr   r   )r7   r/   r   rm   z6Some options are not allowed when loading a Parser: {}r   z<deserialized>r\   )rs   rp   r   r   r   r   r7   r/   r$   r   r   r   rN   rj   r   formatr   rm   r   rf   r3   r\   r]   r  r   r   r   rx   r   r5   r   )
r@   r   kwargsd	memo_jsonr   r   rm   rr   s
             rA   r   
Lark._load  s   aAAAfI	yy ,,YVa8bdfg"..tIEDLtI'K//3{7L7L3MM$%]$fS[3H%HIK Kv"..w=9=gGAd&&q/G
+ 3 3T\\5G5GH66tH~t\\Z22!37>>B>a	>B3NOOOOLL
  H  Cs   % H:%H?c                 N    U R                  U 5      nUR                  " XS.40 UD6$ )Nr  r  )r   r   r   r  r  s        rA   _load_from_dictLark._load_from_dict=  s'    {{3zz46A&AArD   grammar_filenamerel_toc                     U(       a>  [         R                  R                  U5      n[         R                  R                  XA5      n[	        USS9 nU " U40 UD6sSSS5        $ ! , (       d  f       g= f)zCreate 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   rm   basepathr   s         rA   r   	Lark.openB  sR     wwv.H!ww||HG"V4q$G$ 544s   	A##
A1r   packagegrammar_pathsearch_pathszSequence[str]c                     [        X5      nU" SU5      u  pgUR                  SU5        UR                  S/ 5        US   R                  U5        U " U40 UD6$ )aC  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=...)
Nrf   re   )r#   
setdefaultappend)r   r(  r)  r*  rm   package_loader	full_pathtexts           rA   open_from_packageLark.open_from_packageT  s_     +7A(|<	=)4>2.&&~64#7##rD   c                     SU R                   < SU R                  R                  < SU R                  R                  < S3$ )Nz
Lark(open(z
), parser=z, lexer=z, ...))rf   rm   r\   r]   r   s    rA   __repr__Lark.__repr__f  s,    =A=M=Mt||ObObdhdpdpdvdvwwrD   r0  c                 @   [        U S5      (       a  U(       a  U R                  U5      nOU R                  n[        R                  " X15      nUR                  S5      nU R                  R                  (       a%  U R                  R                  R                  U5      $ U$ )zOnly 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.
r]   N)	hasattrr   r]   r0   	from_textlexrm   r_   rB   )r@   r0  r   r]   lexer_threadr;   s         rA   r9  Lark.lexj  sy     tW%%%%k2EJJE",,U9!!$'<<<<''//77rD   rx   c                      U R                   U   $ )z Get information about a terminal)r   )r@   rx   s     rA   get_terminalLark.get_terminal|  s    ##D))rD   rP   r   c                 4    U R                   R                  XS9$ )a  Start an interactive parsing session. Only works when parser='lalr'.

Parameters:
    text (TextOrSlice, optional): Text to be parsed. Required for ``resume_parse()``.
    start (str, optional): Start symbol

Returns:
    A new InteractiveParser instance.

See Also: ``Lark.parse()``
)rP   )r\   parse_interactive)r@   r0  rP   s      rA   r@  Lark.parse_interactive  s     {{,,T,??rD   on_errorz+Optional[Callable[[UnexpectedInput], bool]]r   c                     Ub%  U R                   R                  S:w  a  [        S5      eU R                  R                  XUS9$ )a  Parse the given text, according to the options provided.

Parameters:
    text (TextOrSlice): Text to be parsed, as `str` or `bytes`.
        TextSlice may also be used, but only when lexer='basic' or 'contextual'.
    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 UnexpectedInput error,
        with the exception as its argument. Return true to resume parsing, or false to raise the exception.
        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``.

rn   z?The on_error option is only implemented for the LALR(1) parser.)rP   rB  )rm   r\   r  parse)r@   r0  rP   rB  s       rA   rD  
Lark.parse  sA    ( DLL$7$76$A%&ghh{{  X FFrD   )r   r   r   r   r   r   r]   r   rm   r\   r   r   rf   r   )r   zUnion[Grammar, str, IO[str]]r<   N)F)r<   N)r<   r   )r?   r>   )NN)-rF   rG   rH   rI   r   rJ   rK   rN   r-   r   r/   r   r{   r   rt   r.   r   r   r   r   r   r   r   r   r   r   r   r   r7   r)   r  r   r  r   r   r1  r4  r!   r	   r1   r9  r=  r@  rD  rL   r?   rD   rA   r   r      sE    L+&&9SB 6K3333& &z &_


Tz# 
T 
T $r( "  DcN $sER]_cRcLdGdBe p{   AJ  B  3  R  D B B %$r( %c %8C= %]_ % %" ikhl $tBx $# $S $Xg $|~ $ $"x $ % $* * *@h{&; @RU @`s @G+ Ghsm GLy G  DO G GrD   )Q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'   r(   commonr)   r*   r+   r,   r]   r-   r.   r/   r0   r1   parse_tree_builderr2   r3   r4   r5   r6   r   r7   rX   r   r   r9   rN   r   r   r   r   r   r?   rD   rA   <module>rQ     s    #      	     B%1 J J H H u u  H H E E 0 H  H J&c &B) BN g < D  T fG9 fG{  Js   D DD