
    h                   @   % S SK Jr  S SKrS SKJ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  S SKJrJr  S SK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Jr  S SKrS SK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'J(r(J)r)J*r*J+r,J-r.J/r/  SSK07  SSK17  SSK2J3r3J4r4  SSK5J6r6  \Rn                  r8\9\:4r;S\<S'   S SKJ=r=   " S S\'5      r> " S S\'5      r? " S S\5      r@SS jrASS jrBSS jrCC'      SS jrD\D" \R                  \R                  R                  S5      5      (       a  \C" 5         \H\I\J\K\L\M\N\O\P\Q\R1rS\R                  rU\M\V\4   rW\\3\\3   4   rX\\/ \Y4   \\3/\Y4   \\V\3/\Y4   \\9\V\3/\Y4   4   rZ\\9\VS\[/S4   r\\\9\VS\Y/S4   r]\\9\V\VS\3\Y/S4   r^\\9\VS\[\Y/S4   r_\R                  \R                  -   rbS \<S!'   \6R                  R                  rdS \<S"'   \6R                  R                  reS \<S#'   S$rfS \<S%'   \fS&-   rgS \<S''   \b\f-   rhS \<S('   S)R                  \R                   V s/ s H  o \R                  ;  d  M  U PM     sn 5      rlS \<S*'    " S+ S,\[5      rmSqnS-\<S.'   S/qoSS0 jrp S       SS1 jjrq S       SS2 jjrr S           SS3 jjrs S         SS4 jjrtS5 ru " S6 S\5      rv " S7 S8\v5      rw " S9 S:\v5      rx " S; S<\x5      ry " S= S>\x5      rz " S? S@\z5      r{ " SA SB\z5      r|\z\vl}         " SC SD\x5      r~ " SE SF\z5      r " SG SH\~5      r " SI SJ\x5      r " SK SL\x5      r " SM SN\5      r " SO SP\x5      r " SQ SR\x5      r " SS ST\x5      r " SU SV\x5      r " SW SX\x5      r " SY SZ\5      r " S[ S\\5      r " S] S^\5      r " S_ S`\5      r " Sa Sb\5      r " Sc Sd\5      r " Se Sf\5      r " Sg Sh\x5      r " Si Sj\v5      r " Sk Sl\5      r " Sm Sn\5      r " So Sp\5      r " Sq Sr\5      r " Ss St\v5      r " Su Sv\5      r " Sw Sx\5      r " Sy Sz\5      r " S{ S|\5      r " S} S~\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S5      r " S S\5      r\r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      rSS jr\{" 5       GR[                  S5      r\" 5       GR[                  S5      r\" 5       GR[                  S5      r\" 5       GR[                  S5      r\" 5       GR[                  S5      r\" S5      GRg                  S 5      r\" S5      GRg                  S 5      r\" S5      GRg                  S 5      r\\-  \-  \" SSS9-  r\" \\" S5      -   \-   5      r\z" S5      \" S5      GRs                  S5      -   \" \" \\-  5      5      GRs                  S5      -   \z" S5      -   rSS jrSS jrSS jr\" \" S5      S-   5      GR[                  S5      r\" \" S5      S-   5      GR[                  S5      r\" \" S5      S-   GR[                  S5      \" S5      S-   GR[                  S5      -  5      GR[                  S5      r\" \" S\GR                  S9S-   GR[                  S5      \" S\GR                  S9S-   GR[                  S5      -  \" S5      S-   GR[                  S5      -  \" S5      S-   GR[                  S5      -  5      GR[                  S5      r\" S\R+                  5       -   5      GR[                  S5      r\" S5      r\" S5      r\" 5       GR                  5        Vs/ s H  n\" U\v5      (       d  M  UPM     snrS\<S'   \r\r\r\r\r\r\r\r\/" S\u5      r\/" S\5      r\/" S\q5      r\/" S\5      rgs  sn f s  snf )    )annotationsN)deque)AnyCallable	Generator
NamedTupleSequenceTextIOUnioncast)ABCabstractmethod)Enum)Iterable)
itemgetter)wraps)RLock)Path   )	
_FifoCache_UnboundedCache__config_flags_collapse_string_to_ranges_escape_regex_range_chars_flattenLRUMemoUnboundedMemoreplaced_by_pep8)*)ParseResults_ParseResultsWithOffset)pyparsing_unicodeztuple[type, ...]str_type)cached_propertyc                      \ rS rSrSrSrSr\" 5        V Vs/ s H  oR                  S5      (       a  M  UPM     snn r	SR                  5       rSrgs  snn f )	
__compat__P   a&  
A cross-version compatibility configuration for pyparsing features that will be
released in a future version. By setting values in this configuration to True,
those features can be enabled in prior versions for compatibility development
and testing.

- ``collect_all_And_tokens`` - flag to enable fix for Issue #63 that fixes erroneous grouping
  of results names when an :class:`And` expression is nested within an :class:`Or` or :class:`MatchFirst`;
  maintained for compatibility, but setting to ``False`` no longer restores pre-2.3.1
  behavior
compatibilityT_z(
        collect_all_And_tokens
         N)__name__
__module____qualname____firstlineno____doc__
_type_desccollect_all_And_tokenslocals
startswith
_all_namessplit_fixed_names__static_attributes__).0__s   00@/var/www/html/env/lib/python3.13/site-packages/pyparsing/core.pyr&   r&   P   sJ    
 !J!%xBx}}S/A"xBJEG  Cs
   AAr&   c                     \ rS rSrSrSrSrSrSrSr	Sr
SrSr\" 5        V Vs/ s H  oR                  S5      (       a  M  UPM     snn r\ V Vs/ s H  o"R                  S5      (       d  M  UPM     snn r\ V Vs/ s H  o"R                  S5      (       d  M  UPM     snn r\S
S j5       rSrg	s  snn f s  snn f s  snn f )__diag__g   
diagnosticFr)   warnenable_debugc                L    U R                    H  nU R                  U5        M     g N)_warning_namesenable)clsnames     r:   enable_all_warnings__diag__.enable_all_warningsw   s    &&DJJt '    r*   NreturnNone)r+   r,   r-   r.   r0   )warn_multiple_tokens_in_named_alternation)warn_ungrouped_named_tokens_in_collectionwarn_name_set_on_empty_Forward!warn_on_parse_using_empty_Forwardwarn_on_assignment_to_Forward%warn_on_multiple_string_args_to_oneof(warn_on_match_first_with_lshift_operator!enable_debug_on_named_expressionsr2   r3   r4   rC   _debug_namesclassmethodrG   r7   )r8   r9   rF   s   000r:   r<   r<   g   s    J05-05-%*"(-%$)!,1)/4,(-%%xBx}}S/A"xBJ'1Mzt__V5LdzMN%/SZT??>3RDZSL  CMSs#   B/ B/B5,B5;B;B;r<   c                  8    \ rS rSrSrSrSrSrSrSr	Sr
S	rS
rSrg)Diagnostics}   a_  
Diagnostic configuration (all default to disabled)

- ``warn_multiple_tokens_in_named_alternation`` - flag to enable warnings when a results
  name is defined on a :class:`MatchFirst` or :class:`Or` expression with one or more :class:`And` subexpressions
- ``warn_ungrouped_named_tokens_in_collection`` - flag to enable warnings when a results
  name is defined on a containing expression with ungrouped subexpressions that also
  have results names
- ``warn_name_set_on_empty_Forward`` - flag to enable warnings when a :class:`Forward` is defined
  with a results name, but has no contents defined
- ``warn_on_parse_using_empty_Forward`` - flag to enable warnings when a :class:`Forward` is
  defined in a grammar but has never had an expression attached to it
- ``warn_on_assignment_to_Forward`` - flag to enable warnings when a :class:`Forward` is defined
  but is overwritten by assigning using ``'='`` instead of ``'<<='`` or ``'<<'``
- ``warn_on_multiple_string_args_to_oneof`` - flag to enable warnings when :class:`one_of` is
  incorrectly called with multiple str arguments
- ``enable_debug_on_named_expressions`` - flag to auto-enable debug on all subsequent
  calls to :class:`ParserElement.set_name`

Diagnostics are enabled/disabled by calling :class:`enable_diag` and :class:`disable_diag`.
All warnings can be enabled by calling :class:`enable_all_warnings`.
r   r                     r*   N)r+   r,   r-   r.   r/   rM   rN   rO   rP   rQ   rR   rS   rT   r7   r*   rI   r:   rX   rX   }   s9    . 12-01-%&"()%$%!,-)/0,()%rI   rX   c                B    [         R                  U R                  5        g)zG
Enable a global pyparsing diagnostic flag (see :class:`Diagnostics`).
N)r<   rD   rF   	diag_enums    r:   enable_diagrc      s     OOINN#rI   c                B    [         R                  U R                  5        g)zH
Disable a global pyparsing diagnostic flag (see :class:`Diagnostics`).
N)r<   disablerF   ra   s    r:   disable_diagrf      s     Y^^$rI   c                 ,    [         R                  5         g)zM
Enable all global pyparsing diagnostic warnings (see :class:`Diagnostics`).
N)r<   rG   r*   rI   r:   rG   rG      s       "rI   c                J   [        U5      nU  H  nUS-   R                  S5      S S u  pEpgnUR                  5       R                  S5      (       d  U(       d  U(       d  U(       a  US:X  a  SnMa  UR                  5       R                  S5      (       d  M  US;   d  M  SnM     U$ )	Nz:::::r]   i	pyparsingT)rk    F)boolr5   lowerr3   )	cmd_line_warn_optionswarn_env_varrD   warn_optw_action	w_message
w_categoryw_modulew_lines	            r:   _should_enable_warningsrw      s     ,F)=E=N<U<U=

1=9Z6 ~~**3//jH[9PF^^((--(>O2OF * MrI   PYPARSINGENABLEALLWARNINGSParserElementstralphas
identcharsidentbodychars
0123456789numsABCDEFabcdefhexnums	alphanumsrl   
printablesc                  "    \ rS rSrSrSS jrSrg)_ParseActionIndexError   z
Internal wrapper around IndexError so that IndexErrors raised inside
parse actions aren't misinterpreted as IndexErrors raised inside
ParserElement parseImpl methods.
c                    Xl         X l        g rB   )msgexc)selfr   r   s      r:   __init___ParseActionIndexError.__init__   s    "%rI   )r   r   N)r   rz   r   BaseExceptionrK   rL   )r+   r,   r-   r.   r/   r   r7   r*   rI   r:   r   r      s    &rI   r   ztraceback.StackSummary_trim_arity_call_liner*   c                H  ^ ^^^ T [         ;   a  U 4S j$ SmSmSn[        =(       d    [        R                  " SS9S   q[        =(       d    [        S   [        S   U-   4qUU UU4S	 jn[        T S
[        T S5      R                  5      nXCl        T R                  Ul        U$ )zAdecorator to trim function calls to match the arity of the targetc                   > T" U5      $ rB   r*   )sltfuncs      r:   <lambda>_trim_arity.<locals>.<lambda>  s	    tAwrI   r   F	   rZ   limitr   c                 h  > T(       a  T	" U T
S  6 $   T	" U T
S  6 nSmU$ ! [          a`  nT(       a  e UR                  n[        R                  " USS9nUS   nUS S /S   S S [        :H  nAU(       a  T
T:  a  T
S-  m
 S nAMr  e S nAf[
         a   n[        SU5      R                  S 5      eS nAff = f)Nr   TrZ   r   r   z!IndexError raised in parse action)	TypeError__traceback__	traceback
extract_tbpa_call_line_synth
IndexErrorr   with_traceback)argsrettetbframesframe_summarytrim_arity_type_erroriefound_arityr   r   	max_limits           r:   wrapper_trim_arity.<locals>.wrapper  s    ef&&'DL)"
 ))B&11"A>F$*2JM&r*+B/37II * , 9,!QJE$ ',7 .&''s'    
B1ABBB1B,,B1r+   	__class__)_single_arg_builtinsr   r   extract_stackr   getattrr+   r/   )r   r   	LINE_DIFFr   	func_namer   r   s   ``   @@r:   _trim_arityr     s     ##&&EK I 2YY5L5LST5UVX5Y+o0Ea0HJ_`aJbenJn/o '  'J j'$*D*M*MNI llGONrI   c                   ^ ^^ Ub  UOSmU(       a  [         O[        m[        T 5      m [        T 5      UU U4S j5       nU$ )a  
Function to convert a simple predicate function that returns ``True`` or ``False``
into a parse action. Can be used in places when a parse action is required
and :class:`ParserElement.add_condition` cannot be used (such as when adding a condition
to an operator level in :class:`infix_notation`).

Optional keyword arguments:

- ``message`` - define a custom message to be used in the raised exception
- ``fatal`` - if True, will raise :class:`ParseFatalException` to stop parsing immediately;
  otherwise will raise :class:`ParseException`

zfailed user-defined conditionc                F   > [        T" XU5      5      (       d	  T" XT5      eg rB   )rm   )r   r   r   exc_typefnr   s      r:   pa%condition_as_parse_action.<locals>.paU  s&    BqQK  1%% !rI   )ParseFatalExceptionParseExceptionr   r   )r   messagefatalr   r   r   s   `   @@r:   condition_as_parse_actionr   A  sB      ('.MC&+"H	RB
2Y& & IrI   c                    U(       a  SOSn[        U SU SU S[        X5       S[        X5       S[        X5       SS	S
[        X5       3 35        g )Nr   rl   Match z at loc (,z)
  z
  ^>)printlinenocolline)instringlocexpr	cache_hitcache_hit_strs        r:   _default_start_debug_actionr   ]  sp     %C"M	oVD6#as8M7NaPSTWPbOc dc$% &Qs3)**+-rI   c                \    U(       a  SOSn[        U SU SUR                  5        35        g )Nr   rl   zMatched z -> )r   as_list)r   startlocendlocr   toksr   r   s          r:   _default_success_debug_actionr   j  s-     %C"M	]O8D6dlln-=
>?rI   c           	     l    U(       a  SOSn[        U SU S[        U5      R                   SU 35        g )Nr   rl   r   z	 failed, z	 raised: )r   typer+   )r   r   r   r   r   r   s         r:   _default_exception_debug_actionr   v  s7     %C"M	]O6$yc1C1C0DIcU
STrI   c                     g)zG'Do-nothing' debug action, to suppress debugging output during parsing.Nr*   )r   s    r:   null_debug_actionr         rI   c                     \ rS rSr% SrSrS\S'   SrS\S'   S	rS
\S'   \	SS j5       r
\	SS j5       r\S 5       r " S S\5      rSSS jjr\S 5       r\R&                  S 5       rSS jrS rSS jr SSS.       SS jjjrSSS jjrSSS jjrSS jrSS jrSS jrSS jrSS  jrSS! jrSSS" jjr S# r! S SS$ jjr"SSS%.         SS& jjr#SSS' jjr$\%" 5       r&0 r'S(\S)'    " S* S+\(RR                  5      r* " S, S-\+5      r,\," 5       r-S+\S.'   \%" 5       r.S/S//r/ S SS0 jjr0\"r1\	SS1 j5       r2Sr3Sr4\	SS2 j5       r5\	 SSS3.   SS4 jjj5       r6\	 SSS3.     SS5 jjj5       r7 SSS6.       SS7 jjjr8\9SS4S\9S8.           SS9 jjjr:SS:.SS; jjr;\94S\9S8.         SS< jjjr<\9S4SS=.       SS> jjjr=SS? jr>SS@ jr?SSA jr@SSB jrASSC jrBSSD jrCSSE jrDSSF jrESSG jrFSSH jrGSSI jrHSSJ jrISSK jrJS	rKSL rLSSSM jjrMSSN jrNSSSO jjrOSSSP jjrP S     SSQ jjrQSSR jrRSSS jrS        SST jrTSSSU jjrU\SSV j5       rV\WSSW j5       rXSSX jrY\SSY j5       rZ\ZR&                  SSZ j5       rZSS[ jr[SS\ jr\SS] jr]SS^ jr^S_ r_SSS` jjr`  SSS6.         SSa jjjraSb rbSc rc SSS6.       SSd jjjrd        SSSSSS	Se.                             SSf jjjre     S             SSg jjrf\	" \g" Sh\5      5      rh\	" \g" Si\
5      5      ri\	" \g" Sj\55      5      rj\	" \g" Sk\65      5      rk\	" \g" Sl\75      5      rl\	" \g" Sm\25      5      rm\g" Sn\5      rn\g" So\5      ro\g" Sp\5      rp\g" Sq\5      rq\g" Sr\5      rr\g" Ss\5      rs\g" St\#5      rt\g" Su\85      ru\g" Sv\:5      rv\g" Sw\;5      rw\g" Sx\<5      rx\g" Sy\O5      ry\g" Sz\P5      rz\g" S{\Q5      r{\g" S|\R5      r|\g" S}\T5      r}\g" S~\U5      r~\g" S\Y5      r\g" S\a5      r\g" S\e5      r\g" S\$5      r\VrSrg	)ry   i  z)Abstract base level parser element class.z 
	rz   DEFAULT_WHITE_CHARSFrm   verbose_stacktraceNr   _literalStringClassc                z    U [         l        [         H&  nUR                  (       d  M  [	        U 5      Ul        M(     g)a  
Overrides the default whitespace chars

Example::

    # default whitespace chars are space, <TAB> and newline
    Word(alphas)[1, ...].parse_string("abc def\nghi jkl")  # -> ['abc', 'def', 'ghi', 'jkl']

    # change to just treat newline as significant
    ParserElement.set_default_whitespace_chars(" \t")
    Word(alphas)[1, ...].parse_string("abc def\nghi jkl")  # -> ['abc', 'def']
N)ry   r   _builtin_exprscopyDefaultWhiteCharsset
whiteChars)charsr   s     r:   set_default_whitespace_chars*ParserElement.set_default_whitespace_chars  s/     -2) #D)))"%e* #rI   c                    U [         l        g)a  
Set class to be used for inclusion of string literals into a parser.

Example::

    # default literal class used is Literal
    integer = Word(nums)
    date_str = integer("year") + '/' + integer("month") + '/' + integer("day")

    date_str.parse_string("1999/12/31")  # -> ['1999', '/', '12', '/', '31']


    # change to Suppress
    ParserElement.inline_literals_using(Suppress)
    date_str = integer("year") + '/' + integer("month") + '/' + integer("day")

    date_str.parse_string("1999/12/31")  # -> ['1999', '12', '31']
N)ry   r   )rE   s    r:   inline_literals_using#ParserElement.inline_literals_using  s    ( -0)rI   c              +  >   ^ ^#    UU 4S jU 5        Sh  vN   g N7f)z
Yields a sequence of ``class(obj, **class_kwargs)`` for obj in seq.

Example::

    LPAR, RPAR, LBRACE, RBRACE, SEMI = Suppress.using_each("(){};")

c              3  6   >#    U  H  nT" U40 TD6v   M     g 7frB   r*   )r8   objclass_kwargsrE   s     r:   	<genexpr>+ParserElement.using_each.<locals>.<genexpr>  s     <C,|,s   Nr*   )rE   seqr   s   ` `r:   
using_eachParserElement.using_each  s      =<<<s   c                  4    \ rS rSr% S\S'   S\S'   S\S'   Srg	)
ParserElement.DebugActionsi  z!typing.Optional[DebugStartAction]	debug_tryz#typing.Optional[DebugSuccessAction]debug_matchz%typing.Optional[DebugExceptionAction]
debug_failr*   N)r+   r,   r-   r.   __annotations__r7   r*   rI   r:   DebugActionsr     s    448899rI   r   c                   [        5       U l        S U l        S U l        S U l        S U l        Xl        SU l        [        [        R                  5      U l        SU l        SU l        SU l        [        5       U l        SU l        SU l        SU l        SU l        SU l        U R+                  S S S 5      U l        SU l        SU l        / U l        SU l        g )NTFrl   )listparseAction
failAction
customName_defaultNameresultsName
saveAsListskipWhitespacer   ry   r   r   r   _may_return_emptykeepTabsignoreExprsdebugstreamlinedmayIndexErrorerrmsgmodalResultsr   debugActionscallPreparsecallDuringTrysuppress_warnings_show_in_diagram)r   savelists     r:   r   ParserElement.__init__  s    .2f<@#26 $""m??@%)"!&04
 !(*  --dD$? "57#rI   c                    U R                   $ rB   r  r   s    r:   mayReturnEmptyParserElement.mayReturnEmpty  s    %%%rI   c                    Xl         g rB   r  r   values     r:   r  r        !&rI   c                <    U R                   R                  U5        U $ )a"  
Suppress warnings emitted for a particular diagnostic on this expression.

Example::

    base = pp.Forward()
    base.suppress_warning(Diagnostics.warn_on_parse_using_empty_Forward)

    # statement would normally raise a warning, but is now suppressed
    print(base.parse_string("x"))

)r  append)r   warning_types     r:   suppress_warningParserElement.suppress_warning  s     	&&|4rI   c              #     #    [        U /5      n[        5       nU(       aU  UR                  5       nX2;   a  M  UR                  U5        UR	                  UR                  5       5        Uv   U(       a  MT  gg7f)zsGeneral-purpose method to yield all expressions and sub-expressions
in a grammar. Typically just for internal use.
N)r   r   popleftaddextendrecurse)r   to_visitseencurs       r:   	visit_allParserElement.visit_all  s]      $=u""$C {HHSMOOCKKM*I hs   A0A64A6c                    [         R                   " U 5      nU R                  SS Ul        U R                  SS Ul        U R                  (       a  [	        [
        R                  5      Ul        U$ )a  
Make a copy of this :class:`ParserElement`.  Useful for defining
different parse actions for the same parsing pattern, using copies of
the original parse element.

Example::

    integer = Word(nums).set_parse_action(lambda toks: int(toks[0]))
    integerK = integer.copy().add_parse_action(lambda toks: toks[0] * 1024) + Suppress("K")
    integerM = integer.copy().add_parse_action(lambda toks: toks[0] * 1024 * 1024) + Suppress("M")

    print((integerK | integerM | integer)[1, ...].parse_string("5K 100 640K 256M"))

prints::

    [5120, 100, 655360, 268435456]

Equivalent form of ``expr.copy()`` is just ``expr()``::

    integerM = integer().add_parse_action(lambda toks: toks[0] * 1024 * 1024) + Suppress("M")
N)copyr   r  r   r   ry   r   r   )r   cpys     r:   r-  ParserElement.copy  sU    , iio**1-**1-%% !B!BCCN
rI   )listAllMatchesc               :    U=(       d    UnU R                  X5      $ )aL  
Define name for referencing matching tokens as a nested attribute
of the returned parse results.

Normally, results names are assigned as you would assign keys in a dict:
any existing value is overwritten by later values. If it is necessary to
keep all values captured for a particular results name, call ``set_results_name``
with ``list_all_matches`` = True.

NOTE: ``set_results_name`` returns a *copy* of the original :class:`ParserElement` object;
this is so that the client can define a basic element, such as an
integer, and reference it in multiple places with different names.

You can also set results names using the abbreviated syntax,
``expr("name")`` in place of ``expr.set_results_name("name")``
- see :class:`__call__`. If ``list_all_matches`` is required, use
``expr("name*")``.

Example::

    integer = Word(nums)
    date_str = (integer.set_results_name("year") + '/'
                + integer.set_results_name("month") + '/'
                + integer.set_results_name("day"))

    # equivalent form:
    date_str = integer("year") + '/' + integer("month") + '/' + integer("day")
)_setResultsName)r   rF   list_all_matchesr0  s       r:   set_results_nameParserElement.set_results_name+  s     > (;+;##D99rI   c                    Uc  U $ U R                  5       nUR                  S5      (       a  US S nSnXl        U(       + Ul        U$ )Nr   r   T)r-  endswithr  r  )r   rF   r3  newselfs       r:   r2  ParserElement._setResultsNameM  sM    <K))+==9D#"#33rI   Tc                   ^ U(       a#  U R                   mSU4S jjnTUl        X l         U $ [        U R                   S5      (       a  U R                   R                  U l         U $ )z
Method to invoke the Python pdb debugger when this element is
about to be parsed. Set ``break_flag`` to ``True`` to enable, ``False`` to
disable.
c                *   > [        5         T" XX#5      $ rB   )
breakpoint)r   r   
do_actionscallPreParse_parseMethods       r:   breaker(ParserElement.set_break.<locals>.breakera  s    #H:LLrI   _originalParseMethodTT)_parserB  hasattr)r   
break_flagr@  r?  s      @r:   	set_breakParserElement.set_breakX  sW     ;;LM
 ,8G(!K  T[["899++::DKrI   c                L   [        U5      S/:X  a  U R                  R                  5         U $ [        S U 5       5      (       d  [	        S5      eU Vs/ s H  n[        U5      PM     snU R                  SS& UR                  SUR                  SS5      5      U l        U $ s  snf )a  
Define one or more actions to perform when successfully matching parse element definition.

Parse actions can be called to perform data conversions, do extra validation,
update external data structures, or enhance or replace the parsed tokens.
Each parse action ``fn`` is a callable method with 0-3 arguments, called as
``fn(s, loc, toks)`` , ``fn(loc, toks)`` , ``fn(toks)`` , or just ``fn()`` , where:

- ``s``    = the original string being parsed (see note below)
- ``loc``  = the location of the matching substring
- ``toks`` = a list of the matched tokens, packaged as a :class:`ParseResults` object

The parsed tokens are passed to the parse action as ParseResults. They can be
modified in place using list-style append, extend, and pop operations to update
the parsed list elements; and with dictionary-style item set and del operations
to add, update, or remove any named results. If the tokens are modified in place,
it is not necessary to return them with a return statement.

Parse actions can also completely replace the given tokens, with another ``ParseResults``
object, or with some entirely different object (common for parse actions that perform data
conversions). A convenient way to build a new parse result is to define the values
using a dict, and then create the return value using :class:`ParseResults.from_dict`.

If None is passed as the ``fn`` parse action, all previously added parse actions for this
expression are cleared.

Optional keyword arguments:

- ``call_during_try`` = (default= ``False``) indicate if parse action should be run during
  lookaheads and alternate testing. For parse actions that have side effects, it is
  important to only call the parse action once it is determined that it is being
  called as part of a successful parse. For parse actions that perform additional
  validation, then call_during_try should be passed as True, so that the validation
  code is included in the preliminary "try" parses.

Note: the default parsing behavior is to expand tabs in the input string
before starting the parsing process.  See :class:`parse_string` for more
information on parsing strings containing ``<TAB>`` s, and suggested
methods to maintain a consistent view of the parsed string, the parse
location, and line and column positions within the parsed string.

Example::

    # parse dates in the form YYYY/MM/DD

    # use parse action to convert toks from str to int at parse time
    def convert_to_int(toks):
        return int(toks[0])

    # use a parse action to verify that the date is a valid date
    def is_valid_date(instring, loc, toks):
        from datetime import date
        year, month, day = toks[::2]
        try:
            date(year, month, day)
        except ValueError:
            raise ParseException(instring, loc, "invalid date given")

    integer = Word(nums)
    date_str = integer + '/' + integer + '/' + integer

    # add parse actions
    integer.set_parse_action(convert_to_int)
    date_str.set_parse_action(is_valid_date)

    # note that integer fields are now ints, not strings
    date_str.run_tests('''
        # successful parse - note that integer fields were converted to ints
        1999/12/31

        # fail - invalid date
        1999/13/31
        ''')
Nc              3  8   #    U  H  n[        U5      v   M     g 7frB   )callable)r8   r   s     r:   r   1ParserElement.set_parse_action.<locals>.<genexpr>  s     .#B8B<<#   zparse actions must be callablecall_during_tryr  F)r   r   clearallr   r   getr  r   fnskwargsr   s       r:   set_parse_actionParserElement.set_parse_actionl  s    V 9""$K.#...<==9<=2{2=#ZZvzz/5A
  >s   B!c                    U =R                   U Vs/ s H  n[        U5      PM     sn-  sl         U R                  =(       d"    UR                  SUR                  SS5      5      U l        U $ s  snf )z
Add one or more parse actions to expression's list of parse actions. See :class:`set_parse_action`.

See examples in :class:`copy`.
rN  r  F)r   r   r  rQ  rR  s       r:   add_parse_actionParserElement.add_parse_action  sb     	s;s[_s;;!// 
6::vzz/5A4
 	 <s   A,c                6   U HX  nU R                   R                  [        U[        UR	                  S5      5      [        UR	                  SS5      5      S95        MZ     U R                  =(       d"    UR	                  SUR	                  SS5      5      U l        U $ )a+  Add a boolean predicate function to expression's list of parse actions. See
:class:`set_parse_action` for function call signatures. Unlike ``set_parse_action``,
functions passed to ``add_condition`` need to return boolean success/fail of the condition.

Optional keyword arguments:

- ``message`` = define a custom message to be used in the raised exception
- ``fatal`` = if True, will raise ParseFatalException to stop parsing immediately; otherwise will raise
  ParseException
- ``call_during_try`` = boolean to indicate if this method should be called during internal tryParse calls,
  default=False

Example::

    integer = Word(nums).set_parse_action(lambda toks: int(toks[0]))
    year_int = integer.copy()
    year_int.add_condition(lambda toks: toks[0] >= 2000, message="Only support years 2000 and later")
    date_str = year_int + '/' + integer + '/' + integer

    result = date_str.parse_string("1999/12/31")  # -> Exception: Only support years 2000 and later (at char 0),
                                                                 (line:1, col:1)
r   r   F)r   r   rN  r  )r   r  r   rz   rQ  rm   r  rR  s       r:   add_conditionParserElement.add_condition  s    . B##)

9 56vzz'59:  "// 
6::vzz/5A4
 rI   c                    Xl         U $ )a  
Define action to perform if parsing fails at this expression.
Fail acton fn is a callable function that takes the arguments
``fn(s, loc, expr, err)`` where:

- ``s`` = string being parsed
- ``loc`` = location where expression match was attempted and failed
- ``expr`` = the parse expression that failed
- ``err`` = the exception thrown

The function returns no value.  It may throw :class:`ParseFatalException`
if it is desired to stop parsing immediately.)r   )r   r   s     r:   set_fail_actionParserElement.set_fail_action  s     rI   c                   U R                   (       d  U$ SnU R                    Vs/ s H  oDR                  PM     nnUnU(       a,  SnU H  n  U" X5      u  p(SnM     X&:X  a   U$ UnU(       a  M,  U$ s  snf ! [         a     M<  f = fNTF)r  rD  r   )	r   r   r   
exprsFoundeignore_expr_fnslast_loc	ignore_fndummys	            r:   _skipIgnorablesParserElement._skipIgnorables  s    J
-1-=-=>-=88-=>J,	%.x%=
%)
  - 
 H j 
 ? & s   A2A77
BBc                    U R                   (       a  U R                  X5      nU R                  (       a8  [        U5      nU R                  nX#:  a  X   U;   a  US-  nX#:  a
  X   U;   a  M  U$ Nr   )r  rh  r  lenr   )r   r   r   instrlenwhite_charss        r:   preParseParserElement.preParse  sd    &&x5C8}H//K.X]k%Aq .X]k%A 
rI   c                
    U/ 4$ rB   r*   r   r   r   r=  s       r:   	parseImplParserElement.parseImpl&      BwrI   c                    U$ rB   r*   r   r   r   	tokenlists       r:   	postParseParserElement.postParse)  s    rI   c           
     .   U R                   n[        U5      nU(       d  U R                  (       a   U(       a#  U R                  (       a  U R	                  X5      nOUnUnU R
                  R                  (       a  U R
                  R                  XU S5        U R                  (       d  Xv:  a   U R                  XU5      u  p)OU R                  XU5      u  p)OnU(       a#  U R                  (       a  U R	                  X5      nOUnUnU R                  (       d  Xv:  a   U R                  XU5      u  p)OU R                  XU5      u  p)U R                  XU	5      n	[        XR                   U R"                  U R$                  S9nU R&                  (       a  U(       d  U R(                  (       a  U(       aq   U R&                   H_  n U" XU5      n	U	c  M  XLd  M  [        U	U R                   U R"                  =(       a    [+        U	[        [,        45      U R$                  S9nMa     OoU R&                   H_  n U" XU5      n	U	c  M  XLd  M  [        U	U R                   U R"                  =(       a    [+        U	[        [,        45      U R$                  S9nMa     U(       a9  U R
                  R.                  (       a  U R
                  R/                  XX US5        X+4$ ! [         a    [        XU R                  U 5      ef = f! [         ac  n
U R
                  R                  (       a  U R
                  R                  UWX
S5        U R                  (       a  U R                  UWX
5        e S n
A
ff = f! [         a    [        XU R                  U 5      ef = f! [         a  n[        S5      nXeS nAff = f! [         a>  n
U R
                  R                  (       a  U R
                  R                  XX
S5        e S n
A
ff = f! [         a  n[        S5      nXeS nAff = f)NF)asListmodalz exception raised in parse action)r  rl  r   r  ro  r  r   r
  rs  r   r   r  	Exceptionr   ry  r    r  r  r  r   r  
isinstancer   r   )r   r   r   r=  r>  	debugginglen_instringpre_loctokens_starttokenserr
ret_tokensr   parse_action_excr   s                  r:   _parseNoCacheParserElement._parseNoCache-  s    JJ	8}D$5$5"mmH:G!G&$$..%%//eT%%)@X&*nnX
&SV #'..J"OKC  1 1--6"L!!W%<T"&..J"OKC #nnX
Kv6!$$T__DDUDU

 t/A/A"..<%'
%KF
 "-&2J)5 & $ 0 0'+ (M$.vd7K$L&*&7&7*J /. **B8!#HJ!G
 )f.F%1" ,,#'?? $I *6L$3G H"&"3"3&
 +   ,,!!--Cz5 a & X,XT[[RVWWX  $$//%%00 ,5 ??OOHlDF$ " T(dSST   * <"01S"TC"%;< ! ((33))44$Du  & 8,-OP!78s   A<K9 .K K9 M) 2N- 	NN- N- AN- 2	O8"K66K9 9
M&AM!!M&)"N
N*N%%N**N- -
O579O00O58
PPP)raise_fatalr=  c                    U R                  XUS9S   $ ! [         a     U(       a  e [        XU R                  U 5      ef = f)Nr=  r   )rD  r   r   r  )r   r   r   r  r=  s        r:   	try_parseParserElement.try_parse  sJ    	C;;x;DQGG" 	C TBB	Cs    *?c                R     U R                  XUS9  g! [        [        4 a     gf = f)Nr  TF)r  r   r   rr  s       r:   can_parse_nextParserElement.can_parse_next  s5    	NN8ZN@  
+ 		s    &&zecollections.abc.MutableMapping[tuple[int, Forward, bool], tuple[int, Union[ParseResults, Exception]]]recursion_memosc                  B    \ rS rSr% SrS\S'   S
S jrSS jrSS jrSr	g	)ParserElement._CacheTypei  zU
Class to be used for packrat and left-recursion cacheing of results
and exceptions.
rm   not_in_cachec                    g rB   r*   r   r   s     r:   rQ  ParserElement._CacheType.get      CrI   c                    g rB   r*   r  s     r:   r   ParserElement._CacheType.set      crI   c                    g rB   r*   r  s    r:   rO  ParserElement._CacheType.clear      rI   r*   NrK   z
typing.AnyrJ   )
r+   r,   r-   r.   r/   r   rQ  r   rO  r7   r*   rI   r:   
_CacheTyper    s    	
 /)$rI   r  c                  F    \ rS rSr% SrSrS\S'   SS jrSS jrSS jr	S	r
g
)ParserElement.NullCachei  z
A null cache type for initialization of the packrat_cache class variable.
If/when enable_packrat() is called, this null cache will be replaced by a
proper _CacheType class instance.
Trm   r  c                    g rB   r*   r  s     r:   rQ  ParserElement.NullCache.get  r  rI   c                    g rB   r*   r  s     r:   r   ParserElement.NullCache.set  r  rI   c                    g rB   r*   r  s    r:   rO  ParserElement.NullCache.clear  r  rI   r*   Nr  rJ   )r+   r,   r-   r.   r/   r  r   rQ  r   rO  r7   r*   rI   r:   	NullCacher    s    	 "d!/)$rI   r  packrat_cacher   c           
         Su  pVXX$U4n[         R                     [         R                  nUR                  U5      n	XR                  L aa  [         R
                  U==   S-  ss'    U R                  XX45      n	UR                  XyS   U	S   R                  5       U45        U	sS S S 5        $ [         R
                  U==   S-  ss'   U R                  (       a7  U R                  R                  (       a   U R                  R                  XU SS9  [!        U	["        5      (       aL  U R                  (       a9  U R                  R$                  (       a   U R                  R%                  XX	SS9  U	eU	e['        [(        [*        [,        [*        4   U	5      n	U	S   U	S   R                  5       U	S   pnU R                  (       a8  U R                  R.                  (       a   U R                  R/                  XXUSS9  X4sS S S 5        $ ! [         a.  n
UR                  XzR                  " U
R                  6 5        e S n
A
ff = f! [         a     GN<f = f! [         a     U	ef = f! [         a     Nuf = f! , (       d  f       g = f)N)r   r   r   r   T)r   rZ   )ry   packrat_cache_lockr  rQ  r  packrat_cache_statsr  r   r-  ParseBaseExceptionr   r   r  r  r   r   r  r~  r   r   tupleintr    r   )r   r   r   r=  r>  HITMISSlookupcacher  peloc_resultr   s                 r:   _parseCacheParserElement._parseCache  s9    	#Z@--!//EIIf%E***11$71<7! ..xjWE IIfQxq#&FG  .- 11#6!;6::$"3"3"="=))33H4SW3X eY//zzd&7&7&B&B! --88 (td 9 
  K%KU3c#9:EB',Qxq%(f::$"3"3"?"?))55$F&D 6  |S .- * IIfllBGG&<= %   ) ! K! % M .-s   AI/&H8)I/+AI/3H=AI/I+A.I/I6I/
H:)H55H::I/=
II/
II/
II/II/
I,)I/+I,,I//
I=c                     [         R                  R                  5         S/[        [         R                  5      -  [         R                  S S & [         R
                  R                  5         g Nr   )ry   r  rO  rl  r  r  r*   rI   r:   reset_cacheParserElement.reset_cache  sO    ##))+01sS--6
 0
))!, 	%%++-rI   c                     [         R                  5         S[         l        S[         l        [         R                  [         l        g)z
Disables active Packrat or Left Recursion parsing and their memoization

This method also works if neither Packrat nor Left Recursion are enabled.
This makes it safe to call before activating Packrat nor Left Recursion
to clear any previous settings.
FN)ry   r  _left_recursion_enabled_packratEnabledr  rD  r*   rI   r:   disable_memoization!ParserElement.disable_memoization  s.     	!!#05-(-%,::rI   )forcec                  U(       a  [         R                  5         O [         R                  (       a  [        S5      eU c  [	        5       [         l        O'U S:  a  [        U S9[         l        O[        SU  35      eS[         l        g)ao  
Enables "bounded recursion" parsing, which allows for both direct and indirect
left-recursion. During parsing, left-recursive :class:`Forward` elements are
repeatedly matched with a fixed recursion depth that is gradually increased
until finding the longest match.

Example::

    import pyparsing as pp
    pp.ParserElement.enable_left_recursion()

    E = pp.Forward("E")
    num = pp.Word(pp.nums)
    # match `num`, or `num '+' num`, or `num '+' num '+' num`, ...
    E <<= E + '+' - num | num

    print(E.parse_string("1+2+3"))

Recursion search naturally memoizes matches of ``Forward`` elements and may
thus skip reevaluation of parse actions during backtracking. This may break
programs with parse actions which rely on strict ordering of side-effects.

Parameters:

- ``cache_size_limit`` - (default=``None``) - memoize at most this many
  ``Forward`` elements during matching; if ``None`` (the default),
  memoize all ``Forward`` elements.

Bounded Recursion parsing works similar but not identical to Packrat parsing,
thus the two cannot be used together. Use ``force=True`` to disable any
previous, conflicting settings.
0Packrat and Bounded Recursion are not compatibleNr   )capacityzMemo size of T)	ry   r  r  RuntimeError_UnboundedMemor  _LRUMemoNotImplementedErrorr  cache_size_limitr  s     r:   enable_left_recursion#ParserElement.enable_left_recursion  sl    H --/**QRR#,:,<M)!,4>N,OM)%6F5G&HII04-rI   c               F   U(       a  [         R                  5         O [         R                  (       a  [        S5      e[         R                  (       a  gS[         l        U c  [        5       [         l        O[        U 5      [         l        [         R                  [         l	        g)a  
Enables "packrat" parsing, which adds memoizing to the parsing logic.
Repeated parse attempts at the same string location (which happens
often in many complex grammars) can immediately return a cached value,
instead of re-executing parsing/validating code.  Memoizing is done of
both valid results and parsing exceptions.

Parameters:

- ``cache_size_limit`` - (default= ``128``) - if an integer value is provided
  will limit the size of the packrat cache; if None is passed, then
  the cache size will be unbounded; if 0 is passed, the cache will
  be effectively disabled.

This speedup may break existing programs that use parse actions that
have side-effects.  For this reason, packrat parsing is disabled when
you first import pyparsing.  To activate the packrat feature, your
program must call the class method :class:`ParserElement.enable_packrat`.
For best results, call ``enable_packrat()`` immediately after
importing pyparsing.

Example::

    import pyparsing
    pyparsing.ParserElement.enable_packrat()

Packrat parsing works similar but not identical to Bounded Recursion parsing,
thus the two cannot be used together. Use ``force=True`` to disable any
previous, conflicting settings.
r  NT)
ry   r  r  r  r  r   r  r   r  rD  r  s     r:   enable_packratParserElement.enable_packratO  sj    D --/22QRR(((,%#*9*;M'*45E*FM',88rI   )parseAllc               v   U=(       d    Un[         R                  5         U R                  (       d  U R                  5         U R                   H  nUR                  5         M     U R
                  (       d  UR                  5       n U R                  US5      u  pVU(       aF  U R                  X5      n[        5       [        5       R                  S5      -   nUR                  X5        U$ ! [         a  nUR                  eSnAf[         a,  n	[         R                  (       a  e U	R!                  S5      eSn	A	ff = f)a@  
Parse a string with respect to the parser definition. This function is intended as the primary interface to the
client code.

:param instring: The input string to be parsed.
:param parse_all: If set, the entire input string must match the grammar.
:param parseAll: retained for pre-PEP8 compatibility, will be removed in a future release.
:raises ParseException: Raised if ``parse_all`` is set and the input string does not match the whole grammar.
:returns: the parsed data as a :class:`ParseResults` object, which may be accessed as a `list`, a `dict`, or
  an object with attributes if the given parser includes results names.

If the input string is required to match the entire grammar, ``parse_all`` flag must be set to ``True``. This
is also equivalent to ending the grammar with :class:`StringEnd`\ ().

To report proper column numbers, ``parse_string`` operates on a copy of the input string where all tabs are
converted to spaces (8 spaces per tab, as per the default in ``string.expandtabs``). If the input string
contains tabs and the grammar uses parse actions that use the ``loc`` argument to index into the string
being parsed, one can ensure a consistent view of the input string by doing one of the following:

- calling ``parse_with_tabs`` on your grammar before calling ``parse_string`` (see :class:`parse_with_tabs`),
- define your parse action using the full ``(s,loc,toks)`` signature, and reference the input string using the
  parse action's ``s`` argument, or
- explicitly expand the tabs in your input string before calling ``parse_string``.

Examples:

By default, partial matches are OK.

>>> res = Word('a').parse_string('aaaaabaaa')
>>> print(res)
['aaaaa']

The parsing behavior varies by the inheriting class of this abstract class. Please refer to the children
directly to see more examples.

It raises an exception if parse_all flag is set and instring does not match the whole grammar.

>>> res = Word('a').parse_string('aaaaabaaa', parse_all=True)
Traceback (most recent call last):
...
pyparsing.ParseException: Expected end of text, found 'b'  (at char 5), (line:1, col:6)
r   FN)ry   r  r	  
streamliner  r  
expandtabsrD  ro  Empty	StringEnd	set_debugr   r   r  r   r   )
r   r   	parse_allr  rc  r   r  sepa_excr   s
             r:   parse_stringParserElement.parse_string  s    Z (!!#OO!!ALLN "}}**,H	++h2KCmmH2Wy{44U;;		(( M & 	**! 	+// $$T**	+s%   A!C) )
D83C??D8'D33D8)r  
maxMatchesc             #    #    [        Xb5      nU R                  (       d  U R                  5         U R                   H  nUR                  5         M     U R                  (       d  [        U5      R                  5       n[        U5      nSn	U(       a9  [        5       n
U R                  U
l        U R                  U
l	        U
R                  nOU R                  nU R                  n[        R                  5         Sn X::  a  X:  a|   U" X5      nU" XSS9u  nnX:  aP  US-  nU(       a  [        UR                  5       UUS.5        UX4v   U(       a  U" X5      nUU	:  a  Un	OU	S-  n	O	Un	OUS-   n	 X::  a  X:  a  Mz  gggg! [          a    WS-   n	 N!f = f! ["         a,  n[        R$                  (       a  e UR'                  S5      eSnAff = f7f)a  
Scan the input string for expression matches.  Each match will return the
matching tokens, start location, and end location.  May be called with optional
``max_matches`` argument, to clip scanning after 'n' matches are found.  If
``overlap`` is specified, then overlapping matches will be reported.

Note that the start and end locations are reported relative to the string
being parsed.  See :class:`parse_string` for more information on parsing
strings with embedded tabs.

Example::

    source = "sldjf123lsdjjkf345sldkjf879lkjsfd987"
    print(source)
    for tokens, start, end in Word(alphas).scan_string(source):
        print(' '*start + '^'*(end-start))
        print(' '*start + tokens[0])

prints::

    sldjf123lsdjjkf345sldkjf879lkjsfd987
    ^^^^^
    sldjf
            ^^^^^^^
            lsdjjkf
                      ^^^^^^
                      sldkjf
                               ^^^^^^
                               lkjsfd
r   Fr>  r   )r  startendN)minr	  r  r  r  rz   r  rl  r  r   ro  rD  ry   
resetCacher   r|  r   r  r   r   )r   r   max_matchesoverlapalways_skip_whitespacer  r  rc  rm  r   	preparser
preparseFnparseFnmatchesprelocnextLocr  nextlocr   s                      r:   scan_stringParserElement.scan_string  s    P 1
OO!!ALLN " }}8}//1Hx=!I$($4$4I!#'??I "++JJ++  "$	+/g&:)",X";F '.hU&SOGV }1 !.4mmo-3+2!" %f55"&0&?G&}&- #q")C$qj; /g&:/&:/ & % 1*C%0 " 	+// $$T**	+sO   C5G8
F F  A%F <G FF FF 
G'GGGr  c                  / nSnSU l          U R                  XS9 H  u  pVnXd:  a  UR                  XU 5        UnU(       d  M)  [        U[        5      (       a  X5R                  5       -  nMR  [        U[        5      (       a(  [        U[        5      (       d  UR                  U5        M  UR                  U5        M     UR                  XS 5        U Vs/ s H  o(       d  M  UPM     nnSR                  [        U5       Vs/ s H  n[        U5      PM     sn5      $ s  snf s  snf ! [         a,  n	[        R                  (       a  e U	R                  S5      eSn	A	ff = f)a  
Extension to :class:`scan_string`, to modify matching text with modified tokens that may
be returned from a parse action.  To use ``transform_string``, define a grammar and
attach a parse action to it that modifies the returned token list.
Invoking ``transform_string()`` on a target string will then scan for matches,
and replace the matched text patterns according to the logic in the parse
action.  ``transform_string()`` returns the resulting transformed string.

Example::

    wd = Word(alphas)
    wd.set_parse_action(lambda toks: toks[0].title())

    print(wd.transform_string("now is the winter of our discontent made glorious summer by this sun of york."))

prints::

    Now Is The Winter Of Our Discontent Made Glorious Summer By This Sun Of York.
r   Tr  Nrl   )r  r  r  r  r    r   r   r#   r%  joinr   rz   r  ry   r   r   )
r   r   r  outlastEr   r   rc  or   s
             r:   transform_stringParserElement.transform_string)  s*   (  	+++H+Ba9JJxa01a..99;&C8,,Z85L5LJJqMJJqM C JJx'(!'cQ1cC'77HSM:MqCFM:;; (:! 	+// $$T**	+s<   C
D+ 
D!%D!+D+ D&D+ !
D+ +
E!5'EE!c          
         [        XB5      n [        U R                  XSUS9 VVVs/ s H  u  pVnUPM
     snnn5      $ s  snnnf ! [         a,  n[        R
                  (       a  e UR                  S5      eSnAff = f)a<  
Another extension to :class:`scan_string`, simplifying the access to the tokens found
to match the given parse expression.  May be called with optional
``max_matches`` argument, to clip searching after 'n' matches are found.

Example::

    # a capitalized word starts with an uppercase letter, followed by zero or more lowercase letters
    cap_word = Word(alphas.upper(), alphas.lower())

    print(cap_word.search_string("More than Iron, more than Lead, more than Gold I need Electricity"))

    # the sum() builtin can be used to merge results into a single ParseResults object
    print(sum(cap_word.search_string("More than Iron, more than Lead, more than Gold I need Electricity")))

prints::

    [['More'], ['Iron'], ['Lead'], ['Gold'], ['I'], ['Electricity']]
    ['More', 'Iron', 'Lead', 'Gold', 'I', 'Electricity']
F)r  r  N)r  r    r  r  ry   r   r   )	r   r   r  r  r  r   r   rc  r   s	            r:   search_stringParserElement.search_string\  s    8 1
	+ $(#3#3 URW $4 $$a $  " 	+// $$T**	+s%   A ?A A 
A<'A77A<)includeSeparatorsc             #     #    U=(       d    UnSnU R                  XS9 H  u  pgnXU v   U(       a  US   v   UnM     XS v   g7f)a  
Generator method to split a string using the given expression as a separator.
May be called with optional ``maxsplit`` argument, to limit the number of splits;
and the optional ``include_separators`` argument (default= ``False``), if the separating
matching text should be included in the split results.

Example::

    punc = one_of(list(".,;:/-!?"))
    print(list(punc.split("This, this?, this sentence, is badly punctuated!")))

prints::

    ['This', ' this', '', ' this sentence', ' is badly punctuated', '']
r   )r  N)r  )	r   r   maxsplitinclude_separatorsr  lastr   r   rc  s	            r:   r5   ParserElement.split  s]     . .C1C'''GGA!"" d
D	 H
 uos   AAc                    U[         L a  [        U 5      $ [        U[        5      (       a  U R	                  U5      n[        U[
        5      (       d  [        $ [        X/5      $ )a  
Implementation of ``+`` operator - returns :class:`And`. Adding strings to a :class:`ParserElement`
converts them to :class:`Literal`\ s by default.

Example::

    greet = Word(alphas) + "," + Word(alphas) + "!"
    hello = "Hello, World!"
    print(hello, "->", greet.parse_string(hello))

prints::

    Hello, World! -> ['Hello', ',', 'World', '!']

``...`` may be used as a parse expression as a short form of :class:`SkipTo`::

    Literal('start') + ... + Literal('end')

is equivalent to::

    Literal('start') + SkipTo('end')("_skipped*") + Literal('end')

Note that the skipped text is returned with '_skipped' as a results name,
and to support having multiple skips in the same parser, the value returned is
a list of all skipped text.
)Ellipsis_PendingSkipr  r#   r   ry   NotImplementedAndr   others     r:   __add__ParserElement.__add__  sT    6 H%%eX&&,,U3E%//!!D=!!rI   c                    U[         L a  [        U 5      " S5      U -   $ [        U[        5      (       a  U R	                  U5      n[        U[
        5      (       d  [        $ X-   $ )zT
Implementation of ``+`` operator when left operand is not a :class:`ParserElement`
	_skipped*)r  SkipTor  r#   r   ry   r  r  s     r:   __radd__ParserElement.__radd__  sX     H$<,t33eX&&,,U3E%//!!|rI   c                    [        U[        5      (       a  U R                  U5      n[        U[        5      (       d  [        $ U [
        R                  5       -   U-   $ )zH
Implementation of ``-`` operator, returns :class:`And` with error stop
)r  r#   r   ry   r  r  
_ErrorStopr  s     r:   __sub__ParserElement.__sub__  sK     eX&&,,U3E%//!!cnn&&..rI   c                    [        U[        5      (       a  U R                  U5      n[        U[        5      (       d  [        $ X-
  $ )zT
Implementation of ``-`` operator when left operand is not a :class:`ParserElement`
r  r#   r   ry   r  r  s     r:   __rsub__ParserElement.__rsub__  <     eX&&,,U3E%//!!|rI   c                  ^ ^ U[         L a  SnO1[        U[        5      (       a  USS [         4:X  a  SUSS -   S-   SS n[        U[        [        45      (       d  [        $ [        U[        5      (       a  USp2O[        S U 5       5      nUS	-   SS nUS   c  SUS   4n[        US   [        5      (       aB  US   c<  US   S:X  a  [        T 5      $ US   S:X  a  [        T 5      $ T US   -  [        T 5      -   $ [        US   [        5      (       a!  [        US   [        5      (       a	  Uu  p#X2-  nO[        $ US:  a  [        S
5      eUS:  a  [        S5      eX#s=:X  a  S:X  a  O  O[        / 5      $ U(       aG  UU 4S jmU(       a.  US:X  a  T T" U5      -   nU$ [        T /U-  5      T" U5      -   n U$ T" U5      n U$ US:X  a  T nU$ [        T /U-  5      nU$ )ae  
Implementation of ``*`` operator, allows use of ``expr * 3`` in place of
``expr + expr + expr``.  Expressions may also be multiplied by a 2-integer
tuple, similar to ``{min, max}`` multipliers in regular expressions.  Tuples
may also include ``None`` as in:

- ``expr*(n, None)`` or ``expr*(n, )`` is equivalent
  to ``expr*n + ZeroOrMore(expr)``
  (read as "at least n instances of ``expr``")
- ``expr*(None, n)`` is equivalent to ``expr*(0, n)``
  (read as "0 to n instances of ``expr``")
- ``expr*(None, None)`` is equivalent to ``ZeroOrMore(expr)``
- ``expr*(1, None)`` is equivalent to ``OneOrMore(expr)``

Note that ``expr*(None, n)`` does not raise an exception if
more than n exprs exist in the input stream; that is,
``expr*(None, n)`` does not enforce a maximum number of expr
occurrences.  If this behavior is desired, then write
``expr*(None, n) + ~expr``
)r   NNr   r   rB   rZ   r   c              3  :   #    U  H  o[         La  UOS v   M     g 7frB   )r  )r8   r  s     r:   r   (ParserElement.__mul__.<locals>.<genexpr>  s     JEq0!d:Es   )NNz/cannot multiply ParserElement by negative valuez@second tuple value must be greater or equal to first tuple valuec                T   > U S:  a  [        TT" U S-
  5      -   5      $ [        T5      $ rk  )Opt)nmakeOptionalListr   s    r:   r!  /ParserElement.__mul__.<locals>.makeOptionalList*  s.    q5t&6q1u&==>>t9$rI   )	r  r  r  r  r  
ZeroOrMore	OneOrMore
ValueErrorr  )r   r	  minElementsoptElementsr   r!  s   `    @r:   __mul__ParserElement.__mul__  s   * HEu%%%){*BE!"I%/!4E%#u..!!eS!!',aJEJJE\)2A.EQxE!H%(C((U1X-=8q=%d++8q=$T?*%(?Z-===E!Hc**z%(C/H/H+0(*%%?NOO?R  **r7N% !#!1+!>>C 
 tf{236F{6SSC 
 '{3 
	 a 
 4&;./
rI   c                $    U R                  U5      $ rB   )r(  r  s     r:   __rmul__ParserElement.__rmul__>  s    ||E""rI   c                    U[         L a
  [        U SS9$ [        U[        5      (       a"  US:X  a  [	        U 5      $ U R                  U5      n[        U[        5      (       d  [        $ [        X/5      $ )z@
Implementation of ``|`` operator - returns :class:`MatchFirst`
T)	must_skiprl   )	r  r  r  r#   r  r   ry   r  
MatchFirstr  s     r:   __or__ParserElement.__or__A  sg     H55eX&&{4y ,,U3E%//!!4-((rI   c                    [        U[        5      (       a  U R                  U5      n[        U[        5      (       d  [        $ X-  $ )zT
Implementation of ``|`` operator when left operand is not a :class:`ParserElement`
r  r  s     r:   __ror__ParserElement.__ror__Q  r  rI   c                    [        U[        5      (       a  U R                  U5      n[        U[        5      (       d  [        $ [        X/5      $ )z8
Implementation of ``^`` operator - returns :class:`Or`
)r  r#   r   ry   r  Orr  s     r:   __xor__ParserElement.__xor__[  sA     eX&&,,U3E%//!!4-  rI   c                    [        U[        5      (       a  U R                  U5      n[        U[        5      (       d  [        $ X-  $ )zT
Implementation of ``^`` operator when left operand is not a :class:`ParserElement`
r  r  s     r:   __rxor__ParserElement.__rxor__e  r  rI   c                    [        U[        5      (       a  U R                  U5      n[        U[        5      (       d  [        $ [        X/5      $ )z:
Implementation of ``&`` operator - returns :class:`Each`
)r  r#   r   ry   r  Eachr  s     r:   __and__ParserElement.__and__o  sA     eX&&,,U3E%//!!TM""rI   c                    [        U[        5      (       a  U R                  U5      n[        U[        5      (       d  [        $ X-  $ )zT
Implementation of ``&`` operator when left operand is not a :class:`ParserElement`
r  r  s     r:   __rand__ParserElement.__rand__y  r  rI   c                    [        U 5      $ )z<
Implementation of ``~`` operator - returns :class:`NotAny`
)NotAnyr  s    r:   
__invert__ParserElement.__invert__  s     d|rI   c                   Sn[        5       n[        U[        5      (       a  UR                  UR                  p1Uc  SnSnOQ[        U[
        5      (       a<  [        US   [        5      (       a$  US   US   R                  4US   R                  p1Sn[        U[        5      (       a  U4n [        U5        [        U5      S:  a2  [        S	USS
  [        U5      S
:  a  S[        U5       S3OS S35      eU [        USS 5      -  n[        R                  " [        U5      nU(       a  UR                  U5        U$ ! [         a    X4n Nf = f)a  
use ``[]`` indexing notation as a short form for expression repetition:

- ``expr[n]`` is equivalent to ``expr*n``
- ``expr[m, n]`` is equivalent to ``expr*(m, n)``
- ``expr[n, ...]`` or ``expr[n,]`` is equivalent
     to ``expr*n + ZeroOrMore(expr)``
     (read as "at least n instances of ``expr``")
- ``expr[..., n]`` is equivalent to ``expr*(0, n)``
     (read as "0 to n instances of ``expr``")
- ``expr[...]`` and ``expr[0, ...]`` are equivalent to ``ZeroOrMore(expr)``
- ``expr[1, ...]`` is equivalent to ``OneOrMore(expr)``

``None`` may be used in place of ``...``.

Note that ``expr[..., n]`` and ``expr[m, n]`` do not raise an exception
if more than ``n`` ``expr``\ s exist in the input stream.  If this behavior is
desired, then write ``expr[..., n] + ~expr``.

For repetition with a stop_on expression, use slice notation:

- ``expr[...: end_expr]`` and ``expr[0, ...: end_expr]`` are equivalent to ``ZeroOrMore(expr, stop_on=end_expr)``
- ``expr[1, ...: end_expr]`` is equivalent to ``OneOrMore(expr, stop_on=end_expr)``

FN.Tr   r   r   rZ   z'only 1 or 2 index arguments supported (r]   z... []rl   ))NoMatchr  slicer  stopr  r#   iterr   rl  typingr   _MultipleMatchstopOn)r   keystop_on_definedstop_onr   s        r:   __getitem__ParserElement.__getitem__  sC   6  )c5!!99chh{"OU##
3r7E(B(BFCFLL13q6;;"O c8$$&C	I s8a<9#bq'Z]^aZbefZfU3s8*TUCVlnBoopq 
 U3r7^#kk.#.JJw
  	*C	s   +D= =EEc                J    Ub  U R                  U5      $ U R                  5       $ )a  
Shortcut for :class:`set_results_name`, with ``list_all_matches=False``.

If ``name`` is given with a trailing ``'*'`` character, then ``list_all_matches`` will be
passed as ``True``.

If ``name`` is omitted, same as calling :class:`copy`.

Example::

    # these are equivalent
    userdata = Word(alphas).set_results_name("name") + Word(nums + "-").set_results_name("socsecno")
    userdata = Word(alphas)("name") + Word(nums + "-")("socsecno")
)r2  r-  r   rF   s     r:   __call__ParserElement.__call__  s'     ''--yy{rI   c                    [        U 5      $ )zv
Suppresses the output of this :class:`ParserElement`; useful to keep punctuation from
cluttering up returned output.
)Suppressr  s    r:   suppressParserElement.suppress  s    
 ~rI   c                    SU l         U $ )z
Enables the skipping of whitespace before matching the characters in the
:class:`ParserElement`'s defined pattern.

:param recursive: If ``True`` (the default), also enable whitespace skipping in child elements (if any)
Tr  r   	recursives     r:   ignore_whitespaceParserElement.ignore_whitespace  s     #rI   c                    SU l         U $ )aT  
Disables the skipping of whitespace before matching the characters in the
:class:`ParserElement`'s defined pattern.  This is normally only used internally by
the pyparsing module, but may be needed in some whitespace-sensitive grammars.

:param recursive: If true (the default), also disable whitespace skipping in child elements (if any)
Fr_  r`  s     r:   leave_whitespaceParserElement.leave_whitespace  s     $rI   c                @    SU l         [        U5      U l        X l        U $ )z(
Overrides the default whitespace chars
T)r  r   r   r   )r   r   copy_defaultss      r:   set_whitespace_chars"ParserElement.set_whitespace_chars  s"     #e*%2"rI   c                    SU l         U $ )z
Overrides default behavior to expand ``<TAB>`` s to spaces before parsing the input string.
Must be called before ``parse_string`` when the input grammar contains elements that
match ``<TAB>`` characters.
T)r  r  s    r:   parse_with_tabsParserElement.parse_with_tabs  s     rI   c                ,   [        U[        5      (       a  [        U5      n[        U[        5      (       a,  XR                  ;  a  U R                  R	                  U5        U $ U R                  R	                  [        UR                  5       5      5        U $ )a  
Define expression to be ignored (e.g., comments) while doing pattern
matching; may be called repeatedly, to define multiple comment or other
ignorable patterns.

Example::

    patt = Word(alphas)[...]
    patt.parse_string('ablaj /* comment */ lskjd')
    # -> ['ablaj']

    patt.ignore(c_style_comment)
    patt.parse_string('ablaj /* comment */ lskjd')
    # -> ['ablaj', 'lskjd']
)r  r#   r[  r  r  r-  r  s     r:   ignoreParserElement.ignore  st      eX&&UOEeX&&,,,  ''.  ##HUZZ\$:;rI   c                    U R                  U=(       d    [        U=(       d    [        U=(       d    [        5      U l        SU l        U $ )a  
Customize display of debugging messages while doing pattern matching:

- ``start_action`` - method to be called when an expression is about to be parsed;
  should have the signature ``fn(input_string: str, location: int, expression: ParserElement, cache_hit: bool)``

- ``success_action`` - method to be called when an expression has successfully parsed;
  should have the signature ``fn(input_string: str, start_location: int, end_location: int, expression: ParserELement, parsed_tokens: ParseResults, cache_hit: bool)``

- ``exception_action`` - method to be called when expression fails to parse;
  should have the signature ``fn(input_string: str, location: int, expression: ParserElement, exception: Exception, cache_hit: bool)``
T)r   r   r   r   r  r  )r   start_actionsuccess_actionexception_actions       r:   set_debug_actionsParserElement.set_debug_actions'  s@    $ !--77;;? ?

 
rI   c                    U(       a)  U R                  5        H  nUR                  USS9  M     U $ U(       a!  U R                  [        [        [
        5        U $ SU l        U $ )a  
Enable display of debugging messages while doing pattern matching.
Set ``flag`` to ``True`` to enable, ``False`` to disable.
Set ``recurse`` to ``True`` to set the debug flag on this expression and all sub-expressions.

Example::

    wd = Word(alphas).set_name("alphaword")
    integer = Word(nums).set_name("numword")
    term = wd | integer

    # turn on debugging for wd
    wd.set_debug()

    term[1, ...].parse_string("abc 123 xyz 890")

prints::

    Match alphaword at loc 0(1,1)
    Matched alphaword -> ['abc']
    Match alphaword at loc 3(1,4)
    Exception raised:Expected alphaword (at char 4), (line:1, col:5)
    Match alphaword at loc 7(1,8)
    Matched alphaword -> ['xyz']
    Match alphaword at loc 11(1,12)
    Exception raised:Expected alphaword (at char 12), (line:1, col:13)
    Match alphaword at loc 15(1,16)
    Exception raised:Expected alphaword (at char 15), (line:1, col:16)

The output shown is that produced by the default debug actions - custom debug actions can be
specified using :class:`set_debug_actions`. Prior to attempting
to match the ``wd`` expression, the debugging message ``"Match <exprname> at loc <n>(<line>,<col>)"``
is shown. Then if the parse succeeds, a ``"Matched"`` message is shown, or an ``"Exception raised"``
message is shown. Also note the use of :class:`set_name` to assign a human-readable name to the expression,
which makes debugging and exception messages easier to understand - for instance, the default
name created for the :class:`Word` expression without calling ``set_name`` is ``"W:(A-Za-z)"``.
F)r&  )r*  r  ru  r   r   r   r  )r   flagr&  r   s       r:   r  ParserElement.set_debugA  s]    L (tU3 )K""+-/  DJrI   c                ^    U R                   c  U R                  5       U l         U R                   $ rB   )r  _generateDefaultNamer  s    r:   default_nameParserElement.default_namev  s+    $ $ 9 9 ;D   rI   c                    g)zW
Child classes must define this method, which defines how the ``default_name`` is set.
Nr*   r  s    r:   r{  "ParserElement._generateDefaultName|  r   rI   c                    Xl         S[        U 5       3U l        [        R                  (       a  U R                  USL5        U $ )ao  
Define name for this expression, makes debugging and exception messages clearer. If
`__diag__.enable_debug_on_named_expressions` is set to True, setting a name will also
enable debug for this expression.

If `name` is None, clears any custom name for this expression, and clears the
debug flag is it was enabled via `__diag__.enable_debug_on_named_expressions`.

Example::

    integer = Word(nums)
    integer.parse_string("ABC")  # -> Exception: Expected W:(0-9) (at char 0), (line:1, col:1)

    integer.set_name("integer")
    integer.parse_string("ABC")  # -> Exception: Expected integer (at char 0), (line:1, col:1)
	Expected N)r   rz   r  r<   rT   r  rW  s     r:   set_nameParserElement.set_name  s:    " !#d)-55NN4t+,rI   c                L    U R                   b  U R                   $ U R                  $ rB   )r   r|  r  s    r:   rF   ParserElement.name  s"     #'//"=tT4CTCTTrI   c                &    U R                  U5        g rB   )r  )r   new_names     r:   rF   r    s    hrI   c                    U R                   $ rB   rF   r  s    r:   __str__ParserElement.__str__  s    yyrI   c                    [        U 5      $ rB   rz   r  s    r:   __repr__ParserElement.__repr__  s    4yrI   c                "    SU l         S U l        U $ NT)r	  r  r  s    r:   r  ParserElement.streamline  s     rI   c                    / $ rB   r*   r  s    r:   r&  ParserElement.recurse      	rI   c                f    US S  U /-   nU R                  5        H  nUR                  U5        M     g rB   )r&  _checkRecursionr   parseElementListsubRecCheckListrc  s       r:   r  ParserElement._checkRecursion  s1    *1-6Ao.  rI   c                Z    [         R                  " S[        SS9  U R                  / 5        g)zZ
Check defined expressions for valid structure, check for infinite recursive definitions.
ZParserElement.validate() is deprecated, and should not be used to check for left recursionrZ   
stacklevelN)warningsr?   DeprecationWarningr  )r   validateTraces     r:   validateParserElement.validate  s)     	h	

 	R rI   c                  U=(       d    Un [         R                  " [        U5      nUR                  5       n U R                  WU5      $ ! [         aU    [         R                  " [
        U5      n[        USUS9 nUR                  5       nSSS5         M_  ! , (       d  f        Nn= ff = f! [         a,  n[        R                  (       a  e UR                  S5      eSnAff = f)z
Execute the parse expression on the given file or filename.
If a filename is specified (instead of a file object),
the entire file is opened, read, and closed before parsing.
rencodingN)rN  r   r
   readAttributeErrorrz   openr  r  ry   r   r   )r   file_or_filenamer  r  r  file_contentsfr   s           r:   
parse_fileParserElement.parse_file  s     (y	)%{{63CD,113M
	+$$]H==  	)%{{30@A&h?1 ! @???	) " 	+// $$T**	+s@   +A B- 0B*;BB*
B&	!B*&B*-
C#7'CC#c                    XL a  g[        U[        5      (       a  U R                  USS9$ [        U[        5      (       a  [	        U 5      [	        U5      :H  $ g)NTr  F)r  r#   r  ry   varsr  s     r:   __eq__ParserElement.__eq__  sM    =x((<<<66}--:e,,rI   c                    [        U 5      $ rB   )idr  s    r:   __hash__ParserElement.__hash__  s    $xrI   c               n    U=(       a    Un U R                  [        U5      US9  g! [         a     gf = f)a  
Method for quick testing of a parser against a test string. Good for simple
inline microtests of sub expressions while building up larger parser.

Parameters:

- ``test_string`` - to test against this expression for a match
- ``parse_all`` - (default= ``True``) - flag to pass to :class:`parse_string` when running tests

Example::

    expr = Word(nums)
    assert expr.matches("100")
r  TF)r  rz   r  )r   test_stringr  r  s       r:   r  ParserElement.matches  s@    " )		c+.(C! 		s   ' 
44)r  fullDumpprintResultsfailureTestsry  c
          	        SSK Jn  U
=(       a    Un
U=(       a    UnU=(       a    UnU=(       d    UnU=(       d    Un[        U[        5      (       ad  [        R
                  " [        U5      n[        U5      R                  nUR                  5       R                  5        Vs/ s H  nU" U5      PM     nnUSLnU(       a;  [        U[        5      (       a&  [        R
                  " [        U5      n[        U5      n[        R
                  " [        U5      nUc  [        R                  nUR                  n/ n/ nSn[        S5      R!                  [#        S5      5      R%                  [&        5      nSnSnU GH  nU(       a  UR)                  US5      (       d  U(       a2  U(       d+  UR+                  U	(       a  UR-                  U5      OU5        M[  U(       d  Md  U U(       a  UR/                  U5      OS	 3U	(       a  UR-                  U5      OU/nUR1                  5          UR3                  UR5                  U5      5      nU R7                  UU
S
9nU=(       a    U(       + nUb}   U" UU5      nUbP  [        U[8        5      (       a   UR+                  UR;                  5       5        OZUR+                  [        U5      5        O?UR+                  UR;                  5       5        OUR+                  UR;                  US95         UR+                  S	5        U(       a  U" SR/                  U5      5        UR+                  UU45        GM     UU4$ s  snf ! [<         a^  nUR+                  UR;                  US95        UR+                  UR>                   S[        U5      R>                   SU 35         SnANSnAff = f! [@         a  n[        U[B        5      (       a  SOS	n UR+                  URE                  5       5        UR+                  SU  U 35        [        RF                  (       a/  URI                  [J        RL                  " URN                  5      5        U=(       a    UnUn SnAGNjSnAf[<         Ga  n!Sn"U!RN                  n#[Q        [J        RR                  " U#5      5      n$U$ HT  u  n%n&U%RT                  RV                  U&4[X        :X  d  M(  [[        U$5      S   n'U"SU'RT                  R\                  < S3-  n"  O   UR+                  U" S[        U!5      R>                   SU! 35        [        RF                  (       a/  URI                  [J        RL                  " U!RN                  5      5        U=(       a    UnU!n Sn!A!GNSn!A!ff = f)a  
Execute the parse expression on a series of test strings, showing each
test, the parsed results or where the parse failed. Quick and easy way to
run a parse expression against a list of sample strings.

Parameters:

- ``tests`` - a list of separate test strings, or a multiline string of test strings
- ``parse_all`` - (default= ``True``) - flag to pass to :class:`parse_string` when running tests
- ``comment`` - (default= ``'#'``) - expression for indicating embedded comments in the test
  string; pass None to disable comment filtering
- ``full_dump`` - (default= ``True``) - dump results as list followed by results names in nested outline;
  if False, only dump nested list
- ``print_results`` - (default= ``True``) prints test output to stdout
- ``failure_tests`` - (default= ``False``) indicates if these tests are expected to fail parsing
- ``post_parse`` - (default= ``None``) optional callback for successful parse results; called as
  `fn(test_string, parse_results)` and returns a string to be added to the test output
- ``file`` - (default= ``None``) optional file-like object to which test output will be written;
  if None, will default to ``sys.stdout``
- ``with_line_numbers`` - default= ``False``) show test strings with line and column numbers

Returns: a (success, results) tuple, where success indicates that all tests succeeded
(or failed if ``failure_tests`` is True), and the results contain a list of lines of each
test's output

Example::

    number_expr = pyparsing_common.number.copy()

    result = number_expr.run_tests('''
        # unsigned integer
        100
        # negative integer
        -100
        # float with scientific notation
        6.02e23
        # integer with scientific notation
        1e-12
        ''')
    print("Success" if result[0] else "Failed!")

    result = number_expr.run_tests('''
        # stray character
        100Z
        # missing leading digit before '.'
        -.100
        # too many '.'
        3.14.159
        ''', failure_tests=True)
    print("Success" if result[0] else "Failed!")

prints::

    # unsigned integer
    100
    [100]

    # negative integer
    -100
    [-100]

    # float with scientific notation
    6.02e23
    [6.02e+23]

    # integer with scientific notation
    1e-12
    [1e-12]

    Success

    # stray character
    100Z
       ^
    FAIL: Expected end of text (at char 3), (line:1, col:4)

    # missing leading digit before '.'
    -.100
    ^
    FAIL: Expected {real number with scientific notation | real number | signed integer} (at char 0), (line:1, col:1)

    # too many '.'
    3.14.159
        ^
    FAIL: Expected end of text (at char 4), (line:1, col:5)

    Success

Each test string must be on a single line. If you want to test a string that spans multiple
lines, create a test like this::

    expr.run_tests(r"this is a test\n of strings that spans \n 3 lines")

(Note that this is a raw string literal, you must include the leading ``'r'``.)
r   )pyparsing_testNT\n
u   ﻿Frl   r  )fullz	 failed: : z(FATAL) zFAIL: zFAIL-EXCEPTIONr   z (raised in parse action rI  )/testingr  r  r#   rN  r   rz   r   striprstrip
splitlinesLiteralry   sysstdoutwriterX  replace_withro  quoted_stringr  r  with_line_numbersr  rO  r  lstripr  r    dumpr~  r+   r  r   explainr   r%  r   	format_tbr   rM  walk_tbf_codeco_filenamer   nextco_name)(r   testsr  comment	full_dumpprint_resultsfailure_tests
post_parsefiler  r  r  r  r  ry  r  
line_strip	test_linecomment_specifiedprint_
allResultscommentssuccessNLBOMnlstrr   r  r  pp_valuerc  r  r   r   tagr   itr  r   next_fs(                                           r:   	run_testsParserElement.run_tests  s   j 	,)	)	#5#4}+	eX&&KKU+Ee**J<ALLN<U<U<WX<WyZ	*<WEX#4/'8,, ++c73!'*++mW5<::D HJ
 U^,,\$-?@GGVA W__Q%>%>(ST;LN44Q7RS '(%**X.CD7H003aC NN/;''6**1*A6 "6,&6(#,Q#7#/)(LAA #

8==? ; #

3x= 9JJv{{}5 JJv{{{9:JJrNtyy~&q&k*E H 
""m YP % 

6;;H;#=>

(112)DG<L<L;MRPQsS K & &05H&I&I
r

2::<(

VE72$/0 33JJy2223C3CDE!2l & &&)++B/0!GAt,,d37II!%b!!:6==;P;P:SSTUU	  " 

cU"T#Y%7%7$83%@A 33JJy2233D3DEF!2l!sY   #M&0O *A M+MM
N=AN88N= 
V
BQ//V=AVB-VVc           	     r    SSK JnJn	  U R                  5         U" U UUUUUS9n[        U[        [        45      (       d  UR                  U	" U4SU0UD65        g[        USSS	9 nUR                  U	" U4SU0UD65        SSS5        g! [         a  n
[	        S5      U
eSn
A
ff = f! , (       d  f       g= f)
a<  
Create a railroad diagram for the parser.

Parameters:

- ``output_html`` (str or file-like object) - output target for generated
  diagram HTML
- ``vertical`` (int) - threshold for formatting multiple alternatives vertically
  instead of horizontally (default=3)
- ``show_results_names`` - bool flag whether diagram should show annotations for
  defined results names
- ``show_groups`` - bool flag whether groups should be highlighted with an unlabeled surrounding box
- ``show_hidden`` - bool flag to show diagram elements for internal elements that are usually hidden
- ``embed`` - bool flag whether generated HTML should omit <HEAD>, <BODY>, and <DOCTYPE> tags to embed
  the resulting HTML in an enclosing HTML source
- ``head`` - str containing additional HTML to insert into the <HEAD> section of the generated code;
  can be used to insert custom CSS styling
- ``body`` - str containing additional HTML to insert at the beginning of the <BODY> section of the
  generated code

Additional diagram-formatting keyword arguments can also be included;
see railroad.Diagram class.
r   )to_railroadrailroad_to_htmlzMmust ``pip install pyparsing[diagrams]`` to generate parser railroad diagramsN)verticalshow_results_namesshow_groupsshow_hiddendiagram_kwargsembedwutf-8r  )diagramr  r  ImportErrorr~  r  r  rz   r   r  r  )r   output_htmlr  r  r  r  r  rT  r  r  r   railroad	diag_files                r:   create_diagramParserElement.create_diagram  s    D	> 	1##!
 +T{33.xOuOOP+sW5OO,XMUMfMN 65)  	_	( 65s#   B
 &B(

B%B  B%(
B6inlineLiteralsUsingsetDefaultWhitespaceCharsdisableMemoizationenableLeftRecursionenablePackratr  setResultsNamesetBreaksetParseActionaddParseActionaddConditionsetFailActiontryParseparseString
scanStringtransformStringsearchStringignoreWhitespaceleaveWhitespacesetWhitespaceCharsparseWithTabssetDebugActionssetDebugsetName	parseFilerunTestscanParseNext)r  r  rD  r  r  r   r   r  r  r  r   r  r  r
  r  r   r  r  r  r  r	  r  r   )r   rz   rK   rL   )rE   r   rK   rL   F)r  rm   rK   rL   )r  rX   rK   ry   rK   ry   )rF   rz   r3  rm   r0  rm   rK   ry   T)rF  rm   rK   ry   )rS  ParseActionrT  r   rK   ry   )rS  ParseConditionrT  r   rK   ry   )r   ParseFailActionrK   ry   r   rz   r   r  rK   r  rK   ParseImplReturnTyperC  )rK   ztuple[int, ParseResults])
r   rz   r   r  r  rm   r=  rm   rK   r  )r   rz   r   r  r=  rm   rK   rm   rJ   rB   )r  typing.Optional[int]rK   rL   )   )r  zUnion[int, None]r  rm   rK   rL   )r   rz   r  rm   r  rm   rK   r    )r   rz   r  r  r  rm   r  rm   r  r  rK   z4Generator[tuple[ParseResults, int, int], None, None])r   rz   r  rm   rK   rz   )
r   rz   r  r  r  rm   r  r  rK   r    )r   rz   r  r  r   rm   rK   zGenerator[str, None, None])rF   typing.Optional[str]rK   ry   ra  rm   rK   ry   )r   zUnion[set[str], str]rh  rm   rK   ry   )r	  ry   rK   ry   )rr  DebugStartActionrs  DebugSuccessActionrt  DebugExceptionActionrK   ry   )TF)rx  rm   r&  rm   rK   ry   rK   rz   rK   list[ParserElement])r  F)
r  zUnion[str, Path, TextIO]r  rz   r  rm   r  rm   rK   r    )r  rz   r  rm   r  rm   rK   rm   )T#TTFNNF)r  zUnion[str, list[str]]r  rm   r  *typing.Optional[Union[ParserElement, str]]r  rm   r  rm   r  rm   r  Dtyping.Optional[Callable[[str, ParseResults], typing.Optional[str]]]r  ztyping.Optional[TextIO]r  rm   r  rm   r  rm   r  rm   r  rm   ry  r2  rK   z=tuple[bool, list[tuple[str, Union[ParseResults, Exception]]]])r[   FFFF)r  zUnion[TextIO, Path, str]r  r  r  rm   r  rm   r  rm   r  rm   rK   rL   )r+   r,   r-   r.   r/   r   r   r   r   staticmethodr   r   rV   r   r   r   r   propertyr  setterr   r*  r-  r4  r2  rG  rU  rX  r[  r^  rh  ro  rs  ry  r  r  r  r   recursion_lockr  rN  Protocolr  dictr  r  r  r  r  rD  r  r  r  r  r  r  r  _MAX_INTr  r  r  r5   r
  r  r  r  r(  r+  r0  r3  r7  r:  r>  rA  rE  __iter__rT  rX  r\  rb  re  ri  rl  ro  ru  r  r|  r   r{  r  rF   r  r  r  r&  r  r  r  r  r  r  r  r  r   r  r  r  r  r  r  r  r	  r
  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  defaultNamer7   r*   rI   r:   ry   ry     sC   3(($$ $$- -( 0 0* 	= 	=:z :
$: & & ' ' "< 38 :SX : :+/ :LP :	 :D	(Vp
#J *

 <@c	!cT " CC C
 C C 
C WN 	   %V__ %%D %" !*M:+a&
 <@.$	!.$` F. . O#; ; 15-5@E-5.-5	-5 -5^ -0.9CH.9*.9<@.9	.9 .9b 05EJOEE(,ECGE	ET $#`+ "`+`+ `+ 	`+ `+ `+ 
>`+D @E 1+l $++
 "++++ ++
 ++ ++ 
++` !#(	    !	 
$@""H/N`#) !# H:x(	 BG	)	:>			4& + /	
 
43j ! !
  
2 U U 
[[   
/
	!  	+ +2+ + 	+ + 
+< 37LP+/EI	6 >A"# (,"'U# !" )U#$U# U# <	U#
 U# U# U#
U# &U#  U# U# U#  !U#" #U#$
%U#* 
G+U#t #(!!9O-9O 9O !	9O
 9O 9O 9O 
9Oz ''78MOd'ef ,-=#%A. ! &&67KM`&ab&'78MOd'ef !1/>!RSM.|[IJJ%&68HIN
I6H%&68HIN%&68HIN#NMBL$_oFM
I6H"=,?K!,<J&'8:JKO#NMBL'(:<MN&'8:JKO)*>@TU$_oFM&'8:KLO
I6Hy(3G j9I
I6H#NNCLKrI   c                  T   ^  \ rS rSrSS	U 4S jjjrS
S jrSS jrS rSS jrSr	U =r
$ )r  i:	  c                :   > [         TU ]  5         Xl        X l        g rB   )superr   anchorr.  )r   r   r.  r   s      r:   r   _PendingSkip.__init__=	  s    "rI   c                b    [        U R                  [        5       -   5      R                  SS5      $ )Nr  ...)rz   r?  r  replacer  s    r:   r{  !_PendingSkip._generateDefaultNameB	  s%    4;;()11'5AArI   c                  ^  [        U5      R                  S5      " S5      nT R                  (       aF  S nU 4S jnT R                  U" 5       R	                  U5      -   U" 5       R	                  U5      -  U-   $ T R                  U-   U-   $ )NrB  r  c                    U R                   (       a  U R                   R                  5       S/:X  a  U S	 U R                  SS 5        g g )Nrl   r   _skipped)rG  r   pop)r   s    r:   r.  '_PendingSkip.__add__.<locals>.must_skipI	  s:    zzQZZ%7%7%9bT%A!EE*d+ &BrI   c                   > U R                   R                  5       SS  S/:X  a&  U R                  S5        STR                  < S3U S'   g g )Nr   rl   rG  z	missing <r   )rG  r   rH  r?  )r   r   s    r:   	show_skip'_PendingSkip.__add__.<locals>.show_skipN	  sH    ::%%',4EE*%&/a$@AjM 5rI   )r  r  r.  r?  rX  )r   r	  skipperr.  rK  s   `    r:   r
  _PendingSkip.__add__E	  s    -((/<>>,
A gi88CC),,Y78 
 {{W$u,,rI   c                    U R                   $ rB   )r;  r  s    r:   r  _PendingSkip.__repr__Z	  s    rI   c                    [        S5      e)NzBuse of `...` expression without following SkipTo target expression)r~  r  s     r:   rs  _PendingSkip.parseImpl]	  s    P
 	
rI   )r?  r.  r  )r   ry   r.  rm   rK   rL   r-  r  r$  )r+   r,   r-   r.   r   r{  r
  r  rs  r7   __classcell__r   s   @r:   r  r  :	  s'    # #
B-* 
 
rI   r  c                  :   ^  \ rS rSrSrSU 4S jjrSS jrSrU =r$ )Tokenic	  zQAbstract :class:`ParserElement` subclass, for defining atomic
matching patterns.
c                    > [         TU ]  SS9  g )NFr  r>  r   r   r   s    r:   r   Token.__init__h	  s    %(rI   c                ,    [        U 5      R                  $ rB   )r   r+   r  s    r:   r{  Token._generateDefaultNamek	  s    Dz"""rI   r*   rJ   r-  )	r+   r,   r-   r.   r/   r   r{  r7   rS  rT  s   @r:   rV  rV  c	  s    )# #rI   rV  c                  >   ^  \ rS rSrSrSU 4S jjrSSS jjrSrU =r$ )	rJ  io	  z 
A token that will never match.
c                L   > [         TU ]  5         SU l        SU l        SU l        g )NTFzUnmatchable token)r>  r   r  r
  r  rZ  s    r:   r   NoMatch.__init__t	  s%    !%")rI   c                0    [        XU R                  U 5      erB   )r   r  rr  s       r:   rs  NoMatch.parseImplz	  s    XDKK>>rI   )r  r  r
  rJ   r  r$  	r+   r,   r-   r.   r/   r   rs  r7   rS  rT  s   @r:   rJ  rJ  o	  s    *? ?rI   rJ  c                  v   ^  \ rS rSrSrSSS.SU 4S jjjjrS rSSS.SU 4S jjjjrSS jrSSS	 jjr	S
r
U =r$ )r  i~	  a  
Token to exactly match a specified string.

Example::

    Literal('abc').parse_string('abc')  # -> ['abc']
    Literal('abc').parse_string('abcdef')  # -> ['abc']
    Literal('abc').parse_string('ab')  # -> Exception: Expected "abc"

For case-insensitive matching, use :class:`CaselessLiteral`.

For keyword matching (force word break before and after the matched string),
use :class:`Keyword` or :class:`CaselessKeyword`.
rl   matchStringc                  > U [         L aG  U=(       d    UnU(       d  [        TU ]	  [        5      $ [	        U5      S:X  a  [        TU ]	  [
        5      $ [        TU ]	  U 5      $ rk  )r  r>  __new__r  rl  _SingleCharLiteral)rE   match_stringrf  r   s      r:   rh  Literal.__new__	  sT    '>&6,Lwu--< A%w'9:: ws##rI   c                    U R                   4$ rB   )matchr  s    r:   __getnewargs__Literal.__getnewargs__	  s    

}rI   c                  > [         TU ]  5         U=(       d    UnXl        [        U5      U l        US S U l        SU R                   3U l        SU l        SU l	        g )Nr   r  F)
r>  r   rm  rl  matchLenfirstMatchCharrF   r  r  r
  r   rj  rf  r   s      r:   r   Literal.__init__	  sZ    "2l!
L)*2A.!$))-!&"rI   c                ,    [        U R                  5      $ rB   reprrm  r  s    r:   r{  Literal._generateDefaultName	      DJJrI   c                    X   U R                   :X  a;  UR                  U R                  U5      (       a  X R                  -   U R                  4$ [	        XU R
                  U 5      erB   )rr  r3   rm  rq  r   r  rr  s       r:   rs  Literal.parseImpl	  sX    =D///H4G4GJJ5
 5
 &

22XDKK>>rI   )r  r  rr  rm  rq  r
  rl   )rj  rz   rf  rz   rj  rz   rf  rz   rK   rL   r-  r  r$  )r+   r,   r-   r.   r/   rh  rn  r   r{  rs  r7   rS  rT  s   @r:   r  r  ~	  s>    
$2 
$ 
$#R # # ? ?rI   r  c                  T   ^  \ rS rSrSrS	SS.S
U 4S jjjjrSS jrSSS jjrSrU =r	$ )r  i	  z$
An empty token, will always match.
rl   re  c               @   > [         TU ]  S5        SU l        SU l        g )Nrl   TFr>  r   r  r
  rs  s      r:   r   Empty.__init__	  s     !%"rI   c                    g)Nr  r*   r  s    r:   r{  Empty._generateDefaultName	  s    rI   c                
    U/ 4$ rB   r*   rr  s       r:   rs  Empty.parseImpl	  ru  rI   r  r
  r|  rJ   r-  r  r$  
r+   r,   r-   r.   r/   r   r{  rs  r7   rS  rT  s   @r:   r  r  	  s(    #r # #
 rI   r  c                  "    \ rS rSrSSS jjrSrg)ri  i	  c                v    X   U R                   :X  a  US-   U R                  4$ [        XU R                  U 5      erk  )rr  rm  r   r  rr  s       r:   rs  _SingleCharLiteral.parseImpl	  s8    =D///7DJJ&&XDKK>>rI   r*   Nr  r$  )r+   r,   r-   r.   rs  r7   r*   rI   r:   ri  ri  	  s    ? ?rI   ri  c                     ^  \ rS rSrSr\S-   r   SSSS.           SU 4S jjjjrSS jrSSS	 jjr	\
SS
 j5       r\
" \" S\5      5      rSrU =r$ )Keywordi	  aR  
Token to exactly match a specified string as a keyword, that is,
it must be immediately preceded and followed by whitespace or
non-keyword characters. Compare with :class:`Literal`:

- ``Literal("if")`` will match the leading ``'if'`` in
  ``'ifAndOnlyIf'``.
- ``Keyword("if")`` will not; it will only match the leading
  ``'if'`` in ``'if x=1'``, or ``'if(y==2)'``

Accepts two optional constructor arguments in addition to the
keyword string:

- ``ident_chars`` is a string of characters that would be valid
  identifier characters, defaulting to all alphanumerics + "_" and
  "$"
- ``caseless`` allows case-insensitive matching, default is ``False``.

Example::

    Keyword("start").parse_string("start")  # -> ['start']
    Keyword("start").parse_string("starting")  # -> Exception

For case-insensitive matching, use :class:`CaselessKeyword`.
z_$rl   Nrf  
identCharsc                 > [         TU ]  5         U=(       d    UnUc  [        R                  nU=(       d    UnXl        [        U5      U l        US S U l        U R                  (       d  [        S5      eS[        U 5      R                   SU R                   3U l        SU l        SU l        X0l        U(       a%  UR!                  5       U l        UR!                  5       n[%        U5      U l        g )Nr   z2null string passed to Keyword; use Empty() insteadr   F)r>  r   r  DEFAULT_KEYWORD_CHARSrm  rl  rq  rr  r%  r   r+   rF   r  r  r
  caselessuppercaselessmatchr   r  )r   rj  ident_charsr  rf  r  r   s         r:   r   Keyword.__init__	  s     	.;
 66J"2l!
L)*2A.""QRR!$t*"5"5!6a		{C!&" !-!3!3!5D#))+Jj/rI   c                ,    [        U R                  5      $ rB   rv  r  s    r:   r{  Keyword._generateDefaultName
  ry  rI   c                   U R                   =(       d    SnUnU R                  (       a  XX R                  -    R                  5       U R                  :X  a  US:X  d#  XS-
     R                  5       U R
                  ;  aw  U[        U5      U R                  -
  :  d-  XU R                  -      R                  5       U R
                  ;  a  X R                  -   U R                  4$ US-  nX R                  -   nOUS-  nUS-
  nOX   U R                  :X  a  U R                  S:X  d!  UR                  U R                  U5      (       a  US:X  d  XS-
     U R
                  ;  ai  U[        U5      U R                  -
  :  d  XU R                  -      U R
                  ;  a  X R                  -   U R                  4$ US-  nX R                  -   nO
US-  nUS-
  n[        XX@5      e)Nrl   r   r   z/, was immediately followed by keyword characterz7, keyword was immediately preceded by keyword characterz7, keyword was immediately followed by keyword character)r  r  rq  r  r  r  rl  rm  rr  r3   r   )r   r   r   r=  r  errlocs         r:   rs  Keyword.parseImpl

  s   "==cMM1288:d>P>PP!8xa0668Os8}t}}<<#$--$78>>@W"]]2DJJ>> OOF ==0F WWF 1WF MT000"""4::s33ax8!G,DOOC3x=4==88dmm 34DOOK.

:: SS}}, SSq Xv<<rI   c                    U [         l        g)zH
Overrides the default characters used by :class:`Keyword` expressions.
N)r  r  )r   s    r:   set_default_keyword_chars!Keyword.set_default_keyword_chars6
  s    
 ).%rI   setDefaultKeywordChars)	r  r  r  r  rr  r  rm  rq  r
  )rl   NF)rj  rz   r  r(  r  rm   rf  rz   r  r(  rK   rL   r-  r  r$  rJ   )r+   r,   r-   r.   r/   r   r  r   r{  rs  r3  r  r   r  r7   rS  rT  s   @r:   r  r  	  s    4 &, ,0	* +/** ** 	* * )* 
* *8 *=X . . *13LMrI   r  c                  J   ^  \ rS rSrSrSSS.S	U 4S jjjjrS
SS jjrSrU =r$ )CaselessLiteraliC
  aQ  
Token to match a specified string, ignoring case of letters.
Note: the matched results will always be in the case of the given
match string, NOT the case of the input text.

Example::

    CaselessLiteral("CMD")[1, ...].parse_string("cmd CMD Cmd10")
    # -> ['CMD', 'CMD', 'CMD']

(Contrast with example for :class:`CaselessKeyword`.)
rl   re  c                  > U=(       d    Un[         TU ]  UR                  5       5        Xl        SU R                   3U l        g )Nr  )r>  r   r  returnStringrF   r  rs  s      r:   r   CaselessLiteral.__init__Q
  s;    "2l++-.(!$))-rI   c                    XX R                   -    R                  5       U R                  :X  a  X R                   -   U R                  4$ [	        XU R
                  U 5      erB   )rq  r  rm  r  r   r  rr  s       r:   rs  CaselessLiteral.parseImplX
  sN    #-.446$**D&(9(999XDKK>>rI   )r  r  r|  r}  r  r$  rc  rT  s   @r:   r  r  C
  s#    .R . .? ?rI   r  c                  T   ^  \ rS rSrSr  SSSS.         S	U 4S jjjjrSrU =r$ )
CaselessKeywordi^
  z
Caseless version of :class:`Keyword`.

Example::

    CaselessKeyword("CMD")[1, ...].parse_string("cmd CMD Cmd10")
    # -> ['CMD', 'CMD']

(Contrast with example for :class:`CaselessLiteral`.)
rl   Nr  c               N   > U=(       d    UnU=(       d    Un[         TU ]  XSS9  g )NT)r  rY  )r   rj  r  rf  r  r   s        r:   r   CaselessKeyword.__init__j
  s+      .;
"2lDArI   r*   )rl   N)
rj  rz   r  r(  rf  rz   r  r(  rK   rL   r+   r,   r-   r.   r/   r   r7   rS  rT  s   @r:   r  r  ^
  s_    	 ,0
B
 +/
B
B *
B
 
B )
B 

B 
BrI   r  c                  f   ^  \ rS rSrSr S
SSS.       SU 4S jjjjrSS jrSSS jjrS	rU =r	$ )
CloseMatchiw
  a  A variation on :class:`Literal` which matches "close" matches,
that is, strings with at most 'n' mismatching characters.
:class:`CloseMatch` takes parameters:

- ``match_string`` - string to be matched
- ``caseless`` - a boolean indicating whether to ignore casing when comparing characters
- ``max_mismatches`` - (``default=1``) maximum number of
  mismatches allowed to count as a match

The results from a successful parse will contain the matched text
from the input string and the following named results:

- ``mismatches`` - a list of the positions within the
  match_string where mismatches were found
- ``original`` - the original match_string used to compare
  against the input string

If ``mismatches`` is an empty list, then the match was an exact
match.

Example::

    patt = CloseMatch("ATCATCGAATGGA")
    patt.parse_string("ATCATCGAAXGGA") # -> (['ATCATCGAAXGGA'], {'mismatches': [[9]], 'original': ['ATCATCGAATGGA']})
    patt.parse_string("ATCAXCGAAXGGA") # -> Exception: Expected 'ATCATCGAATGGA' (with up to 1 mismatches) (at char 0), (line:1, col:1)

    # exact match
    patt.parse_string("ATCATCGAATGGA") # -> (['ATCATCGAATGGA'], {'mismatches': [[]], 'original': ['ATCATCGAATGGA']})

    # close match allowing up to 2 mismatches
    patt = CloseMatch("ATCATCGAATGGA", max_mismatches=2)
    patt.parse_string("ATCAXCGAAXGGA") # -> (['ATCAXCGAAXGGA'], {'mismatches': [[4, 9]], 'original': ['ATCATCGAATGGA']})
r   F)maxMismatchesr  c                  > Ub  UOUn[         TU ]  5         Xl        X0l        SU R                  < SU R                   S3U l        X@l        SU l        SU l        g )Nr  z (with up to z mismatches)F)r>  r   rj  r  r  r  r
  r  )r   rj  max_mismatchesr  r  r   s        r:   r   CloseMatch.__init__
  sb     +9*D-(*!$"3"3!6mDDVDVCWWcd "!&rI   c                L    [        U 5      R                   SU R                  < 3$ )Nri   )r   r+   rj  r  s    r:   r{  CloseMatch._generateDefaultName
  s%    t*%%&a(9(9'<==rI   c                   Un[        U5      nU[        U R                  5      -   nXe::  a  U R                  nSn/ n	U R                  n
[        [	        XU U5      5       Hb  u  pUu  pU R
                  (       a  UR                  5       UR                  5       pX:w  d  M@  U	R                  U5        [        U	5      U
:  d  Mb    O"   XH-   S-   n[        XU /5      nX~S'   XS'   X.4$ [        XU R                  U 5      e)Nr   r   original
mismatches)rl  rj  r  	enumeratezipr  rn   r  r    r   r  )r   r   r   r=  r  rm  maxlocrj  match_stringlocr  r  s_msrcmatresultss                  r:   rs  CloseMatch.parseImpl
  s    x=T..//,,LOJ ..M(1H(,7)$ =="yy{CIIK:%%o6:6) -1&s(;'<=&2
#(2%|#XDKK>>rI   )r  r  r  rj  r  r
  rB   )rj  rz   r  r&  r  r  rK   rL   r-  r  r$  r  rT  s   @r:   r  r  w
  sZ     J 04'
 '' -'
 ' 
' '">? ?rI   r  c                     ^  \ rS rSrSr       SSSSSS.                       SU 4S jjjjrSS jrSSS jjrSSS	 jjrS
r	U =r
$ )Wordi
  ar
  Token for matching words composed of allowed character sets.

Parameters:

- ``init_chars`` - string of all characters that should be used to
  match as a word; "ABC" will match "AAA", "ABAB", "CBAC", etc.;
  if ``body_chars`` is also specified, then this is the string of
  initial characters
- ``body_chars`` - string of characters that
  can be used for matching after a matched initial character as
  given in ``init_chars``; if omitted, same as the initial characters
  (default=``None``)
- ``min`` - minimum number of characters to match (default=1)
- ``max`` - maximum number of characters to match (default=0)
- ``exact`` - exact number of characters to match (default=0)
- ``as_keyword`` - match as a keyword (default=``False``)
- ``exclude_chars`` - characters that might be
  found in the input ``body_chars`` string but which should not be
  accepted for matching ;useful to define a word of all
  printables except for one or two characters, for instance
  (default=``None``)

:class:`srange` is useful for defining custom character set strings
for defining :class:`Word` expressions, using range notation from
regular expression character sets.

A common mistake is to use :class:`Word` to match a specific literal
string, as in ``Word("Address")``. Remember that :class:`Word`
uses the string argument to define *sets* of matchable characters.
This expression would match "Add", "AAA", "dAred", or any other word
made up of the characters 'A', 'd', 'r', 'e', and 's'. To match an
exact literal string, use :class:`Literal` or :class:`Keyword`.

pyparsing includes helper strings for building Words:

- :class:`alphas`
- :class:`nums`
- :class:`alphanums`
- :class:`hexnums`
- :class:`alphas8bit` (alphabetic characters in ASCII range 128-255
  - accented, tilded, umlauted, etc.)
- :class:`punc8bit` (non-alphabetic characters in ASCII range
  128-255 - currency, symbols, superscripts, diacriticals, etc.)
- :class:`printables` (any non-whitespace character)

``alphas``, ``nums``, and ``printables`` are also defined in several
Unicode sets - see :class:`pyparsing_unicode``.

Example::

    # a word composed of digits
    integer = Word(nums) # equivalent to Word("0123456789") or Word(srange("0-9"))

    # a word with a leading capital, and zero or more lowercase
    capitalized_word = Word(alphas.upper(), alphas.lower())

    # hostnames are alphanumeric, with leading alpha, and '-'
    hostname = Word(alphas, alphanums + '-')

    # roman numeral (not a strict parser, accepts invalid mix of characters)
    roman = Word("IVXLCDM")

    # any string of non-whitespace characters, except for ','
    csv_value = Word(printables, exclude_chars=",")
NF)	initChars	bodyChars	asKeywordexcludeCharsc               :  > U=(       d    UnU	=(       d    Un	U
=(       d    Un
U=(       d    Un[         TU ]  5         U(       d"  [        S[        U 5      R                   S35      e[        U5      nU(       a3  [        U5      nX-  nU	(       a  SR                  [        U	5      U-
  5      n	Xl        SR                  [        U5      5      U l	        U	(       a0  [        U	5      U l
        SR                  [        U	5      5      U l        OXl
        U R                  U l        US:  U l        US:  a  [        S5      eU R                  (       a  X4:  a  [        SU SU S	35      eX0l        US:  a  X@l        O[        U l        US:  a  U=p4XPl        XPl        S
U R                    3U l        SU l        Xl        U R&                  (       a  U =R"                  S-  sl        SU R                  U R                  -  ;  Ga  [)        U R                  5      S:X  a!  [*        R,                  " U R                  5      nOS[/        U R                  5       S3nU R                  U R                  :X  a  US:X  a  U R                  S:X  a  SnOgUS:X  a  SnO^U R                  U R                  :w  a4  SU R                   SU R                  [        :X  a  SOU R                   S3nOSU R                   S3nU U 3U l        OUS:X  a  SnSnOyS[/        U R                  5       S3nUS:X  a  U R                  S:X  a  SnOGUS:X  a  US::  a  SOSnO6X4:w  a   SUS:  a  US-
  OS SUS:  a  US-
  OS S3nOSUS:  a  US-
  OS S3nU U U 3U l        U R&                  (       a  SU R0                   S3U l         [*        R2                  " U R0                  5      U l        U R*                  R4                  U l        U R8                  U l        g g ! [*        R<                   a
    S U l         g f = f)Nzinvalid z", initChars cannot be empty stringrl   r   r   zUcannot specify a minimum length < 1; use Opt(Word()) if zero-length word is permittedzDinvalid args, if min and max both specified min must be <= max (min=z, max=rI  r  Fz as a keywordr  [rH  +{r   }r   rZ   ?z\b)r>  r   r%  r   r+   r   r  r  sortedinitCharsOrigr  bodyCharsOrigmaxSpecifiedminLenmaxLenr9  rF   r  r
  r  rl  reescaper   reStringcompilerm  re_matchparseImpl_regexrs  error)r   
init_chars
body_charsr  maxexact
as_keywordexclude_charsr  r  r  r  initChars_setexcludeChars_setre_leading_fragmentrepeatre_body_fragmentr   s                    r:   r   Word.__init__  s    +	+	+	#4}4:..//QR  I"<0-MGGC	N5E$EF	&WWVM%:; ^DN!#	):!;D*N!%!3!3D!G7g  VWZV[[abeaffgh  7K"DK19CKK!$))-"">>KK?*K t~~674>>"a'&(ii0B0B&C#()*DT^^*T)UUV&W#~~/!8q 0 FAXF{{dkk1#%dkk]!$++:QBW[WbWb3cce!f#%dkk]"!5#6"7x @!8')$F)*+Ednn+U*VVW'X$axDKK1$4!$(+qb:')S1W#'")EQRUXYRYsQw_aFbbd%eF')S1W#'")ER%HF#6"78H7I& R~~#%dmm_B 76**T]]3 !%!%!5!5Y 8P 88 s   )%O< <PPc                   S nU R                   U R                  :w  a*  SU" U R                   5       SU" U R                  5       S3nOSU" U R                   5       S3nU R                  S:  d  U R                  [        :w  a  U R                  U R                  :X  a(  U R                  S:X  a  USS  $ USU R                   S3-   $ U R                  [        :X  a  USU R                   S	3-   $ USU R                   S
U R                   S3-   $ U$ )Nc                R    Sn[        U SS9n [        U 5      U:  a  U S US-
   S-   $ U $ )N   F)	re_escaper[   rB  )r   rl  )r   max_repr_lens     r:   
charsAsStr-Word._generateDefaultName.<locals>.charsAsStr  s<    L*1>A1v$+<!+,u44HrI   zW:(, rI  r   rZ   r  r  z,...}r   )r  r  r  r  r9  )r   r  bases      r:   r{  Word._generateDefaultName  s    	 >>T^^+DNN34Bz$..7Q6RRSTDDNN34A6D ;;?dkkX5{{dkk);;!#8OBt{{m2"666(4;;-v6664;;-qR@@@rI   c                   X   U R                   ;  a  [        XU R                  U 5      eUnUS-  n[        U5      nU R                  nX@R
                  -   n[        Xu5      nX':  a  X   U;   a  US-  nX':  a
  X   U;   a  M  SnX$-
  U R                  :  a  SnORU R                  (       a  X%:  a  X   U;   a  SnO1U R                  (       a   US:  a  XS-
     U;   d  X%:  a
  X   U;   a  SnU(       a  [        XU R                  U 5      eX!XB 4$ )Nr   FTr   )
r  r   r  rl  r  r  r  r  r  r  )	r   r   r   r=  r  rm  r  r  throw_exceptions	            r:   rs  Word.parseImpl  s   =. TBBqx=#~~
$V&lx}
:1HC lx}
:  ;$"O3>hmz6Q"O^^QY8AI.*<8=J#>"O TBBU'''rI   c                    U R                  X5      nU(       d  [        XU R                  U 5      eUR                  5       nX$R	                  5       4$ rB   )r  r   r  r  group)r   r   r   r=  r  s        r:   r  Word.parseImpl_regex  s@    x- TBBjjlLLN""rI   )r  r  r  r  r  r  r  r  r
  r  rs  r  r  r  )rl   Nr   r   r   FN)r  rz   r  r(  r  r  r  r  r  r  r  rm   r  r(  r  r(  r  r(  r  rm   r  r(  rK   rL   r-  r  r$  )r+   r,   r-   r.   r/   r   r{  rs  r  r7   rS  rT  s   @r:   r  r  
  s    @H +/ .2t6 +/*.-1t6t6 )t6 	t6
 t6 t6 t6 ,t6 (t6 (t6 t6 +t6 
t6 t6l8(:# #rI   r  c                  X   ^  \ rS rSrSr  SSSS.           S	U 4S jjjjrSrU =r$ )
Chari  zA short-cut class for defining :class:`Word` ``(characters, exact=1)``,
when defining a match of any single character in a string of
characters.
FN)r  r  c               P   > U=(       d    UnU=(       d    Un[         TU ]  USXES9  g )Nr   )r  r  r  rY  )r   charsetr  r  r  r  r   s         r:   r   Char.__init__  s2     +	#4}1 	 	
rI   r*   )FN)r  rz   r  rm   r  r(  r  rm   r  r(  rK   rL   r  rT  s   @r:   r  r    sa     !.2	
  -1

 
 ,	
 
 +
 

 
rI   r  c                     ^  \ rS rSrSr   SSSS.             SU 4S jjjjr\SS j5       r\SS j5       r\	S 5       r
\
R                  S	 5       r
SS
 jrSSS jjrSS jrSS jrSS jrSrU =r$ )Regexi  aC  Token for matching strings that match a given regular
expression. Defined with string specifying the regular expression in
a form recognized by the stdlib Python  `re module <https://docs.python.org/3/library/re.html>`_.
If the given regex contains named groups (defined using ``(?P<name>...)``),
these will be preserved as named :class:`ParseResults`.

If instead of the Python stdlib ``re`` module you wish to use a different RE module
(such as the ``regex`` module), you can do so by building your ``Regex`` object with
a compiled RE that was compiled using ``regex``.

Example::

    realnum = Regex(r"[+-]?\d+\.\d*")
    # ref: https://stackoverflow.com/questions/267399/how-do-you-match-only-valid-roman-numerals-with-a-regular-expression
    roman = Regex(r"M{0,4}(CM|CD|D?{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})")

    # named fields in a regex will be returned as named results
    date = Regex(r'(?P<year>\d{4})-(?P<month>\d\d?)-(?P<day>\d\d?)')

    # the Regex class will accept re's compiled using the regex module
    import regex
    parser = pp.Regex(regex.compile(r'[0-9]'))
F)asGroupListasMatchc                 > [         TU ]  5         U=(       d    UnU=(       d    Un[        U[        5      (       a/  U(       d  [	        S5      eSU l        SU l        U=U l        U l        Ox[        US5      (       a7  [        US5      (       a&  Xl        SU l        UR                  =U l        U l        O0[        U5      (       a  Xl        SU l        SU l        O[        S5      eX l        SU R                   3U l        SU l        XPl        X`l        U R                   (       a  U R$                  U l        U R"                  (       a  U R(                  U l        gg)zThe parameters ``pattern`` and ``flags`` are passed
to the ``re.compile()`` function as-is. See the Python
`re module <https://docs.python.org/3/library/re.html>`_ module for an
explanation of the acceptable patterns and flags.
z0null string passed to Regex; use Empty() insteadNpatternrm  zRegex may only be constructed with a string or a compiled RE object, or a callable that takes no arguments and returns a string or a compiled RE objectr  F)r>  r   r  r#   r%  _rer  r  r  rE  rK  r   flagsrF   r  r
  r  r  parseImplAsGroupListrs  parseImplAsMatch)r   r  r  as_group_listas_matchr  r  r   s          r:   r   Regex.__init__  s#    	!2]%Xgx(( !STTDH%)D"+22DMDLWi((WWg-F-FH%)D"+2??:DL4=g"L%)D"DH &  
!$))-"&!66DN<<!22DN rI   c                   U R                   (       a  U R                   $ [        U R                  5      (       a  [        [        / [
        4   U R                  5      " 5       U l        [        U R                  S5      (       ay  [        U R                  S5      (       a^  [        [        R                  [
           U R                  5      U l         U R                   R                  =U l        U l	        U R                   $  [        R                  " U R                  U R                  5      U l         U R                  R                  SSS9S LU l        U R                   $ ! [        R                   a    [        SU R                  < S35      ef = f)Nr  rm  rl   r   )poszinvalid pattern (z) passed to Regex)r   rK  r  r   r   rz   rE  r  Patternr  r  r  rm  r  r  r%  r  s    r:   r  Regex.re/  s   8888ODLL!!S 14<<@BDL t||Y//GDLL'4R4R

3>/3xx/?/??t}xx	zz$,,

;DH &*WW]]21]%=T%ID"88O	 xx 	T00@@QRSS	Ts   :0E /Fc                .    U R                   R                  $ rB   )r  rm  r  s    r:   r  Regex.re_matchF  s    ww}}rI   c                L    U R                   c  U R                    U R                   $ rB   )r  r  r  s    r:   r  Regex.mayReturnEmptyJ  s!    !!)GG%%%rI   c                    Xl         g rB   r  r  s     r:   r  r  Q  r  rI   c                X    [        U R                  5      R                  SS5      nSU S3$ )Nz\\\zRe:(rI  )rw  r  rC  )r   	unescapeds     r:   r{  Regex._generateDefaultNameU  s,    &..vt<	i[""rI   c                   U[        U5      :  a(  U R                  (       a  [        XU R                  U 5      eU R	                  X5      nU(       d  [        XU R                  U 5      eUR                  5       n[        UR                  5       5      nUR                  5       nUR                  5        H	  u  pxXU'   M     X%4$ rB   )
rl  r  r   r  r  r  r    r  	groupdictitems)	r   r   r   r=  r  r   dkvs	            r:   rs  Regex.parseImplY  s     X4#6#6 TBBx- TBBjjl6<<>*GGIDAF  xrI   c                   U[        U5      :  a(  U R                  (       a  [        XU R                  U 5      eU R	                  X5      nU(       d  [        XU R                  U 5      eUR                  5       nUR                  5       nX%4$ rB   )rl  r  r   r  r  r  groupsr   r   r   r=  r  r   s         r:   r  Regex.parseImplAsGroupListm  sj    X4#6#6 TBBx- TBBjjlmmoxrI   c                    U[        U5      :  a(  U R                  (       a  [        XU R                  U 5      eU R	                  X5      nU(       d  [        XU R                  U 5      eUR                  5       nUnX%4$ rB   )rl  r  r   r  r  r  r  s         r:   r  Regex.parseImplAsMatchy  sd    X4#6#6 TBBx- TBBjjlxrI   c                   ^ ^ T R                   (       a  [        S5      eT R                  (       a  [        T5      (       a  [        S5      eT R                  (       a  U4S jnOUU 4S jnT R	                  U5      $ )a[  
Return :class:`Regex` with an attached parse action to transform the parsed
result as if called using `re.sub(expr, repl, string) <https://docs.python.org/3/library/re.html#re.sub>`_.

Example::

    make_html = Regex(r"(\w+):(.*?):").sub(r"<\1>\2</\1>")
    print(make_html.transform_string("h1:main title:"))
    # prints "<h1>main title</h1>"
z/cannot use sub() with Regex(as_group_list=True)z:cannot use sub() with a callable with Regex(as_match=True)c                ,   > U S   R                  T5      $ r  )expand)r  repls    r:   r   Regex.sub.<locals>.pa  s    ay''--rI   c                B   > TR                   R                  TU S   5      $ r  )r  sub)r  r$  r   s    r:   r   r%    s    ww{{433rI   )r  r   r  rK  rX  )r   r$  r   s   `` r:   r'  	Regex.sub  s_     MNN<<HTNNL  <<.
4 $$R((rI   )
r  r   r  r  r  r  r
  rs  r  r  )r   FF)r  r   r  zUnion[re.RegexFlag, int]r  rm   r  rm   r  rm   r  rm   rK   rL   )rK   z
re.Pattern)rK   zCallable[[str, int], Any]r-  r  r$  )r$  rz   rK   ry   )r+   r,   r-   r.   r/   r   r$   r  r  r4  r  r5  r{  rs  r  r  r'  r7   rS  rT  s   @r:   r  r    s    6 +,#53 "5353 (53 	53
 53 53 53 
53 53n  ,   & & ' '#(

) )rI   r  c                     ^  \ rS rSrSr\" S5      r       SSSSSSSS.                           SU 4S jjjjrSS	 jrSSS
 jjr	Sr
U =r$ )QuotedStringi  a  
Token for matching strings that are delimited by quoting characters.

Defined with the following parameters:

- ``quote_char`` - string of one or more characters defining the
  quote delimiting string
- ``esc_char`` - character to re_escape quotes, typically backslash
  (default= ``None``)
- ``esc_quote`` - special quote sequence to re_escape an embedded quote
  string (such as SQL's ``""`` to re_escape an embedded ``"``)
  (default= ``None``)
- ``multiline`` - boolean indicating whether quotes can span
  multiple lines (default= ``False``)
- ``unquote_results`` - boolean indicating whether the matched text
  should be unquoted (default= ``True``)
- ``end_quote_char`` - string of one or more characters defining the
  end of the quote delimited string (default= ``None``  => same as
  quote_char)
- ``convert_whitespace_escapes`` - convert escaped whitespace
  (``'\t'``, ``'\n'``, etc.) to actual whitespace
  (default= ``True``)

Example::

    qs = QuotedString('"')
    print(qs.search_string('lsjdf "This is the quote" sldjf'))
    complex_qs = QuotedString('{{', end_quote_char='}}')
    print(complex_qs.search_string('lsjdf {{This is the "quote"}} sldjf'))
    sql_qs = QuotedString('"', esc_quote='""')
    print(sql_qs.search_string('lsjdf "This is the quote with ""embedded"" quotes" sldjf'))

prints::

    [['This is the quote']]
    [['This is the "quote"']]
    [['This is the quote with "embedded" quotes']]
))z\t	)r  r  )z\f)z\rrl   NT)	quoteCharescCharescQuoteunquoteResultsendQuoteCharconvertWhitespaceEscapesc               	  >^  [         TT ]  5         U	=(       d    UnU
=(       d    UnU=(       a    UnU=(       d    UnU=(       a    UnU=(       d    UnUR                  5       nU(       d  [        S5      eUc  UnO"UR                  5       nU(       d  [        S5      eUT l        [        U5      T l        US   T l        UT l        [        U5      T l	        U=(       d    ST l
        US LT l        U=(       d    ST l        UT l        UT l        UT l        [         R"                  " S5      T l        / nU(       a)  UR'                  S[         R(                  " U5       S35        U(       a)  UR'                  S[         R(                  " U5       S35        [        T R                  5      S:  aQ  UR'                  SS	R+                  U 4S
 j[-        [        T R                  5      S-
  SS5       5       5      -   S-   5        T R                  (       a  T =R$                  [         R.                  [         R0                  -  -  sl        UR'                  S[3        T R                  S   5       T R                  (       a  [3        T R                  5      OS S35        OTUR'                  S[3        T R                  S   5       ST R                  (       a  [3        T R                  5      OS S35        SR+                  [         R(                  " T R                  5      SS	R+                  U5      S[         R(                  " T R                  5      /5      T l        T R                  (       a  T R                  (       as  [         R6                  " SS	R+                  S T R8                   5       5       SS SS SS S[         R(                  " T R                  5       S3T R$                  S9T l        OF[         R6                  " S[         R(                  " T R                  5       S3T R$                  S9T l         [         R6                  " T R4                  T R$                  5      T l        T R4                  T l        T R                   R>                  T l         ST RD                   3T l#        ST l$        ST l%        g ! [         RB                   a    [        ST R4                  < S35      ef = f) Nz%quote_char cannot be the empty stringz)end_quote_char cannot be the empty stringr   rl   (?:rI  z.)r   |c           	   3     >#    U  HP  nS [         R                  " TR                  SU 5       S[         R                  " TR                  US 5       S3v   MR     g7f)r5  Nz(?!z)))r  r  end_quote_char)r8   rj   r   s     r:   r   (QuotedString.__init__.<locals>.<genexpr>  sX      G "))D$7$7$;<=S4K^K^_`_aKbAc@ddfgGs   AAr   z(?:[^z])z\n\rz)*r   c              3  N   #    U  H  n[         R                  " U5      v   M     g 7frB   )r  r  )r8   r  s     r:   r   r9  0  s     !D1"))A,,s   #%z
)|(\\[0-7]r[   z|\\0|\\x[0-9a-fA-F]rZ   z|\\u[0-9a-fA-F]r\   z)|(z	.)|(\n|.)r  zinvalid pattern z passed to Regexr  FT)&r>  r   r  r%  
quote_charrl  quote_char_lenfirst_quote_charr8  end_quote_char_lenesc_charhas_esc_char	esc_quoteunquote_resultsconvert_whitespace_escapes	multiliner  	RegexFlagre_flagsr  r  r  range	MULTILINEDOTALLr   r  r  ws_mapunquote_scan_rer  rm  r  r  rF   r  r
  r  )r   r<  r@  rB  rE  rC  r8  rD  r.  r/  r0  r1  r2  r3  inner_patternr   s   `              r:   r   QuotedString.__init__  s    " 	&h)		(<_%7$C)C 	# ,*
  %%'
DEE!'N+113N! !LMM)#&z?%/]#1'*>':%^"*$"6'o2%40J'"Q $&  C		)(<'=Q!?@  C		((;'<B!?@t""#a'  (( "3t':':#;a#?BG 
  >>MMR\\BII55M  243F3Fq3IJKAEARAR.t}}=XZ\\^`
   243F3Fq3IJK4AEARAR.t}}=XZ\\^`
 ww		$//*'		$--.
 ..')zz!D!DDE F!!"#6qc L))DMM23 4  --($ (*zz4==12 3  --($	Rjjt}}=DG LLDM GGMMDM "$))-"!% xx 	R//??OPQQ	Rs   )AR( (/Sc                    U R                   U R                  :X  a/  [        U R                   [        5      (       a  SU R                   < 3$ SU R                    SU R                   3$ )Nzstring enclosed in zquoted string, starting with z ending with )r<  r8  r  r#   r  s    r:   r{  !QuotedString._generateDefaultNameI  s\    ??d111jOOX7
 7
 )(;<<.t.?}TM`M`LabbrI   c                  ^ ^ X   T R                   :H  =(       a    T R                  X5      =(       d    S nU(       d  [        XT R                  T 5      eUR	                  5       nUR                  5       nSS jmT R                  (       a  UT R                  T R                  *  n[        U[        5      (       a  T R                  (       a6  SR                  UU 4S jT R                  R                  U5       5       5      nO1SR                  S T R                  R                  U5       5       5      nT R                  (       a&  UR!                  T R                  T R"                  5      nX%4$ )Nc                    U S:X  a  gU R                  5       (       a"  [        U 5      S:X  a  [        [        U SS95      $ U R	                  S5      (       a  [        [        U SS  SS95      $ U $ )	N0 r[      )r  )uxr   r  )isdigitrl  chrr  r3   )r   s    r:   convert_escaped_numerics8QuotedString.parseImpl.<locals>.convert_escaped_numerics`  s^    Cxyy{{s1v{3qq>**j))3qu2.//rI   rl   c              3  b  >#    U  H  nUR                  S 5      (       a  TR                  UR                  S 5         OjUR                  S5      (       a  T" UR                  S5      S S 5      O:UR                  S5      (       a  UR                  S5      S   OUR                  S5      v   M     g7f)r   rZ   Nr[   r   r\   )r  rK  )r8   rm  rZ  r   s     r:   r   )QuotedString.parseImpl.<locals>.<genexpr>t  s      " &HE 8={{1~~EKKN3 NS[[YZ^^5ekk!nQR6HI38;;q>>U[[^B/"[[^, &Hs   B,B/c              3     #    U  H@  nUR                  S 5      (       a  UR                  S 5      S   OUR                  S5      v   MB     g7f)r   r   rZ   N)r  )r8   rm  s     r:   r   r]    sF      "
 &HE /4kk!nnAr*"[[^, &Hs   AA
r   rz   rK   rz   )r>  r  r   r  r  r  rC  r=  r?  r  r#   rD  r  rL  finditerrB  rC  r8  )r   r   r   r=  r  r   rZ  s   `     @r:   rs  QuotedString.parseImplQ  s.    MT222 -h, 	
  TBB jjllln	 d))T-D-D,DEC#x((22 '' " &*%9%9%B%B3%G" C '' "
 &*%9%9%B%B3%G" C >>++dnnd6I6IJCxrI   )r  rD  r8  r?  r  r@  rB  r>  rA  r
  rE  r  r<  r=  r  r  rG  r  rC  rL  )rl   NNFTNT)r<  rz   r@  r(  rB  r(  rE  rm   rC  rm   r8  r(  rD  rm   r.  rz   r/  r(  r0  r(  r1  rm   r2  r(  r3  rm   rK   rL   r-  r  r$  )r+   r,   r-   r.   r/   r8  rK  r   r{  rs  r7   rS  rT  s   @r:   r*  r*    s    %N NOF )-*. $/3+/x& (,)-#-1)-x&x& 'x& (	x&
 x& x& -x& %)x& x& &x& 'x& x& +x& #'x&  
!x& x&tc= =rI   r*  c                  r   ^  \ rS rSrSr    S	SS.           S
U 4S jjjjrSS jrSSS jjrSrU =r	$ )
CharsNotIni  a  Token for matching words composed of characters *not* in a given
set (will include whitespace in matched characters if not listed in
the provided exclusion set - see example). Defined with string
containing all disallowed characters, and an optional minimum,
maximum, and/or exact length.  The default value for ``min`` is
1 (a minimum value < 1 is not valid); the default values for
``max`` and ``exact`` are 0, meaning no maximum or exact
length restriction.

Example::

    # define a comma-separated-value as anything that is not a ','
    csv_value = CharsNotIn(',')
    print(DelimitedList(csv_value).parse_string("dkls,lsdkjf,s12 34,@!#,213"))

prints::

    ['dkls', 'lsdkjf', 's12 34', '@!#', '213']
rl   )notCharsc               d  > [         TU ]  5         SU l        U=(       d    UU l        [	        U R                  5      U l        US:  a  [        S5      eX l        US:  a  X0l        O[        U l        US:  a  X@l        X@l        SU R                   3U l        U R                  S:H  U l        SU l        g )NFr   zacannot specify a minimum length < 1; use Opt(CharsNotIn()) if zero-length char group is permittedr   r  )r>  r   r  rd  r   notCharsSetr%  r  r  r9  rF   r  r  r
  )r   	not_charsr  r  r  rd  r   s         r:   r   CharsNotIn.__init__  s     	#!-Xt}}-7L 
 7K"DK19KK!$))-!%!1"rI   c                    [        U R                  5      n[        U5      S:  a  SU R                  S S  S3$ SU R                   S3$ )Nr  z!W:(   z...)rI  )r   rd  rl  )r   not_chars_strs     r:   r{  CharsNotIn._generateDefaultName  sK    24==A}"$--&12$77$--**rI   c                F   U R                   nX   U;   a  [        XU R                  U 5      eUnUS-  n[        XPR                  -   [        U5      5      nX&:  a  X   U;  a  US-  nX&:  a
  X   U;  a  M  X%-
  U R                  :  a  [        XU R                  U 5      eX!XR 4$ rk  )rf  r   r  r  r  rl  r  )r   r   r   r=  notcharsr  maxlens          r:   rs  CharsNotIn.parseImpl  s    ##=H$ TBBqU[[(#h-8lx}H<1HC lx}H< ;$ TBBU'''rI   )r  r  r  r
  r  rd  rf  r  )rl   r   r   r   )rg  rz   r  r  r  r  r  r  rd  rz   rK   rL   r-  r  r$  r  rT  s   @r:   rc  rc    st    , !# !#!# !# 	!#
 !# !# 
!# !#F+( (rI   rc  c                     ^  \ rS rSrS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!S"_S#S$_S%S&S'S(S)S*S+.Er S0         S1U 4S, jjjrS2S- jrS3S4S. jjrS/r	U =r
$ )5Whitei  a}  Special matching class for matching whitespace.  Normally,
whitespace is ignored by pyparsing grammars.  This class is included
when some whitespace structures are significant.  Define with
a string containing the whitespace characters to be matched; default
is ``" \t\r\n"``.  Also takes optional ``min``,
``max``, and ``exact`` arguments, as defined for the
:class:`Word` class.
r  z<SP>r+  z<TAB>r  z<LF>r-  z<CR>r,  z<FF>    z<NBSP>u    z<OGHAM_SPACE_MARK>u   ᠎z<MONGOLIAN_VOWEL_SEPARATOR>u    z	<EN_QUAD>u    z	<EM_QUAD>u    z
<EN_SPACE>u    z
<EM_SPACE>u    z<THREE-PER-EM_SPACE>u    z<FOUR-PER-EM_SPACE>u    z<SIX-PER-EM_SPACE>u    z<FIGURE_SPACE>u    z<PUNCTUATION_SPACE>z<THIN_SPACE>z<HAIR_SPACE>z<ZERO_WIDTH_SPACE>z<NNBSP>z<MMSP>z<IDEOGRAPHIC_SPACE>)u    u    u   ​u    u    u   　c                8  >^  [         TT ]  5         UT l        T R                  SR	                  U 4S jT R
                   5       5      SS9  ST l        ST R                   3T l        UT l	        US:  a  UT l
        O[        T l
        US:  a  UT l
        UT l	        g g )Nrl   c              3  J   >#    U  H  oTR                   ;  d  M  Uv   M     g 7frB   )
matchWhite)r8   cr   s     r:   r   !White.__init__.<locals>.<genexpr>  s     J~!$//1IAA~s   #	#Trh  r  r   )r>  r   rv  ri  r  	whiteStrsr  rF   r  r  r  r9  )r   wsr  r  r  r   s   `    r:   r   White.__init__  s     	!!GGJt~~JJ 	" 	

 "&!$))-7DK"DK19DKDK rI   c                F    SR                  S U R                   5       5      $ )Nrl   c              3  H   #    U  H  n[         R                  U   v   M     g 7frB   )rr  rz  r8   rw  s     r:   r   -White._generateDefaultName.<locals>.<genexpr>  s     C?auq)?s    ")r  rv  r  s    r:   r{  White._generateDefaultName  s    wwC4??CCCrI   c                n   X   U R                   ;  a  [        XU R                  U 5      eUnUS-  nX@R                  -   n[	        U[        U5      5      nX%:  a0  X   U R                   ;   a  US-  nX%:  a  X   U R                   ;   a  M  X$-
  U R                  :  a  [        XU R                  U 5      eX!XB 4$ rk  )rv  r   r  r  r  rl  r  )r   r   r   r=  r  r  s         r:   rs  White.parseImpl   s    =/ TBBq$VS]+lx}?1HC lx}? ;$ TBBU'''rI   )r  r  rv  r  r  )z 	
r   r   r   )
r{  rz   r  r  r  r  r  r  rK   rL   r-  r  r$  )r+   r,   r-   r.   r/   rz  r   r{  rs  r7   rS  rT  s   @r:   rr  rr    s@   Vg 	f 	f	
 	f 	( 	& 	/ 	+ 	+ 	, 	, 	( 	' 	&  	"!" 	'#$ ! &'/I6 MN  (+ 69 FI 	   0D( (rI   rr  c                  ,   ^  \ rS rSrSU 4S jjrSrU =r$ )PositionTokeni0  c                >   > [         TU ]  5         SU l        SU l        g ra  r  rZ  s    r:   r   PositionToken.__init__1  s    !%"rI   r  rJ   r+   r,   r-   r.   r   r7   rS  rT  s   @r:   r  r  0  s    # #rI   r  c                  H   ^  \ rS rSrSrSU 4S jjrSS jrS	S
S jjrSrU =r	$ )
GoToColumni7  zYToken to advance to a specific column of input text; useful for
tabular report scraping.
c                .   > [         TU ]  5         Xl        g rB   )r>  r   r   )r   colnor   s     r:   r   GoToColumn.__init__<  s    rI   c                x   [        X!5      U R                   :X  a  U$ [        U5      nU R                  (       a  U R                  X5      nX#:  al  X   R	                  5       (       aU  [        X!5      U R                   :w  a<  US-  nX#:  a2  X   R	                  5       (       a  [        X!5      U R                   :w  a  M<  U$ rk  )r   rl  r  rh  isspace)r   r   r   rm  s       r:   ro  GoToColumn.preParse@  s    s)Jx=&&x5CN%%''C"dhh.1HC	 N%%''C"dhh. 
rI   c                    [        X!5      nX@R                   :  a  [        XSU 5      eX R                   -   U-
  nXU nXV4$ )NzText not in expected column)r   r   )r   r   r   r=  thiscolnewlocr   s          r:   rs  GoToColumn.parseImplP  sH    c$XX 0MtTTxx')6"{rI   r   )r  r  rK   rL   r#  r  r$  
r+   r,   r-   r.   r/   r   ro  rs  r7   rS  rT  s   @r:   r  r  7  s      rI   r  c                  H   ^  \ rS rSrSrSU 4S jjrSS jrS	S
S jjrSrU =r	$ )	LineStartiY  a|  Matches if current position is at the beginning of a line within
the parse string

Example::

    test = '''\
    AAA this line
    AAA and this line
      AAA but not this one
    B AAA and definitely not this one
    '''

    for t in (LineStart() + 'AAA' + rest_of_line).search_string(test):
        print(t)

prints::

    ['AAA', ' this line']
    ['AAA', ' and this line']

c                "  > [         TU ]  5         U R                  5         [        5       U R                  -  U l        U R                  R                  S5        [        5       R                  U R                  5      U l	        U R                  S5        g )Nr  zstart of line)r>  r   re  r   r   orig_whiteCharsdiscardr  ri  rM  r  rZ  s    r:   r   LineStart.__init__p  sc    "ut6%w33DOODo&rI   c                    US:X  a  U$ U R                   R                  X5      nSU R                  ;   a6  XUS-    S:X  a+  U R                   R                  XS-   5      nXUS-    S:X  a  M+  U$ )Nr   r  r   )rM  ro  r  )r   r   r   r   s       r:   ro  LineStart.preParsex  ss    !8Jll##H24'''q)T1ll++HAg> q)T1 
rI   c                V    [        X!5      S:X  a  U/ 4$ [        XU R                  U 5      erk  )r   r   r  rr  s       r:   rs  LineStart.parseImpl  s+    s"7NXDKK>>rI   )r  rM  rJ   r#  r  r$  r  rT  s   @r:   r  r  Y  s    ,'
? ?rI   r  c                  >   ^  \ rS rSrSrSU 4S jjrSSS jjrSrU =r$ )	LineEndi  zLMatches if current position is at the end of a line within the
parse string
c                   > [         TU ]  5         U R                  R                  S5        U R	                  U R                  SS9  U R                  S5        g )Nr  Fry  zend of line)r>  r   r   r  ri  r  rZ  s    r:   r   LineEnd.__init__  sC    %!!$//!Gm$rI   c                    U[        U5      :  a&  X   S:X  a  US-   S4$ [        XU R                  U 5      eU[        U5      :X  a  US-   / 4$ [        XU R                  U 5      e)Nr  r   rl  r   r  rr  s       r:   rs  LineEnd.parseImpl  sf    X}$Qw}$$XDKKFFCM!7B; TBBrI   r*   rJ   r  r$  rc  rT  s   @r:   r  r    s    %	C 	CrI   r  c                  >   ^  \ rS rSrSrSU 4S jjrSSS jjrSrU =r$ )	StringStarti  zDMatches if current position is at the beginning of the parse
string
c                D   > [         TU ]  5         U R                  S5        g )Nzstart of textr>  r   r  rZ  s    r:   r   StringStart.__init__  s    o&rI   c                n    US:w  a,  X R                  US5      :w  a  [        XU R                  U 5      eU/ 4$ r  )ro  r   r  rr  s       r:   rs  StringStart.parseImpl  s5    !8}}Xq99 TBBBwrI   r*   rJ   r  r$  rc  rT  s   @r:   r  r    s    ' rI   r  c                  >   ^  \ rS rSrSrSU 4S jjrSSS jjrSrU =r$ )	r  i  z?
Matches if current position is at the end of the parse string
c                D   > [         TU ]  5         U R                  S5        g )Nzend of textr  rZ  s    r:   r   StringEnd.__init__  s    m$rI   c                    U[        U5      :  a  [        XU R                  U 5      eU[        U5      :X  a  US-   / 4$ U[        U5      :  a  U/ 4$ [        XU R                  U 5      erk  r  rr  s       r:   rs  StringEnd.parseImpl  sc    X TBB#h-7B;X7NXDKK>>rI   r*   rJ   r  r$  rc  rT  s   @r:   r  r    s    %? ?rI   r  c                  V   ^  \ rS rSrSr\4\S.     SU 4S jjjjrSSS jjrSrU =r	$ )		WordStarti  ag  Matches if the current position is at the beginning of a
:class:`Word`, and is not preceded by any character in a given
set of ``word_chars`` (default= ``printables``). To emulate the
```` behavior of regular expressions, use
``WordStart(alphanums)``. ``WordStart`` will also match at
the beginning of the string being parsed, or at the beginning of
a line.
	wordCharsc                  > U[         :X  a  UOUn[        TU ]	  5         [        U5      U l        U R                  S5        g )Nzstart of a word)r   r>  r   r   r  r  r   
word_charsr  r   s      r:   r   WordStart.__init__  s6     #,z"9Jy	Y'(rI   c                    US:w  a>  XS-
     U R                   ;   d  X   U R                   ;  a  [        XU R                  U 5      eU/ 4$ Nr   r   )r  r   r  rr  s       r:   rs  WordStart.parseImpl  sF    !8q!T^^3=6$XDKKFFBwrI   r  rz   r  rz   rK   rL   r  r$  
r+   r,   r-   r.   r/   r   r   rs  r7   rS  rT  s   @r:   r  r    sA     !+)@J)):=)	) ) rI   r  c                  V   ^  \ rS rSrSr\4\S.     SU 4S jjjjrSS	S jjrSrU =r	$ )
WordEndi  aQ  Matches if the current position is at the end of a :class:`Word`,
and is not followed by any character in a given set of ``word_chars``
(default= ``printables``). To emulate the ```` behavior of
regular expressions, use ``WordEnd(alphanums)``. ``WordEnd``
will also match at the end of the string being parsed, or at the end
of a line.
r  c                  > U[         :X  a  UOUn[        TU ]	  5         [        U5      U l        SU l        U R                  S5        g )NFzend of a word)r   r>  r   r   r  r  r  r  s      r:   r   WordEnd.__init__  s=     #,z"9Jy	Y#o&rI   c                    [        U5      nUS:  aC  X$:  a>  X   U R                  ;   d  XS-
     U R                  ;  a  [        XU R                  U 5      eU/ 4$ r  )rl  r  r   r  )r   r   r   r=  rm  s        r:   rs  WordEnd.parseImpl  sS    x=a<CN/!G$DNN:$XDKKFFBwrI   )r  r  r  r  r$  r  rT  s   @r:   r  r    sA     !+'@J'':='	' ' rI   r  c                  H   ^  \ rS rSrSrSSU 4S jjjrS	S jrS
S jrSrU =r	$ )Tagi  a8  
A meta-element for inserting a named result into the parsed
tokens that may be checked later in a parse action or while
processing the parsed results. Accepts an optional tag value,
defaulting to `True`.

Example::

    end_punc = "." | ("!" + Tag("enthusiastic")))
    greeting = "Hello," + Word(alphas) + end_punc

    result = greeting.parse_string("Hello, World.")
    print(result.dump())

    result = greeting.parse_string("Hello, World!")
    print(result.dump())

prints::

    ['Hello,', 'World', '.']

    ['Hello,', 'World', '!']
    - enthusiastic: True
c                   > [         TU ]  5         SU l        SU l        U R	                  5         Xl        X l        U R                  U R                  5        SU l	        g ra  )
r>  r   r  r
  re  tag_name	tag_valuerX  _add_tagr  )r   r  r  r   s      r:   r   Tag.__init__  sN    !%" dmm,$rI   c                4    U R                   XR                  '   g rB   )r  r  )r   r  s     r:   r  Tag._add_tag#  s     $}}rI   c                f    [        U 5      R                   SU R                   SU R                  < 3$ )Nri   =)r   r+   r  r  r  s    r:   r{  Tag._generateDefaultName&  s-    t*%%&aa7IJJrI   )r  r
  r  r  r  r  )r  rz   r  r   rK   rL   )r  r    r-  )
r+   r,   r-   r.   r/   r   r  r{  r7   rS  rT  s   @r:   r  r    s#    2% %/K KrI   r  c                     ^  \ rS rSrSr S     SU 4S jjjrSS jrSS jrSSU 4S jjjrSSU 4S jjjr	SU 4S jjr
SS	 jrSU 4S
 jjrSSS jjrSU 4S jjrSSU 4S jjjr\" S\5      r\" S\	5      rSrU =r$ )ParseExpressioni*  zUAbstract subclass of ParserElement, for combining and
post-processing parsed tokens.
c                  >^  [         TT ]  U5        T   [        U[        5      (       a  [	        U5      n[        U[
        5      (       a  T R                  U5      /T l        O[        U[        5      (       a	  U/T l        Oe[        U[        5      (       a?  [	        U5      n[        S U 5       5      (       a  U 4S jU 5       n[	        U5      T l        O [	        U5      T l        ST l        g ! [         a    U/T l         Nf = f)Nc              3  B   #    U  H  n[        U[        5      v   M     g 7frB   )r  r#   )r8   r   s     r:   r   +ParseExpression.__init__.<locals>.<genexpr>>  s     @%$:dH--%s   c              3  t   >#    U  H-  n[        U[        5      (       a  TR                  U5      OUv   M/     g 7frB   )r  r#   r   )r8   rc  r   s     r:   r   r  ?  s5      " 4>a3J3JD,,Q/PQQ"s   58F)r>  r   r  _generatorTyper   r#   r   exprsry   r   anyr   r  r   r  r  r   s   `  r:   r   ParseExpression.__init__/  s     	"e^,,KEeX&&2259:DJ}--DJx((KE@%@@@" eDJ%!%[
 "  %#W
%s   C, ,D Dc                     U R                   S S  $ rB   )r  r  s    r:   r&  ParseExpression.recurseK  s    zz!}rI   c                J    U R                   R                  U5        S U l        U $ rB   )r  r  r  r  s     r:   r  ParseExpression.appendN  s!    

%  rI   c                   > [         TU ]  U5        U(       aS  U R                   Vs/ s H  o"R                  5       PM     snU l        U R                   H  nUR                  U5        M     U $ s  snf )z|
Extends ``leave_whitespace`` defined in base class, and also invokes ``leave_whitespace`` on
   all contained expressions.
)r>  re  r  r-  r   ra  rc  r   s      r:   re   ParseExpression.leave_whitespaceS  sY    
 	 +,0JJ7Jq&&(J7DJZZ""9-   8   A-c                   > [         TU ]  U5        U(       aS  U R                   Vs/ s H  o"R                  5       PM     snU l        U R                   H  nUR                  U5        M     U $ s  snf )z}
Extends ``ignore_whitespace`` defined in base class, and also invokes ``leave_whitespace`` on
   all contained expressions.
)r>  rb  r  r-  r  s      r:   rb  !ParseExpression.ignore_whitespace`  sY    
 	!),,0JJ7Jq&&(J7DJZZ##I.   8r  c                T  > [        U[        5      (       aQ  XR                  ;  a@  [        TU ]  U5        U R
                   H!  nUR	                  U R                  S   5        M#     U $ [        TU ]  U5        U R
                   H!  nUR	                  U R                  S   5        M#     U $ Nr   )r  r[  r  r>  ro  r  )r   r	  rc  r   s      r:   ro  ParseExpression.ignorel  s    eX&&,,,u%AHHT--b12 $  GN5!ZZ))"-.  rI   c                L    [        U 5      R                   SU R                   S3$ Nz:(rI  )r   r+   r  r  s    r:   r{  $ParseExpression._generateDefaultNamex  s$    t*%%&bA66rI   c                  > U R                   (       a  U $ [        TU ]	  5         U R                   H  nUR                  5         M     [	        U R                  5      S:X  Ga  U R                  S   n[        X R                  5      (       a  UR                  (       d  UR                  c{  UR                  (       dj  UR                  S S  U R                  S   /-   U l        S U l
        U =R                  UR                  -  sl        U =R                  UR                  -  sl        U R                  S   n[        X R                  5      (       a  UR                  (       d  UR                  cz  UR                  (       di  U R                  S S UR                  S S  -   U l        S U l
        U =R                  UR                  -  sl        U =R                  UR                  -  sl        SU  3U l        U $ )NrZ   r   r   r   r  )r	  r>  r  r  rl  r  r   r   r  r  r  r  r  r
  r  )r   rc  r	  r   s      r:   r  ParseExpression.streamline{  sp   KALLN  tzz?aJJqME5..11))%%-"[[^tzz!}o=
$(!&&%*>*>>&""e&9&99"JJrNE5..11))%%-!ZZ_u{{1~=
$(!&&%*>*>>&""e&9&99"!$(rI   c                    [         R                  " S[        SS9  Ub  UO/ S S  U /-   nU R                   H  nUR	                  U5        M     U R                  / 5        g Nr  rZ   r  )r  r?   r  r  r  r  )r   r  tmprc  s       r:   r  ParseExpression.validate  sX    h	

 !. 9}r1ENAJJsO R rI   c                   > [         TU ]  5       n[        R                  " [        U5      nU R
                   Vs/ s H  o"R                  5       PM     snUl        U$ s  snf rB   )r>  r-  rN  r   r  r  )r   r   rc  r   s      r:   r-  ParseExpression.copy  sF    glnkk/3/'+zz2z!VVXz2	
 3s   Ac                  > [         R                  (       a  [        R                  U R                  ;  d  [        TU ]  X5      $ U R                   H  n[        U[        5      (       d  M  UR                  (       d  M-  [        R                  UR                  ;  d  MM  SU< S[        U 5      R                   SUR                  < S3n[        R                  " USS9    O   [        TU ]  X5      $ Nz@warn_ungrouped_named_tokens_in_collection: setting results name  on z expression collides with z on contained expressionr[   r  )r<   rN   rX   r  r>  r2  r  r  ry   r  r   r+   r  r?   r   rF   r3  rc  warningr   s        r:   r2  ParseExpression._setResultsName  s    >>EE**+ 7*4BBA1m,,MMMII//0
--1HDd9L9L8M N&&'mm%66NP 
 g!4 " w&t>>rI   r  r  )r  r  r  r  r  r  ztyping.Iterable[ParserElement]r  rm   rK   rL   r.  r  r  r)  r-  rB   rJ   )r+   r,   r-   r.   r/   r   r&  r  re  rb  ro  r{  r  r  r-  r2  r   r  r  r7   rS  rT  s   @r:   r  r  *  s    
 GL"3"?C"	" "8
 
 

7'R	!? ?: ''8:JKO'(:<MNrI   r  c                     ^  \ rS rSrSr " S S\5      r S     SU 4S jjjrSU 4S jjrSS jr	S r
S	 rSS
 jrSrU =r$ )r  i  a  
Requires all given :class:`ParserElement` s to be found in the given order.
Expressions may be separated by whitespace.
May be constructed using the ``'+'`` operator.
May also be constructed using the ``'-'`` operator, which will
suppress backtracking.

Example::

    integer = Word(nums)
    name_expr = Word(alphas)[1, ...]

    expr = And([integer("id"), name_expr("name"), integer("age")])
    # more easily written as:
    expr = integer("id") + name_expr("name") + integer("age")
c                  6   ^  \ rS rSrSU 4S jjrSS jrSrU =r$ )And._ErrorStopi  c                F   > [         TU ]  " U0 UD6  U R                  5         g rB   )r>  r   re  )r   r   rT  r   s      r:   r   And._ErrorStop.__init__  s!    Gd-f-!!#rI   c                    g)N-r*   r  s    r:   r{  #And._ErrorStop._generateDefaultName  s    rI   r*   rJ   r-  r+   r,   r-   r.   r   r{  r7   rS  rT  s   @r:   r  r    s    	$	 	rI   r  c                   > U Vs/ s H+  n[        U[        5      (       a  U R                  U5      OUPM-     nn[        U;   ap  US   [        L a  [	        S5      e/ n[        XDSS  5       HA  u  pgU[        L a"  UR                  [        U5      " S5      5        M0  UR                  U5        MC     XTS S& [        TU ]%  XB5        U R                  (       a  [        S U R                   5       5      U l        [        U R                  S   [        5      (       d]  U R                  U R                  S   R                  U R                  S   R                   S9  U R                  S   R"                  U l        OSU l        OS	U l        S	U l        g s  snf )
Nr   z0cannot construct And with sequence ending in ...r   r  c              3  8   #    U  H  oR                   v   M     g 7frB   r  r8   rc  s     r:   r   And.__init__.<locals>.<genexpr>       (N:a)9)9:rM  r   ry  FT)r  rz   r   r  r~  r  r  r  r>  r   r  rP  r  rr  ri  r   r   r  r  )	r   	exprs_argr  rc  r  r  cur_expr	next_exprr   s	           r:   r   And.__init__  s`    OX&
NW:a+=+=D$$Q'1Di 	 &

 u RyH$ RSS')C'*5)'<#x'JJvi0=>JJx(	 (= #2J)::%((N4::(N%ND"djjmU33))JJqM,,"&**Q-"E"E *  '+jjm&B&B#&+#%)D" C&
s   2Fc                P  > U R                   (       Ga  [        S U R                   S S  5       5      (       a  [        5       n[        U R                   S S 5       H  u  p#X1L a  M  [	        U[
        5      (       d  M"  UR                   (       d  M5  [	        UR                   S   [        5      (       d  MY  UR                   S   U R                   US-      -   UR                   S'   XR                   US-   '   M     U R                    Vs/ s H  o3ULd  M	  UPM     snU l         [        T	U ]!  5         [        U R                   U R                   SS  5       H  u  pE[        5       n [        U5      U;   a  M!  UR                  [        U5      5        [	        U[        5      (       a  UR                  U4S j5        Mg  UR                  5       n[!        [#        U5      S 5      nUc  M  [$        R&                  " [(        U5      nM     [+        S U R                    5       5      U l        U $ s  snf )Nc              3     #    U  HL  n[        U[        5      =(       a0    UR                  =(       a    [        UR                  S    [        5      v   MN     g7fr   N)r  r  r  r  r	  s     r:   r   !And.streamline.<locals>.<genexpr>  sJ      
 % q/* 661772;56 %s   AAr   r   c                .    [        US[        X5      5      $ )Nparent_anchor)setattrr   )r   r   r   cur_s       r:   r    And.streamline.<locals>.<lambda>>  s    ' /3q93rI   c              3  8   #    U  H  oR                   v   M     g 7frB   r  r	  s     r:   r   r  I  s     $Jz!%5%5zrM  )r  r  rJ  r  r  r  r  r>  r  r  r   r  r$  IndentedBlockrX  r&  r  rM  rN  r   ry   rP  r  )
r   deleted_expr_markerrj   rc  prevr)  r(  subs
next_firstr   s
            r:   r  And.streamline  s   :::# 
 ZZ_	
 
 
 #*)!$**Sb/2+q/22"1772;=="#''"+

1q50A"AAGGBK(;JJq1u% 3 &*ZZPZ<O3O!ZPDJ
 TZZAB8ID 5Dc7d?C!c=11))-0 
 {{}!$t*d3
%kk-< 	 9* "%$Jtzz$J!J; Qs   H#H#c                   U R                   S   R                  XUSS9u  p$SnU R                   SS   HX  n[        U5      [        R                  L a  SnM#  U(       a   UR                  XU5      u  p'OUR                  XU5      u  p'XG-  nMZ     X$4$ ! [
         a    e [         a!  nS Ul        [
        R                  U5      eS nAf[         a"    [        U[        U5      U R                  U 5      ef = f)Nr   Fr  r   T)r  rD  r   r  r  ParseSyntaxExceptionr  r   _from_exceptionr   rl  r  )	r   r   r   r=  
resultlist	errorStoprc  
exprtokensr  s	            r:   rs  And.parseImplL  s     **Q-..:E / 
 	ABAAw#..( 	
&'hhxj&IOC #$((8*"E$J'  (  , ) C'+B$.>>rBB! . #h-d s   BC0%C/C0c                    [        U[        5      (       a  U R                  U5      n[        U[        5      (       d  [        $ U R                  U5      $ rB   r  r#   r   ry   r  r  r  s     r:   __iadd__And.__iadd__i  A    eX&&,,U3E%//!!{{5!!rI   c                    US S  U /-   nU R                    H'  nUR                  U5        UR                  (       a  M'    g    g rB   )r  r  r  r  s       r:   r  And._checkRecursionp  s>    *1-6Ao.### rI   c                    SR                  S U R                   5       5      n[        U5      S:  aF  USS [        U5      S-
  2   S:X  a.  USS n[        U5      S:  a  USS [        U5      S-
  2   S:X  a  M.  SU S3$ )	Nr  c              3  8   #    U  H  n[        U5      v   M     g 7frB   r  r	  s     r:   r   +And._generateDefaultName.<locals>.<genexpr>x  s     4AQrM  r   r   {}r   r  r  )r  r  rl  r   inners     r:   r{  And._generateDefaultNamew  s    444%j1nq':CJN':!;t!C!BKE %j1nq':CJN':!;t!CE7"~rI   )r  r  r  r  r  )r  z*typing.Iterable[Union[ParserElement, str]]r  rm   rK   rL   r  r-  )r+   r,   r-   r.   r/   r  r  r   r  rs  r)  r  r{  r7   rS  rT  s   @r:   r  r    s_    "U  '!='! '! 
	'! '!R0d:" rI   r  c                     ^  \ rS rSrSr S
     SU 4S jjjrSU 4S jjrSSS jjrS rSS jr	S
SU 4S jjjr
S	rU =r$ )r6  i  a  Requires that at least one :class:`ParserElement` is found. If
two expressions match, the expression that matches the longest
string will be used. May be constructed using the ``'^'``
operator.

Example::

    # construct Or using '^' operator

    number = Word(nums) ^ Combine(Word(nums) + '.' + Word(nums))
    print(number.search_string("123 3.1416 789"))

prints::

    [['123'], ['3.1416'], ['789']]
c                   > [         TU ]  X5        U R                  (       aC  [        S U R                   5       5      U l        [        S U R                   5       5      U l        g SU l        g )Nc              3  8   #    U  H  oR                   v   M     g 7frB   r  r	  s     r:   r   Or.__init__.<locals>.<genexpr>  r  rM  c              3  8   #    U  H  oR                   v   M     g 7frB   r_  r	  s     r:   r   r8         %K
1&6&6
rM  Tr>  r   r  r  r  rP  r  r  s      r:   r   Or.__init__  O     	)::%((N4::(N%ND""%%K

%K"KD%)D"rI   c                  > [         TU ]  5         U R                  (       ae  [        S U R                   5       5      U l        [        S U R                   5       5      U l        [        S U R                   5       5      U l        U $ SU l        U $ )Nc              3  8   #    U  H  oR                   v   M     g 7frB   r  r	  s     r:   r    Or.streamline.<locals>.<genexpr>  r  rM  c              3  8   #    U  H  oR                   v   M     g 7frB   r  r	  s     r:   r   r@         !C
1,,
rM  c              3  p   #    U  H,  oR                   =(       a    [        U[        5      (       + v   M.     g 7frB   r  r  rr  r	  s     r:   r   r@    )      &GQ!  =Au)=%==z   46F)r>  r  r  r  r  r  rP  r  rZ  s    r:   r  Or.streamline  su    ::%((N4::(N%ND"!!C

!CCDO"% &GKzz& #D
  $DOrI   c                x   SnS n/ n/ n[        S U R                   5       5      (       a  U R                  X5      nU R                   H&  n UR                  XSS9n	UR	                  X45        M(     U(       a  UR                  [        S5      SS9  U(       d  US   S   nUR                  XU5      $ SnU H@  u  pXS   ::  a  Us  $  UR                  XU5      u  n	nX:  a  U	U4s  $ XS   :  a  U	U4nM@  MB     US:w  a  U$ U(       aV  [        U5      S:  a@  UR                  S	 S
9  US   R                  US   R                  :X  a  UR                  S S
9  US   nUeUb3  U R                  X5      nUU:X  a  U R                  =(       d    SUl        Ue[        XSU 5      e! [
         a.  n
S U
l        Xl        UR	                  U
5        S nSn S n
A
GM  S n
A
f[         aF  nU(       d3  S Ul        UR                  U:  a  UnUR                  n S nAGM   S nAGM   S nAGM  S nAf[         aD    [        U5      U:  a0  [        U[        U5      UR                  U 5      n[        U5      n GM(   GM,  f = f! [         a8  nS Ul        UR                  U:  a  UnUR                  n S nAGM   S nAGM  S nAff = f)Nr   c              3  8   #    U  H  oR                   v   M     g 7frB   r  r	  s     r:   r   Or.parseImpl.<locals>.<genexpr>  s     2z!~~zrM  Tr  r   )rQ  reverser   r  c                    U R                   * $ rB   r   rc  s    r:   r   Or.parseImpl.<locals>.<lambda>  
    155&rI   rQ  c                Z    U R                   * [        [        U R                  5      5      * 4$ rB   r   rl  rz   parser_elementrQ  s    r:   r   rR    "    vC@P@P<Q8R7R.SrI   rl    no defined alternatives to match)rP  r  ro  r  r  r   r   rW  r   r   r   rl  r  sortr   rD  r   )r   r   r   r=  	maxExcLocmaxExceptionr  fatalsrc  loc2pfer  	best_exprlongestloc1expr1r   	max_fatalparse_start_locs                      r:   rs  Or.parseImpl  s   	35,.2tzz222--.CA*{{8d{C* y)/ 2  LLZ]DL9 $AJqM	 ''zBBAIG&1:%"N-!&hZ!HJD$ |#Tz)
*"&* +!  '& *$6{Q 01!9==F1IMM1KK$SKTq	IO# #mmH:OO+#';;#4" X,NPTUUQ ' $(!%&"c"#	! ,(,C%ww*'*$'GG	 + 
  .x=9,#1 #h-4$L !$HI	 -.: & ,(,C%ww*'*$'GG	 +,sC   F"I7"
I4,"GI4",H##AI43I47
J9%J44J9c                    [        U[        5      (       a  U R                  U5      n[        U[        5      (       d  [        $ U R                  U5      $ rB   r(  r  s     r:   __ixor__Or.__ixor__  r+  rI   c                N    SSR                  S U R                   5       5       S3$ )Nr  z ^ c              3  8   #    U  H  n[        U5      v   M     g 7frB   r  r	  s     r:   r   *Or._generateDefaultName.<locals>.<genexpr>       :z!s1vvzrM  r  r  r  r  s    r:   r{  Or._generateDefaultName  %    EJJ:tzz::;2>>rI   c                .  > [         R                  (       aq  [        R                  U R                  ;  aS  [	        S U R
                   5       5      (       a2  SU< S[        U 5      R                   S3n[        R                  " USS9  [        TU ]-  X5      $ )Nc              3     #    U  H9  n[        U[        5      =(       a    [        R                  UR                  ;  v   M;     g 7frB   r  r  rX   rM   r  r	  s     r:   r   %Or._setResultsName.<locals>.<genexpr>  C       $A 1c" ,II++,, $   AA@warn_multiple_tokens_in_named_alternation: setting results name r   expression will return a list of all parsed tokens in an And alternative, in prior versions only the first token was returned; enclose contained argument in Groupr[   r  r<   rM   rX   r  r  r  r   r+   r  r?   r>  r2  r   rF   r3  r  r   s       r:   r2  Or._setResultsName      >>EE**+   	  --1HDd9L9L8M N33  g!4w&t>>rI   r  r  r  r  r  r  r  r$  r-  )r+   r,   r-   r.   r/   r   r  rs  rh  r{  r2  r7   rS  rT  s   @r:   r6  r6    sR    $ GL*3*?C*	* *
RVh"?? ?rI   r6  c                     ^  \ rS rSrSr S
     SU 4S jjjrSU 4S jjrSSS jjrS rSS jr	S
SU 4S jjjr
S	rU =r$ )r/  i  a  Requires that at least one :class:`ParserElement` is found. If
more than one expression matches, the first one listed is the one that will
match. May be constructed using the ``'|'`` operator.

Example::

    # construct MatchFirst using '|' operator

    # watch the order of expressions to match
    number = Word(nums) | Combine(Word(nums) + '.' + Word(nums))
    print(number.search_string("123 3.1416 789")) #  Fail! -> [['123'], ['3'], ['1416'], ['789']]

    # put more selective expression first
    number = Combine(Word(nums) + '.' + Word(nums)) | Word(nums)
    print(number.search_string("123 3.1416 789")) #  Better -> [['123'], ['3.1416'], ['789']]
c                   > [         TU ]  X5        U R                  (       aC  [        S U R                   5       5      U l        [        S U R                   5       5      U l        g SU l        g )Nc              3  8   #    U  H  oR                   v   M     g 7frB   r  r	  s     r:   r   &MatchFirst.__init__.<locals>.<genexpr>4  r  rM  c              3  8   #    U  H  oR                   v   M     g 7frB   r_  r	  s     r:   r   r  5  r:  rM  Tr;  r  s      r:   r   MatchFirst.__init__/  r=  rI   c                R  > U R                   (       a  U $ [        TU ]	  5         U R                  (       ae  [	        S U R                   5       5      U l        [	        S U R                   5       5      U l        [        S U R                   5       5      U l        U $ SU l        SU l        U $ )Nc              3  8   #    U  H  oR                   v   M     g 7frB   rB  r	  s     r:   r   (MatchFirst.streamline.<locals>.<genexpr>?  rC  rM  c              3  8   #    U  H  oR                   v   M     g 7frB   r  r	  s     r:   r   r  @  r  rM  c              3  p   #    U  H,  oR                   =(       a    [        U[        5      (       + v   M.     g 7frB   rE  r	  s     r:   r   r  A  rF  rG  FT)	r	  r>  r  r  r  r  r  rP  r  rZ  s    r:   r  MatchFirst.streamline9  s    K::!!C

!CCDO%((N4::(N%ND""% &GKzz& #D  $DO%)D"rI   c                   SnS nU R                    H  n UR                  XU5      s  $    Ub2  U R                  X5      n	XI:X  a  U R                  =(       d    SUl        Ue[        XSU 5      e! [         a  nS Ul        Xgl        e S nAf[
         a/  nUR                  U:  a  UnUR                  n S nAM   S nAM  S nAf[         aB    [        U5      U:  a/  [        U[        U5      UR                  U 5      n[        U5      n M   M  f = f)Nr   rl   rY  )r  rD  r   r   rW  r   r   r   rl  r  ro  r   )
r   r   r   r=  r[  r\  rc  r_  r  re  s
             r:   rs  MatchFirst.parseImplI  s   	A.xxz:: $ # #mmH:O+#';;#4" X,NPTUU/ ' $(!%&"! (77Y&#&L #I '  .x=9,#1 #h-4$L !$HI	 -.s*   A--
D7BDB<<AD
Dc                    [        U[        5      (       a  U R                  U5      n[        U[        5      (       d  [        $ U R                  U5      $ rB   r(  r  s     r:   __ior__MatchFirst.__ior__i  r+  rI   c                N    SSR                  S U R                   5       5       S3$ )Nr  z | c              3  8   #    U  H  n[        U5      v   M     g 7frB   r  r	  s     r:   r   2MatchFirst._generateDefaultName.<locals>.<genexpr>q  rm  rM  r  rn  r  s    r:   r{  MatchFirst._generateDefaultNamep  rp  rI   c                .  > [         R                  (       aq  [        R                  U R                  ;  aS  [	        S U R
                   5       5      (       a2  SU< S[        U 5      R                   S3n[        R                  " USS9  [        TU ]-  X5      $ )Nc              3     #    U  H9  n[        U[        5      =(       a    [        R                  UR                  ;  v   M;     g 7frB   rs  r	  s     r:   r   -MatchFirst._setResultsName.<locals>.<genexpr>y  ru  rv  rw  r  rx  r[   r  ry  rz  s       r:   r2  MatchFirst._setResultsNames  r|  rI   r}  r  r  r  r  r$  r-  )r+   r,   r-   r.   r/   r   r  rs  r  r{  r2  r7   rS  rT  s   @r:   r/  r/    sQ    $ GL*3*?C*	* * V@"?? ?rI   r/  c                  n   ^  \ rS rSrSr S	     S
U 4S jjjrS rSU 4S jjrS	SS jjrSS jr	Sr
U =r$ )r=  i  a  Requires all given :class:`ParserElement` s to be found, but in
any order. Expressions may be separated by whitespace.

May be constructed using the ``'&'`` operator.

Example::

    color = one_of("RED ORANGE YELLOW GREEN BLUE PURPLE BLACK WHITE BROWN")
    shape_type = one_of("SQUARE CIRCLE TRIANGLE STAR HEXAGON OCTAGON")
    integer = Word(nums)
    shape_attr = "shape:" + shape_type("shape")
    posn_attr = "posn:" + Group(integer("x") + ',' + integer("y"))("posn")
    color_attr = "color:" + color("color")
    size_attr = "size:" + integer("size")

    # use Each (using operator '&') to accept attributes in any order
    # (shape and posn are required, color and size are optional)
    shape_spec = shape_attr & posn_attr & Opt(color_attr) & Opt(size_attr)

    shape_spec.run_tests('''
        shape: SQUARE color: BLACK posn: 100, 120
        shape: CIRCLE size: 50 color: BLUE posn: 50,80
        color:GREEN size:20 shape:TRIANGLE posn:20,40
        '''
        )

prints::

    shape: SQUARE color: BLACK posn: 100, 120
    ['shape:', 'SQUARE', 'color:', 'BLACK', 'posn:', ['100', ',', '120']]
    - color: BLACK
    - posn: ['100', ',', '120']
      - x: 100
      - y: 120
    - shape: SQUARE


    shape: CIRCLE size: 50 color: BLUE posn: 50,80
    ['shape:', 'CIRCLE', 'size:', '50', 'color:', 'BLUE', 'posn:', ['50', ',', '80']]
    - color: BLUE
    - posn: ['50', ',', '80']
      - x: 50
      - y: 80
    - shape: CIRCLE
    - size: 50


    color: GREEN size: 20 shape: TRIANGLE posn: 20,40
    ['color:', 'GREEN', 'size:', '20', 'shape:', 'TRIANGLE', 'posn:', ['20', ',', '40']]
    - color: GREEN
    - posn: ['20', ',', '40']
      - x: 20
      - y: 40
    - shape: TRIANGLE
    - size: 20
c                   > [         TU ]  X5        U R                  (       a"  [        S U R                   5       5      U l        OSU l        SU l        SU l        SU l        g )Nc              3  8   #    U  H  oR                   v   M     g 7frB   r  r	  s     r:   r    Each.__init__.<locals>.<genexpr>  r  rM  T)r>  r   r  rP  r  r  initExprGroupsr  r  s      r:   r   Each.__init__  sO     	)::%((N4::(N%ND"%)D"""rI   c                    [        U[        5      (       a  U R                  U5      n[        U[        5      (       d  [        $ U R                  U5      $ rB   r(  r  s     r:   __iand__Each.__iand__  r+  rI   c                   > [         TU ]  5         U R                  (       a#  [        S U R                   5       5      U l        U $ SU l        U $ )Nc              3  8   #    U  H  oR                   v   M     g 7frB   r  r	  s     r:   r   "Each.streamline.<locals>.<genexpr>  r  rM  T)r>  r  r  rP  r  rZ  s    r:   r  Each.streamline  sB    ::%((N4::(N%ND"  &*D"rI   c           	     *	   U R                   (       Ga  [        S U R                   5       5      U l        U R                   Vs/ s H&  n[	        U[
        5      (       d  M  UR                  PM(     nnU R                   Vs/ s H:  nUR                  (       d  M  [	        U[
        [        [        45      (       a  M8  UPM<     nnXV-   U l
        U R                   Vs/ s H>  n[	        U[        5      (       d  M  UR                  R                  UR                  SS9PM@     snU l        U R                   Vs/ s H>  n[	        U[        5      (       d  M  UR                  R                  UR                  SS9PM@     snU l        U R                   Vs/ s H'  n[	        U[
        [        [        45      (       a  M%  UPM)     snU l        U =R"                  U R                   -  sl        SU l         UnU R"                  S S  nU R                  S S  n	U R                  S S  n
/ nSn/ n/ nU(       a  X-   U
-   nUR%                  5         UR%                  5         U Hx  n UR'                  XSS9nUR)                  U R                  R+                  [-        U5      U5      5        XH;   a  UR/                  U5        M`  XI;   a  U	R/                  U5        Mx  Mz     [9        U5      [9        U5      :X  a  SnU(       a  M  U(       aV  [9        U5      S:  a@  UR;                  S S9  US	   R<                  US   R<                  :X  a  UR;                  S
 S9  US	   nUeU(       a<  SR?                  U Vs/ s H  n[A        U5      PM     sn5      n[7        UUSU S35      eXR                   Vs/ s H.  n[	        U[
        5      (       d  M  UR                  U	;   d  M,  UPM0     sn-  n[C        / 5      nU H  nURE                  XU5      u  nnUU-  nM     UU4$ s  snf s  snf s  snf s  snf s  snf ! [0         a<  nS Ul        UUl        UR)                  U5        UR)                  U5         S nAGM  S nAf[6         a    UR)                  U5         GM5  f = fs  snf s  snf )Nc              3  ~   #    U  H3  n[        U[        5      (       d  M  [        UR                  5      U4v   M5     g 7frB   )r  r  r  r   r	  s     r:   r   !Each.parseImpl.<locals>.<genexpr>  s*       )3Az!S7IAFFQs   ==T)r3  FrM  r   c                    U R                   * $ rB   rP  rQ  s    r:   r    Each.parseImpl.<locals>.<lambda>  rS  rI   rT  r   c                Z    U R                   * [        [        U R                  5      5      * 4$ rB   rV  rQ  s    r:   r   r  !  rX  rI   r  z'Missing one or more required elements (rI  )#r  r8  r  opt1mapr  r  r   r  r  r#  	optionalsrO  r4  r  multioptionalsr$  multirequiredrequiredrO  r  r  rQ  r  remover   r   rW  r   rl  rZ  r   r  rz   r    rD  )r   r   r   r=  rc  opt1opt2tmpLoctmpReqdtmpOptmultis
matchOrderkeepMatchingfailedr]  tmpExprsr_  rd  missingtotal_resultsr  s                        r:   rs  Each.parseImpl  s     )-  DL %)JJEJq*Q2DFAFFJDE #A## ,6q3z:R,S #  
 "[DN ##Aa0 N'''M##D "#Aa+ N'''M#"D  ::%aZCY;W-X:DM MMT///M"'D--""$$Q'*,
&(,.'&0HLLNLLN)[[t[LF %%dll&6&6r!ua&@A|q)a( %   6{c(m+$+ l0 6{Q 01!9==F1IMM1KK$SKTq	IOii 9AQ 9:G 9'!D  	**X*Q
1c0BqqvvQWGWq*XX
$R(A88H:>LCW$M  M!!a F#
"
, + %(,C%)*C&MM#&MM!$$% %MM!$$%* !: Ysx   PP?PP:PP6(P4P(P$P7PP$$RR<RR$
R.0Q%%RRc                N    SSR                  S U R                   5       5       S3$ )Nr  z & c              3  8   #    U  H  n[        U5      v   M     g 7frB   r  r	  s     r:   r   ,Each._generateDefaultName.<locals>.<genexpr>8  rm  rM  r  rn  r  s    r:   r{  Each._generateDefaultName7  rp  rI   )	r  r  r  r  r  r  r  r  r  r  r  r  r$  r-  )r+   r,   r-   r.   r/   r   r  r  rs  r{  r7   rS  rT  s   @r:   r=  r=    sM    7t GK
3
?C
	
 
"U"n? ?rI   r=  c                     ^  \ rS rSrSrSSU 4S jjjrSS jrSS jrSSU 4S jjjrSSU 4S jjjr	SU 4S jjr
SU 4S	 jjrS
 rSSS jjrSS jr\" S\5      r\" S\	5      rSrU =r$ )ParseElementEnhancei;  z^Abstract subclass of :class:`ParserElement`, for combining and
post-processing parsed tokens.
c                   > [         TU ]  U5        [        U[        5      (       a  [        R
                  " [        U5      n[        U R                  [        5      (       a  U R                  U5      nOJ[        [        U 5      U R                  5      (       a  [        U5      nOU R                  [        U5      5      n[        R
                  " [        U5      nXl        Ub  UR                  U l        UR                  U l        U R#                  UR$                  UR&                  S9  UR(                  U l        UR*                  U l        UR,                  U l        U R.                  R1                  UR.                  5        g g )Nry  )r>  r   r  r#   rN  r   rz   
issubclassr   rV  r   r  ry   r   r
  r  r  ri  r   r   r  r  r  r  r%  )r   r   r  expr_strr   s       r:   r   ParseElementEnhance.__init__@  s'   "dH%%{{3-H$22E:://9DJ(@(@AAx(//0AB{{=$/	!%!3!3D%)%8%8D"%%t/I/I &  #'"5"5D"ooDO $ 1 1D##D$4$45 rI   c                :    U R                   b  U R                   /$ / $ rB   r   r  s    r:   r&  ParseElementEnhance.recurseW  s    "ii3		{;;rI   c                   U R                   c  [        XSU 5      e U R                   R                  XUSS9$ ! [         a    e [         a  nUR
                  =(       d    UUl        UR                  =(       d    UUl        UR                  =(       d    U Ul        [        U [        5      (       d/  U R                  b"  U R                  (       a  U R                  Ul        e S nAff = f)NzNo expression definedFr  )r   r   rD  r!  r  pstrr   rW  r  Forwardr   r  r   )r   r   r   r=  pbes        r:   rs  ParseElementEnhance.parseImplZ  s    99 0GNN	99##H:E#RR# 	! 	xx+8CHggnCG!$!3!3!;tCdG,,1L;;"kkCG	s   7 C#BCC#c                   > [         TU ]  U5        U(       aG  U R                  b:  U R                  R                  5       U l        U R                  R                  U5        U $ rB   )r>  re  r   r-  r   ra  r   s     r:   re  $ParseElementEnhance.leave_whitespacek  sF     +yy$ IINN,			**95rI   c                   > [         TU ]  U5        U(       aG  U R                  b:  U R                  R                  5       U l        U R                  R                  U5        U $ rB   )r>  rb  r   r-  r  s     r:   rb  %ParseElementEnhance.ignore_whitespacet  sF    !),yy$ IINN,			++I6rI   c                   > [        U[        5      (       a  XR                  ;  aD  [        TU ]  U5        U R
                  b(  U R
                  R	                  U R                  S   5        U $ r  )r  r[  r  r>  ro  r   r   r	  r   s     r:   ro  ParseElementEnhance.ignore}  sS    %**e;K;K.KGN5!yy$		  !1!1"!56rI   c                r   > [         TU ]  5         U R                  b  U R                  R                  5         U $ rB   )r>  r  r   rZ  s    r:   r  ParseElementEnhance.streamline  s-    99 II  "rI   c                    X;   a  [        X/-   5      eUS S  U /-   nU R                  b  U R                  R                  U5        g g rB   )RecursiveGrammarExceptionr   r  )r   r  r  s      r:   r  #ParseElementEnhance._checkRecursion  sK    #+,<v,EFF*1-699 II%%o6 !rI   c                    [         R                  " S[        SS9  Uc  / nUS S  U /-   nU R                  b  U R                  R	                  U5        U R                  / 5        g r  r  r?   r  r   r  r  r   r  r  s      r:   r  ParseElementEnhance.validate  s_    h	

  MA$'99 IIs#R rI   c                L    [        U 5      R                   SU R                   S3$ r  )r   r+   r   r  s    r:   r{  (ParseElementEnhance._generateDefaultName  s$    t*%%&b155rI   r  r  )r  r  r   r
  r  r  r  r   Union[ParserElement, str]r  rm   rK   rL   r.  r  r)  r  rB   rJ   r-  )r+   r,   r-   r.   r/   r   r&  rs  re  rb  ro  r  r  r  r{  r   r  r  r7   rS  rT  s   @r:   r  r  ;  sh    6 6.<"  7!6
 ''8:JKO'(:<MNrI   r  c                     ^  \ rS rSrSr " S S\5      r " S S\5      rSSS	.       SU 4S
 jjjrSSS jjr	Sr
U =r$ )r  i  z
Expression to match one or more expressions at a given indentation level.
Useful for parsing text where structure is implied by indentation (like Python source code).
c                  ,   ^  \ rS rSrSU 4S jjrSrU =r$ )IndentedBlock._Indenti  c                b   >^ [         TU ]  5         ST 3U l        U R                  U4S j5        g )Nzexpected indent at column c                    > [        X5      T:H  $ rB   r  r   r   r   ref_cols      r:   r   0IndentedBlock._Indent.__init__.<locals>.<lambda>  s    s1yG/CrI   r>  r   r  r[  r   r  r   s    `r:   r   IndentedBlock._Indent.__init__  s+    G6wi@DKCDrI   r  r  r  rK   rL   r  rT  s   @r:   _Indentr    s    	E 	ErI   r  c                  ,   ^  \ rS rSrSU 4S jjrSrU =r$ )IndentedBlock._IndentGreateri  c                b   >^ [         TU ]  5         ST 3U l        U R                  U4S j5        g )Nz'expected indent at column greater than c                    > [        X5      T:  $ rB   r  r  s      r:   r   7IndentedBlock._IndentGreater.__init__.<locals>.<lambda>  s    s1y7/BrI   r  r  s    `r:   r   %IndentedBlock._IndentGreater.__init__  s+    GCG9MDKBCrI   r  r  r  rT  s   @r:   _IndentGreaterr    s    	D 	DrI   r  FTra  groupedc               H   > [         TU ]  USS9  X l        X0l        SU l        g )NTrX  r   )r>  r   
_recursive_groupedr  )r   r   ra  r  r   s       r:   r   IndentedBlock.__init__  s+     	- $rI   c                    [        5       R                  X5      nU R                  R                  XUS9  [	        XA5      nU R                  U5      n[        5       U-   U R                  -   nU R                  (       ak  U R                  U5      n[        U R                  U R                  U R                  S9n	U	R                  U R                  5        XYl        U[        X-   5      -  nUR                  S[        [!        U5      5      SS  R#                  5        SU 35        [%        U5      n
U R                  U R                  5      ['        5       -  nU R                  (       a  [(        nOS nU" U
5      [+        U5      -   R-                  XU5      $ )Nr  r  zinner @c                    U $ rB   r*   r  s    r:   r   )IndentedBlock.parseImpl.<locals>.<lambda>  s    4rI   )r  ro  r   r  r   r  r  r  r  r  r  r  r  r  r  hexr  r  r$  r  GroupOptionalrs  )r   r   r   r=  
anchor_loc
indent_colpeer_detect_expr
inner_expr
sub_indentnested_blockblocktrailing_undentr   s                r:   rs  IndentedBlock.parseImpl  sO    W%%h4
 			HZH.
<<
3W//$));
??,,Z8J(		T__dmmL ""4::.)3&#j788JfSJ%8%=%C%C%E$Fa
|TU*%,,t'9'9:Y[H==G'G/!::EE*
 	
rI   )r  r  r  )r   ry   ra  rm   r  rm   rK   rL   r  r$  )r+   r,   r-   r.   r/   r  r  r  r   rs  r7   rS  rT  s   @r:   r  r    s_    
E% ED D 9>t!15HL	 !
 !
rI   r  c                  D   ^  \ rS rSrSrSU 4S jjrSSU 4S jjjrSrU =r$ )	AtStringStarti  zMatches if expression matches at the beginning of the parse
string::

    AtStringStart(Word(nums)).parse_string("123")
    # prints ["123"]

    AtStringStart(Word(nums)).parse_string("    123")
    # raises ParseException
c                2   > [         TU ]  U5        SU l        g NFr>  r   r  r   r   r   s     r:   r   AtStringStart.__init__      !rI   c                H   > US:w  a  [        XS5      e[        TU ]	  XU5      $ )Nr   znot found at string start)r   r>  rs  r   r   r   r=  r   s       r:   rs  AtStringStart.parseImpl  s*    !8 0KLLw 
;;rI   rK  r   r  rK   rL   r  r$  rc  rT  s   @r:   r  r    s    "< <rI   r  c                  D   ^  \ rS rSrSrSU 4S jjrSSU 4S jjjrSrU =r$ )	AtLineStarti  a}  Matches if an expression matches at the beginning of a line within
the parse string

Example::

    test = '''\
    AAA this line
    AAA and this line
      AAA but not this one
    B AAA and definitely not this one
    '''

    for t in (AtLineStart('AAA') + rest_of_line).search_string(test):
        print(t)

prints::

    ['AAA', ' this line']
    ['AAA', ' and this line']

c                2   > [         TU ]  U5        SU l        g r  r  r  s     r:   r   AtLineStart.__init__  r  rI   c                Z   > [        X!5      S:w  a  [        XS5      e[        TU ]  XU5      $ )Nr   znot found at line start)r   r   r>  rs  r  s       r:   rs  AtLineStart.parseImpl  s0    s" 0IJJw 
;;rI   rK  r  r  r$  rc  rT  s   @r:   r  r    s    ,"< <rI   r  c                  >   ^  \ rS rSrSrSU 4S jjrSSS jjrSrU =r$ )	
FollowedByi  a'  Lookahead matching of the given parse expression.
``FollowedBy`` does *not* advance the parsing position within
the input string, it only verifies that the specified parse
expression matches at the current position.  ``FollowedBy``
always returns a null token list. If any results names are defined
in the lookahead expression, those *will* be returned for access by
name.

Example::

    # use FollowedBy to match a label only if it is followed by a ':'
    data_word = Word(alphas)
    label = data_word + FollowedBy(':')
    attr_expr = Group(label + Suppress(':') + OneOrMore(data_word, stop_on=label).set_parse_action(' '.join))

    attr_expr[1, ...].parse_string("shape: SQUARE color: BLACK posn: upper left").pprint()

prints::

    [['shape', 'SQUARE'], ['color', 'BLACK'], ['posn', 'upper left']]
c                2   > [         TU ]  U5        SU l        g r  r>  r   r  r  s     r:   r   FollowedBy.__init__6  s    !%rI   c                J    U R                   R                  XUS9u  pEUS S 2	 X%4$ Nr  )r   rD  )r   r   r   r=  r)   r   s         r:   rs  FollowedBy.parseImpl:  s-     !!(J!GFxrI   r  r  r  r$  rc  rT  s   @r:   r#  r#    s    ,& rI   r#  c                  B   ^  \ rS rSrSrSSU 4S jjjrSS	S jjrSrU =r$ )

PrecededByiC  aH  Lookbehind matching of the given parse expression.
``PrecededBy`` does not advance the parsing position within the
input string, it only verifies that the specified parse expression
matches prior to the current position.  ``PrecededBy`` always
returns a null token list, but if a results name is defined on the
given expression, it is returned.

Parameters:

- ``expr`` - expression that must match prior to the current parse
  location
- ``retreat`` - (default= ``None``) - (int) maximum number of characters
  to lookbehind prior to the current parse location

If the lookbehind expression is a string, :class:`Literal`,
:class:`Keyword`, or a :class:`Word` or :class:`CharsNotIn`
with a specified exact or maximum length, then the retreat
parameter is not required. Otherwise, retreat must be specified to
give a maximum number of characters to look back from
the current parse position for a lookbehind match.

Example::

    # VB-style variable names with type prefixes
    int_var = PrecededBy("#") + pyparsing_common.identifier
    str_var = PrecededBy("$") + pyparsing_common.identifier

c                  > [         TU ]  U5        U R                  5       R                  5       U l        SU l        SU l        SU l        [        U[        5      (       a.  [        R                  " [        U5      n[        U5      nSU l        O[        U[        [        45      (       a  UR                  nSU l        Oa[        U[         ["        45      (       a(  UR$                  [&        :w  a  UR$                  nSU l        O[        U[(        5      (       a	  SnSU l        X l        SU 3U l        SU l        U R0                  R3                  S 5        g )NTFr   znot preceded by c                8    UR                  [        S S 5      5      $ rB   )__delitem__rK  r   r   r   s      r:   r   %PrecededBy.__init__.<locals>.<lambda>w  s    eD$>O0PrI   )r>  r   r   re  r  r
  r  r  r#   rN  r   rz   rl  r  r  rq  r  rc  r  r9  r  retreatr  r  r   r  )r   r   r1  r   s      r:   r   PrecededBy.__init__a  s   IIK002	!%"
dH%%;;sD)D$iGDJw011mmGDJtZ011dkkX6MkkGDJm,,GDJ(/# PQrI   c                4   U R                   (       aT  X R                  :  a  [        XU R                  U 5      eX R                  -
  nU R                  R                  X5      u  pVX&4$ U R                  [        5       -   nU[        SX R                  -
  5      U n[        XU R                  U 5      n	[        S[        X R                  S-   5      S-   5       H&  n
 UR                  U[        U5      U
-
  5      u  pV  X&4$    U	e! [         a  nUn	 S nAM>  S nAff = fr  )r  r1  r   r  r   rD  r  r  rH  r  rl  r  )r   r   r   r=  r  r)   r   	test_exprinstring_slice	last_exproffsetr  s               r:   rs  PrecededBy.parseImply  s   ::\\!$XDKKFF,,&EYY%%h6FA8O II	+	!#a||);"<sC(6xdkkSW(X	As3q(89A=>F")).#n:MPV:VW  x ? O &  	 s    D  
D
DD)r  r  r  r   r
  r1  r  r  )r   r  r1  r  rK   rL   )r   Tr$  rc  rT  s   @r:   r+  r+  C  s    :R R0 rI   r+  c                  &    \ rS rSrSrSSS jjrSrg)Locatedi  ar  
Decorates a returned token with its starting and ending
locations in the input string.

This helper adds the following results names:

- ``locn_start`` - location where matched expression begins
- ``locn_end`` - location where matched expression ends
- ``value`` - the actual parsed results

Be careful if the input text contains ``<TAB>`` characters, you
may want to call :class:`ParserElement.parse_with_tabs`

Example::

    wd = Word(alphas)
    for match in Located(wd).search_string("ljsdf123lksdjjf123lkkjj1222"):
        print(match)

prints::

    [0, ['ljsdf'], 5]
    [8, ['lksdjjf'], 15]
    [18, ['lkkjj'], 23]

c                    UnU R                   R                  XUSS9u  p%[        XEU/5      nXFS'   XVS'   X&S'   U R                  (       a  X&/4$ X&4$ )NFr  
locn_startr  locn_end)r   rD  r    r  )r   r   r   r=  r  r  r  s          r:   rs  Located.parseImpl  sh    ii&&x
QV&W!5#"67
#(< $7!$:$$?"rI   r*   Nr  r$  )r+   r,   r-   r.   r/   rs  r7   r*   rI   r:   r:  r:    s    6# #rI   r:  c                  H   ^  \ rS rSrSrSU 4S jjrSS	S jjrS
S jrSrU =r	$ )rD  i  au  
Lookahead to disallow matching with the given parse expression.
``NotAny`` does *not* advance the parsing position within the
input string, it only verifies that the specified parse expression
does *not* match at the current position.  Also, ``NotAny`` does
*not* skip over leading whitespace. ``NotAny`` always returns
a null token list.  May be constructed using the ``'~'`` operator.

Example::

    AND, OR, NOT = map(CaselessKeyword, "AND OR NOT".split())

    # take care not to mistake keywords for identifiers
    ident = ~(AND | OR | NOT) + Word(alphas)
    boolean_term = Opt(NOT) + ident

    # very crude boolean expression - to support parenthesis groups and
    # operation hierarchy, use infix_notation
    boolean_expr = boolean_term + ((AND | OR) + boolean_term)[...]

    # integers that are followed by "." are actually floats
    integer = Word(nums) + ~Char(".")
c                h   > [         TU ]  U5        SU l        SU l        SU R                   3U l        g )NFTzFound unwanted token, )r>  r   r  r  r   r  r  s     r:   r   NotAny.__init__  s4     $!%.tyyk:rI   c                v    U R                   R                  XUS9(       a  [        XU R                  U 5      eU/ 4$ r(  )r   r  r   r  rr  s       r:   rs  NotAny.parseImpl  s5    99##Hj#I TBBBwrI   c                "    SU R                    S3$ )Nz~{r  r  r  s    r:   r{  NotAny._generateDefaultName  s    TYYKr""rI   )r  r  r  r  r  r$  r-  
r+   r,   r-   r.   r/   r   rs  r{  r7   rS  rT  s   @r:   rD  rD    s    0;
# #rI   rD  c                  t   ^  \ rS rSr S	SS.       S
U 4S jjjjrSS jrSSS jjrSSU 4S jjjrSrU =r	$ )rO  i  NrP  c                  > [         TU ]  U5        U=(       d    UnSU l        Un[        U[        5      (       a  U R                  U5      nU R                  U5        g r  )r>  r   r  r  r#   r   rP  )r   r   rS  rP  enderr   s        r:   r   _MultipleMatch.__init__  sQ     	"7eX&&,,U3EErI   c                z    [        U[        5      (       a  U R                  U5      nUb
  U) U l        U $ S U l        U $ rB   )r  r#   r   	not_ender)r   rJ  s     r:   rP  _MultipleMatch.stopOn  s@    eX&&,,U3E#(#4% ;?rI   c                   U R                   R                  nU R                  nSnU R                  b  U R                  R                  nSnU(       a  W" X5        U" XU5      u  p( U R
                  (       n	 U(       a  W" X5        U	(       a	  U" X5      n
OUn
U" XU5      u  p+X-  nM2  ! [        [        4 a     X(4$ f = f)NFT)r   rD  rh  rM  r  r  r   r   )r   r   r   r=  self_expr_parseself_skip_ignorablescheck_endertry_not_enderr  hasIgnoreExprsr  	tmptokenss               r:   rs  _MultipleMatch.parseImpl  s    ))**#33>>% NN44MK ((%hZ@	%)%5%5!5N!(0!1(@F F!0:!N#  
+ 	{	s   %AB( (B=<B=c                  > [         R                  (       a  [        R                  U R                  ;  a  U R                  /U R                  R                  5       -    H  n[        U[        5      (       d  M  UR                  (       d  M-  [        R                  UR                  ;  d  MM  SU< S[        U 5      R                   SUR                  < S3n[        R                  " USS9    O   [        TU ]9  X5      $ r  )r<   rN   rX   r  r   r&  r  ry   r  r   r+   r  r?   r>  r2  r  s        r:   r2  _MultipleMatch._setResultsName  s    >>EE**+ ii[499#4#4#66q-00#MM 334
115T$Z=P=P<Q R**+--)::RT 
 MM'a8 7" w&t>>rI   )rM  r  rB   r   Union[str, ParserElement]rS  r1  rP  r1  rK   rL   r  r  r$  r  )
r+   r,   r-   r.   r   rP  rs  r2  r7   rS  rT  s   @r:   rO  rO    sX     ?C
 >B' <
 ; 
 :? ?rI   rO  c                  "    \ rS rSrSrSS jrSrg)r$  i6  a-  
Repetition of one or more of the given expression.

Parameters:

- ``expr`` - expression that must match one or more times
- ``stop_on`` - (default= ``None``) - expression for a terminating sentinel
  (only required if the sentinel would ordinarily match the repetition
  expression)

Example::

    data_word = Word(alphas)
    label = data_word + FollowedBy(':')
    attr_expr = Group(label + Suppress(':') + OneOrMore(data_word).set_parse_action(' '.join))

    text = "shape: SQUARE posn: upper left color: BLACK"
    attr_expr[1, ...].parse_string(text).pprint()  # Fail! read 'color' as data instead of next label -> [['shape', 'SQUARE color']]

    # use stop_on attribute for OneOrMore to avoid reading label string as part of the data
    attr_expr = Group(label + Suppress(':') + OneOrMore(data_word, stop_on=label).set_parse_action(' '.join))
    OneOrMore(attr_expr).parse_string(text).pprint() # Better -> [['shape', 'SQUARE'], ['posn', 'upper left'], ['color', 'BLACK']]

    # could also be written as
    (attr_expr * (1,)).parse_string(text).pprint()
c                "    SU R                    S3$ )Nr  z}...r  r  s    r:   r{  OneOrMore._generateDefaultNameR  s    DII;e$$rI   r*   Nr-  )r+   r,   r-   r.   r/   r{  r7   r*   rI   r:   r$  r$  6  s    6%rI   r$  c                  j   ^  \ rS rSrSr S	SS.       S
U 4S jjjjrSSU 4S jjjrSS jrSrU =r	$ )r#  iV  aP  
Optional repetition of zero or more of the given expression.

Parameters:

- ``expr`` - expression that must match zero or more times
- ``stop_on`` - expression for a terminating sentinel
  (only required if the sentinel would ordinarily match the repetition
  expression) - (default= ``None``)

Example: similar to :class:`OneOrMore`
NrH  c               @   > [         TU ]  X=(       d    US9  SU l        g )NrH  Tr%  )r   r   rS  rP  r   s       r:   r   ZeroOrMore.__init__d  s"     	&78!%rI   c                ~   >  [         TU ]  XU5      $ ! [        [        4 a    U[	        / U R
                  S94s $ f = f)Nr  )r>  rs  r   r   r    r  r  s       r:   rs  ZeroOrMore.parseImpln  sI    	@7$XJ??
+ 	@Rd.>.>???	@s    &<<c                "    SU R                    S3$ )Nr  ]...r  r  s    r:   r{  ZeroOrMore._generateDefaultNamet  s    499+T""rI   r  rB   rY  r  r$  r-  rF  rT  s   @r:   r#  r#  V  s_      ?C&
 >B&'& <&
 ;& 
& &@ @# #rI   r#  c                  d   ^  \ rS rSr    SSS.             SU 4S jjjjrS	S jrSrU =r$ )
DelimitedListix  F)allow_trailing_delimc                 > [        U[        5      (       a  [        R                  U5      n[        R
                  " [        U5      nUb  US:  a  [        S5      eUb  Ub  XT:  a  [        S5      eXl        [        U5      U l	        X l
        X0l        U(       d  [        U5      U l
        U=(       d    SU l        XPl        X`l        U R                  U R                  U R                  -   U R                  S-
  U R                  c  SOU R                  S-
  4-  -   nU R                  (       a  U[!        U R                  5      -  nU R                  (       a  [#        U5      n[$        TU ]M  USS9  g)a  Helper to define a delimited list of expressions - the delimiter
defaults to ','. By default, the list elements and delimiters can
have intervening whitespace, and comments, but this can be
overridden by passing ``combine=True`` in the constructor. If
``combine`` is set to ``True``, the matching tokens are
returned as a single token string, with the delimiters included;
otherwise, the matching tokens are returned as a list of tokens,
with the delimiters suppressed.

If ``allow_trailing_delim`` is set to True, then the list may end with
a delimiter.

Example::

    DelimitedList(Word(alphas)).parse_string("aa,bb,cc") # -> ['aa', 'bb', 'cc']
    DelimitedList(Word(hexnums), delim=':', combine=True).parse_string("AA:BB:CC:DD:EE") # -> ['AA:BB:CC:DD:EE']
Nr   zmin must be greater than 0z)max must be greater than, or equal to minTrX  )r  r#   ry   r   rN  r   r%  contentrz   	raw_delimdelimcombiner[  r  r  rh  r  Combiner>  r   )	r   r   rl  rm  r  r  rh  delim_list_exprr   s	           r:   r   DelimitedList.__init__y  s)   6 dH%% 44T:D{{=$/?sQw9::?s39HIIU
!%DJ8!$8!,,$**t||*CHHqLHH$D$((Q,H
 *
 
 $$s4::.O<<%o6O48rI   c                `    U R                   R                  5       nU SU R                   SU S3$ )Nz [r  rd  )rj  r  rk  )r   content_exprs     r:   r{  "DelimitedList._generateDefaultName  s2    ||..0r$..!1<.EErI   )rh  rm  rj  rl  r  r  rk  )r   FNN)r   rZ  rl  rZ  rm  rm   r  r&  r  r&  rh  rm   rK   rL   r-  r  rT  s   @r:   rg  rg  x  sv     ,/$($(99 &+99'99 )99 	99
 "99 "99 #99 
99 99vF FrI   rg  c                       \ rS rSrS rS rSrg)
_NullTokeni  c                    gr  r*   r  s    r:   __bool___NullToken.__bool__  s    rI   c                    g)Nrl   r*   r  s    r:   r  _NullToken.__str__  s    rI   r*   N)r+   r,   r-   r.   rw  r  r7   r*   rI   r:   ru  ru    s    rI   ru  c                  f   ^  \ rS rSrSr\" 5       r\4     SU 4S jjjrSS	S jjrS
S jr	Sr
U =r$ )r  i  a  
Optional matching of the given expression.

Parameters:

- ``expr`` - expression that must match zero or more times
- ``default`` (optional) - value to be returned if the optional expression is not found.

Example::

    # US postal code can be a 5-digit zip, plus optional 4-digit qualifier
    zip = Combine(Word(nums, exact=5) + Opt('-' + Word(nums, exact=4)))
    zip.run_tests('''
        # traditional ZIP code
        12345

        # ZIP+4 form
        12101-0001

        # invalid ZIP
        98765-
        ''')

prints::

    # traditional ZIP code
    12345
    ['12345']

    # ZIP+4 form
    12101-0001
    ['12101-0001']

    # invalid ZIP
    98765-
         ^
    FAIL: Expected end of text (at char 5), (line:1, col:6)
c                r   > [         TU ]  USS9  U R                  R                  U l        X l        SU l        g )NFrX  T)r>  r   r   r  defaultValuer  )r   r   defaultr   s      r:   r   Opt.__init__  s6     	.))..#!%rI   c                   U R                   n UR                  XUSS9u  p%X%4$ ! [        [        4 aT    U R                  nX`R
                  La3  UR                  (       a  [        U/5      nXeUR                  '   O	U/n X%4$ / n X%4$ f = f)NFr  )r   rD  r   r   r}  _Opt__optionalNotMatchedr  r    )r   r   r   r=  	self_exprr  default_values          r:   rs  Opt.parseImpl  s    II		#**z + KC { 
+ 		 --M$=$==(()=/:F4A9001+_F { {		s   $ ABBBc                    [        U R                  5      n[        U5      S:  aF  USS [        U5      S-
  2   S:X  a.  USS n[        U5      S:  a  USS [        U5      S-
  2   S:X  a  M.  SU S3$ )Nr   r   r1  r   r  rH  )rz   r   rl  r2  s     r:   r{  Opt._generateDefaultName  sx    DII%j1nq':CJN':!;t!C!BKE %j1nq':CJN':!;t!C5'|rI   )r  r}  r  )r   r  r~  r   rK   rL   r  r$  r-  )r+   r,   r-   r.   r/   ru  r  r   rs  r{  r7   rS  rT  s   @r:   r  r    sJ    %N &< ?S&-&8;&	& &$ rI   r  c                  t   ^  \ rS rSrSr   S
SS.           SU 4S jjjjrS rU 4S jrSS jrS	r	U =r
$ )r  i  a_	  
Token for skipping over all undefined text until the matched
expression is found.

Parameters:

- ``expr`` - target expression marking the end of the data to be skipped
- ``include`` - if ``True``, the target expression is also parsed
  (the skipped text and target expression are returned as a 2-element
  list) (default= ``False``).
- ``ignore`` - (default= ``None``) used to define grammars (typically quoted strings and
  comments) that might contain false matches to the target expression
- ``fail_on`` - (default= ``None``) define expressions that are not allowed to be
  included in the skipped test; if found before the target expression is found,
  the :class:`SkipTo` is not a match

Example::

    report = '''
        Outstanding Issues Report - 1 Jan 2000

           # | Severity | Description                               |  Days Open
        -----+----------+-------------------------------------------+-----------
         101 | Critical | Intermittent system crash                 |          6
          94 | Cosmetic | Spelling error on Login ('log|n')         |         14
          79 | Minor    | System slow when running too many reports |         47
        '''
    integer = Word(nums)
    SEP = Suppress('|')
    # use SkipTo to simply match everything up until the next SEP
    # - ignore quoted strings, so that a '|' character inside a quoted string does not match
    # - parse action will call token.strip() for each matched token, i.e., the description body
    string_data = SkipTo(SEP, ignore=quoted_string)
    string_data.set_parse_action(token_map(str.strip))
    ticket_expr = (integer("issue_num") + SEP
                  + string_data("sev") + SEP
                  + string_data("desc") + SEP
                  + integer("days_open"))

    for tkt in ticket_expr.search_string(report):
        print tkt.dump()

prints::

    ['101', 'Critical', 'Intermittent system crash', '6']
    - days_open: '6'
    - desc: 'Intermittent system crash'
    - issue_num: '101'
    - sev: 'Critical'
    ['94', 'Cosmetic', "Spelling error on Login ('log|n')", '14']
    - days_open: '14'
    - desc: "Spelling error on Login ('log|n')"
    - issue_num: '94'
    - sev: 'Cosmetic'
    ['79', 'Minor', 'System slow when running too many reports', '47']
    - days_open: '47'
    - desc: 'System slow when running too many reports'
    - issue_num: '79'
    - sev: 'Minor'
N)failOnc               b  > [         TU ]  U5        U=(       d    UnX0l        SU l        SU l        X l        SU l        [        U[        5      (       a  U R                  U5      U l
        OXPl
        SU R                   3U l        [        5       R                  5       U l        U R!                  5         g )NTFzNo match found for )r>  r   
ignoreExprr  r
  includeMatchr  r  r#   r   r  r   r  r  re  ignorer_update_ignorer)r   r	  includero  fail_onr  r   s         r:   r   SkipTo.__init__N  s     	"7 !%"#fh''226:DK K+DII;7w//1rI   c                *   U R                   R                  R                  5         U R                  R                   H  nU R                   R	                  U5        M      U R
                  (       a&  U R                   R	                  U R
                  5        g g rB   )r  r  rO  r   ro  r  )r   rc  s     r:   r  SkipTo._update_ignorerf  s`      &&(&&ALL" '??LL0 rI   c                D   > [         TU ]  U5        U R                  5         g rB   )r>  ro  r  r  s     r:   ro  SkipTo.ignoren  s    trI   c                j   Un[        U5      nU R                  R                  nU R                  b  U R                  R                  OS nU R
                  R                  (       a  U R
                  R                  OS nUn	X::  a4  Ub  U" X5      (       a  O:Ub  U	n
  U" X5      n	X:X  a  OU	n
M   U" XSSS9  O[        XU R                  U 5      eU	nXU n[        U5      nU R                  (       a  U" XUSS9u  p-X-  nX,4$ ! [         a     Ma  f = f! [        [        4 a    U	S-  n	 Of = fX::  a  M  N~)Nr   F)r=  r>  r  )rl  r   rD  r  r  r  r  r  r  r   r   r  r    r  )r   r   r   r=  r   rm  rP  self_failOn_canParseNextignorer_try_parsetmplocprev_tmplocskiptext
skipresultr  s                 r:   rs  SkipTo.parseImplr  sX   x=))**(,(?DKK$$T 	! 7;ll6N6NDLL22TX '3+H== ,$!28!D ,"(K UQVW  !TBB S)!(+
&xjuUHCJ; .  #J/ !+  s$   D .D 
DDD*)D*)r  r  r  r  r  r  r
  r  )FNN)r	  r  r  rm   ro  r1  r  r1  r  r1  rK   rL   r  )r+   r,   r-   r.   r/   r   r  ro  rs  r7   rS  rT  s   @r:   r  r    sw    ;@ =A>B >B(  ;	
 < ; 
 013 3rI   r  c                     ^  \ rS rSrSr S   SU 4S jjjrSS jrSS jrSU 4S jjrS r	SSU 4S jjjr
SSS	 jjrSSS
 jjrSS jrSSS jjrSS jrSU 4S jjrSSU 4S jjjr\" S\5      r\" S\5      rSrU =r$ )r  i  a3  
Forward declaration of an expression to be defined later -
used for recursive grammars, such as algebraic infix notation.
When the expression is known, it is assigned to the ``Forward``
variable using the ``'<<'`` operator.

Note: take care when assigning to ``Forward`` not to overlook
precedence of operators.

Specifically, ``'|'`` has a lower precedence than ``'<<'``, so that::

    fwd_expr << a | b | c

will actually be evaluated as::

    (fwd_expr << a) | b | c

thereby leaving b and c out as parseable alternatives.  It is recommended that you
explicitly group the values inserted into the ``Forward``::

    fwd_expr << (a | b | c)

Converting to use the ``'<<='`` operator instead will avoid this problem.

See :class:`ParseResults.pprint` for an example of a recursive
parser created using ``Forward``.
c                h   > [         R                  " SS9S   U l        [        TU ]  USS9  S U l        g )NrZ   r   r   FrX  )r   r   caller_framer>  r   lshift_liner  s     r:   r   Forward.__init__  s7     &33!<Q?/rI   c                   [        U S5      (       a  U ?[        U[        5      (       a  U R	                  U5      n[        U[
        5      (       d  [        $ Xl        UR                  U l        U R                  R                  U l	        U R                  R                  U l        U R                  U R                  R                  U R                  R                  S9  U R                  R                  U l        U R                  R                   U l        U R"                  R%                  U R                  R"                  5        [&        R(                  " SS9S   U l        U $ )Nr  ry  rZ   r   )rE  r  r  r#   r   ry   r  r   r	  r
  r  r  ri  r   r   r  r  r  r%  r   r   r  r  s     r:   
__lshift__Forward.__lshift__  s   4((!eX&&,,U3E%//!!	 ,,!YY44!%!9!9!!II  		0O0O 	" 	
 #ii66))..		 5 56$22;B?rI   c                @    [        U[        5      (       d  [        $ X-  $ rB   )r  ry   r  r  s     r:   __ilshift__Forward.__ilshift__  s    %//!!}rI   c                  > [         R                  " SS9S   n[        R                  (       aB  X R                  :X  a3  [
        R                  U R                  ;  a  [        R                  " SSS9  [        TU ])  U5      nU$ )NrZ   r   r  zfwarn_on_match_first_with_lshift_operator: using '<<' operator with '|' is probably an error, use '<<='r  )r   r   r<   rS   r  rX   r  r  r?   r>  r0  )r   r	  caller_liner   r   s       r:   r0  Forward.__or__  sp    --A6r:==///DD**+ MMP
 gnU#
rI   c                   U R                   cy  [        R                  (       ac  [        R                  U R                  ;  aD  [
        R                  " S[        U R                  R                  U R                  R                  S9  g g g g )Nzhwarn_on_assignment_to_Forward: Forward defined here but no expression attached later using '<<=' or '<<')filenamer   )r   r<   rQ   rX   r  r  warn_explicitUserWarningr  r  r   r  s    r:   __del__Forward.__del__  sp     II6699AXAXX""]**33((// Y 7 rI   c           	       > U R                   c  [        R                  (       a~  [        R                  U R                  ;  a`  Sn[
        R                  " SS9n[        [        U5      SS9 H  u  pgUR                  U;   d  M  US-   n  O   Sn[        R                  " SUS9  [        R                  (       d  [        TU ]=  XU5      $ [        R                      [        R"                  n	 XX4   u  p[%        U[&        5      (       a  UeXR)                  5       4sS S S 5        $ ! [*         Ga    X S	4nX S
4nUS-
  [-        XSU 5      4=u  pX'   U(       a  X   X'     [        TU ]=  XS
5      u  nnO)! [,         a    [%        U[&        5      (       a  e Xnn Of = fX::  a]  U(       a1  X   =u  pX'   X	 X	 U
[(        R(                  " U5      4s sS S S 5        $ X	 U
[(        R(                  " U5      4s sS S S 5        $ U(       a1   [        TU ]=  XS	5      X'   O! [,         a  nUU4=X'   X'   e S nAff = fUU4=u  pX'   M  f = f! , (       d  f       g = f)N)r  r  r  r     r   r   )r  rZ   zjwarn_on_parse_using_empty_Forward: Forward expression was never assigned a value, will not parse any inputr  TFz#Forward recursion without base case)r   r<   rP   rX   r  r   r   r  reversedrF   r  r?   ry   r  r>  rs  r6  r  r  r~  r-  KeyErrorr   )r   r   r   r=  	parse_fnsr   rj   frmr  memoprev_locprev_resultact_keypeek_key	prev_peeknew_locnew_peekrc  r   s                     r:   rs  Forward.parseImpl  s   II::==**+I ((s3B#HRL:88y(!"QJ ;
 
MM[%
 447$XJ??( )) 00D,M(,$-B(C%k955%%!1!1!33 *)  &Md+u- !G" 'Ld8 #dn $(NDM@,1G,=hU,S)) @%i;;!,4	@ *% FJ]R1HDN $#+TYY{-C#CCI *)J !N'9)===M *)P "",1G,=hT,RDM- ">Eq\IDNT]!" <CH;LL'H$.3 &M *)s~   I)/D""9I E0/I 0#FI F5I II 0I;I HI 
H0 H++H00I  I
Ic                    SU l         U $ r  r_  r`  s     r:   re  Forward.leave_whitespacef  s    #rI   c                    SU l         U $ r  r_  r`  s     r:   rb  Forward.ignore_whitespacej  s    "rI   c                    U R                   (       d.  SU l         U R                  b  U R                  R                  5         U $ r  )r	  r   r  r  s    r:   r  Forward.streamlinen  s2    #Dyy$		$$&rI   c                    [         R                  " S[        SS9  Uc  / nX;  a1  US S  U /-   nU R                  b  U R                  R	                  U5        U R                  / 5        g r  r  r  s      r:   r  Forward.validateu  se    h	

  M$"dV+Cyy$		""3'R rI   c                    U R                   nSU l          U R                  b  [        U R                  5      S S nOSn Xl         [	        U 5      R
                   SU 3$ ! [         a    Sn N.f = f)Nz: ...i  rL   rB  r  )r  r   rz   r~  r   r+   )r   save_default_name
ret_strings      r:   r{  Forward._generateDefaultName  sx     --#	yy$ ^ET2
#
 .t*%%&b55	  	J	s   %A A A-,A-c                Z   > U R                   b  [        TU ]	  5       $ [        5       nX-  nU$ rB   )r   r>  r-  r  )r   r   r   s     r:   r-  Forward.copy  s,    99 7<>!)CLCJrI   c                  > [         R                  (       a]  [        R                  U R                  ;  a?  U R                  c2  SU< S[        U 5      R                   S3n[        R                  " USS9  [        TU ])  X5      $ )Nz5warn_name_set_on_empty_Forward: setting results name r  z, expression that has no contained expressionr[   r  )r<   rO   rX   r  r   r   r+   r  r?   r>  r2  rz  s       r:   r2  Forward._setResultsName  sy     33::$BYBYY		!))-T$Z5H5H4I J44 
 MM'a0 w&t>>rI   r  r  )	r  r  r  r   r  r
  r  r  r	  rB   )r	  r1  rK   rL   )rK   r  r  r  r$  r)  rJ   r-  r  )r+   r,   r-   r.   r/   r   r  r  r0  r  rs  re  rb  r  r  r{  r-  r2  r   r  r  r7   rS  rT  s   @r:   r  r    s    : CG ? 	   , ]M ]M~!6"? ?& ''8:JKO'(:<MNrI   r  c                  4   ^  \ rS rSrSrSSU 4S jjjrSrU =r$ )TokenConverteri  zS
Abstract subclass of :class:`ParseElementEnhance`, for converting parsed results.
c                2   > [         TU ]  U5        SU l        g r  )r>  r   r  r   r   r  r   s      r:   r   TokenConverter.__init__  s    rI   rB  r  r  r  rT  s   @r:   r  r    s       rI   r  c                  h   ^  \ rS rSrSr  S	SS.         S
U 4S jjjjrSU 4S jjrS rSrU =r	$ )rn  i  a  Converter to concatenate all matching tokens to a single string.
By default, the matching patterns must also be contiguous in the
input string; this can be disabled by specifying
``'adjacent=False'`` in the constructor.

Example::

    real = Word(nums) + '.' + Word(nums)
    print(real.parse_string('3.1416')) # -> ['3', '.', '1416']
    # will also erroneously match the following
    print(real.parse_string('3. 1416')) # -> ['3', '.', '1416']

    real = Combine(Word(nums) + '.' + Word(nums))
    print(real.parse_string('3.1416')) # -> ['3.1416']
    # no match when there are internal spaces
    print(real.parse_string('3. 1416')) # -> Exception: Expected W:(0123...)
N)
joinStringc                  > [         TU ]  U5        Ub  UOUnU(       a  U R                  5         X0l        SU l        X@l        SU l        g r  )r>  r   re  adjacentr  r  r  )r   r   join_stringr  r  r   s        r:   r   Combine.__init__  sG     	#-#9Z{
!!# "$ rI   c                v   > U R                   (       a  [        R                  X5        U $ [        TU ]	  U5        U $ rB   )r  ry   ro  r>  r  s     r:   ro  Combine.ignore  s2    ==  -  GN5!rI   c                   UR                  5       nUS S 2	 U[        SR                  UR                  U R                  5      5      /U R
                  S9-  nU R                  (       a  UR                  5       (       a  U/$ U$ )Nrl   )r}  )r-  r    r  _asStringListr  r  r  haskeys)r   r   r   rx  retTokss        r:   ry  Combine.postParse  sp    .."AJ<WWY,,T__=>?tGXGX
 	
  1 19NrI   )r  r  r  r  )rl   T)
r   ry   r  rz   r  rm   r  r(  rK   rL   r  )
r+   r,   r-   r.   r/   r   ro  ry  r7   rS  rT  s   @r:   rn  rn    sc    * 	! ,0!! ! 	! )! 
! !$
 
rI   rn  c                  :   ^  \ rS rSrSrSSU 4S jjjrS rSrU =r$ )r  i  a`  Converter to return the matched tokens as a list - useful for
returning tokens of :class:`ZeroOrMore` and :class:`OneOrMore` expressions.

The optional ``aslist`` argument when set to True will return the
parsed tokens as a Python list instead of a pyparsing ParseResults.

Example::

    ident = Word(alphas)
    num = Word(nums)
    term = ident | num
    func = ident + Opt(DelimitedList(term))
    print(func.parse_string("fn a, b, 100"))
    # -> ['fn', 'a', 'b', '100']

    func = ident + Group(Opt(DelimitedList(term)))
    print(func.parse_string("fn a, b, 100"))
    # -> ['fn', ['a', 'b', '100']]
c                >   > [         TU ]  U5        SU l        X l        g r  )r>  r   r  _asPythonList)r   r   aslistr   s      r:   r   Group.__init__      #rI   c                    U R                   (       aH  [        R                  " [        U[        5      (       a  UR	                  5       5      $ [        U5      5      $ U/$ rB   )r  r    Listr  r|  r   rw  s       r:   ry  Group.postParse  sV    $$i66   "  )_  {rI   )r  r  r  )r   ry   r  rm   rK   rL   	r+   r,   r-   r.   r/   r   ry  r7   rS  rT  s   @r:   r  r    s    ($ $
 rI   r  c                  :   ^  \ rS rSrSrSSU 4S jjjrS rSrU =r$ )Dicti  a  Converter to return a repetitive expression as a list, but also
as a dictionary. Each element can also be referenced using the first
token in the expression as its key. Useful for tabular report
scraping when the first column can be used as a item key.

The optional ``asdict`` argument when set to True will return the
parsed tokens as a Python dict instead of a pyparsing ParseResults.

Example::

    data_word = Word(alphas)
    label = data_word + FollowedBy(':')

    text = "shape: SQUARE posn: upper left color: light blue texture: burlap"
    attr_expr = (label + Suppress(':') + OneOrMore(data_word, stop_on=label).set_parse_action(' '.join))

    # print attributes as plain groups
    print(attr_expr[1, ...].parse_string(text).dump())

    # instead of OneOrMore(expr), parse using Dict(Group(expr)[1, ...]) - Dict will auto-assign names
    result = Dict(Group(attr_expr)[1, ...]).parse_string(text)
    print(result.dump())

    # access named fields as dict entries, or output as dict
    print(result['shape'])
    print(result.as_dict())

prints::

    ['shape', 'SQUARE', 'posn', 'upper left', 'color', 'light blue', 'texture', 'burlap']
    [['shape', 'SQUARE'], ['posn', 'upper left'], ['color', 'light blue'], ['texture', 'burlap']]
    - color: 'light blue'
    - posn: 'upper left'
    - shape: 'SQUARE'
    - texture: 'burlap'
    SQUARE
    {'color': 'light blue', 'posn': 'upper left', 'texture': 'burlap', 'shape': 'SQUARE'}

See more examples at :class:`ParseResults` of accessing fields by results name.
c                >   > [         TU ]  U5        SU l        X l        g r  )r>  r   r  _asPythonDict)r   r   asdictr   s      r:   r   Dict.__init__G  r  rI   c                ,   [        U5       GH  u  pE[        U5      S:X  a  M  US   n[        U[        5      (       a  [	        U5      R                  5       n[        U5      S:X  a  [        SU5      X6'   Mi  [        U5      S:X  a+  [        US   [        5      (       d  [        US   U5      X6'   M   UR                  5       nUS	 [        U5      S:w  d*  [        U[        5      (       a$  UR                  5       (       a  [        Xt5      X6'   M  [        US   U5      X6'   GM     U R                  (       a2  U R                  (       a  UR                  5       /$ UR                  5       $ U R                  (       a  U/$ U$ ! [         a    [        S5      nUS ef = f)Nr   r   rl   rZ   zdcould not extract dict values from parsed results - Dict expression must contain Grouped expressions)r  rl  r  r  rz   r  r!   r    r-  r~  r   r  r  r  as_dict)	r   r   r   rx  rj   tokikey	dictvaluer   s	            r:   ry  Dict.postParseL  s_   	*FA3x1}q6D$$$4y(3x1}"9"a"@	SQz#a&,'G'G"9#a&!"D	( #
I aLy>Q&y,77I<M<M<O<O&=i&KIO&=ilA&NIO? +B ,0,<,<I%%'(U)BSBSBUU"..	{=I=' ! (#NC 4'(s   0E::F)r  r  r  )r   ry   r  rm   rK   rL   r  rT  s   @r:   r  r    s    'R$ $
%> %>rI   r  c                  d   ^  \ rS rSrSrS	S
U 4S jjjrSU 4S jjrSU 4S jjrS rSS jr	Sr
U =r$ )r[  it  ah  Converter for ignoring the results of a parsed expression.

Example::

    source = "a, b, c,d"
    wd = Word(alphas)
    wd_list1 = wd + (',' + wd)[...]
    print(wd_list1.parse_string(source))

    # often, delimiters that are useful during parsing are just in the
    # way afterward - use Suppress to keep them out of the parsed output
    wd_list2 = wd + (Suppress(',') + wd)[...]
    print(wd_list2.parse_string(source))

    # Skipped text (using '...') can be suppressed as well
    source = "lead in START relevant text END trailing text"
    start_marker = Keyword("START")
    end_marker = Keyword("END")
    find_body = Suppress(...) + start_marker + ... + end_marker
    print(find_body.parse_string(source)

prints::

    ['a', ',', 'b', ',', 'c', ',', 'd']
    ['a', 'b', 'c', 'd']
    ['START', 'relevant text ', 'END']

(See also :class:`DelimitedList`.)
c                T   > USL a  [        [        5       5      n[        TU ]  U5        g )N.)r  rJ  r>  r   r  s      r:   r   Suppress.__init__  s#    3;	*DrI   c                   > [        U R                  [        5      (       a  [        [	        U5      5      U-   $ [
        TU ]  U5      $ rB   )r  r   r  r[  r  r>  r
  r  s     r:   r
  Suppress.__add__  7    dii..F5M*U22wu%%rI   c                   > [        U R                  [        5      (       a  [        [	        U5      5      U-
  $ [
        TU ]  U5      $ rB   )r  r   r  r[  r  r>  r  r  s     r:   r  Suppress.__sub__  r  rI   c                    / $ rB   r*   rw  s       r:   ry  Suppress.postParse  r  rI   c                    U $ rB   r*   r  s    r:   r\  Suppress.suppress  s    rI   r*   r  r  r  )r+   r,   r-   r.   r/   r   r
  r  ry  r\  r7   rS  rT  s   @r:   r[  r[  t  s+    < 
&& rI   r[  c                L   ^  [        T 5      m U 4S jnT R                  Ul        U$ )a3  Decorator for debugging parse actions.

When the parse action is called, this decorator will print
``">> entering method-name(line:<current_source_line>, <parse_location>, <matched_tokens>)"``.
When the parse action completes, the decorator will print
``"<<"`` followed by the returned value, or any exception that the parse action raised.

Example::

    wd = Word(alphas)

    @trace_parse_action
    def remove_duplicate_chars(tokens):
        return ''.join(sorted(set(''.join(tokens))))

    wds = wd[1, ...].set_parse_action(remove_duplicate_chars)
    print(wds.parse_string("slkdjs sld sldd sdlf sdljf"))

prints::

    >>entering remove_duplicate_chars(line: 'slkdjs sld sldd sdlf sdljf', 0, (['slkdjs', 'sld', 'sldd', 'sdlf', 'sdljf'], {}))
    <<leaving remove_duplicate_chars (ret: 'dfjkls')
    ['dfjkls']
c                   > TR                   nU SS  u  p#n[        U 5      S:  a  [        U S   5      R                    SU 3n[        R                  R                  SU S[        X25      < SU SU< S3	5         T" U 6 n[        R                  R                  S	U SU< S35        U$ ! [         aB  n[        R                  R                  S	U S
[        U5      R                    SU S35        e S nAff = f)Nr[   r   .z>>entering z(line: r  z)
z
<<leaving z (exception: r  z (ret: )r+   rl  r   r  stderrr  r   r~  )paArgsthisFuncr   r   r   r   r   r  s          r:   ztrace_parse_action.<locals>.z  s    ::+av;?vay/2231XJ?H

;xjQ
~Rs"QEQTUV	V*C 	

:hZwsgSAB
  	JJXJmDI4F4F3Gr#cR 		s   :B( (
C42=C//C4)r   r+   )r  r  s   ` r:   trace_parse_actionr    s%    2 	AA  AJHrI   empty
line_startline_endstring_start
string_endz\\[\\[\]\/\-\*\.\$\+\^\?()~ ]c                    US   S   $ r  r*   r/  s      r:   r   r     s    AaDGrI   z\\0?[xX][0-9a-fA-F]+c                P    [        [        US   R                  S5      S5      5      $ )Nr   z\0xr  )rY  r  r  r/  s      r:   r   r     s    CAaDKK/45rI   z	\\0[0-7]+c                8    [        [        US   SS  S5      5      $ )Nr   r   rU  )rY  r  r/  s      r:   r   r     s    CAaDHa()rI   z\])r  r  r  r   negatebodyrH  c           	         S n SR                  [        R                  U 5      R                   VVs/ s H  o!" U5        H  o3PM     M     snn5      $ s  snnf ! [         a
  n SnAgSnAff = f)a  Helper to easily define string ranges for use in :class:`Word`
construction. Borrows syntax from regexp ``'[]'`` string range
definitions::

    srange("[0-9]")   -> "0123456789"
    srange("[a-z]")   -> "abcdefghijklmnopqrstuvwxyz"
    srange("[a-z$_]") -> "abcdefghijklmnopqrstuvwxyz$_"

The input string must be enclosed in []'s, and the returned string
is the expanded character set joined into a single string. The
values enclosed in the []'s may be:

- a single character
- an escaped character with a leading backslash (such as ``\-``
  or ``\]``)
- an escaped hex character with a leading ``'\x'``
  (``\x21``, which is a ``'!'`` character) (``\0x##``
  is also supported for backwards compatibility)
- an escaped octal character with a leading ``'\0'``
  (``\041``, which is a ``'!'`` character)
- a range of any of the above, separated by a dash (``'a-z'``,
  etc.)
- any combination of the above (``'aeiouy'``,
  ``'a-zA-Z0-9_$'``, etc.)
c              3     #    [        U [        5      (       a7  S [        [        U S   5      [        U S   5      S-   5       5        S h  vN   g U v   g  N
7f)Nc              3  8   #    U  H  n[        U5      v   M     g 7frB   )rY  r  s     r:   r   ,srange.<locals>._expanded.<locals>.<genexpr>  s     H(G1A(GrM  r   r   )r  r    rH  ord)ps    r:   	_expandedsrange.<locals>._expanded  sF     a&&Hc!A$iQqTQ(GHHHG Is   AA	A
Arl   N)r  _reBracketExprr  r  r~  )r   r  partrw  rc  s        r:   sranger#    se    6ww)66q9>>X>4	RV1QQ>X
 	
X s"   -A A
A A 
A.)A.c                f   ^ ^ UU 4S jn[        T S[        T S5      R                  5      nX2l        U$ )a  Helper to define a parse action by mapping a function to all
elements of a :class:`ParseResults` list. If any additional args are passed,
they are forwarded to the given function as additional arguments
after the token, as in
``hex_integer = Word(hexnums).set_parse_action(token_map(int, 16))``,
which will convert the parsed data to an integer using base 16.

Example (compare the last to example in :class:`ParserElement.transform_string`::

    hex_ints = Word(hexnums)[1, ...].set_parse_action(token_map(int, 16))
    hex_ints.run_tests('''
        00 11 22 aa FF 0a 0d 1a
        ''')

    upperword = Word(alphas).set_parse_action(token_map(str.upper))
    upperword[1, ...].run_tests('''
        my kingdom for a horse
        ''')

    wd = Word(alphas).set_parse_action(token_map(str.title))
    wd[1, ...].set_parse_action(' '.join).run_tests('''
        now is the winter of our discontent made glorious summer by this sun of york
        ''')

prints::

    00 11 22 aa FF 0a 0d 1a
    [0, 17, 34, 170, 255, 10, 13, 26]

    my kingdom for a horse
    ['MY', 'KINGDOM', 'FOR', 'A', 'HORSE']

    now is the winter of our discontent made glorious summer by this sun of york
    ['Now Is The Winter Of Our Discontent Made Glorious Summer By This Sun Of York']
c                B   > U Vs/ s H  nT" U/TQ76 PM     sn$ s  snf rB   r*   )r   r   r   toknr   r   s       r:   r   token_map.<locals>.paD  s%    ./0adT!D!a000s   r+   r   )r   r+   )r   r   r   r   s   ``  r:   	token_mapr(    s0    J1 j'$*D*M*MNIKIrI   c                 F   [        [        SS 5      n U " S5      nUc  g[        R                  " [        R
                  U5      nUR                  R                  5        H@  u  p#[        U[        5      (       d  M  UR                  (       a  M/  UR                  U5        MB     g)zm
Utility to simplify mass-naming of parser elements, for
generating railroad diagram with named subdiagrams.
	_getframec                    g rB   r*   )r)   s    r:   r   #autoname_elements.<locals>.<lambda>T  s    drI   r   N)r   r  rN  r   types	FrameTypef_localsr  r  ry   r   r  )getframe_fncalling_framerF   vars       r:   autoname_elementsr3  M  sv     #{N;KNM KK?M"++113	c=))#...LL 4rI   z4"(?:[^"\n\r\\]|(?:"")|(?:\\(?:[^x]|x[0-9a-fA-F]+)))*"z string enclosed in double quotesz4'(?:[^'\n\r\\]|(?:'')|(?:\\(?:[^x]|x[0-9a-fA-F]+)))*'z string enclosed in single quoteszdouble quoted stringzsingle quoted stringz+quoted string using single or double quotesz""""(?:[^"\\]|""(?!")|"(?!"")|\\.)*r;  z"""zmultiline double quoted stringz"'''(?:[^'\\]|''(?!')|'(?!'')|\\.)*z'''zmultiline single quoted stringz5"(?:[^"\n\r\\]|(?:\\")|(?:\\(?:[^x]|x[0-9a-fA-F]+)))*z5'(?:[^'\n\r\\]|(?:\\')|(?:\\(?:[^x]|x[0-9a-fA-F]+)))*zPython quoted stringrV  zunicode string literalz#[\0xc0-\0xd6\0xd8-\0xf6\0xf8-\0xff]z[\0xa1-\0xbf\0xd7\0xf7]r/  r   nullDebugActiontraceParseActionconditionAsParseActiontokenMap)rb   rX   rK   rL   rJ   )ro   ztyping.Iterable[str]rp   r(  rK   rm   )r[   r  )r   r!  r   r(  r   rm   rK   r   r  )r   rz   r   r  r   ry   r   rm   )r   rz   r   r  r   r  r   ry   r   r    r   rm   )
r   rz   r   r  r   ry   r   r~  r   rm   )r  r   rK   r   r_  )rK   r   )
__future__r   collections.abccollectionsr   osrN  r   r   r   r   r	   r
   r   r   abcr   r   enumr   stringr-  r  r  r  r   r   r-  operatorr   	functoolsr   	threadingr   pathlibr   utilr   r   r   r   r   r   r   r  r   r  r   
exceptionsactionsr  r    r!   unicoder"   maxsizer9  rz   bytesr#   r   r$   r&   r<   rX   rc   rf   rG   rw   warnoptionsenvironrQ  sumrl  r  r  r   r  r   r  rP  r  r  r   GeneratorTyper  r  r%  PostParseReturnTyperm   r!  r~  r"  r*  r+  r,  ascii_uppercaseascii_lowercaser{   Latin1r|   r}   r   r   r   r  	printable
whitespacer   r   r   r   r   r   r   r   r   r   ry   r  rV  rJ  r  r  ri  r   r  r  r  r  r  r  r  r*  rc  rr  r  r  r  r  r  r  r  r  r  r  r  r6  r/  r=  r  r  r  r  r#  r+  r:  rD  rO  r$  r#  rg  ru  r  r  r  r  r  rn  r  r  r[  r  r  r  r  r  r  r  rU  _escapedPunc_escapedHexChar_escapedOctChar_singleChar
_charRanger4  r!  r#  r(  r3  dbl_quoted_stringsgl_quoted_stringr  rI  python_quoted_stringunicode_string
alphas8bitpunc8bitr  valuesr  r   sglQuotedStringdblQuotedStringquotedStringunicodeString	lineStartlineEndstringStart	stringEndr6  r7  r8  r9  )rw  r  s   00r:   <module>ri     s=
   #   	 	 	 	 $     	 
 $      
 
 
   : &;;!5\
 )2 & .~ ,*$ *D$%# /?S	" OORZZ^^$@A   fheS#sC 
 $$CHo L(<*@@A RXl^T!"c< $&'c3%t+,. CoyA4GHS#=tCD #sO\48$>   c?It Ld RS  $$v'='== =#**55
C 5'..== =c n$ $$	3 ''f&6&6U&66CTCT:T1&6UV
C V	&Y 	& 15 - 4 =B MR!5EI: EJ


#0
=A
& 	@	@	@ 	@ 		@
 	@ 	@" UU	U U 
	U
 URqC qj=&
= &
R	#M 	#?e ?2?e 2?jG "? ? %, !re rj?g ?6Bg B2T? T?nx#5 x#v
4 
,C)E C)Li5 iXM( M(`L(E L(^#E # D.? .?bCm C.- "? ?( 8m :(K% (KViOm iOZe/ eP[? [?|k? k?\m?? m?`jO- jO\=
' =
@<' <*<% <B!$ !HN$ Nb'#! '#T(#  (#VJ?( J?Z% %@# #D>F' >FB I
 IX U  UpIO! IOZ (  6n 6r"N "JT>> T>n4~ 4n,` 	![!!,/
9j)}%%n5[!!,/
56GG /0AA5 %66) ?"_4z%q7QQ  ;#.<=
CL	#h)*Ij;./0AA&IJ cl &R+\( 	
ABSH
(-.  	
ABSH
(-.  
BCcISS DEKUU (89  
0EMWW( 	32<<H5Ph/01 EFLVV EFLVV (!"  }11334==>VW :;
,-
 v}}'!*Q">A'#  $#	
	"#46GH#$68JK )*BD]^ J	2Y} Vv|'s   7``=``