Files
intellecton/venv/lib/python3.12/site-packages/pyparsing/__pycache__/helpers.cpython-312.pyc
T

634 lines
48 KiB
Plaintext
Raw Normal View History

Ë
vRjA£ãóÄUddlZddlZddlZddlZddlZddlmZddl­ddl m
Z
m Z m Z m
Z
mZdeeefdefdZ d\ded ej&edefd
Zdedefd Zdedefd Z d]deej.eefdedededef
dZdededefdZ d^dededefdZdedefdZdedefdZe«Z ddde fdeeefdeeefdej&ed ej&edef
d!„Z!e"d"«e"d#«fd$„Z#d%eeefde$eeffd&„Z%d%eeefde$eeffd'„Z&ee'd(<ee'd)<e%e(e)e*d*z«jWd+««\Z,Z-ej\j^ja«Dcic]\}}|jcd,«|Œc}}Z2d-jgd.d/«Z4e5d0„«jWd1«Z6d2„Z7Gd3„d4e8«Z9eeee$eeefeeefffZ:ee$e:e;e9ej&e<fe$e:e;e9ffZ=e"d«e"d«fd5ed6e>e=d7eeefd8eeefde?f
d9„Z@dgfd:„ZAe5d;«jWd<«ZB e5d=«jWd>«ZC e5d?«j‰«jWd@«ZEe5dA«jWdB«ZF e5dC«jWdD«ZG eGZH e5dE«jWdF«ZI eJ«j—«Dcgc]}eL|e«sŒ
|Œc}ZMe>ee'dG< d_d
dHœdeeefdIeeefdJedKej&e;dLej&e;dMedefdN„ZNe9ZOe,ZPe-ZQe6ZReBZSeCZTeEZUeFZVeGZWeHZXeIZYedOeZ«Z[edPeZ«ZNedQe«Z\edRe«Z]edSe«Z^edTe«Z_edUe«Z`edVe«ZaedWe!«ZbedXe%«ZcedYe&«ZdedZe7«Zeed[e@«Zfycc}}wcc}w)`é)Ú__diag__)Ú*)Ú_bslashÚ_flattenÚ_escape_regex_range_charsÚmake_compressed_reÚreplaced_by_pep8ÚexprÚreturncó<t|t«r|St|«S©N)Ú
isinstanceÚSuppress©r s úT/home/antigravity/intellecton/venv/lib/python3.12/site-packages/pyparsing/helpers.pyÚ _suppressionrsäÔˆ Ü DóÚint_exprc ó(t|dd«}|xs|}t«Šˆˆfd}|€ tt«j d«}n|j «}|j
d«|j|d¬«|zj
dd «S)
a$Helper to define a counted list of expressions.
This helper defines a pattern of the form::
integer expr expr expr...
where the leading integer tells how many expr expressions follow.
The matched tokens returns the array of expr tokens as a list - the
leading count token is suppressed.
If ``int_expr`` is specified, it should be a pyparsing expression
that produces an integer value.
Examples:
.. doctest::
>>> counted_array(Word(alphas)).parse_string('2 ab cd ef')
ParseResults(['ab', 'cd'], {})
- In this parser, the leading integer value is given in binary,
'10' indicating that 2 values are in the array:
.. doctest::
>>> binary_constant = Word('01').set_parse_action(lambda t: int(t[0], 2))
>>> counted_array(Word(alphas), int_expr=binary_constant
... ).parse_string('10 ab cd ef')
ParseResults(['ab', 'cd'], {})
- If other fields must be parsed after the count but before the
list items, give the fields results names and they will
be preserved in the returned ParseResults:
.. doctest::
>>> ppc = pyparsing.common
>>> count_with_metadata = ppc.integer + Word(alphas)("type")
>>> typed_array = counted_array(Word(alphanums),
... int_expr=count_with_metadata)("items")
>>> result = typed_array.parse_string("3 bool True True False")
>>> print(result.dump())
['True', 'True', 'False']
- items: ['True', 'True', 'False']
- type: 'bool'
ÚintExprNcóB|d}|r|zn t«zŠ|dd=y©Nr)ÚEmpty)Ú
array_exprr s €€rÚcount_field_parse_actionz/counted_array.<locals>.count_field_parse_actionUs'ø€à
ˆa‰DˆØ¡Q˜˜qš¬E«GÑ
à
Ša‰Drcót|d«Sr)Úint©rs rú<lambda>zcounted_array.<locals>.<lambda>]s¼¸A¸a¹D» €rÚarrayLenT©Úcall_during_tryz(len) z...)Údeprecate_argumentÚForwardÚWordÚnumsÚset_parse_actionÚcopyÚset_nameÚadd_parse_action)r rÚkwargsrr rs` @rÚ
counted_arrayr1s˜ù€ôb/AØ ˜4ó/€GðÒ€GÜ€JõðÜ”t“*×-Ñ.AÓB‰à—,‘,“.ˆØ ×Ñ Ø ×ÑÐ5ÀtÐÔ  × *¨V°D°6¸Ð+=Ó >rcótt«Šˆfd}|j|d¬«jd|«S)aIHelper to define an expression that is indirectly defined from
the tokens matched in a previous expression, that is, it looks for
a 'repeat' of a previous expression. For example::
.. testcode::
first = Word(nums)
second = match_previous_literal(first)
match_expr = first + ":" + second
will match ``"1:1"``, but not ``"1:2"``. Because this
matches a previous literal, will also match the leading
``"1:1"`` in ``"1:10"``. If this is not desired, use
:class:`match_previous_expr`. Do *not* use with packrat parsing
enabled.
có°|st«zyt|«dk(r ‰|dzyt|j««}t d|D««zy)Nrrc3ó2K|]}t|«Œy­wr)ÚLiteral)Ú.0Útts rú <genexpr>zImatch_previous_literal.<locals>.copy_token_to_repeater.<locals>.<genexpr>ƒsèø€Ò/ 2”7˜2—;Ñ/ùó)rÚlenrÚas_listÚAnd)rrrÚtflatÚreps €rÚcopy_token_to_repeaterz6match_previous_literal.<locals>.copy_token_to_repeaterxsPø€ÙØ ”5“7ŠNØ ä ˆq‹6QŠ;Ø 1Q‘4ŠKØ ô˜ŸÓØ ŒsÑÔ/rTr&ú(prev) )r)r/r.)r r?r>s @rÚmatch_previous_literalrAes?ø€ô" )€Cô  ×ÑÐ0À$ÐÔ‡LL7˜4˜ €Jrcóžt«Š|j«}|zŠˆfd}|j|d¬«jd|«S)afHelper to define an expression that is indirectly defined from
the tokens matched in a previous expression, that is, it looks for
a 'repeat' of a previous expression. For example:
.. testcode::
first = Word(nums)
second = match_previous_expr(first)
match_expr = first + ":" + second
will match ``"1:1"``, but not ``"1:2"``. Because this
matches by expressions, will *not* match the leading ``"1:1"``
in ``"1:10"``; the expressions are evaluated first, and then
compared, so ``"1"`` is compared with ``"10"``. Do *not* use
with packrat parsing enabled.
cójt|j««Šˆfd}j|d¬«y)Ncóht|j««}|k7rt||dd|«y)Nz Expected z, found)rr;ÚParseException)rrrÚ theseTokensÚ matchTokenss €rÚmust_match_these_tokenszTmatch_previous_expr.<locals>.copy_token_to_repeater.<locals>.must_match_these_tokens¢sAø€Ü" 1§9¡9£;Ó/ˆ˜q˜I k ]°'¸+¸Ððð*rTr&)rr;r,)rrrrHrGr>s @€rr?z3match_previous_expr.<locals>.copy_token_to_repeaterŸs.ù€Ü˜qŸy™y›{Ó ô ð ×ÑÐ4ÀdÐÕKrTr&r@)r)r-r/r.)r Úe2r?r>s @rÚmatch_previous_exprrJŠsTø€ô" )€CØ
€B؈BJ€Cô
Lð ×ÑÐ0À$ÐÔ‡LL7˜4˜ €JrFTÚstrsÚcaselessÚ use_regexÚ
as_keywordc óêt|dd«}t|dd«}|xs|}|xr|}t|t«r,tjrt
j
dtd¬«|rd}d „}ntj}d
}t|t«r+tjt|«}|j«} n't|t«r t|«} n t!d «| s
t#«Sd }
|
t%| «d
z
kr‡| |
} t'| |
d
zd«D]W\} }
||
| «r | |
| zd
z=nEt%|
«t%| «kDsŒ2|| |
«sŒ<| |
| zd
z=| j)|
|
«n|
d
z
}
|
t%| «d
z
krŒ‡|rÏ|rt*j,nd } t/d| D««rddj1d| D««d}ndj1d| D««}|rd|d}t3||¬«}|j5dj1d| D«««|r3| Dcic]}|j7«|Œc}Š|j9ˆfd«|Sdx}}||ft<|| ft>| |ft@| | ftBi||fŠtEˆfd| D««j5dj1| ««Scc}w#t*j:$rt
j
dtd¬«YŒ—wxYw)aHelper to quickly define a set of alternative :class:`Literal` s,
and makes sure to do longest-first testing when there is a conflict,
regardless of the input order, but returns
a :class:`MatchFirst` for best performance.
:param strs: a string of space-delimited literals, or a collection of
string literals
:param caseless: treat all literals as caseless
:param use_regex: bool - as an optimization, will
generate a :class:`Regex` object; otherwise, will generate
a :class:`MatchFirst` object (if ``caseless=True`` or
``as_keyword=True``, or if creating a :class:`Regex` raises an exception)
:param as_keyword: bool - enforce :class:`Keyword`-style matching on the
generated expressions
Parameters ``asKeyword`` and ``useRegex`` are retained for pre-PEP8
compatibility, but will be removed in a future release.
Example:
.. testcode::
comp_oper = one_of("< = > <= >= !=")
var = Word(alphas)
number = Word(nums)
term = var | number
comparison_expr = term + comp_oper + term
print(comparison_expr.search_string("B = 12 AA=23 B<=AA AA>12"))
prints:
.. testoutput::
[['B', '=', '12'], ['AA', '=', '23'], ['B', '<=', 'AA'], ['AA', '>', '12']]
ÚuseRegexTÚ asKeywordFz‡warn_on_multiple_string_args_to_oneof: More than one string argument passed to one_of, pass choices as a list or space-delimited stringé©Ú
stacklevelcóD|j«|j«k(Sr)Úupper©Úbs rr$zone_of.<locals>.<lambda>ís §¡£ ¨Q¯W©W«YÑ 6€rcó\|j«j|j««Sr)rVÚ
startswithrWs rr$zone_of.<locals>.<lambda>îs˜QŸW™WY×1°!·'±'³)Ó<€rcó$|j|«Sr)r[rWs rr$zone_of.<locals>.<lambda>ñs˜QŸ\™\¨!_€rz7Invalid argument to one_of, expected string or iterablerrNc3ó8K|]}t|«dk(Œy­w)rN)r:©r6Úsyms rr8zone_of.<locals>.<genexpr>sèø€Ò4 S”3s“8˜q•=Ñ4ùsúc3ó2K|]}t|«Œy­wr)rr^s rr8zone_of.<locals>.<genexpr>sèø€Ò"UÀcÔ#<¸S×#AÑ"Uùr9ú|c3óFK|]}tj|«Œy­wr)ÚreÚescaper^s rr8zone_of.<locals>.<genexpr>sèø€ÒB°3¤§ ¡ ¨#§ÑBùs!z\b(?:z)\b)Úflagsz | c3ó2K|]}t|«Œy­wr)Úrepr)r6rs rr8zone_of.<locals>.<genexpr>sèø€Ò#=°¤D¨§GÑ#=ùr9có0|dj«Sr©Úlower)rrrÚ
symbol_maps €rr$zone_of.<locals>.<lambda>#sø€°ZÀÀ!ÁÇ
Á
à Ñ5M€rz8Exception creating Regex for one_of, building MatchFirstc3ó.K|] }|«Œy­wr©)r6r_Úparse_element_classs €rr8zone_of.<locals>.<genexpr>7søèø€ÒB°3Ñ)¨#×Bùsƒ)#r(rÚstr_typerÚ%warn_on_multiple_string_args_to_oneofÚwarningsÚwarnÚPyparsingDiagnosticWarningÚoperatorÚeqÚtypingÚcastÚstrÚsplitÚIterableÚlistÚ TypeErrorÚNoMatchr:Ú enumerateÚinsertrfÚ
IGNORECASEÚallÚjoinÚRegexr.rmr/ÚerrorÚCaselessKeywordÚCaselessLiteralÚKeywordr5Ú
MatchFirst)rKrLrMrNr0rPrQÚis_equalÚmasksÚsymbolsÚcurÚotherÚre_flagsÚpattÚretr_ÚCASELESSÚKEYWORDrqrns @@rÚone_ofr˜°s ù€ôT°
¸DÓA€Hܰ¸eÓD€IàÒ'˜Z€IØÒ%˜I€Hô 8œXÔ × 
ð

ð ô
ñÙÙ<‰ä—;‘;ˆÙôÔ{‰{œ3 ÓØ—*‘*“,‰Ü Dœ(Ô #Üt“*‰äÐ Ü‹yÐð
€AØ
Œc'l˜Ò
Øa‰jˆÜ! '¨!¨a©%¨'Ð"2Ó ‰HˆAˆ˜˜sÔ˜A ™E A™IÐÜ5zœC ¨s°EÕ):ؘA ™E A™IИq ð ð
‰Fˆ Œc'l˜Ó
ñÙ)1œŸ
š
°qˆð ÜÑ4¨GÔ˜2Ÿ7™7Ñ"UÈWÔ"UÓVÐVWÐXà—xB¸BñØ ˜v SÐ)䘠HÔ-ˆCØ L‰L˜ŸÑ#=°WÔ#=Ó ð;BÖB°3˜cŸi™ik¨3ÑB
Ø×$Ó%MÔˆJðЀHˆwà œ_Ø w¤Ø
ˆ¤Ø
ˆ˜7#¤Wð ð
Ðñ Ðô ÓB¸'Ô B× 
ó ðùò+Cøô
x‰xò Ü M‰MØð
ö
ð ús%Æ B KÈ)J;ÉKÊ;KË/K2Ë1K2ÚkeyÚvaluecóBttt||z«««S)Helper to easily and clearly define a dictionary by specifying
the respective patterns for the key and value. Takes care of
defining the :class:`Dict`, :class:`ZeroOrMore`, and
:class:`Group` tokens in the proper order. The key pattern
can include delimiting markers or punctuation, as long as they are
suppressed, thereby leaving the significant key text. The value
pattern can include named results, so that the :class:`Dict` results
can include named token fields.
Example:
.. doctest::
>>> text = "shape: SQUARE posn: upper left color: light blue texture: burlap"
>>> data_word = Word(alphas)
>>> label = data_word + FollowedBy(':')
>>> attr_expr = (
... label
... + Suppress(':')
... + OneOrMore(data_word, stop_on=label)
... .set_parse_action(' '.join))
>>> print(attr_expr[1, ...].parse_string(text).dump())
['shape', 'SQUARE', 'posn', 'upper left', 'color', 'light blue', 'texture', 'burlap']
>>> attr_label = label
>>> attr_value = Suppress(':') + OneOrMore(data_word, stop_on=label
... ).set_parse_action(' '.join)
# similar to Dict, but simpler call format
>>> result = dict_of(attr_label, attr_value).parse_string(text)
>>> print(result.dump())
[['shape', 'SQUARE'], ['posn', 'upper left'], ['color', 'light blue'], ['texture', 'burlap']]
- color: 'light blue'
- posn: 'upper left'
- shape: 'SQUARE'
- texture: 'burlap'
[0]:
['shape', 'SQUARE']
[1]:
['posn', 'upper left']
[2]:
['color', 'light blue']
[3]:
['texture', 'burlap']
>>> print(result['shape'])
SQUARE
>>> print(result.shape) # object attribute access works too
SQUARE
>>> print(result.as_dict())
{'shape': 'SQUARE', 'posn': 'upper left', 'color': 'light blue', 'texture': 'burlap'}
)ÚDictÚ OneOrMoreÚGroup)r™s rÚdict_ofrŸ<sôl ” œ%   Ó .rÚ as_stringc óJt|dd«}|xr|}t«jd«}|j«}d|_|d«|z|d«z}|rd}nd}|j|«|j
|_|j
tj«|S) a)Helper to return the original, untokenized text for a given
expression. Useful to restore the parsed fields of an HTML start
tag into the raw tag text itself, or to revert separate tokens with
intervening whitespace back to the original matching input text. By
default, returns a string containing the original parsed text.
If the optional ``as_string`` argument is passed as
``False``, then the return value is
a :class:`ParseResults` containing any results names that
were originally matched, and a single token containing the original
matched text from the input string. So if the expression passed to
:class:`original_text_for` contains expressions with defined
results names, you must set ``as_string`` to ``False`` if you
want to preserve those results name values.
The ``asString`` pre-PEP8 argument is retained for compatibility,
but will be removed in a future release.
Example:
.. testcode::
src = "this is test <b> bold <i>text</i> </b> normal text "
for tag in ("b", "i"):
opener, closer = make_html_tags(tag)
patt = original_text_for(opener + ... + closer)
print(patt.search_string(src)[0])
prints:
.. testoutput::
['<b> bold <i>text</i> </b>']
['<i>text</i>']
ÚasStringTcó|Srrp)rÚlocrs rr$z#original_text_for.<locals>.<lambda>Ÿs¸3€r_original_startÚ
_original_endcó4||j|jSr)©rrrs rr$z#original_text_for.<locals>.<lambda>¤s ×(9Ñ(9¸A¿O¹OÐ&L€rcóR||jd«|jd«g|ddy)Nr¥©Úpopr¨s rÚ extractTextz&original_text_for.<locals>.extractText§s(Øa—e‘eз±°Ó1GÐIˆA‰a‰Dr) r(rr,r-Ú callPreparseÚ ignoreExprsÚsuppress_warningÚ DiagnosticsÚ)warn_ungrouped_named_tokens_in_collection)r r r0Ú locMarkerÚ endlocMarkerÚ matchExprr¬s rÚoriginal_text_forrµuôL°
¸DÓA€HàÒ%˜I€Hä×(Ñ)>Ó?€IØ—>#€LØ %€LÔÙÐ,¨tÑ3±lÀ?Ó6SÑS€IÙÙL‰ ò Jð×ј{Ô ×,€IÔØ
×Ñœ{× Ðrcó8t|«jd«S)zkHelper to undo pyparsing's default grouping of And expressions,
even if all but one are non-empty.
có |dSrrpr#s rr$zungroup.<locals>.<lambda>´s
¸1¸Q¹4€r)ÚTokenConverterr/rs rÚungroupr¹°sô ˜$Ó × Ó @rcóötjdddtd¬«t«j d«}t |d«|d«z|j
«j«d «z«S)
a\
.. deprecated:: 3.0.0
Use the :class:`Located` class instead. Note that `Located`
returns results with one less grouping level.
Helper to decorate a returned token with its starting and ending
locations in the input string.
This helper adds the following results names:
- ``locn_start`` - location where matched expression begins
- ``locn_end`` - location where matched expression ends
- ``value`` - the actual parsed results
Be careful if the input text contains ``<TAB>`` characters, you
may want to call :meth:`ParserElement.parse_with_tabs`
Ú locatedExprú deprecated - use ÚLocatedrRrScó|Srrp)ÚssÚllr7s rr$zlocatedExpr.<locals>.<lambda>Ïs¸"€rÚ
locn_startršÚlocn_end)rtruÚPyparsingDeprecationWarningrr,r-Úleave_whitespace)r Úlocators r·sô$
‡M Ð
Ð-¨i¨]Ððôô g×&Ñ'<Ó=€GÜ Ù ÓÙ
ˆw à
+ˆ',‰,.×
+¨JÓ
 ðrúopenerÚcloserÚcontentÚ ignore_exprc óþt|dt«}||k7r |tur|n|}|tur
t«}||k(r td«|€£t |t
«ret |t
«rTt
jt|«}t
jt|«}t|«dk(r|t|«dk(rn|8tt|t||ztjzd¬«z««}nÕtt«t||ztjz«z«}n¡|Ltt|t!|«zt!|«zttjd¬«z««}nSttt!|«t!|«zttjd¬«z««}n td«tjr|j#d«t%«}|6|t't)|«t+||z|z«zt)|«z«z}n2|t't)|«t+||z«zt)|«z«z}|j-d||d «d|_|S)
a
Helper method for defining nested lists enclosed in opening and
closing delimiters (``"("`` and ``")"`` are the default).
:param opener: str - opening character for a nested list
(default= ``"("``); can also be a pyparsing expression
:param closer: str - closing character for a nested list
(default= ``")"``); can also be a pyparsing expression
:param content: expression for items within the nested lists
:param ignore_expr: expression for ignoring opening and closing delimiters
(default = :class:`quoted_string`)
Parameter ``ignoreExpr`` is retained for compatibility
but will be removed in a future release.
If an expression is not provided for the content argument, the
nested expression will capture all whitespace-delimited content
between delimiters as a list of separate values.
Use the ``ignore_expr`` argument to define expressions that may
contain opening or closing characters that should not be treated as
opening or closing characters for nesting, such as quoted_string or
a comment expression. Specify multiple expressions using an
:class:`Or` or :class:`MatchFirst`. The default is
:class:`quoted_string`, but if no expressions are to be ignored, then
pass ``None`` for this argument.
Example:
.. testcode::
data_type = one_of("void int short long char float double")
decl_data_type = Combine(data_type + Opt(Word('*')))
ident = Word(alphas+'_', alphanums+'_')
number = pyparsing_common.number
arg = Group(decl_data_type + ident)
LPAR, RPAR = map(Suppress, "()")
code_body = nested_expr('{', '}', ignore_expr=(quoted_string | c_style_comment))
c_function = (decl_data_type("type")
+ ident("name")
+ LPAR + Opt(DelimitedList(arg), [])("args") + RPAR
+ code_body("body"))
c_function.ignore(c_style_comment)
source_code = '''
int is_odd(int x) {
return (x%2);
}
int dec_to_hex(char hchar) {
if (hchar >= '0' && hchar <= '9') {
return (ord(hchar)-ord('0'));
} else {
return (10+ord(hchar)-ord('A'));
}
}
'''
for func in c_function.search_string(source_code):
print(f"{func.name} ({func.type}) args: {func.args}")
prints:
.. testoutput::
is_odd (int) args: [['int', 'x']]
dec_to_hex (int) args: [['char', 'hchar']]
Ú
ignoreExprz.opening and closing strings cannot be the sameNr)ÚexactzOopening and closing arguments must be strings if no content expression is givencóF|djtj«Sr)ÚstripÚ
ParserElementÚDEFAULT_WHITE_CHARSr#s rr$znested_expr.<locals>.<lambda>hs˜!˜A™$Ÿ*™*¤]×%FÑ%FÓG€rznested z expression)r(Ú_NO_IGNORE_EXPR_GIVENÚ
quoted_stringÚ
ValueErrorrrrryrzr{r:ÚCombinerÚ
CharsNotInrÑrr5r,r)rÚ
ZeroOrMorer.Úerrmsg)r0r•s rÚ nested_exprrÚÜsô^!3Ø Ô!€Jð Ø$.Ô2GÑ$G[ÈZˆ
àÔ"“_ˆ
à
ÒÜÐÜ fœhÕ '¬J°v¼xÕ,HÜ—[ fÓ-ˆFÜ—[‘[¤ fÓ-ˆFÜ6‹{˜aÒ¤C¨£K°1Ò$4ØÐ'˜(Ø &¨¡´-×2SÑ2SÑ SØ&'ôñóó‘GôÜ" V™O¬m×.OÑ.OÑñó‘GðÐ'˜& vÐ& vÐ×)JÑ)JÐRSÔUóó$ V& vÐ×)JÑ)JÐRSÔUóó‘GôØð
ô
× × 
ô ‹)€CØÐØ Ü ˜Ó ܘ cÑ)¨GÑ
˜

ñ
ð Ü ˜Ó ¤:¨c°G©mÓ#<Ñ <¼|ÈFÓ?SÑ 
ñ
ˆð‡LL7˜6˜( 6 (¨+ЀC„JØ €Jrú>c
óŽt|t«r|Št|| ¬«}n |jŠt t
t dz«}|rˆtj«jt«}||d«zttt|td«z|z«««ztddg¬«d«jd „«z|z}n²t j«jt«t t"d
¬ «z}||d«zttt|jd «ttd«|z«z«««ztddg¬«d«jd
«z|z}t%t'd«|zd
zd¬«}|j)dd
«|j+ˆfd«|ddj-j/dd«j1«j3««z«j)dd
«}|_|_t7|««|_||fS)zVInternal helper to construct opening and closing tag expressions,
given a tag name)rLz_-:Útagú/F)ÚdefaultÚemptycó|ddk(S©Nrrps rr$z_makeTags.<locals>.<lambda>ó  ¨¡ r)Ú
exclude_charscó(|dj«Srrlr#s rr$z_makeTags.<locals>.<lambda>s¸¹t¿z¹z»|€rcó|ddk(Srps rr$z_makeTags.<locals>.<lambda>£rz</)ÚadjacentrÛc óÀ|jddjjdd«j«j ««z|j ««S)startraú )Ú __setitem__r…ÚreplaceÚtitler|r-)rÚresnames €rr$z_makeTags.<locals>.<lambda>¬sFø€!—- b—g‘g˜gŸo™o¨c°3Ó?× HÈ!Ï&É&Ë(ó
rÚendra)rrrÚnamer*ÚalphasÚ alphanumsÚdbl_quoted_stringr-r,Ú
remove_quotesrœrÚOptrÔÚ
printablesrÖr5r.r/r…r|ÚSkipToÚtag_body) ÚtagStrÚxmlÚ suppress_LTÚ suppress_GTÚ tagAttrNameÚ tagAttrValueÚopenTagÚcloseTagrñs @rÚ _makeTagsr~s9ø€ô&œ(Ԉܘ¨c¨'Ô2‰à—+‘+ˆä”vœy¨5Ñ1€KÙ
ÜÓ à ÙU‹mñ
ä”:œe K´(¸3³-Ñ$?À,Ñ$NÓ
Rð(Œc# ˜Ó0×ñ
ð ñ

ñ ô%×+×<¼]ÓKÌdÜ  O
ñ
ˆ ð
ÙU
äÜÜØ4Ñ5KÓœh sm¨lÑóóñ
ð(Œc# ˜Ó0×ñ
ðñ
ð ô ”w˜t“} vÑÑ3¸eÔD€Hà ×ј   ×Ñó
ôñ
Ø
˜Ÿ¨¨SÓçhG9˜AˆÓð
ð€G„KØ€H„LÜ™h›jÓ)€GÔØ  ÐrÚtag_strcót|d«S)alHelper to construct opening and closing tag expressions for HTML,
given a tag name. Matches tags in either upper or lower case,
attributes with namespaces and with quoted or unquoted values.
Example:
.. testcode::
text = '<td>More info at the <a href="https://github.com/pyparsing/pyparsing/wiki">pyparsing</a> wiki page</td>'
# make_html_tags returns pyparsing expressions for the opening and
# closing tags as a 2-tuple
a, a_end = make_html_tags("A")
link_expr = a + SkipTo(a_end)("link_text") + a_end
for link in link_expr.search_string(text):
# attributes in the <A> tag (like "href" shown here) are
# also accessible as named results
print(link.link_text, '->', link.href)
prints:
.. testoutput::
pyparsing -> https://github.com/pyparsing/pyparsing/wiki
r©rs rÚmake_html_tagsr ¹sô8 W˜ $rcót|d«S)z½Helper to construct opening and closing tag expressions for XML,
given a tag name. Matches tags only in the given upper/lower case.
Example: similar to :class:`make_html_tags`
Trrs rÚ
make_xml_tagsr Øsô W˜ #rÚ any_open_tagÚ
any_close_tagz_:zany tagú;z-nbsp lt gt amp quot apos cent pound euro copyrírdcó6dtdtt«dS)Nz &(?P<entity>rdz);)Ú_most_common_entitiesr Ú_htmlEntityMaprprrr$r$îsˆÔ3EÄnÓ3UÐ2VÐVXÐ Y€rzcommon HTML entitycó@tj|j«S)zRHelper parser action to replace common HTML entities with their special characters)rÚgetÚentityr¨s rÚreplace_html_entityròsä × Ñ ˜aŸh™hÓ 'rcóeZdZdZdZdZy)ÚOpAssoczvEnumeration of operator associativity
- used in constructing InfixNotationOperatorSpec for :class:`infix_notation`rrRN)Ú__name__Ú
__module__Ú __qualname__Ú__doc__ÚLEFTÚRIGHTrprrrr÷sñTð
€DØ
ErrÚ base_exprÚop_listÚlparÚrparcó®Gddt«}d|_t«}|j|jd«t |t «r t|«}t |t «r t|«}||z|zjd|jd«}t |t«rt |t«s|t|«z}n||z}|D}|dzdd\} }
} } t | t«rtj| «} tjt| «} |
d k(r<t | ttf«rt!| «d
k7r t#d «| \}
}|
|d }n| d }d
|
cxkrd kst#d«t#d«| t$j&t$j(fvr t#d«t«j|«}tjt|«}t+g«}| t$j&ur|
d
k(r||| z«}t|| dz«}nG|
d
k(rA| $||| z|z«}t|| |zdz«}n|||z«}t|d«}n|
d k(||
z|zz|z«}t||
|z|z|zdz«}nÍ| t$j(ur»|
d
k(r?t | t,«s t-| «} || j.|z«}t| |z«}nw|
d
k(rB| #||| z|z«}t|| |zdz«}nM|||z«}t||dz«}n0|
d k(r+||
z|zz|z«}t||
z|z|z|z«}d|_|z}| r7t | ttf«r|j2| Žn|j3| «|||zj|«z}|}Œÿ||z}|S) Helper method for constructing grammars of expressions made up of
operators working in a precedence hierarchy. Operators may be unary
or binary, left- or right-associative. Parse actions can also be
attached to operator expressions. The generated parser will also
recognize the use of parentheses to override operator precedences
(see example below).
Note: if you define a deep operator list, you may see performance
issues when using infix_notation. See
:class:`ParserElement.enable_packrat` for a mechanism to potentially
improve your parser performance.
Parameters:
:param base_expr: expression representing the most basic operand to
be used in the expression
:param op_list: list of tuples, one for each operator precedence level
in the expression grammar; each tuple is of the form ``(op_expr,
num_operands, right_left_assoc, (optional)parse_action)``, where:
- ``op_expr`` is the pyparsing expression for the operator; may also
be a string, which will be converted to a Literal; if ``num_operands``
is 3, ``op_expr`` is a tuple of two expressions, for the two
operators separating the 3 terms
- ``num_operands`` is the number of terms for this operator (must be 1,
2, or 3)
- ``right_left_assoc`` is the indicator whether the operator is right
or left associative, using the pyparsing-defined constants
``OpAssoc.RIGHT`` and ``OpAssoc.LEFT``.
- ``parse_action`` is the parse action to be associated with
expressions matching this operator expression (the parse action
tuple member may be omitted); if the parse action is passed
a tuple or list of functions, this is equivalent to calling
``set_parse_action(*fn)``
(:class:`ParserElement.set_parse_action`)
:param lpar: expression for matching left-parentheses; if passed as a
str, then will be parsed as ``Suppress(lpar)``. If lpar is passed as
an expression (such as ``Literal('(')``), then it will be kept in
the parsed results, and grouped with them. (default= ``Suppress('(')``)
:param rpar: expression for matching right-parentheses; if passed as a
str, then will be parsed as ``Suppress(rpar)``. If rpar is passed as
an expression (such as ``Literal(')')``), then it will be kept in
the parsed results, and grouped with them. (default= ``Suppress(')')``)
Example:
.. testcode::
# simple example of four-function arithmetic with ints and
# variable names
integer = pyparsing_common.signed_integer
varname = pyparsing_common.identifier
arith_expr = infix_notation(integer | varname,
[
('-', 1, OpAssoc.RIGHT),
(one_of('* /'), 2, OpAssoc.LEFT),
(one_of('+ -'), 2, OpAssoc.LEFT),
])
arith_expr.run_tests('''
5+3*6
(5+3)*6
(5+x)*y
-2--11
''', full_dump=False)
prints:
.. testoutput::
:options: +NORMALIZE_WHITESPACE
5+3*6
[[5, '+', [3, '*', 6]]]
(5+3)*6
[[[5, '+', 3], '*', 6]]
(5+x)*y
[[[5, '+', 'x'], '*', 'y']]
-2--11
[[['-', 2], '-', ['-', 11]]]
cóeZdZddZy)úinfix_notation.<locals>._FBcóB|jj||«|gfSr)r Ú try_parse)ÚselfÚinstringr¤Ú doActionss rÚ parseImplz%infix_notation.<locals>._FB.parseImplpsØ I‰I× Ñ  ¨#Ô ˜7ˆNrT)rrrr*rprrÚ_FBr$osô rr,z FollowedBy>Ú _expressionÚnested_rérRz@if numterms=3, opExpr must be a tuple or list of two expressionsz operationsrz6operator must be unary (1), binary (2), or ternary (3)z2operator must indicate right or left associativity)r.)rR.F)Ú
FollowedByrr)r.rr{rrrÚ_literalStringClassryrzÚtupler~r:rrrr<r Úshow_in_diagramr,)rrr r!r,r•ÚlastExprÚoperDefÚopExprÚarityÚrightLeftAssocÚpaÚopExpr1ÚopExpr2Ú term_nameÚthisExprÚmatch_lookaheadr´s rÚinfix_notationr@sô|Œjôð
!€C„Lä
)€C؇LLI—N# ;ÐÔܘ‹~ˆÜÔܘ‹~ˆà˜#‘: Ñ¸¿¹Ð8HÈ Ð/TÓU€Kô
tœXÔ &¬:°d¼HÔ+EØœu 1‰à˜{ÑðóLˆØ-4°wÑ->ÀÀÐ,CÑ)ˆ~  fœhÔ "×6°vÓ>ˆœ]¨FÓØ AŠ:ܘf¤u¬d mÔ¸F» ÀqÒ8HÜ Øðð ˆG"˜) G 9¨KÐ8‰Ià!˜( .ˆIà˜QŠÜÐ ÜÐ ¤'§,¡,´·
±
Ð!>Ñ Ð Rä")£)×"4Ñ"4°YÓ"?ˆÜ—;;œw¨Ó1ˆÜ˜b›'ˆØ œWŸ\™\Ñ ˜ŠzÙ"% Ñ&7Ó"8Ü! (¨V°F©^Ñ";Ó< ؘ!ØÐ%Ù&)¨(°VÑ*;¸hÑ*FÓ&GOÜ % h°&¸8Ñ2CÀVÑ1LÑ&LÓ MIá&)¨(°XÑ*=Ó&>OÜ % h¨vÑ&6Ó 7˜!Ù"%ؘÑ1°GÑ;¸#ô ¨(Ñ 2°WÑ <¸xÑ GÈÑ‘ ðœwŸ}™}Ñ
˜Šzä! &¬#Ô  [FÙ"% f§k¡k°HÑ&<Ó"=Ü! &¨8Ñ"3Ó4 ؘ!ØÐ%Ù&)¨(°VÑ*;¸hÑ*FÓ&GOÜ % h°&¸8Ñ2CÀVÑ1LÑ&LÓ MIá&)¨(°XÑ*=Ó&>OÜ % ¸&Ñ1AÑ&AÓ B˜!Ù"%ؘÑ1°GÑ;¸#ô" (¨WÑ"4°xÑ"?À'Ñ"IÈHÑ"TÓU ð+0ˆÔ$ /ˆ á
ܘ"œu¤d˜* ×*¨BÒ×*¨2Ôi (Ñ4°YÓØŠðYLð\ˆHÑ€CØ €Jrc ó¾ tjdddtd¬«jdd«ˆˆfdŠ ˆfd}ˆfd „}ˆfd
}t t «j
d «j««}t«t«j|«zjd «}t«j|«jd
«} t«j|«jd«}
|r?tt|«|zt | t|«zt|«z«z|
z«} nDtt|«t | t|«zt|«z«zt|
«z«} | jˆfd«| jˆ fd«|jt t «z«| jd«S)
.. deprecated:: 3.0.0
Use the :class:`IndentedBlock` class instead. Note that `IndentedBlock`
has a difference method signature.
Helper method for defining space-delimited indentation blocks,
such as those used to define block statements in Python source code.
:param blockStatementExpr: expression defining syntax of statement that
is repeated within the indented block
:param indentStack: list created by caller to manage indentation stack
(multiple ``statementWithIndentedBlock`` expressions within a single
grammar should share a common ``indentStack``)
:param indent: boolean indicating whether block must be indented beyond
the current level; set to ``False`` for block of left-most statements
A valid block must contain at least one ``blockStatement``.
(Note that indentedBlock uses internal parse actions which make it
incompatible with packrat parsing.)
Example:
.. testcode::
data = '''
def A(z):
A1
B = 100
G = A2
A2
A3
B
def BB(a,b,c):
BB1
def BBA():
bba1
bba2