[iAUddlZddlZddlZddlZddlZddlmZddlTddl m Z m Z m Z m Z mZdeeefdefdZ d^ded ejedefd Zdedefd Zdedefd Z d_deejeefdedededef dZdededefdZ d`dededefdZdedefdZdedefdZeZ ddde fdeeefdeeefdejed ejedef 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+d+\Z,Z-d,ej.j/0DZ1d-2d.d/Z3e4d0+d1Z5d2Z6Gd3d4e7Z8eeee$eeefeeefffZ9ee$e9e:e8eje;fe$e9e:e8ffZ<e"de"dfd5ed6e=e<d7eeefd8eeefde>f d9Z?dgfd:Z@e4d;+d<ZA e4d=+d>ZB e4d?C+d@ZDe4dA+dBZE e4dC+dDZF eFZG e4dE+dFZH dGeIJDZKe=ee'dH< dad dJdeeefdKeeefdLedMeje:dNeje:dOedefdPZLe8ZMe,ZNe-ZOe5ZPeAZQeBZReDZSeEZTeFZUeGZVeHZWedQeXZYedReXZLedSeZZedTeZ[edUeZ\edVeZ]edWeZ^edXeZ_edYe!Z`edZe%Zaed[e&Zbed\e6Zced]e?ZddS)bN)__diag__)*)_bslash_flatten_escape_regex_range_charsmake_compressed_rereplaced_by_pep8exprreturncNt|tr|St|SN) isinstanceSuppressr s a/home/jenkins/workspace/simtester-sanitize/venv/lib/python3.11/site-packages/pyparsing/helpers.py _suppressionrs%$!! D>>int_exprc ft|dd}|p|}tfd}|)ttd}n|}|d||d|zdd 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' intExprNcR|d}|r|zn tz|dd=dSNr)Empty)sltn array_exprr s rcount_field_parse_actionz/counted_array..count_field_parse_actionUs6 aDQ3qEGG3 aaaDDDrc,t|dSr)intrs rzcounted_array..]sAaD rarrayLenTcall_during_tryz(len) z...)deprecate_argumentForwardWordnumsset_parse_actioncopyset_nameadd_parse_action)r rkwargsrr rs` @r counted_arrayr1sb/A 4//G!GJt**--.A.ABB,,.. Z    5tLLL j * *+=D+=+=+= > >>rctfd}||dd|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|stzdSt|dkr |dzdSt|}t d|DzdS)Nrrc34K|]}t|VdSr)Literal).0tts r zImatch_previous_literal..copy_token_to_repeater..s(//272;;//////r)rlenras_listAnd)rrrtflatreps rcopy_token_to_repeaterz6match_previous_literal..copy_token_to_repeaterxs}  577NN F q66Q;; 1Q4KK F%% s///////////rTr&(prev) )r)r/r.)r r>r=s @rmatch_previous_literalr@esc" ))C 0 0 0 0 0 0$GGGLL!4!!""" Jrct|}|zfd}||dd|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. ct|fd}|ddS)Nct|}|krt||dd|dS)Nz Expected z, found)rr:ParseException)rrr theseTokens matchTokenss rmust_match_these_tokenszTmatch_previous_expr..copy_token_to_repeater..must_match_these_tokenssU"199;;//Kk))$qGkGG+GG*)rTr&)rr:r,)rrrrGrFr=s @rr>z3match_previous_expr..copy_token_to_repeatersTqyy{{++       4dKKKKKrTr&r?)r)r-r/r.)r e2r>r=s @rmatch_previous_exprrIs~" ))C BBJC L L L L L 0$GGGLL!4!!""" JrFTstrscaseless use_regex as_keywordc t|dd}t|dd}|p|}|o|}t|tr.tjr"t dtd|rd}d }ntj }d }t|tr/tj t|}| } n4t|trt|} nt!d | st#Sd } | t%| d z kr| | } t'| | d zdD]i\} } || | r | | | zd z=nSt%| t%| kr-|| | r!| | | zd z=| | | nj| d z } | t%| d z k|r|r t*jnd } t/d| Dr$ddd| Dd}ndd| D}|rd|d}t3||}|dd| D|r$d| D|fd|S#t*j$r%t dtdYnwxYwdx}}||ft:|| ft<| |ft>| | ft@i||ftCfd| Dd| S)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 asKeywordFzwarn_on_multiple_string_args_to_oneof: More than one string argument passed to one_of, pass choices as a list or space-delimited string stacklevelcV||kSr)upperabs rr$zone_of..s QWWYY 6rct||Sr)rU startswithrVs rr$zone_of..s$QWWYY11!''))<<rc,||Sr)rZrVs rr$zone_of..sQ\\!__rz7Invalid argument to one_of, expected string or iterablerrNc3<K|]}t|dkVdS)rN)r9r6syms rr8zone_of..s,44S3s88q=444444r[c34K|]}t|VdSr)rr]s rr8zone_of..s+"U"Uc#K|]}tj|VdSr)reescaper]s rr8zone_of..s*BB3 #BBBBBBrz\b(?:z)\b)flagsz | c34K|]}t|VdSr)repr)r6rs rr8zone_of..s(#=#=DGG#=#=#=#=#=#=rc8i|]}||Slowerr]s r zone_of.."s"BBB3ciikk3BBBrcD|dSrrl)rrr symbol_maps rr$zone_of..#sZ! 5Mrz8Exception creating Regex for one_of, building MatchFirstc3.K|]}|VdSrrk)r6r^parse_element_classs rr8zone_of..7s/BB3))#..BBBBBBr)"r(rstr_typer%warn_on_multiple_string_args_to_oneofwarningswarnPyparsingDiagnosticWarningoperatoreqtypingcaststrsplitIterablelist TypeErrorNoMatchr9 enumerateinsertre IGNORECASEalljoinRegexr.r/errorCaselessKeywordCaselessLiteralKeywordr5 MatchFirst)rJrKrLrMr0rOrPis_equalmaskssymbolsicurjotherre_flagspattretCASELESSKEYWORDrrrps @@rone_ofrsT( DAAH(eDDI'ZI%IH 8X&&   :     ; '    -66<<;,,$!!S{3%%**,, D( # #St**QRRR yy A c'llQ  aj!'!a%''"233  HAuxs## AEAI&5zzCHH$$sE):):$AEAI&q%((( FA c'llQ  )18 q 44G44444 CX277"U"UW"U"U"UUUXXXxxBB'BBBBB *))))H---C LL#=#=W#=#=#=== > > > OCB'BBB $$%M%M%M%MNNNJx    MMJ*       Hw 7_ w; w 7{#W    BBBB'BBB B B K K 7  s#CJ221K&%K&keyvaluecZttt||zS)aHelper 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 OneOrMoreGroup)rrs rdict_ofr<s'l  %e ,,-- . ..r as_stringc pt|dd}|o|}td}|}d|_|d|z|dz}|rd}nd}|||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 bold text 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:: [' bold text '] ['text'] asStringTc|Srrk)rlocrs rr$z#original_text_for..s3rF_original_start _original_endc*||j|jSr)rrrrrs rr$z#original_text_for..sa(9AO(K&Lrcr||d|dg|dd<dS)Nrrpoprs r extractTextz&original_text_for..extractTexts9aee-..1G1GGHIAaaaDDDr) r(rr,r- callPreparse ignoreExprssuppress_warning Diagnostics)warn_ungrouped_named_tokens_in_collection)r rr0r locMarker endlocMarker matchExprrs roriginal_text_forrusL( DAAH%IH(()>)>??I>>##L %L +,,t3ll?6S6SSIJLL  J J J{+++ ,I {TUUU rcHt|dS)zkHelper to undo pyparsing's default grouping of And expressions, even if all but one are non-empty. c|dSrrkr#s rr$zungroup..s 1Q4r)TokenConverterr/rs rungrouprs" $   0 0 @ @@rc<tdddtdtd}t |d|dz|d zS) 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 ```` characters, you may want to call :meth:`ParserElement.parse_with_tabs` locatedExpr deprecated - use LocatedrQrRc|Srrk)ssllr7s rr$zlocatedExpr..s"r locn_startrlocn_end)rurvPyparsingDeprecationWarningrr,rr-leave_whitespace)r locators rrrs$ MM ;;i;;# gg&&'<'<==G   $w--  +',,.. ) ) + +J 7 7 8  r()openerclosercontent ignore_exprc t|dt}||kr |tur|n|}|turt}||krtd|t |t rt |t rt jt|}t jt|}t|dkrt|dkr|Att|t||ztjzdz}nttt||ztjzz}n|\tt|t!|zt!|zttjdz}ngttt!|t!|zttjdz}ntdtjr|dt%}|F|t't)|t+||z|zzt)|zz}nB|t't)|t+||zzt)|zz}|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 givencL|dtjSr)strip ParserElementDEFAULT_WHITE_CHARSr#s rr$znested_expr..hs!A$**]%FGGrznested z expression)r(_NO_IGNORE_EXPR_GIVEN quoted_string ValueErrorrrsrzr{r|r9Combiner CharsNotInrrrr5r,r)rr ZeroOrMorer.errmsg)rrrrr0rrs r nested_exprrs8^!3 3!!J[  $.2G$G$G[[Z ***"__  IJJJ fh ' '* Jvx,H,H* [f--F[f--F6{{aCKK1$4$4)%!'K( &-2S S&'GG&$"VOm.OOGG)%!'K&v./&v./))JRSTTTUGG&!$V__,&v./()JRSTTTUGGa   ,   $ $GG    ))C   c)G344 56"" #      :cGm#<#< <|F?S?S S   LL6666666777CJ Jr<>c t|tr|t|| }n|jt t t dz}|rt t}||dzttt|tdz|zztddgd d z|z}nt  tt t"d z}||dzttt| d ttd|zzztddgd d z|z}t%t'd|zd zd}|dd |fd|ddddzdd }|_|_t7||_||fS)zVInternal helper to construct opening and closing tag expressions, given a tag name)rKz_-:tag=/F)defaultemptyc|ddkSNrrrkrs rr$z_makeTags..! rr) exclude_charsc6|dSrrlr#s rr$z_makeTags..sqtzz||rc|ddkSrrkrs rr$z_makeTags..rrz.sY!-- bgggooc377==??EEGGHH H!&&((  rendr`rr)rrsrnamer*alphas alphanumsdbl_quoted_stringr-r, remove_quotesrrrrOptr printablesrr5r.r/rrrr}rSkipTotag_body) tagStrxml suppress_LT suppress_GT tagAttrName tagAttrValueopenTagcloseTagrs @r _makeTagsr~s&(##c'222+vy5011K  (--//@@OO fUmm :eK(3--$?,$NOOPPQQ R(c#w'''00AA++     %))++<<]KKd cO O O   fUmm #445K5KLLhsmml:;;< (c#w'''00AA++    wt}}v-3eDDDH ^^^^$$$      x S117799??AABBBhG GKHLhhjj))G H rtag_strc"t|dS)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 = 'More info at the pyparsing wiki page' # 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 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 Frrs rmake_html_tagsr s8 We $ $$rc"t|dS)zHelper 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` Trr s r make_xml_tagsr s Wd # ##r any_open_tag any_close_tagz_:zany tagc@i|]\}}|d|S);)rstrip)r6kvs rrnrns(KKKtq!!((3--KKKrz-nbsp lt gt amp quot apos cent pound euro copyrrccBdtdttdS)Nz &(?Prcz);)_most_common_entitiesr _htmlEntityMaprkrrr$r$s$ Y0 Y Y3En3U3U Y Y Yrzcommon HTML entityc@t|jS)zRHelper parser action to replace common HTML entities with their special characters)rgetentityrs rreplace_html_entityrs   ah ' ''rceZdZdZdZdZdS)OpAssoczvEnumeration of operator associativity - used in constructing InfixNotationOperatorSpec for :class:`infix_notation`rrQN)__name__ __module__ __qualname____doc__LEFTRIGHTrkrrrrs&TT D EEErr base_exprop_listlparrparcGddt}d|_t}||jdt |t rt|}t |t rt|}||z|zd|jd}t |trt |ts|t|z}n||z}|D]t}|dzdd\} } } } t | trt | } tj t| } | d krKt | ttfrt!| d krt#d | \} }| |d }n| d }d | cxkrd ksnt#d| t$jt$jfvrt#dt|}tj t|}t+g}| t$jur| d kr(||| z}t|| dz}n| d krU| .||| z|z}t|| |zdz}nV|||z}t|d}n1| d kr8||| z|z|z|z}t|| |z|z|zdz}n| t$jur| d krJt | t,st-| } || j|z}t| |z}n| d krV| -||| z|z}t|| |zdz}n_|||z}t||dz}n8| d kr2||| z|z|z|z}t|| z|z|z|z}d|_||z}| r._FBTc@|j|||gfSr)r try_parse)selfinstringr doActionss r parseImplz%infix_notation.._FB.parseImplps# I  # . . .7NrNT)rrrr/rkrr_FBr)os(      rr1z FollowedBy> _expressionnested_rNrQz@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.)rQ.F) FollowedByrr)r.rrr|rrrsr_literalStringClassrzr{tuplerr9rrr!r"r;rr show_in_diagramr,)r#r$r%r&r1rrlastExproperDefopExprarityrightLeftAssocpaopExpr1opExpr2 term_namethisExprmatch_lookaheadrs rinfix_notationrEs|j !CL ))CLLIN///000$~~$~~#:$../T/T/T/TUUK tX & &+:dH+E+E+u[111{*LL-4w->,C)~r fh ' ' ?"66v>>F]F33 A::fudm44 F q8H8H V & GW"8G888II!...IEQUVV V ', !> > >QRR R")))"4"4Y"?"?;w11b'' W\ ) )zz"%#h&7"8"8!(VF^";<< !%&)c(V*;h*F&G&GO %h&82CV1L&L M MII&)c(X*=&>&>O %hv&6 7 7II!"%#w&1G;hF##"( 2W &>O %h&1A&A B BII!"%#w&1G;hF##"(W"4x"?'"IH"TUU +0'$i/  /"udm,, /* *B///**2...i(*44Y???HC Jrc  tdddtdddfd fd}fd }fd }t t d }tt |z d }t | d } t | d} |rStt||zt | t|zt|zz| z} n\tt|t | t|zt|zzt| z} | fd|  fd|t t z| dS)a .. 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 bba3 C D def spam(x,y): def eggs(z): pass ''' indentStack = [1] stmt = Forward() identifier = Word(alphas, alphanums) funcDecl = ("def" + identifier + Group("(" + Opt(delimitedList(identifier)) + ")") + ":") func_body = indentedBlock(stmt, indentStack) funcDef = Group(funcDecl + func_body) rvalue = Forward() funcCall = Group(identifier + "(" + Opt(delimitedList(rvalue)) + ")") rvalue << (funcCall | identifier | Word(nums)) assignment = Group(identifier + "=" + rvalue) stmt << (funcDef | assignment | identifier) module_body = stmt[1, ...] parseTree = module_body.parseString(data) parseTree.pprint() prints: .. testoutput:: [['def', 'A', ['(', 'z', ')'], ':', [['A1'], [['B', '=', '100']], [['G', '=', 'A2']], ['A2'], ['A3']]], 'B', ['def', 'BB', ['(', 'a', 'b', 'c', ')'], ':', [['BB1'], [['def', 'BBA', ['(', ')'], ':', [['bba1'], ['bba2'], ['bba3']]]]]], 'C', 'D', ['def', 'spam', ['(', 'x', 'y', ')'], ':', [[['def', 'eggs', ['(', 'z', ')'], ':', [['pass']]]]]]] indentedBlockr IndentedBlockrQrRNc"ddd<dSNrk) backup_stacks indentStacksr reset_stackz"indentedBlock..reset_stackAs&r* AAArc|t|krdSt||}|dkr.|dkrt||dt||ddS)NrKzillegal nestingznot a peer entry)r9colrDrrrcurColrMs rcheckPeerIndentz&indentedBlock..checkPeerIndentDsp A;; FQ [_ $ $ B''$Q+<=== A'9:: : % $rct||}|dkr|dSt||d)NrKznot a subentry)rPappendrDrQs rcheckSubIndentz%indentedBlock..checkSubIndentMsLQ KO # #   v & & & & & A'788 8rc|t|krdSt||}r|vst||d|dkrdSdS)Nznot an unindentrK)r9rPrDrrQs r checkUnindentz$indentedBlock..checkUnindentTsv A;; FQ :+ 5 5 A'899 9 KO # # OO      $ #rz INDENTr`UNINDENTc:rdodndSrJr)rLsrr$zindentedBlock..qs"-I !!"%%.$TrcSrrk)rWrXcdrNs rr$zindentedBlock..ss kkmmrzindented block)rurvrrUrLineEndset_whitespace_charssuppressrr,r.rrr/set_fail_actionignorer) blockStatementExprrMindentrLrSrVrXNLrYPEERUNDENTsmExprrNs ` ` @rrGrGsv MM CCCC# QQQ(((++++++;;;;;99999 79911%88AACC D DBgg00@@@ J J8 T TF 77 # #O 4 4 = =b A AD WW % %m 4 4 = =j I IF   GG u%78883r77BCC D    GGu%78883r77BCC D&kk    IIII ;;;;<<<g 1222 ??+ , ,,rz/\*(?:[^*]|\*(?!/))*\*\/zC style commentzz HTML commentz.*z rest of linez//(?:\\\n|[^\n])*z // commentz2(?:/\*(?:[^*]|\*(?!/))*\*\/)|(?://(?:\\\n|[^\n])*)zC++ style commentz#.*zPython style commentc<g|]}t|t|Srk)rr)r6rs r rks7''' *Q ">">''''r_builtin_exprs,allow_trailing_delimdelimcombineminmaxroc,t||||||S)zT .. deprecated:: 3.1.0 Use the :class:`DelimitedList` class instead. rn) DelimitedList)r rprqrrrsros rdelimited_listrvs)  eWc3=Q   r delimitedListrv countedArraymatchPreviousLiteralmatchPreviousExproneOfdictOforiginalTextFor nestedExpr makeHTMLTags makeXMLTagsreplaceHTMLEntity infixNotationr)FTFr0)rmFNN)e html.entitieshtmlrxresysrzr`rcoreutilrrrr r Unionrr|rOptionalr1r@rIr~boolrrrrrrrrrrrr8r r __annotations__r*rrr.r rentitieshtml5itemsrrrrcommon_html_entityrEnumrInfixNotationOperatorArgTyper" ParseActionInfixNotationOperatorSpecrr)rErGc_style_comment html_commentr rest_of_linedbl_slash_commentcpp_style_commentjava_style_commentpython_style_commentvarsvaluesrlrvopAssoc anyOpenTag anyCloseTagcommonHTMLEntity cStyleComment htmlComment restOfLinedblSlashCommentcppStyleCommentjavaStyleCommentpythonStyleCommentrurwrxryrzr{r|r}r~rrrrrkrrrs u]C/0]EIE?E? E?#)?=#AE?E?E?E?E?P""=""""J#m# ####P II $c) *III I  IIIIX6/6/}6/6/6/6/6/t,088 8$(88888vA-AMAAAAm D  ),(+.22G __ #}$ %_ #}$ %__] +_/ _  ____D(0x}}((3--8888v% 3 % &% =- '(%%%%>$ 3 % &$ =- '($$$$,nDT!""++I66 mLKt}/B/H/H/J/JKKKGOOUYY (    ((( d %3eM3$67}c?Q9RRSS " $  $ &  $    $'/hsmm&.hsmm JJJ + ,J ]" #J ]" # J  JJJJZ;?bW-W-W-W-x%344==>OPP#u'((11.AA &uU||,,..77GG E.//88FF1E9 ( P&$uV}}--.DEE0 ''tvv}}''']#(+ $ $ "' ]" # m# $      (    %   ##%)  -@@ !!"2MBB >> ''(>@VWW$$%8:MNN&))  (G , ,""#46GHH  lK 8 8 ?? }m<< $$%8:MNN  .AA r