2bil %SSKJr SSKrSSKrSSKJrJrJrJrJrJ r J r J r J r J r Jr SSKJrJr SSKJr SSKrSSKrSSKrSSKrSSKrSSKJr SSKrSSKrSSKJr SSKJ r SS K!J"r" SS K#J$r$ S S K%J&r&J'r'J(r(J)r)J*r*J+r+J,r,J-r.J/r0J1r1 S S K27 S S K37 S SK4J5r5J6r6 S SK7J8r8 \Rrr:\;\<4r=\ \>S4\?S'\RS:aSSKJArA O "SS5rA"SS\(5rB"SS\(5rC"SS\5rDS\DSS4SjrES\DSS4SjrFSS jrGC(S!\R4\;S"\R\;S\I4S#jrJ\J"\R\RRS$55(a\G"5 \N\O\P\Q\R\S\T\U\V\W\X1 rY\Rr[\ \\\4r]\ \5\ \54r^\ \/\4\\5/\4\\\\5/\4\\;\\\5/\44r_\ \/\I4\\5/\I4\\\\5/\I4\\;\\\5/\I44r`\\;\\S%\a/S4rb\\;\\S%\I/S4rc\\;\\\\S%\5\I/S4rd\\;\\S%\a\I/S4re\R\R-rh\8RRrj\8RRrkS&rl\lS'-rm\h\l-rnS(R\RVs/sHo\R;dMUPM sn5rrSqs\R\?S)'SS*jruSS+\`S,\R\;S-\IS\_4S.jjrvSS/\;S0\\S1S%S2\I4S3jjrwSS/\;S4\\S5\\S1S%S6\5S2\I4 S7jjrxSS/\;S0\\S1S%S8\aS2\I4 S9jjryS:rz"S;S%\5r{"S<S=\{5r|"S>S?\{5r}"S@SA\}5r~"SBSC\}5r"SDSE\5r"SFSG\5r\\{l"SHSI\}5r"SJSK\5r"SLSM\5r"SNSO\}5r"SPSQ\}5r"SRSS\5r"STSU\}5r"SVSW\}5r"SXSY\}5r"SZS[\}5r"S\S]\}5r"S^S_\5r"S`Sa\5r"SbSc\5r"SdSe\5r"SfSg\5r"ShSi\5r"SjSk\5r"SlSm\{5r"SnSo\5r"SpSq\5r"SrSs\5r"StSu\5r"SvSw\{5r"SxSy\5r"SzS{\5r"S|S}\5r"S~S\5r"SS\5r"SS\5r"SS\5r"SS\5r"SS\5r"SS\5r"SS\5r"SS5r"SS\5r\rH"SS\5r"SS\5r"SS\5r"SS\5r"SS\5r"SS\5r"SS\5rS\_S\_4Sjr\"5GRaS5r\"5GRaS5r\"5GRaS5r\"5GRaS5r\"5GRaS5r\"S5GRmS5r\"S5GRmS5r\"S5GRmS5r\\-\-\"SS S9-r\"\\"S5-\-5r\"S5\"S5GRyS5-\"\"\\-55GRyS5-\"S5-rS\;S\;4SjrS\_4SjrSSjr\"\"S5S-5GRaS5r\"\"S5S-5GRaS5r\"\"S5S-GRaS5\"S5S-GRaS5-5GRaS5r\"\"S\GRS9S-GRaS5\"S\GRS9S-GRaS5- \"S5S-GRaS5- \"S5S-GRaS5- 5GRaS5r\"S\R+5-5GRaS5r\"S5r\"S5r\"5GR5Vs/sHn\"U\{5(dMUPM snr\\{\?S'\r\r\r\r\r\r\r\r\1"\z5S5r\1"\5S5r\1"\v5S5r\1"\5S5rgs snfs snf))dequeN) AnyCallable GeneratorList NamedTupleSequenceSetTextIOTupleUnioncast)ABCabstractmethod)Enum)Iterable) itemgetter)wraps)RLock)Path) _FifoCache_UnboundedCache__config_flags_collapse_string_to_ranges_escape_regex_range_chars_bslash_flattenLRUMemo UnboundedMemoreplaced_by_pep8)*) ParseResults_ParseResultsWithOffset)pyparsing_unicode.str_type))cached_propertyc$\rSrSrSrSSjrSrg)r)TcXlgN_func)selffuncs ڌ/builddir/build/BUILDROOT/alt-python313-pip-23.3.1-3.el8.x86_64/opt/alt/python313/lib/python3.13/site-packages/pip/_vendor/pyparsing/core.py__init__cached_property.__init__UsJNclURU5=o1RURR'U$r-)r/__dict____name__)r0instanceownerrets r2__get__cached_property.__get__Xs-;?::h;O OC##DJJ$7$78Jr5r.r-)r8 __module__ __qualname____firstlineno__r3r<__static_attributes__r5r2r)r)Ts   r5r)c\rSrSrSrSrSr\"5VVs/sHoRS5(aMUPM snnr SR5r Sr gs snnf) __compat__]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 rBN) r8r>r?r@__doc__ _type_desccollect_all_And_tokenslocals startswith _all_namessplit _fixed_namesrA).0__s00r2rDrD]sJ !J!%xBx}}S/A"xBJ EGCs AArDc\rSrSrSrSrSrSrSrSr Sr Sr Sr \ "5VVs/sHoRS5(aMUPM snnr\VVs/sHo"RS5(dMUPM snnr\VVs/sHo"RS5(dMUPM snnr\S Sj5rS rgs snnfs snnfs snnf) __diag__t diagnosticFrGwarn enable_debugNcLURHnURU5 M gr-)_warning_namesenable)clsnames r2enable_all_warnings__diag__.enable_all_warningss&&D JJt 'r5rBreturnN)r8r>r?r@rI)warn_multiple_tokens_in_named_alternation)warn_ungrouped_named_tokens_in_collectionwarn_name_set_on_empty_Forward!warn_on_parse_using_empty_Forwardwarn_on_assignment_to_Forward%warn_on_multiple_string_args_to_oneof(warn_on_match_first_with_lshift_operator!enable_debug_on_named_expressionsrKrLrMrY _debug_names classmethodr]rA)rPrQr\s000r2rSrStsJ05-05-%*"(-%$)!,1)/4,(-%%xBx}}S/A"xBJ'1Mzt__V5LdzMN%/SZT??>3RDZSL CMSs#B/B/B5,B5;B;B;rSc8\rSrSrSrSrSrSrSrSr Sr S r S r S r g ) Diagnosticsa_ 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`. rrr'rBN)r8r>r?r@rHrarbrcrdrerfrgrhrArBr5r2rlrls9.12-01-%&"()%$%!,-)/0,()%r5rl diag_enumr`cB[RUR5 g)zG Enable a global pyparsing diagnostic flag (see :class:`Diagnostics`). N)rSrZr\rss r2 enable_diagrvs OOINN#r5cB[RUR5 g)zH Disable a global pyparsing diagnostic flag (see :class:`Diagnostics`). N)rSdisabler\rus r2 disable_diagrys Y^^$r5c,[R5 g)zM Enable all global pyparsing diagnostic warnings (see :class:`Diagnostics`). N)rSr]rBr5r2r]r]s   "r5cmd_line_warn_options warn_env_varcJ[U5nUHnUS-RS5SSupEpgnUR5RS5(dU(dU(dU(aUS:XaSnMaUR5RS5(dMUS;dMSnM U$) Nz:::::rpi pyparsingT)rF)boolrNlowerrL) r{r|rZwarn_optw_action w_message w_categoryw_modulew_lines r2_should_enable_warningsrs, F)=E=NO2OF* Mr5PYPARSINGENABLEALLWARNINGS ParserElement 0123456789 ABCDEFabcdefr_trim_arity_call_linec2^^^^^T[;aU4Sj$SmSmSn[=(d [R"SS9Sq[S[SU-4mUUUUU4S jn[ TS [ TS 5R 5nXClTR UlU$) zAdecorator to trim function calls to match the arity of the targetc>T"U5$r-rB)sltr1s r2_trim_arity..s tAwr5rFrrrnlimitrc>T"UT S6nSmU$![a\nT(aeURn[R"USS9nUSnUSS/SSST :HnAU(aT T :a T S- m SnAMneSnAff=f)NrTrnrr) TypeError __traceback__ traceback extract_tb) argsr;tetbframes frame_summarytrim_arity_type_error found_arityr1r max_limitpa_call_line_synths r2wrapper_trim_arity..wrapper!s DL)"   ))B&11"A>F$*2JM&r*+B/37II*, 9,!QJE$% s  A6AA10A11A6r8 __class__)_single_arg_builtinsrr extract_stackgetattrr8rH)r1r LINE_DIFFr func_namerrrs`` @@@r2 _trim_arityr s ##&& EK I3Zi6M6MTU6VWY6Z/24I!4Ly4XY<j'$ *D*M*MNI llGO Nr5fnmessagefatalc^^^UbUOSmU(a[O[m[T5m[T5UUU4Sj5nU$)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` zfailed user-defined conditioncF>[T"XU55(d T"XT5egr-)r)rrrexc_typermsgs r2pa%condition_as_parse_action..paZs&BqQK  1% %!r5)ParseFatalExceptionParseExceptionrr)rrrrrrs` @@r2condition_as_parse_actionrFsB ('.MC&+"H RB 2Y&& Ir5instringlocexpr cache_hitcU(aSOSn[USUSUS[X5S[X5S[X5SS [X5S - -S 35 g) Nr"rMatch z at loc (,z) z  r^)printlinenocolline)rrrr cache_hit_strs r2_default_start_debug_actionrbsr%C"M oVD6#as8M7NaPSTWPbOcdc$%&C*Q./0 3r5startlocendloctoksc\U(aSOSn[USUSUR535 g)Nr"rzMatched z -> )ras_list)rrrrrrrs r2_default_success_debug_actionros-%C"M ]O8D6dlln-= >?r5excc lU(aSOSn[USUS[U5RSU35 g)Nr"rrz failed, z raised: )rtyper8)rrrrrrs r2_default_exception_debug_actionr{s7%C"M ]O6$yc1C1C0DIcU STr5cg)zG'Do-nothing' debug action, to suppress debugging output during parsing.NrB)rs r2null_debug_actionrr5c' \rSrSr%SrSr\\S'Sr\ \S'Sr \ \S'\ S \S S4S j5r \ S \ S S4S j5r\S5r"SS\5rSS\ 4SjjrS\S S4SjrSrSSjrSSS.S\S\ S\ S S4SjjjrSSjrSS\ S S4SjjrS \S S4S!jrS \S S4S"jrS \S S4S#jrS$\ S S4S%jr!S&\S'\"S \"4S(jr#S&\S'\"S \"4S)jr$SS*jr%S+r&SS \'\"\(44S,jjr)SSS-.S&\S'\"S.\ S/\ S \"4 S0jjr*SS&\S'\"S/\ S \ 4S1jjr+\,"5r-0r.\/R`\'\"S2\ 4\'\"\1\(\2444\S3'"S4S5\35r4\4"5r5\,"5r6S6S6/r7SS \'\"\(44S7jjr8\)r9\ SS8j5r:Sr;Sr<\ SS9j5r=\ SSS:.S;\/R|\"S S4S<jjj5r?\ SSS:.S;\"S=\ S S4S>jjj5r@SSS?.S&\S@\ SA\ S \(4SBjjjrA\BS4S\BSC.S&\SD\"SE\ SF\ SG\"S \C\'\(\"\"4SS44 SHjjjrDSSI.S&\SF\ S \4SJjjrE\B4S\BSC.S&\SD\"SF\ SG\"S \(4 SKjjjrF\BS4SSL.S&\SM\"SN\ S \C\SS44SOjjjrGSSPjrHSSQjrISSRjrJSSSjrKSSTjrLSSUjrMSSVjrNSSWjrOSSXjrPSSYjrQSSZjrRSS[jrSSS\jrTSrUS]rVSS\/R|\S S4S^jjrWSS_jrXSS`\ S S4SajjrYSS`\ S S4SbjjrZSS \1\[\\4Sc\ S S4Sdjjr\SSejr]SSfjr^Sg\_Sh\`Si\aS S4SjjrbSSk\ Sl\ S S4Smjjrc\dS \4Snj5re\fS \4Soj5rgS\S S4Spjrh\dS \4Sqj5riS \4SrjrjS \4SsjrkSStjrlS \mS4SujrnSvroSSSwjjrpSSS?.Sx\1\\q\r4Sy\S@\ SA\ S \(4 SzjjjrsS{rtS|ruSSS?.S}\S@\ SA\ S \ 4S~jjjrvSSSSSSS.S\1\\m\4S@\ S\/R|\1S\4S\ S\ S\ S\/R|\w\\(/\4S\/R|\rS\ SA\ S\ S\ S\ S\/R|\w\\(/\4S \'\ \m\'\\1\(\24444SjjjrxSS\1\r\q\4S\"S\ S\ S\ S S4 Sjjry\ \z"\5S55r{\ \z"\ 5S55r|\z"\5S5r}\z"\5S5r~\z"\5S5r\z"\5S5r\z"\5S5r\z"\!5S5r\z"\*5S5r\ \z"\?5S55r\ \z"\@5S55r\z"\A5S5r\z"\D5S5r\z"\E5S5r\z"\F5S5r\z"\Y5S5r\z"\Z5S5r\z"\\5S5r\z"\]5S5r\z"\b5S5r\z"\c5S5r\z"\h5S5r\z"\s5S5r\z"\x5S5r\+r\:r\erSrg)riz)Abstract base level parser element class.z DEFAULT_WHITE_CHARSFverbose_stacktraceN_literalStringClasscharsr`czU[l[H&nUR(dM[ U5UlM( g)a Overrides the default whitespace chars Example:: # default whitespace chars are space, 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)rr_builtin_exprscopyDefaultWhiteCharsset whiteChars)rrs r2set_default_whitespace_chars*ParserElement.set_default_whitespace_charss/-2 )#D)))"%e*#r5r[cU[lg)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)rr)r[s r2inline_literals_using#ParserElement.inline_literals_usings (-0 )r5c+>^^# UU4SjU5ShvN gN7f)z Yields a sequence of class(obj, **class_kwargs) for obj in seq. Example:: LPAR, RPAR, LBRACE, RBRACE, SEMI = Suppress.using_each("(){};") c36># UHnT"U40TD6v M g7fr-rB)rPobj class_kwargsr[s r2 +ParserElement.using_each..s<C,|,sNrB)r[seqrs` `r2 using_eachParserElement.using_eachs=<<r?r@typingOptionalDebugStartAction__annotations__DebugSuccessActionDebugExceptionActionrArBr5r2 DebugActionsParserElement.DebugActionss2??#344__%788OO$899r5rsavelistc[5UlSUlSUlSUlSUlXlSUl[[R5Ul SUl SUl SUl[5UlSUlSUlSUlSUlSUlUR+SSS5UlSUlSUl/Ulg)NTFr)list parseAction failAction customName _defaultName resultsName saveAsListskipWhitespacerrrrrmayReturnEmptykeepTabs ignoreExprsdebug streamlined mayIndexErrorerrmsg modalResultsr debugActions callPreparse callDuringTrysuppress_warnings_)r0rs r2r3ParserElement.__init__s.2f<@#26 $""m??@%)"# 26&  !   --dD$? "57r5 warning_typec<URRU5 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")) )rappend)r0rs r2suppress_warningParserElement.suppress_warnings &&|4 r5c## [U/5n[5nU(aUUR5nX2;aMURU5 UR UR 55 Uv U(aMTgg7f)zsGeneral-purpose method to yield all expressions and sub-expressions in a grammar. Typically just for internal use. N)rrpopleftaddextendrecurse)r0to_visitseencurs r2 visit_allParserElement.visit_alls]$=u""$C{ HHSM OOCKKM *Ihs A0A64A6c[R"U5nURSSUlURSSUlUR(a[ [ R 5UlU$)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)copyrr rrrrr)r0cpys r2r%ParserElement.copy sU,iio**1-**1-  % % !B!BCCN r5)listAllMatchesr\list_all_matchesr(c:U=(d UnURX5$)a3 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:: 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)r0r\r)r(s r2set_results_nameParserElement.set_results_name's <(;+;##D99r5cUcU$UR5nURS5(aUSSnSnXlU(+UlU$)Nr"rT)r%endswithrr)r0r\r(newselfs r2r+ParserElement._setResultsNameHsL <K))+ ==  9D!N"#11r5T break_flagc^U(a#URmSU4SjjnTUlX lU$[URS5(aURRUlU$)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>>SSKnUR5 T"XX#5$Nr)pdb set_trace)rr doActions callPreParser6 _parseMethods r2breaker(ParserElement.set_break..breaker\s #H9KKr5_originalParseMethodTT)_parser=hasattr)r0r2r;r:s @r2 set_breakParserElement.set_breakSsW ;;L L,8G (!K t{{$:;;"kk>>  r5fnsc[U5S/:Xa /UlU$[SU55(d [S5eUVs/sHn[ U5PM snUlUR SUR SS55UlU$s snf)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 ```` 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 ''') Nc38# UHn[U5v M g7fr-)callable)rPrs r2r1ParserElement.set_parse_action..s2cx||czparse actions must be callablecall_during_tryrF)rrallrrgetrr0rCkwargsrs r2set_parse_actionParserElement.set_parse_actionjsV 9 !D  2c222 @AA:=>#B B#>D !'!6::ou#E"D  ?sBcU=RUVs/sHn[U5PM sn- slUR=(d" URSURSS55UlU$s snf)z Add one or more parse actions to expression's list of parse actions. See :class:`set_parse_action`. See examples in :class:`copy`. rIrF)rrrrKrLs r2add_parse_actionParserElement.add_parse_actionsb s;s[_s;;!// 6:: vzz/5A4  = 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) rrF)rrrIr)rrrstrrKrrrLs r2 add_conditionParserElement.add_conditions.B    # #) 9 56vzz'59: "// 6:: vzz/5A4  r5rcXlU$)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)r0rs r2set_fail_actionParserElement.set_fail_actions r5rrcUR(dU$SnURVs/sHoDRPM nnU(a"SnUHnU"X5up'SnM U(aM"U$s snf![a M2f=fNTF)r r?r)r0rr exprsFoundeignore_expr_fns ignore_fndummys r2_skipIgnorablesParserElement._skipIgnorablessJ -1-=-=>-=88-=>J, %.x%= %) -j ?&sA& A++ A98A9cUR(aURX5nUR(a8[U5nURnX#:aXU;aUS- nX#:a XU;aMU$Nr)r rarlenr)r0rrinstrlen white_charss r2preParseParserElement.preParsesd   &&x5C   8}H//K.X]k%Aq.X]k%A r5c U/4$r-rBr0rrr8s r2 parseImplParserElement.parseImpl Bwr5cU$r-rBr0rr tokenlists r2 postParseParserElement.postParse sr5c <SupVnURn[U5n U(dUR(aU(a#UR(aUR X5n OUn U n UR R (aUR R XUS5 UR(dX:aURXU5up,OURXU5up,OnU(a#UR(aUR X5n OUn U n UR(dX:aURXU5up,OURXU5up,URXU 5n [XR UR"UR$S9nUR&(aU(dUR((aU(aqUR&H_nU"XU5n U cMXLdM[U UR UR"=(a [+U [[,45UR$S9nMa OoUR&H_nU"XU5n U cMXLdM[U UR UR"=(a [+U [[,45UR$S9nMa U(a9UR R.(aUR R/XX US5 X.4$![a [XURU5ef=f![acn UR R(aUR RUW X S5 UR(aURUW X 5 eSn A ff=f![a [XURU5ef=f![an[S5nUUeSnAff=f![a>n UR R(aUR RXX S5 eSn A ff=f![an[S5nUUeSnAff=f)NrrrnF)asListmodalz exception raised in parse action)r rerrrhrrr rl IndexErrorrr Exceptionrrrr#rrrrr isinstancerr)r0rrr8r9TRYMATCHFAIL debugging len_instringpre_loc tokens_starttokenserr ret_tokensrparse_action_excrs r2 _parseNoCacheParserElement._parseNoCache$s#DJJ 8}  D$5$5"mmH:G!G& $$..%%//eT%%)@X&*nnX &R V#'..I"NKC 1 1--6"L!!W%<T"&..I"NKC#nnX J v6! $$T__DDUDU    d.@.@"..<%' %KF "-&2J)5 & $ 0 0'+(M$.v d7K$L&*&7&7 *J/.**B8!#HJ!G )f.F%1" ,,#'??$I *6L$3G H"&"3"3 & +   ,,!!--Cz5a&X,XT[[RVWWX $$//%%00 ,5??OOHlDF $"T(dSST *<"01S"TC"%+;;<!((33))44$Du &8,-OP!'778sA3KK>"M.7N3 NN3N3A N37 O>"K;;K>> M+AM&&M+."N N0N++N00N33 O;=9O66O;> PPP) raise_fatal do_actionsrrcURXUS9S$![a U(ae[XURU5ef=f)Nr8r)r?rrr)r0rrrrs r2 try_parseParserElement.try_parsesJ C;;x ;CAF F" C  TB B Cs*?cRURXUS9 g![[4a gf=f)NrTF)rrrx)r0rrrs r2can_parse_nextParserElement.can_parse_nexts5  NN8ZN @ +  s &&Forwardrecursion_memosc0\rSrSr%Sr\\S'SrSrSr g)zParserElement._CacheTypeiz class to help type checking not_in_cachecgr-rBr0rs r2rKParserElement._CacheType.get r5cgr-rBrs r2rParserElement._CacheType.setrr5rBN) r8r>r?r@rHrrrKrrArBr5r2 _CacheTypeParserElement._CacheTypes   r5rrc  SupVSupxn XX$U4n [R [Rn U RU 5n XRLaa[R U==S- ss'UR XX45n U RXSU SR5U45 U sSSS5 $[R U==S- ss'UR(a7URR(aURRXUSS9 [!U ["5(aLUR(a9URR$(aURR%XX SS9 U eU e['[([*[,[*4U 5n U SU SR5U SnpUR(a8URR.(aURR/XUXSS9 X4sSSS5 $![a.n U RXR"U R65 eSn A ff=f![a GNN,OM )%&7:J&JK K04 -r5rcFU(a[R5 O [R(a [S5e[R(dPS[lUc[ 5[lO[U5[l[R[l gg)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:: from pip._vendor 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. rTN) rrrrrrrrrr?rs r2enable_packratParserElement.enable_packrat9sl@   - - /  2 2QR R,,,0M )'.=.? +.89I.J +#0#<#>> 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) rN)rrr  streamliner r  expandtabsr?rhEmpty StringEndrrwith_traceback) r0rrrr]rrsers r2 parse_stringParserElement.parse_stringesZ(!!# OO !!A LLN"}}**,H ++h2KCmmH2Wy{* ((M" ///((..  /sAC D$'D  D)r  maxMatches max_matchesoverlapr rc## [XR5nUR(dUR5 URHnUR5 M UR(d[ U5R 5n[U5nSnURn URn [R5 Sn X::aX:azU "X5n U "XSS9upX:aOU S- n U(a[UR5U U S.5 XU 4v U(aU "X5nX:aU nOUS- nO U nOU S-nX::aX:aMxgggg![a W S-nN!f=f![a,n[R (aeUR#S5eSnAff=f7f)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 rFr9r)rstartendN)minr rr r rTrrerhr?r resetCacherrvrrrr)r0rrrr rr]rfr preparseFnparseFnmatchesprelocnextLocrnextlocrs r2 scan_stringParserElement.scan_strings~N1  OO !!A LLN"}}8}//1Hx=]] ++  "$ //g&:)",X";F'.hU&SOG}1  !.4mmo-3+2!"%g55"&0&?G&}&- #q")C$qj;/g&:/&:/ &% 1*C%0" ///((..  /sOB5F 8 ED>A$E:F >E EEE F 'FF  F r c/nSnSUlURXS9HupVnURXU5 U(au[U[5(aX5R 5- nOM[U[ 5(a'[U[5(dURU5 OURU5 UnM URXS5 UVs/sH o(dM UPM nnSR[U5Vs/sHn[U5PM sn5$s snfs snf![a,n [R(aeU RS5eSn A ff=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. rTrNr)r rrrzr#rrr&rjoinrrTrrrr) r0rr outlastErrr]ors r2transform_stringParserElement.transform_strings"(  /++H+Ba 8!,-!!\22yy{*#Ax00Ax9P9P 1  1 C JJx' (!'cQ1cC'77HSM:MqCFM:; ;(:! ///((..  /s<CD" DD"D"<DD" D"" E,'EEc [XB5n[URXUS9VVVs/sHupVouPM snnn5$s snnnf![a,n[R (aeUR S5eSnAff=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'] rN)rr#rrrrr) r0rrr rrrr]rs r2 search_stringParserElement.search_string3sz81  /"&"2"28u"2"UV"UwqQ"UV V! ///((..  /s%A= AA A:'A55A:)includeSeparatorsmaxsplitinclude_separatorsc## U=(d UnSnURXS9HupgnXUv U(aUSv UnM XSv g7f)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)rN)r) r0rrrrlastrrr]s r2rNParserElement.split[s]..C1C'''GGA!" " d D H uosAAcU[La [U5$[U[5(aUR U5n[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 _PendingSkiprzr&rrNotImplementedAndr0others r2__add__ParserElement.__add__{sT6 H % % eX & &,,U3E%//! !D=!!r5cU[La[U5"S5U-$[U[5(aUR U5n[U[ 5(d[ $X-$)zT Implementation of ``+`` operator when left operand is not a :class:`ParserElement` _skipped*)rSkipTorzr&rrrrs r2__radd__ParserElement.__radd__sX H $< ,t3 3 eX & &,,U3E%//! !|r5c[U[5(aURU5n[U[5(d[$U[ R 5-U-$)zH Implementation of ``-`` operator, returns :class:`And` with error stop )rzr&rrrr _ErrorStoprs r2__sub__ParserElement.__sub__sK eX & &,,U3E%//! !cnn&&..r5c[U[5(aURU5n[U[5(d[$X- $)zT Implementation of ``-`` operator when left operand is not a :class:`ParserElement` rzr&rrrrs r2__rsub__ParserElement.__rsub__< eX & &,,U3E%//! !|r5c^^U[LaSnO1[U[5(aUSS[4:XaSUSS-S-SSn[U[5(aUSp2O[U[5(a[SU55nUS -SSnUScSUS4n[US[5(aBUSc<USS:Xa [ T5$USS:Xa [ T5$TUS-[ T5-$[US[5(a![US[5(a Uup#X2-nO [ $[ $US:a [S 5eUS:a [S 5eX#s=:XaS:XaO O [/5$U(aGUU4S jmU(a.US:Xa TT"U5-nU$[T/U-5T"U5-nU$T"U5nU$US:XaTnU$[T/U-5nU$) 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`` )rNNr)rr-rnrc3:# UHo[LaUOSv M g7fr-)r)rPrs r2r(ParserElement.__mul__..sJEq0!d:Es)NNz/cannot multiply ParserElement by negative valuez@second tuple value must be greater or equal to first tuple valuecT>US:a[TT"US- 5-5$[T5$rd)Opt)nmakeOptionalListr0s r2r/ParserElement.__mul__..makeOptionalLists.q5t&6q1u&==>>t9$r5) rrztupler ZeroOrMore OneOrMorer ValueErrorr)r0r minElements optElementsr;rs` @r2__mul__ParserElement.__mul__s* H E u % %%){*BE!"I%/!4E eS ! !',a u % %JEJJE\)2A.EQxE!H %(C((U1X-=8q=%d++8q=$T?*%(?Z-===E!Hc**z%(C/H/H+0( * %%! ! ?NO O ?R   * *r7N  % !#!1+!>>C tf{236F{6SSC '{3  a 4&;./ r5c$URU5$r-)rrs r2__rmul__ParserElement.__rmul__s||E""r5cU[La [USS9$[U[5(a"US:Xa [ U5$UR U5n[U[ 5(d[$[X/5$)z@ Implementation of ``|`` operator - returns :class:`MatchFirst` T) must_skipr) rrrzr&rrrr MatchFirstrs r2__or__ParserElement.__or__sg H 5 5 eX & &{4y ,,U3E%//! !4-((r5c[U[5(aURU5n[U[5(d[$X-$)zT Implementation of ``|`` operator when left operand is not a :class:`ParserElement` rrs r2__ror__ParserElement.__ror__"r r5c[U[5(aURU5n[U[5(d[$[ X/5$)z8 Implementation of ``^`` operator - returns :class:`Or` )rzr&rrrOrrs r2__xor__ParserElement.__xor__,sA eX & &,,U3E%//! !4-  r5c[U[5(aURU5n[U[5(d[$X- $)zT Implementation of ``^`` operator when left operand is not a :class:`ParserElement` rrs r2__rxor__ParserElement.__rxor__6r r5c[U[5(aURU5n[U[5(d[$[ X/5$)z: Implementation of ``&`` operator - returns :class:`Each` )rzr&rrrEachrs r2__and__ParserElement.__and__@sA eX & &,,U3E%//! !TM""r5c[U[5(aURU5n[U[5(d[$X-$)zT Implementation of ``&`` operator when left operand is not a :class:`ParserElement` rrs r2__rand__ParserElement.__rand__Jr r5c[U5$)z< Implementation of ``~`` operator - returns :class:`NotAny` )NotAnyr0s r2 __invert__ParserElement.__invert__Tsd|r5cSn[5n[U[5(aURURp1UcSnSnOQ[U[ 5(a<[US[5(a$USUSR4USRp1Sn[U[ 5(aU4n[U5 [U5S:a2[S USS [U5S :aS [U5S 3OS S35eU[ USS5-n[R"[U5nU(aURU5 U$![a X4nNf=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.Trrrrnz'only 1 or 2 index arguments supported (rpz... []r))NoMatchrzslicerstoprr&iterrrerr_MultipleMatchstopOn)r0keystop_on_definedstop_onr;s r2 __getitem__ParserElement.__getitem__^sC6 ) c5 ! !99chh{"O U # # 3r7E(B(BFCFLL13q6;;"O c8 $ $&C  I s8a<9#bq'Z]^aZbefZfU3s8*TUCVlnBoopq  U3r7^#kk.#.  JJw   *C s+ D== E  E cJUbURU5$UR5$)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") )r+r%r0r\s r2__call__ParserElement.__call__s'  ''- -99; r5c[U5$)zv Suppresses the output of this :class:`ParserElement`; useful to keep punctuation from cluttering up returned output. )Suppressr5s r2suppressParserElement.suppresss ~r5 recursivecSUlU$)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) Trr0rNs r2ignore_whitespaceParserElement.ignore_whitespaces# r5cSUlU$)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) FrPrQs r2leave_whitespaceParserElement.leave_whitespaces$ r5 copy_defaultsc@SUl[U5UlX lU$)z( Overrides the default whitespace chars T)rrrr)r0rrWs r2set_whitespace_chars"ParserElement.set_whitespace_charss" #e*%2" r5cSUlU$)z Overrides default behavior to expand ```` s to spaces before parsing the input string. Must be called before ``parse_string`` when the input grammar contains elements that match ```` characters. T)r r5s r2parse_with_tabsParserElement.parse_with_tabss   r5c4SSKn[U[5(a [U5n[U[5(a,XR;aURR U5 U$URR [UR 555 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)[1, ...] patt.parse_string('ablaj /* comment */ lskjd') # -> ['ablaj'] patt.ignore(c_style_comment) patt.parse_string('ablaj /* comment */ lskjd') # -> ['ablaj', 'lskjd'] rN)rrzr&rKr rr%)r0rrs r2ignoreParserElement.ignoresw  eX & &UOE eX & &,,,  ''.     # #HUZZ\$: ; r5 start_actionsuccess_actionexception_actioncURU=(d [U=(d [U=(d [5UlSUlU$)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)rrrrrr )r0rarbrcs r2set_debug_actionsParserElement.set_debug_actionss@$!--  77  ;;  ? ?    r5flagrcU(a)UR5HnURUSS9 M U$U(a!UR[[[ 5 U$SUlU$)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 at loc (,)"`` 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" set_debugrerrrr )r0rgrrs r2riParserElement.set_debugs]L (tU3)K   " "+-/  DJ r5c^URcUR5UlUR$r-)r_generateDefaultNamer5s r2 default_nameParserElement.default_nameIs+    $ $ 9 9 ;D    r5cg)zW Child classes must define this method, which defines how the ``default_name`` is set. NrBr5s r2rl"ParserElement._generateDefaultNameOrr5cXlSUR-Ul[R(aUR 5 U$)a6 Define name for this expression, makes debugging and exception messages clearer. Example:: Word(nums).parse_string("ABC") # -> Exception: Expected W:(0-9) (at char 0), (line:1, col:1) Word(nums).set_name("integer").parse_string("ABC") # -> Exception: Expected integer (at char 0), (line:1, col:1) Expected )rr\rrSrhrirGs r2set_nameParserElement.set_nameUs1!DII-  5 5 NN  r5cLURb UR$UR$r-)rrmr5s r2r\ParserElement.nameds"#'//"=tT4CTCTTr5cUR$r-r\r5s r2__str__ParserElement.__str__is yyr5c[U5$r-rTr5s r2__repr__ParserElement.__repr__ls 4yr5c"SUlSUlU$NT)r rr5s r2rParserElement.streamlineos  r5c/$r-rBr5s r2rParserElement.recurset r5cfUSSU/-nUR5HnURU5 M gr-)r_checkRecursionr0parseElementListsubRecCheckListr]s r2rParserElement._checkRecursionws1*1-6A  o . r5cZ[R"S[SS9 UR/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 recursionrn stacklevelN)warningsrVDeprecationWarningr)r0 validateTraces r2validateParserElement.validate|s)  h  R r5file_or_filenameencodingcU=(d Un[R"[U5nUR5nURWU5$![aU [R"[ U5n[ USUS9nUR5nSSS5 M_!,(df  Nn=ff=f![a,n[R(aeURS5eSnAff=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. rrN) rrr readAttributeErrorrTopenrrrrr)r0rrrr file_contentsfrs r2 parse_fileParserElement.parse_files(y )%{{63CD ,113M  /$$]H= =  )%{{30@A &h?1 ! @??? ) " ///((..  /s@+A B- 0B*;B B* B& !B*&B*- C#7'CC#cXLag[U[5(aURUSS9$[U[5(a[ U5[ U5:H$g)NTrF)rzr&rrvarsrs r2__eq__ParserElement.__eq__sM = x ( (<<<6 6 } - -:e, ,r5c[U5$r-)idr5s r2__hash__ParserElement.__hash__s $xr5 test_stringcnU=(a UnUR[U5US9 g![a gf=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") rTF)rrTr)r0rrrs r2rParserElement.matchess@")     c+.(  C!  s ' 44)rfullDump printResults failureTestsrrtestscomment full_dump print_results failure_tests post_parsefilewith_line_numbersrrrrrc   SSKJn U =(a Un U =(a Un U =(a Un U =(d Un U=(d Un[U[5(ad[R "[ U5n[U5RnUR5R5Vs/sH nU"U5PM nnUSLnU(a;[U[5(a&[R "[ U5n[U5n[R "[U5nUc[RnURn/n/nSn[S5R![#S55R%[&5nSnUGHnU(aUR)US5(dU(a2U(d+UR+U (aUR-U5OU5 M[U(dMdU(aSSR/U5-OS U (aUR-U5OU/n/nUR1UR3U55nUR5UU S 9nU=(a U (+nUb}U"UU5nUbP[U[65(a UR+UR955 OZUR+[ U55 O?UR+UR955 OUR+UR9U S 95 UR+S 5 U (aU"SR/U55 UR+UU45 GM UU4$s snf![:a^nUR+UR9U S 95 UR+UR<S [U5R<S U35 SnANSnAff=f![>an[U[@5(aSOS nUR+URC55 UR+S[ U5-5 [RD(a/URG[HRJ"URL55 U=(a U nUnSnAGNqSnAf[:an UR+S[U 5R<S U 35 [RD(a/URG[HRJ"U RL55 U=(a U nU nSn A GNSn A ff=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 uFrr)fullz failed: : z(FATAL)zFAIL: zFAIL-EXCEPTION: )'testingrrzr&rrrTrstriprstrip splitlinesLiteralrsysstdoutwriterQ replace_withr_ quoted_stringrrrrrlstriprr#dumpryr8rrexplainrrr format_tbr)!r0rrrrrrrrrrrrrrrr line_strip test_linecomment_specifiedprint_ allResultscommentssuccessNLBOMrrrpp_valuer]rrrs! r2 run_testsParserElement.run_testssb ,) ) #5 #4} + eX & &KKU+Ee**J%>(ST;LN44Q7RS.6tyy**B7H003aCH$ ;'' 6**1*A "6,&6( #,Q#7#/)(LAA # 8==? ; # 3x= 9JJv{{}5JJv{{{9: JJrNtyy~&   q&k *or ""UYx% 6;;H;#=> (112)DG, , and tags to embed the resulting HTML in an enclosing HTML source - ``head`` - str containing additional HTML to insert into the 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 section of the generated code Additional diagram-formatting keyword arguments can also be included; see railroad.Diagram class. r) to_railroadrailroad_to_htmlzMmust ``pip install pyparsing[diagrams]`` to generate parser railroad diagramsN)rrrdiagram_kwargswutf-8rr) diagramrr ImportErrorryrrzrTrrr) r0rrrrrrMrrierailroad diag_files r2create_diagramParserElement.create_diagrams@  >  1#!   kC; / /k39Y 0 Q Q& QR:9   .xOuOO P' _  :9s#B B' B$ BB$' B5cgr-rBrBr5r2inlineLiteralsUsing!ParserElement.inlineLiteralsUsing"r5cgr-rBrBr5r2setDefaultWhitespaceChars'ParserElement.setDefaultWhitespaceCharss%(r5cgr-rBr5s r2setResultsNameParserElement.setResultsName!r5cgr-rBr5s r2setBreakParserElement.setBreakr5cgr-rBr5s r2setParseActionParserElement.setParseActionrr5cgr-rBr5s r2addParseActionParserElement.addParseActionrr5cgr-rBr5s r2 addConditionParserElement.addConditionr5cgr-rBr5s r2 setFailActionParserElement.setFailAction r5cgr-rBr5s r2tryParseParserElement.tryParserr5cgr-rBrBr5r2enableLeftRecursion!ParserElement.enableLeftRecursionrr5cgr-rBrBr5r2 enablePackratParserElement.enablePackratsr5cgr-rBr5s r2 parseStringParserElement.parseStringsr5cgr-rBr5s r2 scanStringParserElement.scanStringsr5cgr-rBr5s r2transformStringParserElement.transformString"r5cgr-rBr5s r2 searchStringParserElement.searchStringrr5cgr-rBr5s r2ignoreWhitespaceParserElement.ignoreWhitespace #r5cgr-rBr5s r2leaveWhitespaceParserElement.leaveWhitespacerr5cgr-rBr5s r2setWhitespaceChars ParserElement.setWhitespaceChars s"%r5cgr-rBr5s r2 parseWithTabsParserElement.parseWithTabs rr5cgr-rBr5s r2setDebugActionsParserElement.setDebugActions rr5cgr-rBr5s r2setDebugParserElement.setDebug rr5cgr-rBr5s r2setNameParserElement.setName r5cgr-rBr5s r2 parseFileParserElement.parseFile sr5cgr-rBr5s r2runTestsParserElement.runTests rr5)rr?rrrrr rrrr r r rrrrrrr rrFr`rTr>r_r-))rrr`r)TF)rF)T#TTFNNF)r'FFF)r8r>r?r@rHrrTrrrrr staticmethodrrrjrrrr3rlrr"r%r,r+rA ParseActionrNrQParseConditionrUParseFailActionrXrrarhrlrrr r#rrrrrecursion_lockrrDictr rydictrrrrrr?rrrrrrrr_MAX_INTrrrrrNrrrrrrr r#r'r*r.r1r6__iter__rDrHrLrRrUr rYr\r_rrrreripropertyrmrrlrsr\ryr}rrrrrrr rrrrrrrr!rrrrrrrrrr r rrrrrr!r$r'r*r-r0r4r7 canParseNextr defaultNamerArBr5r2rrs 3(($$ $$-C-D--(040D00* = =:z: 888[_ "<38:SX::+/:LP: :B DO.T[TTl [  #.##J/o ##  3 3  ;?d sL !dV" C C C  C  C  Cs$SWWN V[[ c9d"#U3lI6M0N+N%OO  T   a& ;?/$ sL !/$bF..O# ; ;15-5@E-5 //#.-5 -5-5^)=U)=)=d)=t)=)=X05CJOCC(,CCGC CP$ Y/ "Y/Y/Y/ Y/  Y/Y/ 5sC/0$< =Y/v@E,/,/,/,/b$&/ " &/&/&/  &/  &/ &/V!#(   !  3d? #@""H /M^#) !#H:xV__S1_(4? $ / BG 3s8S=) :>   8&+/   43d3D3_3j!c!!  c  S _ UcUU# o./ !  /  /T6 12// /  / /<37LP+/EI 6@C"#JN(,"'E#!"IM!E#S$s)^$E#E#';!<= E#  E#  E#E#OOHc<-@#-E$FGE#oof%E# E#E#E#E#E# ??8S,,?,D#EF!E#" tT%U<+B%C CDEE F#E#T#(! 5Q64,-5Q5Q! 5Q  5Q  5Q 5Qr+,"-"23(4(&'!(!i !&'!(!&'!(!m$%o& ' i !+,"-"n%&l#$k"#&'"("m$%'(#)#&'"("*+%,%o& ' '(")"i !h j!"i !!LJKr5c\^\rSrSrS S\S\4U4SjjjrS\4SjrS Sjr Sr S r S r U=r $) ri rrc:>[TU]5 XlX lgr-)superr3anchorr)r0rrrs r2r3_PendingSkip.__init__ s  "r5r`cb[UR[5-5RSS5$)Nr...)rTrMrreplacer5s r2rl!_PendingSkip._generateDefaultName# s%4;;()11'5AAr5c^[U5RS5"S5nTR(aFSnU4SjnTRU"5R U5-U"5R U5-U-$TRU-U-$)NrPrcUR(aURR5S/:XaUS URSS5 gg)Nrr_skipped)rUrpop)rs r2r'_PendingSkip.__add__..must_skip* s:zzQZZ%7%7%9bT%A!EE*d+&Br5c>URR5SSS/:Xa0URS5 S[TR5-S-US'gg)NrrrUz missing <>)rUrrVreprrM)rr0s r2 show_skip'_PendingSkip.__add__..show_skip/ sN::%%',4EE*%$/$t{{2C$Cc$IAjM5r5)rrsrrMrQ)r0rskipperrr[s` r2r_PendingSkip.__add__& s-((/ < >> ,  J  gi88CC),,Y78  {{W$u,,r5cUR$r-)rIr5s r2r}_PendingSkip.__repr__; sr5c[S5e)NzBuse of `...` expression without following SkipTo target expression)ryrs r2rl_PendingSkip.parseImpl> s P  r5)rMrr9r:)r8r>r?r@rrr3rTrlrr}rlrA __classcell__rs@r2rr s=#]#t## BcB-*   r5rc:^\rSrSrSrU4SjrS\4SjrSrU=r $)TokeniD zQAbstract :class:`ParserElement` subclass, for defining atomic matching patterns. c >[TU]SS9 g)NFrrLr3r0rs r2r3Token.__init__I s %(r5r`c,[U5R$r-)rr8r5s r2rlToken._generateDefaultNameL sDz"""r5rB) r8r>r?r@rHr3rTrlrArcrds@r2rfrfD s)#c##r5rfc6^\rSrSrSrU4SjrSSjrSrU=r$)r;iP z A token that will never match. cL>[TU]5 SUlSUlSUlg)NTFzUnmatchable token)rLr3rr rrjs r2r3NoMatch.__init__U s% "") r5c0[XURU5er-)rrrks r2rlNoMatch.parseImpl[ sXDKK>>r5)rr rr; r8r>r?r@rHr3rlrArcrds@r2r;r;P s* ??r5r;c^\rSrSrSrSSS.S\S\4U4SjjjjrSrSSS.S\S\4U4S jjjjrS \4S jr SS jr S r U=r $)ri_ a Token to exactly match a specified string. Example:: Literal('blah').parse_string('blah') # -> ['blah'] Literal('blah').parse_string('blahfooblah') # -> ['blah'] Literal('blah').parse_string('bla') # -> Exception: Expected "blah" 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`. r matchString match_stringrvc>U[LaGU=(d UnU(d[TU] [5$[ U5S:Xa[TU] [ 5$[TU] U5$rd)rrL__new__rre_SingleCharLiteral)r[rwrvrs r2ryLiteral.__new__o sT '>&6,Lwu--< A%w'9::ws##r5cUR4$r-)matchr5s r2__getnewargs__Literal.__getnewargs__| s }r5c>[TU]5 U=(d UnXl[U5UlUSSUlSUR -UlSUlSUl g)NrrrF) rLr3r}rematchLenfirstMatchCharr\rrr r0rwrvrs r2r3Literal.__init__ sX "2l ! L) *2A.!DII- #"r5r`c,[UR5$r-rZr}r5s r2rlLiteral._generateDefaultName DJJr5cXUR:Xa;URURU5(aX R-UR4$[ XUR U5er-)rrLr}rrrrks r2rlLiteral.parseImpl sX =D// /H4G4G JJ5 5 & 2 2XDKK>>r5)rrr}rr rrr;) r8r>r?r@rHrTryr~r3rlrlrArcrds@r2rr_ sa  $2 $3 $S $ $#R#S#s## c ??r5rcP^\rSrSrSrS SS.U4SjjjrS\4SjrS SjrS r U=r $) ri z$ An empty token, will always match. rruc@>[TU]S5 SUlSUlg)NrTFrLr3rr rs r2r3Empty.__init__ s  ""r5r`cg)NrrBr5s r2rlEmpty._generateDefaultName sr5c U/4$r-rBrks r2rlEmpty.parseImpl rnr5r rrr;) r8r>r?r@rHr3rTrlrlrArcrds@r2rr s/#r## cr5rc\rSrSrSSjrSrg)rzi cvXUR:XaUS-UR4$[XURU5erd)rr}rrrks r2rl_SingleCharLiteral.parseImpl s8 =D// /7DJJ& &XDKK>>r5rBNr;)r8r>r?r@rlrArBr5r2rzrz s?r5rzc ^\rSrSrSr\S-rSSSS.S\S\R\S \ S \S \R\4 U4S jjjjr S \4Sjr SSjr \SSj5r\rSrU=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_$rNrv identCharsrw ident_charscaselessrvrc>[TU]5 U=(d UnUc[RnU=(d UnXl[ U5UlUSUlS[U5RSUR3Ul SUlSUlX0lU(a%UR#5UlUR#5n['U5Ulg![a [S5ef=f)Nrz2null string passed to Keyword; use Empty() insteadrrrF)rLr3rDEFAULT_KEYWORD_CHARSr}rerrrxrrr8r\rrr rupper caselessmatchrr)r0rwrrrvrrs r2r3Keyword.__init__ s .;   66J"2l ! L)  S".q/D "$t*"5"5!6a {C #" !-!3!3!5D #))+Jj/ SQR R Ss  CC+r`c,[UR5$r-rr5s r2rlKeyword._generateDefaultName rr5cURnUnUR(aXX R-R5UR:XaUS:Xd#XS- R5UR ;awU[ U5UR- :d-XUR-R5UR ;aX R-UR4$US- nX R-nOUS- nUS- nOXUR:XaURS:Xd!URURU5(aUS:XdXS- UR ;aiU[ U5UR- :dXUR-UR ;aX R-UR4$US- nX R-nO US- nUS- n[XX@5e)Nrrz/, was immediately followed by keyword characterz7, keyword was immediately preceded by keyword characterz7, keyword was immediately followed by keyword character) rrrrrrrer}rrLr)r0rrr8rerrlocs r2rlKeyword.parseImpl s ==cMM1288:d>P>PP!8xa0668Os8}t}}<<#$--$78>>@W"]]2DJJ>>"SS!$}}!4WWF 1WF  !4!44MMQ&&&tzz377!8xa0Gs8}t}}<<#$--$78O"]]2DJJ>>U"%}}!4WWF 1WFXv<r?r@rH alphanumsrrTrrrr3rlrlr>rsetDefaultKeywordCharsrArcrds@r2rr s4&,,0 * +/**__S)* *  *OOC(**: c -=^.. 7r5rcN^\rSrSrSrS SS.S\S\4U4SjjjjrS SjrS rU=r $) CaselessLiterali% 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`.) rrurwrvc>U=(d Un[TU]UR55 XlSUR-Ulg)Nrr)rLr3r returnStringr\rrs r2r3CaselessLiteral.__init__3 s9"2l  ++-.(!DII- r5cXX R-R5UR:XaX R-UR4$[ XUR U5er-)rrr}rrrrks r2rlCaselessLiteral.parseImpl: sN # - . 4 4 6$** D&(9(99 9XDKK>>r5)rrrr;) r8r>r?r@rHrTr3rlrArcrds@r2rr% s1 .R.S.s..??r5rc ^\rSrSrSrS SSS.S\S\R\S\S \R\4U4S jjjjrS 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`.) rNrrwrrvrcN>U=(d UnU=(d Un[TU]XSS9 g)NT)rri)r0rwrrvrrs r2r3CaselessKeyword.__init__L s+ .; "2l  DAr5rB)rN) r8r>r?r@rHrTrrr3rArcrds@r2rr@ sf ,0 B +/ B B__S) B  B OOC( B Br5rc~^\rSrSrSrSSSS.S\S\R\S\4U4S jjjjr S \4S jr SS jr S r U=r $) CloseMatchiY aA 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']}) rF) maxMismatchesrrwmax_mismatchesrc>UbUOUn[TU]5 XlX0lSUR<SURS3UlX@lSUlSUlg)Nrrz (with up to z mismatches)F)rLr3rwrrrr r)r0rwrrrrs r2r3CloseMatch.__init__| sb+9*D-  (*!$"3"3!6mDDVDVCWWcd  "#r5r`cL[U5RSUR<3$)Nr~)rr8rwr5s r2rlCloseMatch._generateDefaultName s%t*%%&a(9(9'<==r5cUn[U5nU[UR5-nXe::aURnSn/n URn [[ XUU55HbupU upUR (aU R 5U R 5pX:wdM@U RU5 [U 5U :dMb O" XH-S-n[XU/5nX~S'XS'X.4$[XURU5e)Nrroriginal mismatches) rerwr enumerateziprrrr#rr)r0rrr8rrfmaxlocrwmatch_stringlocrrs_msrcmatresultss r2rlCloseMatch.parseImpl sx=T..//  ,,LOJ ..M(1H(,7)$=="yy{CIIK:%%o6:6)-1&s(;'<=&2 #(2 %|#XDKK>>r5)rrrwrr rr-r;)r8r>r?r@rHrTrrrr3rlrlrArcrds@r2rrY s` J04$  $$,$  $$">c>??r5rc ^\rSrSrSrSSSSSS.S\S\R\S\S \S \S \ S \R\S \R\S\R\S\ S\R\4U4Sjjjjr S\4Sjr SSjr SSjr SrU=r$)Wordi an 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 capital_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 excludeChars init_chars body_charsrmaxexact as_keyword exclude_charsrrrrc>U=(d UnU =(d Un U =(d Un U =(d Un [TU]5 U(d"[S[U5RS35e[ U5n U (a3[ U 5n X-n U (aSR [ U 5U - 5n XlSR [U 55Ul U (a0[ U 5Ul SR [U 55Ul OXl URUl US:Ul US:a [S5eUR(aX4:a[SUSUS 35eX0l US:aX@lO [UlUS:aU=p4XPlXPl S UR -UlS UlXlUR&(aU=R"S - slS URUR-;Ga[)UR5S:Xa![*R,"UR5nOS[/UR5S3nURUR:Xa|US:XaSnOgUS:XaSnO^URUR:wa4SURSUR[:XaSO URS3nOSURS3nUU3UlOyUS:XaSnSnOaS[/UR5S3nUS:XaSnO?US:Xa US::aSOSnO.X4:waSUS:aUS- OSSUS- S3nOSUS:aUS- OSS3nUUU3UlUR&(aSUR0S3Ul[*R2"UR05UlUR*R4UlUR8Ulgg![*R<a SUlgf=f)Nzinvalid z", initChars cannot be empty stringrrrzUcannot 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=r:rrFz as a keywordr[r9+{r}r"rn?z\b)rLr3rrr8rrrsorted initCharsOrigr bodyCharsOrig maxSpecifiedminLenmaxLenrEr\rr rrereescaperreStringcompiler}re_matchparseImpl_regexrlerror)r0rrrrrrrrrrr initChars_setexcludeChars_setre_leading_fragmentrepeatre_body_fragmentrs r2r3 Word.__init__ s+ + + #4}  4:..//QR I "<0   -MGGC N5E$EF &WWVM%:;  ^DN!# ):!;D *N!%!3!3D !G 7g    VWZV[[abeaffgh  7K"DK 19 CKK!DII- "" >> KK? *K t~~6 74>>"a'&(ii0B0B&C#()*DT^^*T)UUV&W#~~/!8 FAXF{{dkk1#%dkk]!$++:QBW[WbWb3cce!f#%dkk]"!5#6"7x @ !8')$F)*+Ednn+U*VVW'X$ax!$(+qb:')S1W#'!)DAcAgYb%QF')S1W#'!)DB%GF++0@/AfXN ~~#%dmm_B 7  6**T]]3!%  !%!5!5] 8T88  s%OO21O2r`cSnURUR:wa*SU"UR5SU"UR5S3nOSU"UR5S3nURS:dUR[:waURUR:Xa(URS:XaUSS$USURS3-$UR[:XaUSURS 3-$USURS URS3-$U$) NcRSn[USS9n[U5U:a USUS- S-$U$)NF) re_escaper'rP)rre)r max_repr_lens r2 charsAsStr-Word._generateDefaultName..charsAsStrl s<L*1>A1v $+>T^^ +DNN34Bz$..7Q6RRSTDDNN34A6D ;;?dkkX5{{dkk);;!#8OBt{{m2"666(4;;-v6664;;-q R@@@ r5cXUR;a[XURU5eUnUS- n[U5nURnX@R -n[ Xu5nX':aXU;aUS- nX':a XU;aMSnX$- UR:aSnORUR(aX%:a XU;aSnO1UR(a US:a XS- U;d X%:a XU;aSnU(a[XURU5eX!XB4$)NrFTr) rrrrerrrrrr) r0rrr8rrf bodycharsrthrowExceptions r2rlWord.parseImpl s  = .  TB B qx=NN $V&lx} 9 1HClx} 9 ; $!N   3>hmy6P!N ^^ QY'94>MY.!%   TB BU'''r5cURX5nU(d[XURU5eUR5nX$R 54$r-)rrrrgroup)r0rrr8rs r2rWord.parseImpl_regex s@x-  TB BjjlLLN""r5)rrrrrrrrr rrlrrr)rNrrrFNr;)r8r>r?r@rHrTrrrrr3rlrlrrArcrds@r2rr s@H+/ .2v6+/*.-1v6v6OOC(v6 v6  v6  v6v6s+v6??3'v6??3'v6v6ooc*v6v6pc6(@##r5rc ^\rSrSrSrS SSS.S\S\S\R\S \S \R\4 U4S jjjjr 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)rrcharsetrrrrcP>U=(d UnU=(d Un[TU]USXES9 g)Nr)rrrri)r0rrrrrrs r2r3 Char.__init__ s2+ #4}   1  r5rB)FN) r8r>r?r@rHrTrrrr3rArcrds@r2rr si!.2   -1      s+    ooc*   r5rc^\rSrSrSrSSSS.S\S\\R\ 4S\ S\ S \ S \ 4 U4S jjjjr \ S 5r\ S 5r \ S5rS\4SjrSSjrSSjrSSjrS\S\4SjrSrU=r$)Regexi aCToken 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 `_. If the given regex contains named groups (defined using ``(?P...)``), 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\d{4})-(?P\d\d?)-(?P\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) asGroupListasMatchpatternflags as_group_listas_matchr r cP>[TU]5 U=(d UnU=(d Un[U[5(a.U(d [ S5eSUlU=UlUlX lOR[US5(a6[US5(a%XlUR=UlUlX lO [S5eSUR-Ul SUl XPlX`lUR(aUR UlUR(aUR$Ulgg)zThe parameters ``pattern`` and ``flags`` are passed to the ``re.compile()`` function as-is. See the Python `re module `_ module for an explanation of the acceptable patterns and flags. z0null string passed to Regex; use Empty() insteadNr r}zCRegex may only be constructed with a string or a compiled RE objectrrF)rLr3rzr&r_rerr r r@rr\rr r r parseImplAsGroupListrlparseImplAsMatch)r0r r r rr r rs r2r3Regex.__init__ s !2] %X gx ( ( !STTDH+2 2DMDLJ Wi ( (WWg-F-FH+2?? :DL4=JU "DII- "&   !66DN <<!22DN r5cUR(a UR$[R"URUR5$![R a [ SUR<S35ef=f)Nzinvalid pattern (z) passed to Regex)rrrr r rrr5s r2rRegex.re sa 8888O Xzz$,, ;;88 X #4T\\4DDU!VWW Xs *A /A9c.URR$r-)rr}r5s r2rRegex.re_match sww}}r5c(URS5SL$Nr)rr5s r2rRegex.mayReturnEmpty s}}R ,,r5r`cjSR[UR5RSS55$)NzRe:({})z\\\)formatrZr rQr5s r2rlRegex._generateDefaultName s)T\\ 2 : :64 HIIr5c URX5nU(d[XURU5eUR5n[ UR 55nUR 5nU(aUR5H upxXU'M X%4$r-)rrrrr#r groupdictitems) r0rrr8rr;dkvs r2rlRegex.parseImpl! srx-  TB Bjjl6<<>*      A"xr5cURX5nU(d[XURU5eUR5nUR 5nX%4$r-)rrrrgroupsr0rrr8rr;s r2rRegex.parseImplAsGroupList. sCx-  TB Bjjlmmoxr5cURX5nU(d[XURU5eUR5nUnX%4$r-)rrrrr(s r2rRegex.parseImplAsMatch7 s=x-  TB Bjjlxr5replc^^TR(a [S5eTR(a[T5(a [S5eTR(aU4SjnOUU4SjnTR U5$)a[ Return :class:`Regex` with an attached parse action to transform the parsed result as if called using `re.sub(expr, repl, string) `_. Example:: make_html = Regex(r"(\w+):(.*?):").sub(r"<\1>\2") print(make_html.transform_string("h1:main title:")) # prints "

main title

" z/cannot use sub() with Regex(as_group_list=True)z:cannot use sub() with a callable with Regex(as_match=True)c,>USRT5$r5)expand)rr,s r2rRegex.sub..paU say''--r5cB>TRRTUS5$r5)rsub)rr,r0s r2rr0Z sww{{433r5)r rr rFrQ)r0r,rs`` r2r2 Regex.sub@ s_   MN N <r?r@rHrr r RegexFlagrrr3r)rrrTrlrlrrrr2rArcrds@r2rr s6+,# ,3",3,3R\\3&',3 ,3  ,3,3,3,3\XX--JcJ )) ))r5rcL^\rSrSrSr\"S5rSSSSSSSS.S\S \R\S \R\S \ S \ S \R\S\ S\S\R\S\R\S\ S\R\S\ 4U4Sjjjjr S\4Sjr SSjr SrU=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 )rr)z\f )z\r rNT) quoteCharescCharescQuoteunquoteResults endQuoteCharconvertWhitespaceEscapes quote_charesc_char esc_quote multilineunquote_resultsend_quote_charconvert_whitespace_escapesr:r;r<r=r>r?c >^[TT]5 U =(d Un U =(d Un U =(a Un U =(d Un U =(a Un U=(d UnUR5nU(d [S5eU cUn O"U R5n U (d [S5eUTl[ U5TlUSTlU Tl[ U 5Tl U =(d STl U =(d STl U Tl U Tl UTlSnSnU (a XS[R "U 5S3- nSnU (a>XS[R "U 5S3- nSn[R "U 5S -Tl[ TR5S :aJUUS3SR%U4S j['[ TR5S - SS 555-S-- nSn[R("S5TlU(aX[R,[R.-TlUUS [1TRS5U b [1U 5OSS3- nO2UUS [1TRS5SU b [1U 5OSS3- nSR%[R "TR5SUS[R "TR5/5TlTR(aTR(aj[R4"SSR%STR655S[R "TR5S3TR*S9TlOF[R4"S[R "TR5S3TR*S9Tl[R4"TR2TR*5TlTR2TlTRR<TlSTRB-Tl"STl#STl$g![R@a [STR2<S35ef=f)Nz%quote_char cannot be the empty stringz)end_quote_char cannot be the empty stringrr(?:r:|z.)z(.)rc 3># UHPnS[R"TRSU5S[R"TRUS5S3v MR g7f)rHNz(?!z)))rrr>)rPrr0s r2r(QuotedString.__init__.. sXE"))D$5$5bq$9:;3ryyIZIZ[\[]I^?_>``bcEsAArz(?:[^z])z\n\rz)*rc3N# UHn[R"U5v M g7fr-)rr)rPr#s r2rrK s!D 1"))A,, s#%z)|(z .)|(\n|.)r zinvalid pattern z passed to RegexrrFT)%rLr3rrr:re quoteCharLenfirstQuoteCharr>endQuoteCharLenr;r<r=r?rCrrescCharReplacePatternrranger4r  MULTILINEDOTALLrr rws_mapunquote_scan_rerr}rrr\rr r)r0r@rArBrCrDrErFr:r;r<r=r>r?sep inner_patternrs` r2r3QuotedString.__init__ s" %X(y';O#5~ $ C)C !,*  %%' DE E  %L'--/L !LMM(!$Z#-a=!-$' $5#Mr %^ $2.F%"  S8)<(=Q? ?MC  S7);(rzr&r5s r2rl!QuotedString._generateDefaultName sU >>T.. .:dnnh3W3W((:; ;.t~~.>mDL]L]K^__r5c^XTR:H=(a TRX5=(d SnU(d[XTRT5eUR 5nUR 5nTR (aUTRTR*n[U[5(aTR(a5SRU4SjTRRU555nO1SRSTRRU555nTR(a&UR!TRTR"5nX%4$)Nrc3># UHtnURS5(aTRURS5O:URS5(aURS5SOURS5v Mv g7f)rrnrr'N)rrU)rPr}r0s r2r)QuotedString.parseImpl.. so" &HE !;;q>> EKKN3!;;q>>#[[^B/"[[^ , &HsAr(s` r2rlQuotedString.parseImpl s MT00 0 - h,     TB Bjjllln   d''4+?+?*?@C#x((00''" &*%9%9%B%B3%G "C''"%)%9%9%B%B3%G"C ==++dmmT5F5FGCxr5)r?r>rPrr;rQr<rOr r rrCr r:rNrrrr=rV)rNNFTNTr;)r8r>r?r@rHrDrUrTrrrr3rlrlrArcrds@r2r6r6` s/%LN OF)-*. $/3+/u#(,)-#-1)-u#u#//#&u#??3' u#  u#  u#,u#%)u#u#%u#//#&u#u#ooc*u##'u#u#n`c` $$r5r6c p^\rSrSrSrSSS.S\S\S\S\S \4 U4S jjjjrS \4S jrSS jr Sr U=r $) CharsNotIni- aToken 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'] r)notChars not_charsrrrrdcd>[TU]5 SUlU=(d UUl[ UR5UlUS:a [ S5eX lUS:aX0lO [UlUS:a X@lX@lSUR-Ul URS:HUl SUl g)NFrzacannot specify a minimum length < 1; use Opt(CharsNotIn()) if zero-length char group is permittedrrr)rLr3rrdr notCharsSetrrrrEr\rrr )r0rerrrrdrs r2r3CharsNotIn.__init__B s #!-X t}}- 7K   7K"DK 19KK!DII- "kkQ."r5r`c[UR5n[U5S:aSURSSS3$SURS3$)Nrz!W:( z...)r:)rrdre)r0 not_chars_strs r2rlCharsNotIn._generateDefaultNamee sK24==A }  "$--&12$7 7$--* *r5cFURnXU;a[XURU5eUnUS- n[XPR-[ U55nX&:aXU;aUS- nX&:a XU;aMX%- UR :a[XURU5eX!XR4$rd)rgrrrrrer)r0rrr8notcharsrmaxlens r2rlCharsNotIn.parseImpll s## =H $  TB B qU[[(#h-8lx}H< 1HClx}H< ; $  TB BU'''r5)rrr rrrdrgr)rrrrr;) r8r>r?r@rHrTrr3rlrlrArcrds@r2rcrc- sq, !#!#!#!# !#  !#!#!#F+c+((r5rcc ^\rSrSrSr0SS_SS_SS_S S _S S _S S_SS_SS_SS_SS_SS_SS_SS_SS_SS _S!S"_S#S$_S%S&S'S(S)S*S+.ErS5S,\S-\S.\S/\4U4S0jjjrS1\4S2jr S6S3jr S4r U=r $)7Whitei} 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. rzr7zrzr9zr8z zu zu᠎zu z u z u z u z u zu zu zu zu zz z zzzz)u u u​u u u wsrrrc8>^[TT]5 UTlTRSR U4SjTR 55SS9 STlSTR-TlUTl US:aUTl O [Tl US:aUTl UTl gg)Nrc3J># UHoTR;dMUv M g7fr-) matchWhite)rPcr0s r2r!White.__init__.. sJ~!$//1IAA~s# #TrWrrr) rLr3rwrYr whiteStrsrr\rrrrE)r0rtrrrrs` r2r3White.__init__ s  !! GGJt~~J J " #!DII-  7DK"DK 19DKDK r5r`cFSRSUR55$)Nrc3H# UHn[RUv M g7fr-)rrr{rPrxs r2r-White._generateDefaultName.. sC?auq)?s ")rrwr5s r2rlWhite._generateDefaultName swwC4??CCCr5cnXUR;a[XURU5eUnUS- nX@R-n[ U[ U55nX%:a0XUR;aUS- nX%:aXUR;aMX$- UR :a[XURU5eX!XB4$rd)rwrrrrrer)r0rrr8rrs r2rlWhite.parseImpl s = /  TB B q$VS]+lx}? 1HClx}? ; $  TB BU'''r5)rrwrrr)z rrrr;) r8r>r?r@rHr{rTrr3rlrlrArcrds@r2rrrr} s5 V g f f  f  (  & / + + , , ( ' & "!" '#$! &'/I4 3  s s  ,DcD ( (r5rrc(^\rSrSrU4SjrSrU=r$) PositionTokeni c>>[TU]5 SUlSUlgr[rrjs r2r3PositionToken.__init__ s ""r5r)r8r>r?r@r3rArcrds@r2rr s ##r5rcT^\rSrSrSrS\4U4SjjrS\S\S\4SjrS S jr S r U=r $) GoToColumni zYToken to advance to a specific column of input text; useful for tabular report scraping. colnoc.>[TU]5 Xlgr-)rLr3r)r0rrs r2r3GoToColumn.__init__ s r5rrr`ct[X!5UR:wa[U5nUR(aURX5nX#:alXR 5(aU[X!5UR:wa<US- nX#:a2XR 5(a[X!5UR:waM<U$rd)rrer raisspace)r0rrrfs r2rhGoToColumn.preParse s s  )8}H**89M))++&$((2q M))++&$((2 r5c[X!5nX@R:a [XSU5eX R-U- nXUnXV4$)NzText not in expected column)rr)r0rrr8thiscolnewlocr;s r2rlGoToColumn.parseImpl sHc$ XX  0MtT Txx')6"{r5rr;) r8r>r?r@rHrr3rTrhrlrArcrds@r2rr s8c  3 3 r5rcL^\rSrSrSrU4SjrS\S\S\4SjrS Sjr S r U=r $) LineStarti 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>[TU]5 UR5 [5UR-UlURR S5 [5RUR5Ul SUl g)NrzExpected start of line) rLr3rUrrorig_whiteCharsdiscardrrYr]rrjs r2r3LineStart.__init__s^  "ut6 %w33DOOD . r5rrr`cUS:XaU$URRX5nSUR;a6XUS-S:Xa+URRXS-5nXUS-S:XaM+U$)Nrrr)r]rhr)r0rrr;s r2rhLineStart.preParsesq !8J,,''6Ct+++S1W-5,,//'BCS1W-5Jr5cV[X!5S:XaU/4$[XURU5erd)rrrrks r2rlLineStart.parseImpls+ s  "7NXDKK>>r5)rrr]r;) r8r>r?r@rHr3rTrrhrlrArcrds@r2rr s1,/33??r5rc6^\rSrSrSrU4SjrSSjrSrU=r$)LineEndizLMatches if current position is at the end of a line within the parse string c>[TU]5 URRS5 UR URSS9 SUlg)NrFrzzExpected end of line)rLr3rrrYrrjs r2r3LineEnd.__init__$s>  % !!$//!G, r5cU[U5:a&XS:XaUS-S4$[XURU5eU[U5:XaUS-/4$[XURU5e)Nrrrerrrks r2rlLineEnd.parseImpl*sf X }$Qw}$$XDKKFF CM !7B;   TB Br5rr;rsrds@r2rrs- C Cr5rc6^\rSrSrSrU4SjrSSjrSrU=r$) StringStarti6zDMatches if current position is at the beginning of the parse string c0>[TU]5 SUlg)NzExpected start of textrLr3rrjs r2r3StringStart.__init__;s . r5cnUS:wa,X RUS5:wa[XURU5eU/4$r5)rhrrrks r2rlStringStart.parseImpl?s6 !8mmHa00$XDKKFFBwr5rr;rsrds@r2rr6s/r5rc6^\rSrSrSrU4SjrSSjrSrU=r$)riGz? Matches if current position is at the end of the parse string c0>[TU]5 SUlg)NzExpected end of textrrjs r2r3StringEnd.__init__Ls , r5cU[U5:a[XURU5eU[U5:XaUS-/4$U[U5:aU/4$[XURU5erdrrks r2rlStringEnd.parseImplPsc X   TB B CM !7B;  3x= 7N  TB Br5rr;rsrds@r2rrGs-CCr5rcP^\rSrSrSr\4\S.S\S\4U4SjjjjrS SjrSr U=r $) WordStarti[agMatches 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.  wordChars word_charsrcl>U[:XaUOUn[TU] 5 [U5UlSUlg)NzNot at the start of a word) printablesrLr3rrrr0rrrs r2r3WordStart.__init__es."+z"9Jy  Y2 r5cUS:wa>XS- UR;dXUR;a[XURU5eU/4$Nrr)rrrrks r2rlWordStart.parseImplksF !8q!T^^3=6$XDKKFFBwr5)rrr; r8r>r?r@rHrrTr3rlrArcrds@r2rr[s6*43333333 r5rcP^\rSrSrSr\4\S.S\S\4U4SjjjjrS SjrSr U=r $) WordEndiuaQMatches 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. rrrcz>U[:XaUOUn[TU] 5 [U5UlSUlSUlg)NFzNot at the end of a word)rrLr3rrrrrs r2r3WordEnd.__init__~s6"+z"9Jy  Y#0 r5c[U5nUS:aCX$:a>XUR;dXS- UR;a[XURU5eU/4$r)rerrr)r0rrr8rfs r2rlWordEnd.parseImplsSx= a^[TT]U5 T [U[5(a [ U5n[U[ 5(aTR U5/TlO[U[5(a U/TlOe[U[5(a?[ U5n[SU55(a U4SjU5n[ U5TlO[ U5TlSTl g![a U/TlNf=f)Nc3B# UHn[U[5v M g7fr-)rzr&)rPrs r2r+ParseExpression.__init__..s@%$:dH--%sc3t># UH-n[U[5(aTRU5OUv M/ g7fr-)rzr&r)rPr]r0s r2rrs5"4>a3J3JD,,Q/PQQ"s58F) rLr3rz_generatorTyperr&rrrranyrrr0rrrs` r2r3ParseExpression.__init__s " e^ , ,KE eX & &2259:DJ } - -DJ x ( (KE@%@@@"eDJ %!%[ " %#W  %sC,,DDr`c URSS$r-)rr5s r2rParseExpression.recurseszz!}r5cJURRU5 SUlU$r-)rrrrs r2rParseExpression.appends! %   r5rNc>[TU]U5 U(aSURVs/sHo"R5PM snUlURHnURU5 M U$s snf)z| Extends ``leave_whitespace`` defined in base class, and also invokes ``leave_whitespace`` on all contained expressions. )rLrUrr%r0rNr]rs r2rU ParseExpression.leave_whitespacesY  + ,0JJ7Jq&&(J7DJZZ""9-  8A-c>[TU]U5 U(aSURVs/sHo"R5PM snUlURHnURU5 M U$s snf)z} Extends ``ignore_whitespace`` defined in base class, and also invokes ``leave_whitespace`` on all contained expressions. )rLrRrr%rs r2rR!ParseExpression.ignore_whitespacesY !), ,0JJ7Jq&&(J7DJZZ##I.  8rcT>[U[5(aQXR;a@[TU]U5 UR H!nUR URS5 M# U$[TU]U5 UR H!nUR URS5 M# U$Nr)rzrKr rLr_r)r0rr]rs r2r_ParseExpression.ignores eX & &,,,u%AHHT--b12$   GN5 !ZZ))"-.  r5c`URRS[UR5S3$Nz:(r:)rr8rTrr5s r2rl$ParseExpression._generateDefaultNames)..))*"S_,=Q??r5c>UR(aU$[TU] 5 URHnUR5 M [ UR5S:XGaURSn[ X R 5(aUR(dURc{UR(djURSSURS/-UlSUl U=RUR-sl U=RUR-sl URSn[ X R 5(aUR(dURczUR(diURSSURSS-UlSUl U=RUR-sl U=RUR-sl S[U5-UlU$)Nrnrrrrr)r rLrrrerzrrrr rrr rTr)r0r]rrs r2rParseExpression.streamlinesr   K A LLN tzz?a JJqME5..11))%%- "[[^tzz!}o= $(!##u';';;#""e&9&99"JJrNE5..11))%%- !ZZ_u{{1~= $(!##u';';;#""e&9&99"!CI-  r5c[R"S[SS9 UbUO/SSU/-nURHnUR U5 M UR /5 gNrrnr)rrVrrrr)r0rtmpr]s r2rParseExpression.validatesX h  !. 9}r1ENA JJsO R r5c>[TU]5n[R"[U5nUR Vs/sHo"R5PM snUlU$s snfr-)rLr%rrrr)r0r;r]rs r2r%ParseExpression.copysFglnkk/3/'+zz2z!VVXz2  3sAc >[R(a[RUR;aURHn[ U[ 5(dMUR(dM-[RUR;dMM[R"SRSU[U5RUR5SS9 M [TU]9X5$NzY{}: setting results name {!r} on {} expression collides with {!r} on contained expressionrbr'r)rSrbrlrrrzrrrrVrrr8rLr+r0r\r(r]rs r2r+ParseExpression._setResultsNames  > >EE**+ZZq-00 #MM//0MMEEKVG  J//MM F $%  $w&t<r?r@rHrrrrr3rrrrUrRr_rTrlrrr%r+r!r!rrArcrds@r2rrs"foom<"""4m,} $ -   4 =   } @c@'M'R !m =8&'"("'(#)#r5rc^\rSrSrSr"SS\5rSS\R\ S\ 4U4Sjjjr S\ 4U4S jjr SS jr S rS rS\4S jrSrU=r$)ri=a Requires all given :class:`ParseExpression` 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") c6^\rSrSrU4SjrS\4SjrSrU=r$)zAnd._ErrorStopiOcF>[TU]"U0UD6 UR5 gr-)rLr3rU)r0rrMrs r2r3And._ErrorStop.__init__Ps! G d -f -  ! ! #r5r`cg)N-rBr5s r2rl#And._ErrorStop._generateDefaultNameTsr5rB) r8r>r?r@r3rTrlrArcrds@r2rAnd._ErrorStopOs $ #  r5r exprs_argrc@>[U5nU(a[U;a/n[U5HupVU[LawU[U5S- :aZ[R "[ [5X5S--5RSnUR[U5"S55 Mz[S5eURU5 M XCSS&[TU]5X25 UR(a[SUR55Ul[!URS["5(d]UR%URSR&URSR(S9 URSR*UlOSUlOS UlS Ulg) Nrrrz0cannot construct And with sequence ending in ...c38# UHoRv M g7fr-rrPr]s r2rAnd.__init__..m%K 1&6&6 rHrrzFT)rrrrerrrrrrrryrLr3rJrrzrrrYrrrr) r0rrrrrr skipto_argrs r2r3 And.__init__WsV&*)_ X&C$U+8#3u:>)4:KK+eg!e .D5%5$  6*#5k#BC'NJJt$,!H ) ::"%%K %K"KD djjmU33))JJqM,,"&**Q-"E"E*'+jjm&B&B#&+#"&D  r5r`cP>UR(Ga [SURSS55(a[5n[URSS5Hup#X1LaM [ U[ 5(dM"UR(dM5[ URS[ 5(dMYURSURUS--URS'XRUS-'M URVs/sH o3ULdM UPM snUl[T U]!5 [URURSS5HupE[5n[U5U;aM!UR[U55 [ U[5(aURU4Sj5 MgUR5n[![#U5S5nUcM[$R&"[(U5nM [+SUR55UlU$s snf)Nc3# UHLn[U[5=(a0 UR=(a [URS[5v MN g7frN)rzrrrrs r2r!And.streamline..}sJ)A1o.:GG:qwwr{L9:)sAArrc.[US[X55$)N parent_anchor)setattrr)rrrcur_s r2r And.streamline..s' /3q93r5c38# UHoRv M g7fr-rrs r2rrs!GJq"2"2JrH)rrr;rrzrrrLrrrrr IndentedBlockrQrnextr>rrrrJr) r0deleted_expr_markerrr]prevr!r subs next_firstrs r2rAnd.streamlinezs :::CR  '.i#%djj"o6DA/ "1o66GGG&qwwr{LAA&'ggbkDJJq1u4E&E ,? 1q5)7*.TA@S7SaT   TZZAB8ID5Dc7d?C!c=11))-0 {{}!$t*d3 %kk-< 9*"!GDJJ!GG ;Us H#H#cURSRXUSS9up$SnURSSHXn[U5[RLaSnM#U(aURXU5up'OURXU5up'XG- nMZ X$4$![ a e[ a!nSUl[ RU5eSnAf[a" [ U[U5URU5ef=f)NrFrrT) rr?rrrParseSyntaxExceptionrr_from_exceptionrxrer) r0rrr8 resultlist errorStopr] exprtokensrs r2rl And.parseImpls**Q-.. 95/  ABAAw#..(  &'hhxi&HOC#$((8)"D  $J' (,)C'+B$.>>rBB!. #h-dsBC0%C/C0c[U[5(aURU5n[U[5(d[$UR U5$r-rzr&rrrrrs r2__iadd__ And.__iadd__A eX & &,,U3E%//! !{{5!!r5cUSSU/-nURH'nURU5 UR(aM' g gr-)rrrrs r2rAnd._checkRecursions>*1-6A  o .###r5cSRSUR55n[U5S:aFUSS[U5S- 2S:Xa.USSn[U5S:aUSS[U5S- 2S:XaM.SU-S-$) Nrc38# UHn[U5v M g7fr-r|rs r2r+And._generateDefaultName..s4AQrHrr{}rrr)rrrer0inners r2rlAnd._generateDefaultNames444%j1nq':CJN':!;t!C!BKE%j1nq':CJN':!;t!CU{S  r5)rrrrr;)r8r>r?r@rHrrrrrrr3rrlrrrTrlrArcrds@r2rr=sl"UKO!!7!!CG!!!!F1M1f:"!c!!r5rc^\rSrSrSrS S\R \S\4U4Sjjjr S\4U4Sjjr SSjr S r S\ 4S jrS U4S jjrS rU=r$)r&iaRequires that at least one :class:`ParseExpression` 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']] rrc>[TU]X5 UR(aC[SUR55Ul[ SUR55UlgSUlg)Nc38# UHoRv M g7fr-rrs r2rOr.__init__..rrHc38# UHoRv M g7fr-rPrs r2rr+rrHTrLr3rrrrJrrs r2r3 Or.__init__M ) ::"%%K %K"KD "%%K %K"KD "&D r5r`c>[TU]5 UR(ae[SUR55Ul[SUR55Ul[ SUR55UlU$SUlU$)Nc38# UHoRv M g7fr-rrs r2r Or.streamline..rrHc38# UHoRv M g7fr-rrs r2rr2!C 1,, rHc3p# UH,oR=(a [U[5(+v M. g7fr-rrzrrrs r2rr2)&GQ!  =Au)=%==z46F)rLrrrrrrJrrjs r2r Or.streamlinesu  ::"%%K %K"KD !!C !CCDO"%&GKzz&#D   $DO r5cBSnSn/n/n[SUR55(aURX5nURH&nURXSS9n UR X45 M( U(aUR[S5SS9 U(dUSSn U RXU5$Sn UH@upXS::aU s $URXU5un nX:aU U4s $XS:aU U4n M@MB U S:waU $U(aV[U5S:a@URS S 9 USRUSR:XaURS S 9 USnUeUbXB:XaURUlUe[XS U5e![ a.n SU lXlUR U 5 SnSnSn A GMsSn A f[aFn U(d3SU lU RU:aU nU RnSn A GMSn A GMSn A GMSn A f[aD [U5U:a0[U[U5URU5n[U5nGM GMf=f![a8n SU lU RU:aU nU RnSn A GMSn A GMSn A ff=f) Nrc38# UHoRv M g7fr-rrs r2rOr.parseImpl.. s2z!~~zrHTrr)rAreverserrcUR*$r-rr]s r2rOr.parseImpl..J 155&r5rAcZUR*[[UR55*4$r-rrerTparser_elementrCs r2rrDL"vC@P@P.c; 1A rHrrrr5s r2rlOr._generateDefaultNameb%UZZ; ;;;cAAr5c <>[R(ax[RUR;aZ[ SUR 55(a9[ R"SRSU[U5R5SS9 [TU]1X5$)Nc3# UH9n[U[5=(a [RUR;v M; g7fr-rzrrlrarrs r2r%Or._setResultsName..kC$A1c",II++,,$AA{}: setting results name {!r} on {} 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 Grouprar'r rSrarlrrrrrVrrr8rLr+r0r\r(rs r2r+Or._setResultsNamee  > >EE**+   239&CT ++3 ! w&t<r?r@rHrrrrr3rrlrYrTrlr+rArcrds@r2r&r&sY"'foom<''' M Sj"BcB==r5r&c^\rSrSrSrS S\R \S\4U4Sjjjr S\4U4Sjjr SSjr S r S\ 4S jrS U4S jjrS rU=r$)riaRequires that at least one :class:`ParseExpression` 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']] rrc>[TU]X5 UR(aC[SUR55Ul[ SUR55UlgSUlg)Nc38# UHoRv M g7fr-rrs r2r&MatchFirst.__init__..rrHc38# UHoRv M g7fr-rPrs r2rrqrrHTr-rs r2r3MatchFirst.__init__r/r5r`cR>UR(aU$[TU] 5 UR(ae[ SUR55Ul[ SUR55Ul[SUR55UlU$SUlSUlU$)Nc38# UHoRv M g7fr-r4rs r2r(MatchFirst.streamline..r5rHc38# UHoRv M g7fr-rrs r2rrvrrHc3p# UH,oR=(a [U[5(+v M. g7fr-r7rs r2rrvr8r9FT) r rLrrrrrrJrrjs r2rMatchFirst.streamlines   K  ::!!C !CCDO"%%K %K"KD "%&GKzz&#D   $DO"&D  r5cSnSnURHnURUUU5s $ UbXB:XaURUl Ue[ XSU5e![anSUlXgleSnAf[ a/nUR U:aUnUR nSnAMSnAMSnAf[aB [U5U:a/[ U[U5URU5n[U5nMMf=f)NrrK) rr?rrrIrrrxrerr) r0rrr8rMrNr]rQrs r2rlMatchFirst.parseImpls  A .xx,  ##';;    A4 -' $(!%&"! (77Y&#&L #I' .x=9,#1 #h-4$L!$H I - .s*A C2A,, C29B##AC21C2c[U[5(aURU5n[U[5(d[$UR U5$r-rrs r2__ior__MatchFirst.__ior__rr5cRSSRSUR55-S-$)Nrz | c38# UHn[U5v M g7fr-r|rs r2r2MatchFirst._generateDefaultName..r^rHrr_r5s r2rlMatchFirst._generateDefaultNamerar5c <>[R(ax[RUR;aZ[ SUR 55(a9[ R"SRSU[U5R5SS9 [TU]1X5$)Nc3# UH9n[U[5=(a [RUR;v M; g7fr-rdrs r2r-MatchFirst._setResultsName..rfrgrhrar'rrirjs r2r+MatchFirst._setResultsNamerlr5rmr9r;)r8r>r?r@rHrrrrr3rrlr}rTrlr+rArcrds@r2rrsX"'foom<'''M #J"BcB==r5rc^\rSrSrSrS S\R \S\4U4Sjjjr Sr S\4U4Sjjr S S jr S\ 4S jrS rU=r$) r-iaRequires all given :class:`ParseExpression` 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 rrc>[TU]X5 UR(a"[SUR55UlOSUlSUlSUlSUlg)Nc38# UHoRv M g7fr-rrs r2r Each.__init__..1rrHT)rLr3rrJrrinitExprGroupsrrs r2r3 Each.__init__.sM ) ::"%%K %K"KD "&D ""r5c[U[5(aURU5n[U[5(d[$UR U5$r-rrs r2__iand__ Each.__iand__8rr5r`c>[TU]5 UR(a#[SUR55UlU$SUlU$)Nc38# UHoRv M g7fr-rrs r2r"Each.streamline..BrrHT)rLrrrJrrjs r2rEach.streamline?sB  ::"%%K %K"KD  #'D  r5c * UR(Ga[SUR55UlURVs/sH&n[ U[ 5(dMUR PM( nnURVs/sH:nUR(dM[ U[ [[45(aM8UPM< nnXV-Ul URVs/sH>n[ U[5(dMUR RURSS9PM@ snUlURVs/sH>n[ U[5(dMUR RURSS9PM@ snUlURVs/sH'n[ U[ [[45(aM%UPM) snUlU=R"UR - slSUlUnUR"SSnURSSn URSSn /n Sn /n /nU (aX-U -nU R%5 UR%5 UHxnUR'XSS9nU R)URR+[-U5U55 XH;aUR/U5 M`XI;aU R/U5 MxMz [9U 5[9U5:XaSn U (aMU(aV[9U5S:a@UR;SS9 US R<USR<:XaUR;S S9 US nUeU(a<S R?UVs/sHn[AU5PM sn5n[7UUS US 35eXRVs/sH.n[ U[ 5(dMUR U ;dM,UPM0 sn- n [C/5nU HnUREXU5unnUU- nM UU4$s snfs snfs snfs snfs snf![0a<nSUlUUlUR)U5 U R)U5 SnAGMSnAf[6a U R)U5 GM5f=fs snfs snf)Nc3~# UH3n[U[5(dM[UR5U4v M5 g7fr-)rzrrrrs r2r!Each.parseImpl..Is* )3Az!S7IAFFQs==T)r)Fr?rcUR*$r-rBrCs r2r Each.parseImpl..rEr5rFrcZUR*[[UR55*4$r-rHrCs r2rrrJr5rz'Missing one or more required elements (r:)#rrDropt1maprzrrrrr optionalsr?r,rmultioptionalsr multirequiredrequiredrrrrKrremoverrrIrrerLrrrTr#r?)r0rrr8r]opt1opt2tmpLoctmpReqdtmpOptmultis matchOrder keepMatchingfailedrOtmpExprsrQrVmissing total_resultsrs r2rlEach.parseImplGs     )- DL%)JJEJq*Q2DFAFFJDE#A##,6q3z:R,S#  "[DN##Aa0N'' 'M##D "#Aa+N'' 'M#"D   ::%aZCY;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==F1IMM1KK$SKTq IO ii 9AQ 9:G 9'!D  **X*Q 1c0BqqvvQWGWq*XX $R( A88H9=LC W $MM!!aF # " ,+%(,C%)*C&MM#&MM!$$%%MM!$$%*!:YsxP P ?PP:PP6(P4P(P$P7PP$$R R<RR$ R.0Q%%RRcRSSRSUR55-S-$)Nrz & c38# UHn[U5v M g7fr-r|rs r2r,Each._generateDefaultName..r^rHrr_r5s r2rlEach._generateDefaultNamerar5) rrrrrrrrrr;)r8r>r?r@rHrrrrr3rrrlrTrlrArcrds@r2r-r-sV7rfoom<"MU"nBcBBr5r-c^\rSrSrSrSS\\\4S\4U4Sjjjr S\ \4Sjr SSjr SS \S\4U4S jjjr SS \S\4U4S jjjrS\4U4S jjrS\4U4S jjrSrSSSjjrS\4Sjr\"\ 5S5r\"\5S5rSrU=r$)ParseElementEnhanceiz^Abstract subclass of :class:`ParserElement`, for combining and post-processing parsed tokens. rrc>[TU]U5 [U[5(a[R "[ U5n[UR[5(aURU5nOJ[[U5UR5(a [U5nOUR[U55n[R "[U5nXl UbURUlURUlUR!UR"UR$S9 UR&UlUR(UlUR*UlUR,R/UR,5 gg)Nrz)rLr3rzr&rrrT issubclassrrfrrrrr rrYrrrrrr r)r0rrexpr_strrs r2r3ParseElementEnhance.__init__s' " dH % %{{3-H$22E:://9DJ(@(@AAx(//0AB{{=$/  !%!3!3D "&"5"5D   % %t/I/I & #'"5"5D "ooDO $ 1 1D     # #D$4$4 5 r5r`c:URb UR/$/$r-rr5s r2rParseElementEnhance.recurses"ii3 {;;r5cURbURRXUSS9$[ XSU5e![anURUleSnAff=f)NFrzNo expression defined)rr?rrrr)r0rrr8pbes r2rlParseElementEnhance.parseImpls_ 99  yy''yu'UU !0GN N & ++ s7 AAArNc>[TU]U5 U(aGURb:URR5UlURRU5 U$r-)rLrUrr%r0rNrs r2rU$ParseElementEnhance.leave_whitespacesF  + yy$ IINN,  **95 r5c>[TU]U5 U(aGURb:URR5UlURRU5 U$r-)rLrRrr%rs r2rR%ParseElementEnhance.ignore_whitespacesF !), yy$ IINN,  ++I6 r5cd>[U[5(aUXR;aD[TU]U5 UR b(UR R URS5 U$[TU]U5 UR b(UR R URS5 U$r)rzrKr rLr_rr0rrs r2r_ParseElementEnhance.ignores eX & &,,,u%99(II$$T%5%5b%9:   GN5 !yy$   !1!1"!56 r5cr>[TU]5 URbURR5 U$r-)rLrrrjs r2rParseElementEnhance.streamlines-  99 II " r5cX;a[X/-5eUSSU/-nURbURRU5 ggr-)RecursiveGrammarExceptionrr)r0rrs r2r#ParseElementEnhance._checkRecursionsK  #+,>r5cgr-rBr5s r2r!#ParseElementEnhance.leaveWhitespacerr5cgr-rBr5s r2r$ParseElementEnhance.ignoreWhitespace rr5)rrr rrrr9r;r-r_)r8r>r?r@rHr rrTrr3rrrlrUrRr_rrrrlr!r!rrArcrds@r2rrs6U=##566$66.<m,<O$-4= } M 7 !?c? &'"("'(#)#r5rc|^\rSrSrSr"SS\5r"SS\5rSSS .S \S \ S \ 4U4S jjjr SSjr Sr U=r $)r iz 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). c0^\rSrSrS\4U4SjjrSrU=r$)zIndentedBlock._Indentiref_colcb>^[TU]5 ST3UlURU4Sj5 g)Nzexpected indent at column c >[X5T:H$r-rrrrrs r2r0IndentedBlock._Indent.__init__..ss1yG/Cr5rLr3rrUr0rrs `r2r3IndentedBlock._Indent.__init__s+ G  6wi@DK   C Dr5rr8r>r?r@rr3rArcrds@r2_IndentIndentedBlock._Indents EC E Er5rc0^\rSrSrS\4U4SjjrSrU=r$)zIndentedBlock._IndentGreaterircb>^[TU]5 ST3UlURU4Sj5 g)Nz'expected indent at column greater than c >[X5T:$r-rrs r2r7IndentedBlock._IndentGreater.__init__.. ss1y7/Br5rrs `r2r3%IndentedBlock._IndentGreater.__init__s+ G  CG9MDK   B Cr5rrrds@r2_IndentGreaterIndentedBlock._IndentGreaters DC D Dr5rFTrNgroupedrrNrcH>[TU]USS9 X lX0lSUlg)NTrhr)rLr3 _recursive_groupedr)r0rrNrrs r2r3IndentedBlock.__init__"s+ -$ r5c [5RX5nURRXUS9 [ XA5nUR U5n[5U-UR-nUR (akURU5n[URUR URS9n U RUR5 XYl U[X-5- nURS[[!U55SSR#5SU35 [%U5n UR UR5['5-n UR(a[(n OSn U "U 5[+U 5-R-XU5$)Nrrzinner @cU$r-rBrs r2r)IndentedBlock.parseImpl..Js4r5)rrhrrrrrrr rrir rrrshexrrrrGrouprrl) r0rrr8 anchor_loc indent_colpeer_detect_expr inner_expr sub_indent nested_blockblocktrailing_undentrs r2rlIndentedBlock.parseImpl,sOW%%h4  HYG. << 3W//$)); ??,,Z8J( T__dmmL  " "4:: .)3 & #j78 8JfSJ%8%=%C%C%E$Fa |TU*%,,t'9'9:Y[H ==G'G/!::EE )  r5)rrrr;)r8r>r?r@rHrrrrrr3rlrArcrds@r2r r sW E%E DD9>t!15HL! ! r5r cN^\rSrSrSrS\\\44U4SjjrSU4Sjjr Sr U=r $) AtStringStartiPzMatches 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 rc2>[TU]U5 SUlgNFrLr3rr0rrs r2r3AtStringStart.__init__[ !r5cH>US:wa [XS5e[TU] XU5$)Nrznot found at string start)rrLrlr0rrr8rs r2rlAtStringStart.parseImpl_s* !8 0KL Lw  ::r5r=r; r8r>r?r@rHr rrTr3rlrArcrds@r2rrPs("U=##56";;r5rcN^\rSrSrSrS\\\44U4SjjrSU4Sjjr Sr U=r $) AtLineStartiea}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'] rc2>[TU]U5 SUlgrrrs r2r3AtLineStart.__init__|rr5cZ>[X!5S:wa [XS5e[TU] XU5$)Nrznot found at line start)rrrLrlrs r2rlAtLineStart.parseImpls0 s  " 0IJ Jw  ::r5r=r;r rds@r2r r es(,"U=##56";;r5r cH^\rSrSrSrS\\\44U4SjjrSSjr Sr U=r $) FollowedByia'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']] rc2>[TU]U5 SUlgrrLr3rrs r2r3FollowedBy.__init__s "r5cJURRXUS9upEUSS2 X%4$)Nr)rr?)r0rrr8rGr;s r2rlFollowedBy.parseImpls-!!(9!E Fxr5rr;r rds@r2rrs(,#U=##56#r5rcl^\rSrSrSrSS\\\4S\R\ 4U4Sjjjr S Sjr Sr U=r$) PrecededByiaHLookbehind 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 rretreatc>[TU]U5 UR5R5UlSUlSUlSUl[U[5(a.[R"[U5n[U5nSUlO[U[[45(aURnSUlOa[U[ ["45(a(UR$[&:waUR$nSUlO[U[(5(a SnSUlX lS[U5-UlSUlUR0R3S5 g)NTFrznot preceded by c8UR[SS55$r-) __delitem__r<rrrs r2r%PrecededBy.__init__..s eD$>O0Pr5)rLr3rrUrr rrzr&rrrTrerrrrrcrrErrrrrr)r0rrrs r2r3PrecededBy.__init__s IIK002 "" dH % %;;sD)D$iGDJ w0 1 1mmGDJ tZ0 1 1dkkX6MkkGDJ m , ,GDJ (3t94 #  PQr5c0UR(aSX R:a[XUR5eX R- nURR X5upVX&4$UR[ 5-nU[SX R- 5Un[XUR5n [S[X RS-5S-5H&n UR U[U5U - 5upV X&4$ U e![a n U n Sn A M>Sn A ff=fr) rrrrrr?rrrRrrer) r0rrr8rrGr; test_exprinstring_slice last_exproffsetrs r2rlPrecededBy.parseImpls ::\\!$XDKK@@,,&EYY%%h6FA$x IK/I%c!S<<-?&@3GN&xdkkBI3sLL1,<#=#AB&--&N(;f(DFA xC  *$ #I$s C>> DDD)rrrr rrrr-)rT)r8r>r?r@rHr rrTrrrr3rlrArcrds@r2rrsJ<PTR-,-R8>8LRR4r5rc"\rSrSrSrSSjrSrg)Locatediar 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 ```` 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] cUnURRXUSS9up%[XEU/5nXFS'XVS'X&S'UR(aX&/4$X&4$)NFr locn_startrlocn_end)rr?r#r)r0rrr8rrrs r2rlLocated.parseImplshii&&x PU&V !5#"67 #(< $7!$:    $ $? "r5rBNr;)r8r>r?r@rHrlrArBr5r2r'r's 6 #r5r'cV^\rSrSrSrS\\\44U4SjjrS Sjr S\4Sjr Sr U=r $) r4i&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(".") rcz>[TU]U5 SUlSUlS[ UR 5-Ulg)NFTzFound unwanted token, )rLr3rrrTrrrs r2r3NotAny.__init__?s6 $".TYY? r5cvURRXUS9(a[XURU5eU/4$)Nr)rrrrrks r2rlNotAny.parseImplHs5 99 # #Hi # H  TB BBwr5r`c8S[UR5-S-$)Nz~{rrTrr5s r2rlNotAny._generateDefaultNameMsc$))n$s**r5)rrrr;) r8r>r?r@rHr rrTr3rlrlrArcrds@r2r4r4&s60@U=##56@ +c++r5r4c ^\rSrSrS SS.S\\\4S\R\\\4S\R\\\44U4Sjjjjr S\4S jr SS jr SU4S jjr S r U=r$)r?iQNr@rrCr@c>[TU]U5 U=(d UnSUlUn[U[5(aUR U5nUR U5 gr)rLr3rrzr&rr@)r0rrCr@enderrs r2r3_MultipleMatch.__init__RsQ "7 eX & &,,U3E Er5r`cz[U[5(aURU5nUb U)UlU$SUlU$r-)rzr&r not_ender)r0r7s r2r@_MultipleMatch.stopOnas@ eX & &,,U3E#(#4% ;? r5cURRnURnURSLnU(aURRnU(aW"X5 U"XU5up(UR (n U(aW"X5 U (a U"X5n OUn U"XU5up+X- nM2![ [4a X(4$f=fr-)rr?rar:rr rrx) r0rrr8self_expr_parseself_skip_ignorables check_ender try_not_enderrhasIgnoreExprsr tmptokenss r2rl_MultipleMatch.parseImplgs))**#33nnD0  NN44M  ( (%hY?  %)%5%5!5N!(0!1(@F F!09!M# +  { s)AB,,CCc >[R(a[RUR;aUR/URR 5-Hn[ U[5(dMUR(dM-[RUR;dMM[R"SRSU[U5RUR5SS9 M [TU]=X5$r)rSrbrlrrrrzrrrrVrrr8rLr+rs r2r+_MultipleMatch._setResultsNames  > >EE**+ii[499#4#4#66q-00 #MM//0MMEEKVG  J//MM F $% 7$w&t<r?r@r rTrrrr3r@rlr+rArcrds@r2r?r?Qs?C  >B C&' }c'9!:;  mS&8 9:  } 8==r5r?c&\rSrSrSrS\4SjrSrg)ria- 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() r`c8S[UR5-S-$)Nrz}...r2r5s r2rlOneOrMore._generateDefaultNameS^#f,,r5rBN)r8r>r?r@rHrTrlrArBr5r2rrs6-c-r5rc ^\rSrSrSrS SS.S\\\4S\R\\\4S\R\\\44U4Sjjjjr SU4S jjr S \4S jr S r U=r$)riaP 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` Nr5rrCr@c@>[TU]X=(d US9 SUlg)Nr5Tr)r0rrCr@rs r2r3ZeroOrMore.__init__s" &78"r5c~>[TU]XU5$![[4a U[ /UR S94s$f=f)Nrx)rLrlrrxr#rrs r2rlZeroOrMore.parseImplsI @7$XI> > + @ Rd.>.>?? ? @s &<<r`c8S[UR5-S-$)Nrz]...r2r5s r2rlZeroOrMore._generateDefaultNamerIr5rr-r;)r8r>r?r@rHr rTrrrr3rlrlrArcrds@r2rrs  ?C# >B #C&'#}c'9!:;# mS&8 9: ##@ -c--r5rc^\rSrSrSSS.S\\\4S\\\4S\S\R\ S\R\ S \4 U4S jjjjr S \4S jr S r U=r$) DelimitedListiF)allow_trailing_delimrdelimcombinerrrSc>[U[5(a[RU5n[R "[U5nUbUS:a [ S5eUbUbXT:a [ S5eXl[U5Ul X l X0l U(d[U5Ul U=(d SUl XPlX`lURURUR-URS- URcSOURS- 4--nUR(aU[!UR5- nUR(a [#U5n[$TU]MUSS9 g)aHelper 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'] Nrzmin must be greater than 0z)max must be greater than, or equal to minTrh)rzr&rrrrrcontentrT raw_delimrTrUrKrrrSrCombinerLr3) r0rrTrUrrrSdelim_list_exprrs r2r3DelimitedList.__init__s+6 dH % % 44T:D{{=$/ ?Qw !=>> ?39 !LMM U  !%DJ8!$8!,,$**t||*C HHqLHH$D$((Q,H *    $ $ s4:: .O <<%o6O 48r5r`cjSRURR5UR5$)Nz{0} [{1} {0}]...)rrWrrXr5s r2rl"DelimitedList._generateDefaultNames&!(()@)@)BDNNSSr5)rSrUrWrTrrrX)rFNN)r8r>r?r@r rTrrrrrr3rlrArcrds@r2rRrRs,/$($( :9&+:9C&':9S-'(:9 :9 __S ! :9 __S ! :9#:9:9xTcTTr5rRc \rSrSrSrSrSrg) _NullTokeni!cgrrBr5s r2__bool___NullToken.__bool__"sr5cgrrBr5s r2ry_NullToken.__str__%sr5rBN)r8r>r?r@raryrArBr5r2r_r_!s r5r_cn^\rSrSrSr\"5r\4S\\\ 4S\ 4U4Sjjjr S Sjr S\ 4Sjr S rU=r$) ri)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) rdefaultcr>[TU]USS9 URRUlX lSUlg)NFrhT)rLr3rr defaultValuer)r0rrfrs r2r3 Opt.__init__Ss6 .))..#"r5cURnURXUSS9up%X%4$![[4aT URnX`R La3UR (a[U/5nXeUR 'O U/nX%4$/nX%4$f=f)NFr)rr?rrxrh_Opt__optionalNotMatchedrr#)r0rrr8 self_exprr default_values r2rl Opt.parseImpl[sII  #**8)RW*XKC{ +  --M$=$==(()=/:F4A9001+_F{{ s$ABBBr`c[UR5n[U5S:aFUSS[U5S- 2S:Xa.USSn[U5S:aUSS[U5S- 2S:XaM.SU-S-$)Nrrr$rrr9)rTrrer%s r2rlOpt._generateDefaultNameksyDII%j1nq':CJN':!;t!C!BKE%j1nq':CJN':!;t!CU{S  r5)rhrrr;)r8r>r?r@rHr_rkr rrTrr3rlrlrArcrds@r2rr)sS%N&<?S#-,-#8;## !c!!r5rc^\rSrSrSrS SS.S\\\4S\S\ R\\\4S\ R\\\4S \ R\\\44 U4S jjjjr SS jr S r U=r$)riva_ 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)failOnrincluder_fail_onrrc6>[TU]U5 U=(d UnUbURU5 SUlSUlX lSUl[U[5(aURU5Ul OXPl S[UR5-Ul g)NTFzNo match found for )rLr3r_rr  includeMatchrrzr&rrrrTrr)r0rrsr_rtrrrs r2r3SkipTo.__init__s "7   KK ""# fh ' '226:DK K+c$))n< r5cUn[U5nURRnURbURROSnUR (a UR OSnUn X::a&UbU"X5(aO,UbU"X5n U"XSSS9 O[XURU5eU nXUn [U 5n UR(aU"XUSS9up,X- n X+4$![[4a U S- n Of=fX::aMNm)NF)r8r9rr) rerr?rrrHrrhrrxrr#rv) r0rrr8rrfr=self_failOn_canParseNext self_preParsetmplocskiptext skipresultrs r2rlSkipTo.parseImplsx=))**(, (?DKK $ $T !*.):):   '3+H==(&x8 EPUV ! TB BS)!(+   &xieTHC  J)#J/ !   s CC76C7)rrrrvr rr)FNNr;)r8r>r?r@rHr rrTrrrr3rlrArcrds@r2rrvs;@=A>B =>B=]C'(==mS&8 9: = }c'9!:; =mS&8 9:==.**r5rcH^\rSrSrSrSS\R \\\ 44U4Sjjjr SSjr SSjr SU4Sjjr S rSU4S jjrSS \S\4S jjrSS \S\4S jjrS\4SjrSSSjjrS\ 4SjrS\4U4SjjrSU4Sjjr\"\5S5r\"\5S5rSrU=r$)ria3 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``. rch>[R"SS9SUl[TU]USS9 SUlg)NrnrrFrh)rr caller_framerLr3 lshift_liners r2r3Forward.__init__s5%33![R"SS9Sn[R(aBX R:Xa3[ RUR ;a[R"SSS9 [TU])U5nU$)NrnrrzURc[R(a~[RUR;a`Sn[ R "SS9n[[U5SS9HupgURU;dMUS-n O Sn[R"SUS9 [R(d[TU]=XU5$[R  [R"n XX4up[%U [&5(aU eXR)54sSSS5 $![*Ga X S 4n X S 4n US- [-XS U54=upX'U(aXX'[TU]=XS 5unnO)![,a [%U[&5(aeXnnOf=fX::aOU(a*X=upX'X X XR)54ssSSS5 $X XR)54ssSSS5 $U(a1[TU]=XS 5X'O![,anUU4=X'X'eSnAff=fUU4=upX'Mf=f!,(df  g=f) N)rrrrrr)rrnzGForward expression was never assigned a value, will not parse any inputrTFz#Forward recursion without base case)rrSrdrlrrrrreversedr\rrVrrrLrlrBrrzryr%KeyErrorr)r0rrr8 parse_fnsrrfrmrmemoprev_loc prev_resultact_keypeek_key prev_peeknew_locnew_peekr]rs r2rlForward.parseImplSsz II ::==**+I ((s3B#HRL:88y(!"QJ;  MMY% 447$XI> >( ) ) 00D- Q(,$-A(B%k955%%!1!1!33* )' Qd+u-!G" 'Ld8#dn $(NDM@,1G,=hU,S))@%i;;!,4 @ *$FJ]R1HDN $ #+-=-=-?#??I* )J!N')999M* )R%&050A(QU0V #1&BI1 M %&@G?PP+dn5' Q* )s~H5)/D""9H2E0/H20#FH2F.H2H5H2"H5-H25HH2 H" HH""H22H55 IrNcSUlU$rrPrQs r2rUForward.leave_whitespaces# r5cSUlU$rrPrQs r2rRForward.ignore_whitespaces" r5cUR(d.SUlURbURR5 U$r)r rrr5s r2rForward.streamlines2#D yy$ $$& r5c[R"S[SS9 Uc/nX;a1USSU/-nURbURR U5 UR /5 grrrs r2rForward.validatese h   M  $"dV+Cyy$ ""3' R r5cSUlSnURb[UR5SSnOSnURRS-U-$!URRS-U-s s$=f)Nz: ...rPiNoner)rrrTrr8)r0 retStrings r2rlForward._generateDefaultNamesn#  >yy$ N5D1 " >>**T1I= =4>>**T1I= =s (AA0cZ>URb[TU] 5$[5nX-nU$r-)rrLr%r)r0r;rs r2r% Forward.copys, 99 7<> !)C LCJr5c >[R(ad[RUR;aFURc9[ R "SRSU[U5R5SS9 [TU]-X5$)NzO{}: setting results name {!r} on {} expression that has no contained expressionrcr'r) rSrcrlrrrrVrrr8rLr+)r0r\r)rs r2r+Forward._setResultsNamesr  3 3::**+yy  77=v8$T @S@S8 ! w&t>>r5cgr-rBr5s r2r!Forward.leaveWhitespacerr5cgr-rBr5s r2rForward.ignoreWhitespacerr5) rrrrr rrrr r-)r`rr:r;r_r9)r8r>r?r@rHrrr rrTr3rrr rrlrrUrRrrrlr%r+r!r!rrArcrds@r2rrs8 fooeM34F.GH  ,  ]Q~$-4=M ! >c >m?&&'"("'(#)#r5rcB^\rSrSrSrSS\\\44U4SjjjrSr U=r $)TokenConverterizO Abstract subclass of :class:`ParseExpression`, for converting parsed results. rc2>[TU]U5 SUlgr)rLr3rr0rrrs r2r3TokenConverter.__init__s r5r4r9) r8r>r?r@rHr rrTr3rArcrds@r2rrs# U=##56  r5rc ^\rSrSrSrSSS.S\S\S\S\R\4U4S jjjjr S \4U4S jjr S r S r U=r$)rYi aConverter 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) joinStringr join_stringadjacentrc>[TU]U5 UbUOUnU(aUR5 X0lSUlX@lSUlgr)rLr3rUrrrr)r0rrrrrs r2r3Combine.__init__sG #-#9Z{   ! ! # "$ r5r`cv>UR(a[RX5 U$[TU] U5 U$r-)rrr_rLrs r2r_Combine.ignore0s2 ==   -  GN5 ! r5cUR5nUSS2 U[SRURUR55/UR S9- nUR (aUR5(aU/$U$)Nr)rw)r%r#r _asStringListrrrhaskeys)r0rrrqretTokss r2rrCombine.postParse7sp.." AJ< WWY,,T__= > ?tGXGX      1 19 Nr5)rrrr)rT)r8r>r?r@rHrrTrrrr3r_rrrArcrds@r2rYrY si* ! ,0 !!! ! OOC( !!$}  r5rYcB^\rSrSrSrSS\S\4U4SjjjrSrSr U=r $) riDa`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']] raslistc>>[TU]U5 SUlX lgr)rLr3r _asPythonList)r0rrrs r2r3Group.__init__Y #r5cUR(aH[R"[U[5(aUR 55$[ U55$U/$r-)rr#rrzrvrrps r2rrGroup.postParse^sV   $$i66  " )_  ; r5)rrr9 r8r>r?r@rHrrr3rrrArcrds@r2rrDs*($]$D$$ r5rcB^\rSrSrSrSS\S\4U4SjjjrSrSr U=r $) rCiiaConverter 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. rasdictc>>[TU]U5 SUlX lgr)rLr3r _asPythonDict)r0rrrs r2r3 Dict.__init__rr5c,[U5GHupE[U5S:XaMUSn[U[5(a[ U5R 5n[U5S:Xa[ SU5X6'Mi[U5S:Xa+[US[5(d[ USU5X6'MUR5nUS [U5S:wd*[U[5(a$UR5(a[ Xt5X6'M[ USU5X6'GM UR(a2UR(aUR5/$UR5$UR(aU/$U$![a [S5nUSef=f)Nrrrrnzdcould not extract dict values from parsed results - Dict expression must contain Grouped expressions)rrerzrrTrr$r#r%ryrrrras_dict) r0rrrqrtokikey dictvaluers r2rrDict.postParses_ *FA3x1}q6D$$$4y(3x1}"9"a"@ SQz#a&,'G'G"9#a&!"D ( # IaLy>Q&y,77IUSLa[[55n[TU] U5 g)N.)rr;rLr3rs r2r3Suppress.__init__s# 3; *D r5r`c>[UR[5(a[[ U55U-$[ TU]U5$r-)rzrrrKrrLrrs r2rSuppress.__add__7 dii . .F5M*U2 27?5) )r5c>[UR[5(a[[ U55U- $[ TU]U5$r-)rzrrrKrrLrrs r2rSuppress.__sub__rr5c/$r-rBrps r2rrSuppress.postParserr5cU$r-rBr5s r2rLSuppress.suppresss r5rBr9r:)r8r>r?r@rHr rrTrr3rrrrrLrArcrds@r2rKrKsJ<U=##56$ * * -r5rKrcL^[T5mU4SjnTRUlU$)a3Decorator for debugging parse actions. When the parse action is called, this decorator will print ``">> entering method-name(line:, , )"``. 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'], {})) <TRnUSSup#n[U5S:aUSRRS-U-n[RR SUS[ X25<SUSU<S3 5 T"U6n[RR S US U<S35 U$![a,n[RR S US US35 eSnAff=f) Nr'r.z >>entering z(line: rz) z <.zs::+a v;?ay**33c9HDH ;xjQ ~Rs"QEQTUV V*C :hZwsgSAB   JJ  z(=SI J  s<B** C 4'CC )rr8)rrs` r2trace_parse_actionrs%2 AA AJ Hr5empty line_startline_end string_start string_endz\\[\\[\]\/\-\*\.\$\+\^\?()~ ]cUSS$rrBrs r2rr,s AaDGr5z\\0?[xX][0-9a-fA-F]+cP[[USRS5S55$)Nrz\0xr)chrrrrs r2rr/sCAaDKK/45r5z \\0[0-7]+c8[[USSSS55$)Nrrr()rrrs r2rr2sCAaDHa()r5z\])rrrrnegatebodyr9rc^SmSRU4Sj[RU5R55$![a nSnAgSnAff=f)aHelper 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 [U[5(dU$SRS[[ US5[ US5S-555$)Nrc38# UHn[U5v M g7fr-)rrs r2r+srange....]sE%DSVV%DrHrr)rzr#rrRord)ps r2rsrange..[sM!\**F WWEU3qt9c!A$i!m%DE EFr5rc34># UH nT"U5v M g7fr-rB)rPpart _expandeds r2rsrange..`sW3V4y3VsN)r_reBracketExprrrry)rr]rs @r2sranger @sL6 F wwW>3N3Nq3Q3V3VWWW s7> A Acf^^UU4Sjn[TS[TS5R5nX2lU$)aHelper 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'] cB>UVs/sH nT"U/TQ76PM sn$s snfr-rB)rrrtoknrr1s r2rtoken_map..pas%./0adT!D!a000sr8r)rr8)r1rrrs`` r2 token_mapres0J1j'$ *D*M*MNIK Ir5cP[R"5RnUcg[R"[ R U5nURR5H@up[U[5(dMUR(aM/URU5 MB g)zm Utility to simplify mass-naming of parser elements, for generating railroad diagram with named subdiagrams. N) r _getframef_backrrtypes FrameTypef_localsr!rzrrrs) calling_framer\vars r2autoname_elementsrsn MMO**MKK?M"++113  c= ) )#... LL 4r5z4"(?:[^"\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 quoteszdouble quoted stringzsingle quoted stringz+quoted string using single or double quotesz""""(?:[^"\\]|""(?!")|"(?!"")|\\.)*rMz"""zmultiline double quoted stringz"'''(?:[^'\\]|''(?!')|'(?!'')|\\.)*z'''zmultiline single quoted stringz5"(?:[^"\n\r\\]|(?:\\")|(?:\\(?:[^x]|x[0-9a-fA-F]+)))*z5'(?:[^'\n\r\\]|(?:\\')|(?:\\(?:[^x]|x[0-9a-fA-F]+)))*zPython quoted stringuzunicode string literalz#[\0xc0-\0xd6\0xd8-\0xf6\0xf8-\0xff]z[\0xa1-\0xbf\0xd7\0xf7]rcgr-rBrBr5r2nullDebugActionrr2r5cgr-rBrBr5r2traceParseActionrrr5cgr-rBrBr5r2conditionAsParseActionr!rr5cgr-rBrBr5r2tokenMapr#sr5r_)r'rr9) collectionsrosrrrrrrr r r r r rabcrrenumrstringr%rrrcollections.abcrrroperatorr functoolsr threadingrpathlibrutilrrrrrrrrrr rr! exceptionsactionsrr#r$unicoder%maxsizerErTbytesr&rr version_infor)rDrSrlrvryr]rrr warnoptionsenvironrKsumrerrrrrrrJrrr GeneratorTyperrParseImplReturnTypePostParseReturnTyper?r@ryrArrrascii_uppercaseascii_lowercasealphasLatin1 identcharsidentbodycharsnumshexnumsrr printable whitespacerr StackSummaryrrrrrrrrrfr;rrrzrrrrrrrrr6rcrrrrrrrrrrrrr&rr-rr rr rrr'r4r?rrrRr_rrrrrYrrCrKrrsrrrrrrN _escapedPunc_escapedHexChar_escapedOctChar _singleChar _charRanger,r r rrdbl_quoted_stringsgl_quoted_stringrrSpython_quoted_stringunicode_string alphas8bitpunc8bitrvaluesrzrsglQuotedStringdblQuotedString quotedString unicodeString lineStartlineEnd stringStart stringEndrrr!r#)rxr$s00r2rZs       $  $    :& ;;!5\%c )4v).~,*$*D$;$4$%K%D%#!??3/?Es?S "OORZZ^^$@A     $$CHoL(<*@@A RW l^S ! c< # %& c3 %s *+-  RX l^T !" c< $ &' c3 %t +,. CoyA4GHS#=tCD#sO\48$> c?It Ld RS   &"8"8 8  % % 0 0 "))88   TM WW!1!1P!1Af>O>O5Oa!1P Q 04y--46tMR!'!5EI:GL   #2 ?C & @ @ @  @  @  @  @" UU U U  U  URMCMb<& =& R #M # ?e ?2?e2?jG"??%, !s7es7l?g?6BgB2T?T?n|#5|#~ 4 ,X)EX)vJ5JZM(M(`J(EJ(Z#E#>,? ,?^CmC.-"C C( 4m6i$mi$Z`!/`!F]=]=@q=q=hkB?kB\j$-j$\= '= @;';*;%;B!$!HO$Od'#!'#T(+ (+VJ=(J=Z--@--D>T'>TBG! G!T  DE$!E$R ( 6n6r"N"JTB>TBn4~4n* +* +* \ ! [ ! !, / 9  j )}%%n5 [ ! !, / 56GG /0AA5 %66)?"_4z%q7QQ ;#.< =  CL #h)* Ij;. /0AA&IJcl"c"c"J+k+\  ABSH ( -. ABSH ( -. BCcISS DEKUU ( 89 0 EMWW( 32<<H5Ph/0 1  EFLVV  EFLVV   ( !"}11334==>VW: ; , - v}}'!*Q ">A']# $#     #$%$%&+,!-!)uvQBv's<a:a: a? a?