R`il UddlmZddlZddlZddlmZmZmZmZmZm Z m Z m Z m Z m Z mZddlmZmZddlmZddlZddlZddlZddlZddlZddlmZddlZddlZddlmZddlm Z dd l!m"Z"dd l#m$Z$d d l%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z.m/Z0m1Z1d d l2d d l3d dl4m5Z5m6Z6d dl7m8Z8ejrZ:e;edfe?d<ejdk\rddlmAZAn GddZAGdde(ZBGdde(ZCGddeZDdeDddfdZEdeDddfdZFdd ZG[(d!ej4e;d"eje;deIfd#ZJeJejejjd$reGeNeOePeQeReSeTeUeVeWeXh ZYejZ[e e\efZ]e e5e e5fZ^e egefee5gefee\e5gefee;e\e5geffZ_e egeIfee5geIfee\e5geIfee;e\e5geIffZ`ee;e\d%eagdfZbee;e\d%eIgdfZcee;e\e\d%e5eIgdfZdee;e\d%eaeIgdfZeejejzZhe8jjZje8jjZkd&Zleld'zZmehelzZnd(jejDcgc]}|ejvs|c}Zrdaseje?d)<dd*Zu dd+e`d,eje;d-eIde_fd.Zv dd/e;d0e\d1d%d2eIfd3Zw dd/e;d4e\d5e\d1d%d6e5d2eIf d7Zx dd/e;d0e\d1d%d8ead2eIf d9Zyd:ZzGd;d%eZ{Gd<d=e{Z|Gd>d?e{Z}Gd@dAe}Z~GdBdCe}ZGdDdEeZGdFdGeZee{_GdHdIe}ZGdJdKeZGdLdMeZGdNdOe}ZGdPdQe}ZGdRdSeZGdTdUe}ZGdVdWe}ZGdXdYe}ZGdZd[e}ZGd\d]e}ZGd^d_eZGd`daeZGdbdceZGdddeeZGdfdgeZGdhdieZGdjdkeZGdldme{ZGdndoeZGdpdqeZGdrdseZGdtdueZGdvdwe{ZGdxdyeZGdzd{eZGd|d}eZGd~deZGddeZGddeZGddeZGddeZGddeZGddeZGddeZGddZGddeZeZHGddeZGddeZGddeZGddeZGddeZGddeZGddeZde_de_fdZejadZejadZejadZejadZejadZedjmdZedjmdZedjmdZeezezedd zZeeedzezZededjydzeeeezjydzedzZde;de;fdZde_fdZddZeeddzjadZeeddzjadZeeddzjadeddzjadzjadZeedejëdzjadūedejëdzjadȫz edɫdzjadz edʫdzjadz jad˫Zedej+zjadͫZedΫZedϫZeɫjDcgc]}e|e{s |c}Zee{e?d<eZeZeZeZeZeZeZeZe1ezdфZe1ed҄Ze1evdӄZe1edԄZycc}wcc}w))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_propertyceZdZdZddZy)r)c||_yN)_func)selffuncs /builddir/build/BUILDROOT/alt-python312-pip-23.3.1-3.el8.x86_64/opt/alt/python312/lib/python3.12/site-packages/pip/_vendor/pyparsing/core.py__init__zcached_property.__init__Us DJNcn|j|x}|j|jj<|Sr,)r-__dict____name__)r.instanceownerrets r0__get__zcached_property.__get__Xs/;?::h;O OC(##DJJ$7$78Jr2r,)r5 __module__ __qualname__r1r9r2r0r)r)Ts   r2r)ceZdZdZdZdZeDcgc]}|jdr|c}}ZdjZ ycc}}w) __compat__aJ A cross-version compatibility configuration for pyparsing features that will be released in a future version. By setting values in this configuration to True, those features can be enabled in prior versions for compatibility development and testing. - ``collect_all_And_tokens`` - flag to enable fix for Issue #63 that fixes erroneous grouping of results names when an :class:`And` expression is nested within an :class:`Or` or :class:`MatchFirst`; maintained for compatibility, but setting to ``False`` no longer restores pre-2.3.1 behavior compatibilityT_z( collect_all_And_tokens N) r5r:r;__doc__ _type_desccollect_all_And_tokenslocals startswith _all_namessplit _fixed_names).0__s00r0r>r>]sL !J!%xBxr}}S/A"xBJ EGCs AAr>cHeZdZdZdZdZdZdZdZdZ dZ dZ e Dcgc]}|jdr|c}}ZeDcgc]}|jds|c}}ZeDcgc]}|jds|c}}ZeddZycc}}wcc}}wcc}}w) __diag__ diagnosticFr@warn enable_debugNcH|jD]}|j|yr,)_warning_namesenable)clsnames r0enable_all_warningsz__diag__.enable_all_warningss&&D JJt 'r2returnN)r5r:r;rB)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_expressionsrDrErFrQ _debug_names classmethodrU)rIrJrTs000r0rLrLtsJ05-05-%*"(-%$)!,1)/4,(-%%xBxr}}S/A"xBJ'1MztT__V5LdzMN%/SZT4??>3RDZSL CMSs"BBBB)BBrLc0eZdZdZdZdZdZdZdZdZ dZ d Z y ) 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'N) r5r:r;rArXrYrZr[r\r]r^r_r<r2r0rcrcs9.12-01-%&"()%$%!,-)/0,()%r2rc diag_enumrWcBtj|jy)zO Enable a global pyparsing diagnostic flag (see :class:`Diagnostics`). N)rLrRrTris r0 enable_diagrls OOINN#r2cBtj|jy)zP Disable a global pyparsing diagnostic flag (see :class:`Diagnostics`). N)rLdisablerTrks r0 disable_diagros Y^^$r2c,tjy)zU Enable all global pyparsing diagnostic warnings (see :class:`Diagnostics`). N)rLrUr<r2r0rUrUs   "r2cmd_line_warn_options warn_env_varc t|}|D]s}|dzjddd\}}}}}|jjds|s|s|r|dk(rd}M|jjdsm|dvsrd}u|S) Nz:::::rfi pyparsingT)rvF)boolrGlowerrE) rqrrrRwarn_optw_action w_message w_categoryw_modulew_lines r0_should_enable_warningsrs, F)=E=NO2OF* Mr2PYPARSINGENABLEALLWARNINGS ParserElement 0123456789 ABCDEFabcdefrw_trim_arity_call_linec&tvrfdSddd}txstjddatdtd|zffd }t d t d j }||_j |_|S) zAdecorator to trim function calls to match the arity of the targetc|Sr,r<)sltr/s r0z_trim_arity..s tAwr2rFrhrdlimitrc | d}d|S#t$rR}r|j}tj|d}|d}|ddgddd k(}~|r kr dz Yd}~cd}~wwxYw)NrTrdrr) TypeError __traceback__ traceback extract_tb) argsr8tetbframes frame_summarytrim_arity_type_error found_arityr/r max_limitpa_call_line_synths r0wrapperz_trim_arity..wrapper!s DL)"   ))B&11"A>F$*2JM&r*+B/37II*, 9,!QJE$% s  A+AA&%A&&A+r5 __class__)_single_arg_builtinsrr extract_stackgetattrr5rA)r/r LINE_DIFFr func_namerrrs`` @@@r0 _trim_arityr s ##&& EK I3Zi6M6MTU6VWY6Z/24I!4Ly4XY<j'$ *D*M*MNI GllGO Nr2fnmessagefatalct||nd|rtntttfd}|S)aC 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 conditionc@t|||s ||yr,)rx)rrrexc_typermsgs r0paz%condition_as_parse_action..paZs'Bq!QK 1a% %!r2)ParseFatalExceptionParseExceptionrr)rrrrrrs` @@r0condition_as_parse_actionrFsB ('.MC&+"H RB 2Y&& Ir2instringlocexpr cache_hitc|rdnd}t|d|d|dt||dt||dt||dd t||d z zd y) Nr"rwMatch z at loc (,z) z  r^)printlinenocolline)rrrr cache_hit_strs r0_default_start_debug_actionrbs{%C"M oVD6#asH8M7NaPSTWYaPbOcdc8$%&C*Q./0 3r2startlocendloctokscR|rdnd}t|d|d|jy)Nr"rwzMatched z -> )ras_list)rrrrrrrs r0_default_success_debug_actionros-%C"M ]O8D6dlln-= >?r2excc b|rdnd}t|d|dt|jd|y)Nr"rwrz failed, z raised: )rtyper5)rrrrrrs r0_default_exception_debug_actionr{s7%C"M ]O6$yc1C1C0DIcU STr2cy)zG'Do-nothing' debug action, to suppress debugging output during parsing.Nr<)rs r0null_debug_actionrr2c'> eZdZUdZdZeed<dZeed<dZ e ed<e ded dfd Z e d e d dfd Z ed ZGddeZddefdZded dfdZdZddZ ddddededed dfdZddZdded dfdZded dfd Zded dfd!Zded dfd"Zd#ed dfd$Z d%ed&e!d e!fd'Z"d%ed&e!d e!fd(Z#dd)Z$d*Z% dd e&e!e'ffd+Z(ddd,d%ed&e!d-ed.ed e!f d/Z)dd%ed&e!d.ed efd0Z*e+Z,iZ-e.j^e&e!d1efe&e!e0e'e1fffed2<Gd3d4e2Z3e3Z4e+Z5d5d5gZ6 dd e&e!e'ffd6Z7e(Z8e dd7Z9dZ:dZ;e dd8Ze ddd9d:e!dd%ed?ed@ed e'fdAZ@eAdfdeAdBd%edCe!dDedEedFe!d eBe&e'e!e!fddff dGZCddHd%edEed efdIZDeAfdeAdBd%edCe!dEedFe!d e'f dJZEeAdfddKd%edLe!dMed eBeddffdNZFddOZGddPZHddQZIddRZJddSZKddTZLddUZMddVZNddWZOddXZPddYZQddZZRdd[ZSdZTd\ZUdde.jzed dfd]ZVdd^ZWdd_ed dfd`ZXdd_ed dfdaZY dde0eZeefdbed dfdcZ[dddZ\ddeZ]dfe^dge_dhe`d dfdiZaddjedked dfdlZbecd efdmZdeed efdnZfded dfdoZgecd efdpZhd efdqZid efdrZjddsZkd eldfdtZmduZndddvZo ddd>dwe0eepeqfdxed?ed@ed e'f dyZrdzZsd{Zt ddd>d|ed?ed@ed efd}Zu ddddddd~de0eelefd?ede.jze0defdededede.jzevee'gefde.jzeqded@edededede.jzevee'gefd e&eele&ee0e'e1ffffdZw dde0eqepefde!dededed df dZxe eye dZze eye dZ{eyedZ|eyedZ}eyedZ~eyedZeyedZeye dZeye)dZe eye>dZe eye?dZeye@dZeyeCdZeyeDdZeyeEdZeyeXdZeyeYdZeye[dZeye\dZeyeadZeyebdZeyegdZeyerdZeyewdZe*Ze9ZedZy)rz)Abstract base level parser element class.z DEFAULT_WHITE_CHARSFverbose_stacktraceN_literalStringClasscharsrWcj|t_tD]}|jst ||_!y)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 r0set_default_whitespace_charsz*ParserElement.set_default_whitespace_charss,-2 )#D))"%e*#r2rSc|t_y)al 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)rSs r0inline_literals_usingz#ParserElement.inline_literals_usings (-0 )r2c+<Kfd|DEd{y7w)z Yields a sequence of class(obj, **class_kwargs) for obj in seq. Example:: LPAR, RPAR, LBRACE, RBRACE, SEMI = Suppress.using_each("(){};") c30K|] }|fiywr,r<)rIobj class_kwargsrSs r0 z+ParserElement.using_each..s<C,|,sNr<)rSseqrs` `r0 using_eachzParserElement.using_eachs=<<.breaker\s" #Hc9lKKr2_originalParseMethodTT)_parser%hasattr)r.rr$r#s @r0 set_breakzParserElement.set_breakSsV ;;L L,8G (!DK t{{$:;"kk>>  r2fnsct|dgk(r g|_|Std|Ds td|Dcgc] }t |c}|_|j d|j dd|_|Scc}w)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 ''') Nc32K|]}t|ywr,)callable)rIrs r0rz1ParserElement.set_parse_action..s2cx|czparse actions must be callablecall_during_tryrF)rrallrrgetrr.r*kwargsrs r0set_parse_actionzParserElement.set_parse_actionjsV 9 !D  2c22 @AA:=>#B B#>D !'!6::ou#E"D  ?sA=c|xj|Dcgc] }t|c}z c_|jxs"|jd|jdd|_|Scc}w)z Add one or more parse actions to expression's list of parse actions. See :class:`set_parse_action`. See examples in :class:`copy`. r/rF)rrrr1r2s r0add_parse_actionzParserElement.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)rrr/r)rrrstrr1rxrr2s r0 add_conditionzParserElement.add_conditions.B    # #) 9 56vzz'59: "// 6:: vzz/5A4  r2rc||_|S)a Define action to perform if parsing fails at this expression. Fail acton fn is a callable function that takes the arguments ``fn(s, loc, expr, err)`` where: - ``s`` = string being parsed - ``loc`` = location where expression match was attempted and failed - ``expr`` = the parse expression that failed - ``err`` = the exception thrown The function returns no value. It may throw :class:`ParseFatalException` if it is desired to stop parsing immediately.)r)r.rs r0set_fail_actionzParserElement.set_fail_actions r2rrc|js|Sd}|jDcgc]}|j}}|rd}|D]} |||\}}d}|r|Scc}w#t$rY*wxYwNTF)rr'r)r.rr exprsFoundeignore_expr_fns ignore_fndummys r0_skipIgnorableszParserElement._skipIgnorablessJ -1-=-=>-=188-=>J, %.x%= U%) - ?&sAA A%$A%c|jr|j||}|jr5t|}|j}||kr|||vr|dz }||kr|||vr|SNr)rrCrlenr)r.rrinstrlen white_charss r0preParsezParserElement.preParsesn   &&x5C   8}H//K.Xc]k%Aq.Xc]k%A r2c |gfSr,r<r.rrr!s r0 parseImplzParserElement.parseImpl Bwr2c|Sr,r<r.rr tokenlists r0 postParsezParserElement.postParse sr2c d\}}}|j}t|} |s |jr |r|jr|j ||} n|} | } |j j r|j j || |d|js| | k\r |j|| |\}} n|j|| |\}} nd|r|jr|j ||} n|} | } |js| | k\r |j|| |\}} n|j|| |\}} |j||| } t| |j |j"|j$}|j&r|s |j(r|rk |j&D]Z} ||| |} | | |ust| |j |j"xrt+| tt,f|j$}\ni|j&D]Z} ||| |} | | |ust| |j |j"xrt+| tt,f|j$}\|r6|j j.r |j j/|| |||d||fS#t$rt|| |j|wxYw#t$r[} |j jr|j j| || d|jr|j| || d} ~ wwxYw#t$rt|| |j|wxYw#t$r}td}||d}~wwxYw#t$r;} |j jr|j j|| || dd} ~ wwxYw#t$r}td}||d}~wwxYw)NrrrdF)asListmodalz exception raised in parse action)rrFrrrIrrrrL IndexErrorrr ExceptionrrQr#rrrrr isinstancerr)r.rrr!r"TRYMATCHFAIL debugging len_instringpre_loc tokens_starttokenserr ret_tokensrparse_action_excrs r0 _parseNoCachezParserElement._parseNoCache$s#UDJJ 8}  D$5$5"mmHc:G!G& $$..%%//,eT%%L)@X&*nnXw &R V#'..7I"NKC 1 1--#6"L!!W %<T"&..7I"NKC#nnXw J V#v6! D$$T__DDUDU    d.@.@"..<%', %KF "-& 2J)5 & $ 0 0'+(M$.v d7K$L&*&7&7 *J/.**B8!#HlJ!G )fJ.F%1" ,,#'??$I *6L$3G H"&"3"3 & +   ,,!!--lCz5Ja&X,X|T[[RVWWX $$//%%00 ,c5??OOHlD#F $"T(<dSST *<"01S"TC"%+;;<!((33))44$lD#u &8,-OP!'778sA*J;J.J;=L"M& M!M&$M&)AM& N-"J88J;; LALL""M M#MM##M&& N*/6N%%N*- O 6OO ) raise_fatal do_actionsrerfc |j|||dS#t$r|rt|||j|wxYw)Nr!r)r'rrr)r.rrrerfs r0 try_parsezParserElement.try_parsesN C;;x ;CAF F" C 3 TB B Cs%>cX |j|||y#ttf$rYywxYw)NrfTF)rirrV)r.rrrfs r0can_parse_nextzParserElement.can_parse_nexts7  NN8SZN @ +  s ))Forwardrecursion_memosc(eZdZUdZeed<dZdZy)ParserElement._CacheTypez- class to help type checking not_in_cachecyr,r<r.rs r0r1zParserElement._CacheType.get r2cyr,r<rss r0rzParserElement._CacheType.setrtr2N)r5r:r;rArxrr1rr<r2r0 _CacheTyperps   r2rvrc d\}}d\}}} |||||f} tj5tj} | j| } | | jurdtj |xxdz cc< |j ||||} | j| | d| dj|f| cdddStj |xxdz cc<|jr6|jjr |jj|||dt!| t"rG|jr9|jj$r# |jj%|||| d| | t't(t*t,t*f| } | d| dj| d}}}|jr8|jj.r" |jj/|||||d||fcdddS#t$r/} | j| | j| jd} ~ wwxYw#t$rY.wxYw#t$rY| wxYw#t$rYswxYw#1swYyxYw)N)rrrSrrT)rrd)rpackrat_cache_lock packrat_cacher1rqpackrat_cache_statsrdrrParseBaseExceptionrrrrrrrXrWrrr intr#r)r.rrr!r"HITMISSrYrZr[lookupcachevaluepeloc_resultrs r0 _parseCachezParserElement._parseCachesb T"UD#|Y?  - -!//EIIf%E***11$71<7! ..xiVE IIfuQxq#&FG . -11#6!;6::$"3"3"="=))33Hc4SW3XeY/zzd&7&7&B&B! --88 (#tUd9  K%KU3 c#9:EB',Qxq%(ff::$"3"3"?"?))55$dFD&D6 V|S. -*IIflbllBGG&<=% )! K!%M. -sA I%/G;*I%7=I%5H62I% I'A%I% !I.I%; H3*H..H33I%6 I?I%II% II%II% I"I%!I""I%%I.ctjjdgttjztjddtj jyr)rryclearrFrzrnr<r2r0 reset_cachezParserElement.reset_cachesO##))+01sS  - -6 0 ))!, %%++-r2ctjdt_dt_tjt_y)a$ Disables active Packrat or Left Recursion parsing and their memoization This method also works if neither Packrat nor Left Recursion are enabled. This makes it safe to call before activating Packrat nor Left Recursion to clear any previous settings. FN)rr_left_recursion_enabled_packratEnabledrdr'r<r2r0disable_memoizationz!ParserElement.disable_memoizations. !!#05 -(- %,:: r2)forcecache_size_limitc|rtjntjr td|t t_dt_y|dkDr!t |t_dt_ytd|z)a8 Enables "bounded recursion" parsing, which allows for both direct and indirect left-recursion. During parsing, left-recursive :class:`Forward` elements are repeatedly matched with a fixed recursion depth that is gradually increased until finding the longest match. Example:: from pip._vendor import pyparsing as pp pp.ParserElement.enable_left_recursion() E = pp.Forward("E") num = pp.Word(pp.nums) # match `num`, or `num '+' num`, or `num '+' num '+' num`, ... E <<= E + '+' - num | num print(E.parse_string("1+2+3")) Recursion search naturally memoizes matches of ``Forward`` elements and may thus skip reevaluation of parse actions during backtracking. This may break programs with parse actions which rely on strict ordering of side-effects. Parameters: - ``cache_size_limit`` - (default=``None``) - memoize at most this many ``Forward`` elements during matching; if ``None`` (the default), memoize all ``Forward`` elements. Bounded Recursion parsing works similar but not identical to Packrat parsing, thus the two cannot be used together. Use ``force=True`` to disable any previous, conflicting settings. 0Packrat and Bounded Recursion are not compatibleNr)capacityzMemo size of %sT) rrr RuntimeError_UnboundedMemorn_LRUMemoNotImplementedErrorrrrs r0enable_left_recursionz#ParserElement.enable_left_recursion szH   - - /  * *QR R  #,:,N,OM )15 -&&7:J&JK Kr2rc&|rtjntjr tdtjsOdt_|t t_nt|t_tjt_ yy)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) rrrrrrryrrr'rs r0enable_packratzParserElement.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 streamlinerr expandtabsr'rIEmpty StringEndr{rwith_traceback) r.rrrr?rr`sers r0 parse_stringzParserElement.parse_stringesZ(!!# OO !!A LLN"}}**,H ++h2KCmmHc2Wy{* (C(M" ///((..  /s5AC C7"C22C7)r maxMatches max_matchesoverlaprrc#Kt||}|js|j|jD]}|j|jst |j }t|}d}|j} |j} tjd} ||kr}| |krw | ||} | || d\} }| |kDrG| dz } |rt|j| | d|| | f|r| ||}||kDr| }n|dz }n | }n| dz} ||kr| |kruyyyy#t$r dz}YwxYw#t$r'}tj r|j#dd}~wwxYww)at 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 rFr"r)r`startendN)minrrrrr8rrFrIr'r resetCacherrTrr{rr)r.rrrrrr?rGr preparseFnparseFnmatchesprelocnextLocr`nextlocrs r0 scan_stringzParserElement.scan_stringsN[1  OO !!A LLN"}}8}//1Hx=]] ++  "$ //g &:)",Xs";F'.hU&SOGV}1  !.4mmo-3+2!"%fg55"&03&?G&}&- #q")C$qj;/g &:/&:/ &% 1*C%0" ///((..  /sOB*E7- E8D0AE,E70E>EEE E4 "E//E44E7rcxg}d}d|_ |j||D]\}}}|j||||rgt|tr||j z }nCt|t r"t|ts|j|n|j||}|j||d|Dcgc]}|s| }}djt|Dcgc] }t|c}Scc}wcc}w#t$r'} tjr| jdd} ~ wwxYw)ab 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. rTrNrw)rrrrXr#rrr&r joinrr8r{rrr) r.rroutlastErrr?ors r0transform_stringzParserElement.transform_strings#(  /++HE+B1a 8E!,-!!\2qyy{*#Ax0Ax9P 1  1 C JJx' (!'cQ1cC'77HSM:MqCFM:; ;(:! ///((..  /s<B3D C?C? D &D8D ? D D9"D44D9c t||} t|j|||Dcgc]\}}}| c}}}Scc}}}w#t$r'}tj r|j dd}~wwxYw)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#rr{rrr) r.rrrrrrr?rs r0 search_stringzParserElement.search_string3s8[1  /"&"2"28Zu"2"UV"Uwq!Q"UV V! ///((..  /s'A A AA A8"A33A8)includeSeparatorsmaxsplitinclude_separatorsc#K|xs|}d}|j||D]\}}}||||r|d|}||dyw)aT 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) r.rrrrlastrrr?s r0rGzParserElement.split[sf..C1C''h'GGAq!4" " d D H tuos?Ac|tur t|St|tr|j |}t|t st St||gS)al 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 _PendingSkiprXr&rrNotImplementedAndr.others r0__add__zParserElement.__add__{sP6 H % % eX &,,U3E%/! !D%=!!r2c|turt|d|zSt|tr|j |}t|t st S||zS)zd Implementation of ``+`` operator when left operand is not a :class:`ParserElement` _skipped*)rSkipTorXr&rrrrs r0__radd__zParserElement.__radd__sV H 6$< ,t3 3 eX &,,U3E%/! !t|r2ct|tr|j|}t|tstS|t j z|zS)zX Implementation of ``-`` operator, returns :class:`And` with error stop )rXr&rrrr _ErrorStoprs r0__sub__zParserElement.__sub__sE eX &,,U3E%/! !cnn&&..r2czt|tr|j|}t|tstS||z S)zd Implementation of ``-`` operator when left operand is not a :class:`ParserElement` rXr&rrrrs r0__rsub__zParserElement.__rsub__8 eX &,,U3E%/! !t|r2cH|turd}n+t|tr|ddtfk(rd|ddzdzdd}t|tr|d}}nt|trtd|D}|d zdd}|dd|df}t|dtr?|d:|ddk(r t S|ddk(r t S|dzt zSt|dtrt|dtr |\}}||z}n t St S|dkr td |dkr td ||cxk(rdk(r tgS|r>fd |r,|dk(r |z}|Stg|z|z}|S|}|S|dk(r}|Stg|z}|S) a 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,rdrc34K|]}|tur|ndywr,)r)rIrs r0rz(ParserElement.__mul__..sJEqq0!d:E)NNz/cannot multiply ParserElement by negative valuez@second tuple value must be greater or equal to first tuple valuecR|dkDrt|dz zStSrE)Opt)nmakeOptionalListr.s r0rz/ParserElement.__mul__..makeOptionalLists.q5t&6q1u&==>>t9$r2) rrXtupler| ZeroOrMore OneOrMorer ValueErrorr)r.r minElements optElementsr8rs` @r0__mul__zParserElement.__mul__s * H E u %%){*BE!"I%/!4E eS !',aK u %JEJJE\)2A.EQxE!H %(C(U1X-=8q=%d++8q=$T?*%(?Z-===E!Hc*z%(C/H+0( [{* %%! ! ?NO O ?R  + * *r7N +  % !#!1+!>>C tf{236F{6SSC '{3  a 4&;./ r2c$|j|Sr,)rrs r0__rmul__zParserElement.__rmul__s||E""r2c|tur t|dSt|tr!|dk(r t |S|j |}t|t stSt||gS)zP Implementation of ``|`` operator - returns :class:`MatchFirst` T) must_skiprw) rrrXr&rrrr MatchFirstrs r0__or__zParserElement.__or__sc H 5 5 eX &{4y ,,U3E%/! !4-((r2czt|tr|j|}t|tstS||zS)zd Implementation of ``|`` operator when left operand is not a :class:`ParserElement` rrs r0__ror__zParserElement.__ror__"rr2ct|tr|j|}t|tstSt ||gS)zH Implementation of ``^`` operator - returns :class:`Or` )rXr&rrrOrrs r0__xor__zParserElement.__xor__,s= eX &,,U3E%/! !4-  r2czt|tr|j|}t|tstS||z S)zd Implementation of ``^`` operator when left operand is not a :class:`ParserElement` rrs r0__rxor__zParserElement.__rxor__6rr2ct|tr|j|}t|tstSt ||gS)zJ Implementation of ``&`` operator - returns :class:`Each` )rXr&rrrEachrs r0__and__zParserElement.__and__@s= eX &,,U3E%/! !T5M""r2czt|tr|j|}t|tstS||zS)zd Implementation of ``&`` operator when left operand is not a :class:`ParserElement` rrs r0__rand__zParserElement.__rand__Jrr2ct|S)zL Implementation of ``~`` operator - returns :class:`NotAny` )NotAnyr.s r0 __invert__zParserElement.__invert__Tsd|r2cjd}t}t|tr|j|j}}|d}d}nHt|t r8t|dtr%|d|djf|dj}}d}t|t r|f} t|t|dkDr1td |dd t|d kDrd t|d nd d|t |ddz}tjt|}|r|j||S#t$r||f}YwxYw)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.Trrrrdz'only 1 or 2 index arguments supported (rfz... []rw))NoMatchrXslicerstoprr&iterrrFrr_MultipleMatchstopOn)r.keystop_on_definedstop_onr8s r0 __getitem__zParserElement.__getitem__^s=6 ) c5 !99chhC{"O U # 3r7E(BFCFLL13q6;;C"O c8 $&C  I s8a<9#bq'Z]^aZbefZfU3s8*TUCVlnBoopq  U3r7^#kk.#.  JJw   *C s D"" D21D2cH||j|S|jS)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") )rrr.rTs r0__call__zParserElement.__call__s'  ''- -99; r2ct|S)z Suppresses the output of this :class:`ParserElement`; useful to keep punctuation from cluttering up returned output. )Suppressrs r0suppresszParserElement.suppresss ~r2 recursivecd|_|S)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) Trr.r s r0ignore_whitespacezParserElement.ignore_whitespaces# r2cd|_|S)a| 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) Frrs r0leave_whitespacezParserElement.leave_whitespaces$ r2 copy_defaultscBd|_t||_||_|S)z8 Overrides the default whitespace chars T)rrrr)r.rrs r0set_whitespace_charsz"ParserElement.set_whitespace_charss$ #e*%2" r2cd|_|S)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)rrs r0parse_with_tabszParserElement.parse_with_tabss   r2cddl}t|tr t|}t|tr+||jvr|jj ||S|jj t|j |S)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)rrXr&r rrr)r.rrs r0ignorezParserElement.ignoress  eX &UOE eX &D,,,  ''.     # #HUZZ\$: ; r2 start_actionsuccess_actionexception_actionct|j|xst|xst|xst|_d|_|S)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)r.rrrs r0set_debug_actionszParserElement.set_debug_actionss@$!--  77  ;;  ? ?    r2flagr c|r*|jD]}|j|d|S|r!|jttt |Sd|_|S)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_debugrrrrr)r.rr rs r0r!zParserElement.set_debugs]L (tU3)K   " "+-/  DJ r2c\|j|j|_|jSr,)r_generateDefaultNamers r0 default_namezParserElement.default_nameIs+    $ $ 9 9 ;D    r2cy)zg Child classes must define this method, which defines how the ``default_name`` is set. Nr<rs r0r#z"ParserElement._generateDefaultNameOrr2c|||_d|jz|_tjr|j |S)a^ 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 )rrTrrLr_r!rs r0set_namezParserElement.set_nameUs3!DII-  5 5 NN  r2cJ|j |jS|jSr,)rr$rs r0rTzParserElement.nameds"#'//"=tT4CTCTTr2c|jSr,rTrs r0__str__zParserElement.__str__is yyr2ct|Sr,r8rs r0__repr__zParserElement.__repr__ls 4yr2c"d|_d|_|SNT)rrrs r0rzParserElement.streamlineos  r2cgSr,r<rs r0r zParserElement.recurset r2cb|dd|gz}|jD]}|j|yr,)r _checkRecursionr.parseElementListsubRecCheckListr?s r0r5zParserElement._checkRecursionws1*1-6A  o . r2c^tjdtd|jgy)zj Check defined expressions for valid structure, check for infinite recursive definitions. ZParserElement.validate() is deprecated, and should not be used to check for left recursionrd stacklevelN)warningsrNDeprecationWarningr5)r. validateTraces r0validatezParserElement.validate|s)  h  R r2file_or_filenameencodingc|xs|} tjt|}|j} |j|S#t$rQtjt |}t |d|5}|j}dddn #1swYnxYwYlwxYw#t$r'}tjr|jdd}~wwxYw)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. rrBN) rrr readAttributeErrorr8openrr{rrr)r.rArBrr file_contentsfrs r0 parse_filezParserElement.parse_files(y )%{{63CD ,113M  /$$]H= =  )%{{30@A &h?1 ! @?? ) " ///((..  /s@*AB"1B6B BB BB" C+"C  Cc||uryt|tr|j|dSt|trt |t |k(Sy)NTrF)rXr&rrvarsrs r0__eq__zParserElement.__eq__sI 5= x (<<<6 6 } -:e, ,r2ct|Sr,)idrs r0__hash__zParserElement.__hash__s $xr2 test_stringch|xr|} |jt||y#t$rYywxYw)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") rMTF)rr8r{)r.rSrrs r0rzParserElement.matchess@")     c+.(  C!  s % 11)rfullDump printResults failureTestsrQtestscomment full_dump print_results failure_tests post_parsefilewith_line_numbersrUrVrWrQc  ddlm}| xr|} | xr|} | xr|} | xs|} |xs|}t|tr`t j t |}t|j}|jjDcgc] }|| }}|du}|r5t|tr%t j t |}t|}t j t|}|tj}|j}g}g}d}tdj!t#dj%t&}d}|D]}|r|j)|ds|r'|s%|j+| r|j-|n|A|sD|rddj/|znd | r|j-|n|g}g} |j1|j3|}|j5|| }|xr| }|w |||}|Kt|t6r |j+|j9n:|j+t |n|j+|j9n"|j+|j9|  |j+d | r|dj/||j+||f||fScc}w#t:$ra}|j+|j9| |j+|j<d t|j<d |Yd}~d}~wwxYw#t>$r}t|t@rdnd }|j+|jC|j+dt |ztjDr.|jGtIjJ|jL|xr| }|}Yd}~[d}~wt:$r{} |j+dt| j<d | tjDr.|jGtIjJ| jL|xr| }| }Yd} ~ d} ~ wwxYw)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 uFrwrM)fullz failed: : z(FATAL)zFAIL: zFAIL-EXCEPTION: )'testingrarXr&rrr8rstriprstrip splitlinesLiteralrsysstdoutwriter6 replace_withr quoted_stringrrr_rrlstriprr#dumprWr5r{rexplainrr r format_tbr)!r.rXrrYrZr[r\r]r^r_rrUrVrWrQra line_strip test_linecomment_specifiedprint_ allResultscommentssuccessNLBOMrrrpp_valuer?rrrs! r0 run_testszParserElement.run_testssb ,) ) #5 #4} + eX &KKU+Ee**J(ST;LN44Q7RS.6tyy**B7H003aCH$ ;'' 6**1*A "6,&6( #,Q#7#/)(LA # 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-8rEr) diagramrr ImportErrorrWrrXr8rrHrm) r.rrrrrr3rrierailroad diag_files r0create_diagramzParserElement.create_diagrams@  >  1#!   kC; /k39Y 0 Q Q& QR:9   .xOuOO P' _  :9s#B B' B$ BB$'B0cyr,r<r<r2r0inlineLiteralsUsingz!ParserElement.inlineLiteralsUsing"r2cyr,r<r<r2r0setDefaultWhitespaceCharsz'ParserElement.setDefaultWhitespaceCharss%(r2cyr,r<rs r0setResultsNamezParserElement.setResultsName!r2cyr,r<rs r0setBreakzParserElement.setBreakr2cyr,r<rs r0setParseActionzParserElement.setParseActionrr2cyr,r<rs r0addParseActionzParserElement.addParseActionrr2cyr,r<rs r0 addConditionzParserElement.addConditionr2cyr,r<rs r0 setFailActionzParserElement.setFailAction r2cyr,r<rs r0tryParsezParserElement.tryParserr2cyr,r<r<r2r0enableLeftRecursionz!ParserElement.enableLeftRecursionrr2cyr,r<r<r2r0 enablePackratzParserElement.enablePackratsr2cyr,r<rs r0 parseStringzParserElement.parseStringsr2cyr,r<rs r0 scanStringzParserElement.scanStringsr2cyr,r<rs r0transformStringzParserElement.transformString"r2cyr,r<rs r0 searchStringzParserElement.searchStringrr2cyr,r<rs r0ignoreWhitespacezParserElement.ignoreWhitespace #r2cyr,r<rs r0leaveWhitespacezParserElement.leaveWhitespacerr2cyr,r<rs r0setWhitespaceCharsz ParserElement.setWhitespaceChars s"%r2cyr,r<rs r0 parseWithTabszParserElement.parseWithTabs rr2cyr,r<rs r0setDebugActionszParserElement.setDebugActions rr2cyr,r<rs r0setDebugzParserElement.setDebug rr2cyr,r<rs r0setNamezParserElement.setName r2cyr,r<rs r0 parseFilezParserElement.parseFile sr2cyr,r<rs r0runTestszParserElement.runTests rr2FrWrTr&rVr,))rrrWr)TF)rF)T#TTFNNF)r'FFF)r5r:r;rArr8rrrxrr staticmethodrrrarrrr1rcrrrrrr) ParseActionr4r6ParseConditionr9ParseFailActionr;r|rCrIrLrQr r#rdrirlrrecursion_lockrnrDictr rWdictrvryrxrzrr'rrrrrrrr_MAX_INTrrrrrGrrrrrrrrrrrrr__iter__rrr rrr rrrrrrrr!propertyr$rr#r(rTr,r/rrr r5r@rr rKrOrRrrr~rr!rrrrrrrrrrrrrrrrrrrrrrrr canParseNextr defaultNamer<r2r0rrs 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 !!LJKr2cJeZdZd dedeffd ZdefdZd dZdZ dZ xZ S) rrrc>t|||_||_yr,)superr1anchorr)r.rrrs r0r1z_PendingSkip.__init__ s  "r2rWcbt|jtzjddS)Nr...)r8rrreplacers r0r#z!_PendingSkip._generateDefaultName# s%4;;()11'5AAr2c t|jdd}jrEd}fd}j|j |z|j |z|zSj|z|zS)Nrrc|jr|jjdgk(r|d=|jddyy)Nrwr_skipped)rrpop)rs r0rz'_PendingSkip.__add__..must_skip* s:zzQZZ%7%7%9bT%A!EE*d+&Br2c|jjdddgk(r0|jddtjzdz|d<yy)Nrrwrz missing <>)rrrreprr)rr.s r0 show_skipz'_PendingSkip.__add__..show_skip/ sN::%%',4EE*%$/$t{{2C$Cc$IAjM5r2)rr(rrr6)r.rskipperrrs` r0rz_PendingSkip.__add__& s/&-((/ < >> ,  J  gi88CC),,Y78  {{W$u,,r2c|jSr,)rrs r0r/z_PendingSkip.__repr__; sr2ctd)NzBuse of `...` expression without following SkipTo target expression)rWrss r0rLz_PendingSkip.parseImpl> s P  r2rr) r5r:r;rrxr1r8r#rr/rL __classcell__rs@r0rr s3#]#t# BcB-*  r2rc.eZdZdZfdZdefdZxZS)TokenzYAbstract :class:`ParserElement` subclass, for defining atomic matching patterns. c&t|dy)NFrrr1r.rs r0r1zToken.__init__I s %(r2rWc,t|jSr,)rr5rs r0r#zToken._generateDefaultNameL sDz"""r2)r5r:r;rAr1r8r#rrs@r0rrD s)#c#r2rc*eZdZdZfdZddZxZS)rz( A token that will never match. cLt|d|_d|_d|_y)NTFzUnmatchable token)rr1rrrrs r0r1zNoMatch.__init__U s% "") r2c2t|||j|r,)rrrKs r0rLzNoMatch.parseImpl[ sXsDKK>>r2rr5r:r;rAr1rLrrs@r0rrP s* ?r2rcjeZdZdZd dddedeffdZdZd dddedeffdZd efd Zd d Z xZ S)rja 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`. rw matchString match_stringrc|tur<|xs|}|st| tSt |dk(rt| t St| |SrE)rjr__new__rrF_SingleCharLiteral)rSrrrs r0rzLiteral.__new__o sT '>&6,Lwu--< A%w'9::ws##r2c|jfSr,)matchrs r0__getnewargs__zLiteral.__getnewargs__| s }r2ct||xs|}||_t||_|dd|_d|j z|_d|_d|_ y)Nrr'F) rr1rrFmatchLenfirstMatchCharrTrrrr.rrrs r0r1zLiteral.__init__ sZ "2l ! L) *2A.!DII- #"r2rWc,t|jSr,rrrs r0r#zLiteral._generateDefaultName DJJr2c|||jk(r7|j|j|r||jz|jfSt |||j |r,)rrErrrrrKs r0rLzLiteral.parseImpl sY C=D// /H4G4G JJ5 & 2 2XsDKK>>r2rwr) r5r:r;rAr8rrr1r#rLrrs@r0rjrj_ sR  $2 $3 $S $#R#S#s# c ?r2rjc>eZdZdZdddfd ZdefdZd dZxZS) rz, An empty token, will always match. rwrc@t|dd|_d|_y)NrwTFrr1rrrs r0r1zEmpty.__init__ s  ""r2rWcy)Nrr<rs r0r#zEmpty._generateDefaultName sr2c |gfSr,r<rKs r0rLzEmpty.parseImpl rMr2r r) r5r:r;rAr1r8r#rLrrs@r0rr s%#r# cr2rceZdZddZy)rcx|||jk(r|dz|jfSt|||j|rE)rrrrrKs r0rLz_SingleCharLiteral.parseImpl s< C=D// /7DJJ& &XsDKK>>r2Nr)r5r:r;rLr<r2r0rr s?r2rc eZdZdZedzZ dddddedejede d ed ejef fd Z d efd Z ddZ e ddZeZxZS)Keyworda 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_$rwNr identCharsr ident_charscaselessrrct||xs|}|tj}|xs|}||_t ||_ |d|_dt|jd|j|_ d|_d|_||_|r%|j#|_|j#}t'||_y#t$r tdwxYw)Nrz2null string passed to Keyword; use Empty() insteadr'rF)rr1rDEFAULT_KEYWORD_CHARSrrFrrrVrrr5rTrrrrupper caselessmatchrr)r.rrrrrrs r0r1zKeyword.__init__ s .;   66J"2l ! L)  S".q/D "$t*"5"5!6a {C #"  !-!3!3!5D #))+Jj/ SQR R Ss  CCrWc,t|jSr,rrs r0r#zKeyword._generateDefaultName rr2c|j}|}|jr||||jzj|jk(rr|dk(s"||dz j|j vrw|t ||jz k\s,|||jzj|j vr||jz|jfS|dz }||jz}n|dz }|dz }n|||jk(r|jdk(s|j|j|r|dk(s||dz |j vri|t ||jz k\s|||jz|j vr||jz|jfS|dz }||jz}n |dz }|dz }t||||)Nrrz/, was immediately followed by keyword characterz7, keyword was immediately preceded by keyword characterz7, keyword was immediately followed by keyword character) rrrrrrrFrrrEr)r.rrr!rerrlocs r0rLzKeyword.parseImpl s ==cDMM1288:d>P>PP!8xa0668Os8}t}}<<#C$--$78>>@W"T]]2DJJ>>"SS!$t}}!4WWF 1WF  !4!44MMQ&&&tzz37!8xa0Gs8}t}}<<#C$--$78O"T]]2DJJ>>U"%t}}!4WWF 1WFXvvt< ['CMD', 'CMD', 'CMD'] (Contrast with example for :class:`CaselessKeyword`.) rwrrrc|xs|}t||j||_d|jz|_y)Nr')rr1r returnStringrTrrs r0r1zCaselessLiteral.__init__3 s;"2l  ++-.(!DII- r2c||||jzj|jk(r||jz|jfSt |||j |r,)rrrr&rrrKs r0rLzCaselessLiteral.parseImpl: sV C# - . 4 4 6$** D&(9(99 9XsDKK>>r2r r)r5r:r;rAr8r1rLrrs@r0r$r$% s' .R.S.s.?r2r$c veZdZdZ d ddddedej ededej effd ZxZS) CaselessKeywordz Caseless version of :class:`Keyword`. Example:: CaselessKeyword("CMD")[1, ...].parse_string("cmd CMD Cmd10") # -> ['CMD', 'CMD'] (Contrast with example for :class:`CaselessLiteral`.) rwNrrrrrcB|xs|}|xs|}t|||dy)NT)rr)r.rrrrrs r0r1zCaselessKeyword.__init__L s- .; "2l  zDAr2)rwN) r5r:r;rAr8rrr1rrs@r0r)r)@ sf ,0 B +/ B B__S) B  B OOC( B Br2r)cjeZdZdZ d ddddedej edeffdZd efd Z d d Z xZ S) CloseMatchaA 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) maxMismatchesrrmax_mismatchesr-c||n|}t|||_||_d|jd|jd|_||_d|_d|_y)Nr'z (with up to z mismatches)F)rr1rr-rrrr)r.rr.r-rrs r0r1zCloseMatch.__init__| sh+9*D-  (*!$"3"3!6mDDVDVCWWcd   "#r2rWcJt|jd|jS)Nrt)rr5rrs r0r#zCloseMatch._generateDefaultName s%t*%%&a(9(9'<==r2c|}t|}|t|jz}||kr|j}d}g} |j} tt ||||D]]\}} | \} } |j r | j | j } } | | k7s=| j|t| | kDs]n&||zdz}t|||g}||d<| |d<||fSt|||j|)Nrroriginal mismatches) rFrr- enumerateziprryrr#rr)r.rrr!rrGmaxlocrmatch_stringlocr3r-s_msrcmatresultss r0rLzCloseMatch.parseImpl sx=T..// X ,,LOJ ..M(1HS(,7)$S=="yy{CIIKC#:%%o6:6)o-1&s(;'<=&2 #(2 %G|#XsDKK>>r2r,r) r5r:r;rAr8rrr|r1r#rLrrs@r0r,r,Y sV J04$  $$,$  $">c>?r2r,c eZdZdZ dddddddedej ededed ed ed ej ed ej ed ej ededej effdZ defdZ ddZ ddZ xZ S)Worda: 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_charsr>r?r@rAcf|xs|}| xs|} | xs|} | xs|} t||s"tdt|jdt |} | r/t | } | | z} | rdj t | | z } | |_dj t| |_ | r0t | |_ dj t| |_ n| |_ |j|_ |dkD|_ |dkr td|jr||kDrtd|d|d ||_ |dkDr||_n t|_|dkDr|x}}||_||_ d |j z|_d |_| |_|j&r|xj"d z c_d |j|jzvrt)|jdk(r t+j,|j}ndt/|jd}|j|jk(rx|dk(rd}nd|dk(rd}n\|j|jk7r3d|jd|jtk(rdn |jd}nd|jd}|||_ns|dk(rd}d}n\dt/|jd}|dk(rd}n;|dk(r |dkrdnd}n,||k7rd|dkDr|dz ndd|dz d}nd|dkDr|dz ndd}||||_|j&rd|j0d|_ t+j2|j0|_|j*j4|_|j8|_yy#t*j<$r d|_YywxYw)Nzinvalid z", initChars cannot be empty stringrwrrzUcannot 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=rr'Fz as a keywordr[r+{r}r"rd?z\b)rr1rrr5rrr>sorted initCharsOrigr? bodyCharsOrig maxSpecifiedminLenmaxLenrrTrrr@rFreescaperreStringcompilerre_matchparseImpl_regexrLerror)r.rBrCrrDrErFrGr>r?r@rA initChars_setexcludeChars_setre_leading_fragmentrepeatre_body_fragmentrs r0r1z Word.__init__ s+ + + #4}  4:..//QR I "<0  - -MGGC N5E$EF &WWVM%:;  ^DN!# ):!;D *DN!%!3!3D !G 7g    sVWZV[[abeaffgh  7DK"DK 19 C#DKDK!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$NN0/N0rWcd}|j|jk7r*d||jd||jd}nd||jd}|jdkDs|jtk7r|j|jk(r'|jdk(r|ddS|d|jdzS|jtk(r|d|jd zS|d|jd |jdzS|S) NcVd}t|d}t||kDr |d|dz dzS|S)NF) re_escaper'r)rrF)r max_repr_lens r0 charsAsStrz-Word._generateDefaultName..charsAsStrl s<L*1>A1v $+r?rRrSr)r.rebases r0r#zWord._generateDefaultNamek s  >>T^^ +DNN34Bz$..7Q6RRSTDDNN34A6D ;;?dkkX5{{dkk);;!#8OBt{{m2"666(4;;-v6664;;-q R@@@ r2c|||jvrt|||j||}|dz }t|}|j}||j z}t ||}||kr|||vr|dz }||kr|||vrd}||z |jkrd}nD|jr||kr |||vrd}n)|jr|dkDr ||dz |vs ||kr |||vrd}|rt|||j|||||fS)NrFTr) r>rrrFr?rSrrRrQr@) r.rrr!rrG bodycharsr6throwExceptions r0rLzWord.parseImpl s, C= . 3 TB B qx=NN $VX&Flx} 9 1HCFlx} 9 ; $!N   3>hsmy6P!N ^^ UQY'94>SMY.!%  3 TB BHU3'''r2c|j||}|st|||j||j}||j fSr,)rXrrrgroup)r.rrr!rs r0rYzWord.parseImpl_regex sFx- 3 TB BjjlFLLN""r2)rwNrrrFNr)r5r:r;rAr8rrr|rxr1r#rLrYrrs@r0r=r= s@H+/ .2v6+/*.-1v6v6OOC(v6 v6  v6  v6v6s+v6??3'v6??3'v6v6ooc*v6pc6(@#r2r=c zeZdZdZ d ddddededejeded ejef fd ZxZ S) CharzA short-cut class for defining :class:`Word` ``(characters, exact=1)``, when defining a match of any single character in a string of characters. FN)r@rAcharsetrFrGr@rAcD|xs|}|xs|}t||d||y)Nr)rErFrGr)r.rorFrGr@rArs r0r1z Char.__init__ s4+ #4}   1,  r2)FN) r5r:r;rAr8rxrrr1rrs@r0rnrn si!.2   -1      s+    ooc*   r2rnceZdZdZ dddddedeejefde de de d e f fd Z e d Ze d Z e d Z defdZddZddZddZdedefdZxZS)RegexaToken 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_matchrsrtc t||xs|}|xs|}t|tr*|s t dd|_|x|_|_||_nJt|dr3t|dr'||_|jx|_|_||_n tdd|jz|_ d|_ ||_||_|jr|j |_|jr|j$|_yy)aThe 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() insteadNrurzCRegex may only be constructed with a string or a compiled RE objectr'F)rr1rXr&r_rerVrurvr(rrTrrrsrtparseImplAsGroupListrLparseImplAsMatch)r.rurvrwrxrsrtrs r0r1zRegex.__init__ s !2] %X gx ( !STTDH+2 2DMDLDJ Wi (WWg-FDH+2?? :DL4=DJU "DII- "&   !66DN <<!22DN r2c|jr |jS tj|j|jS#tj $rt d|jdwxYw)Nzinvalid pattern (z) passed to Regex)rzrTrWrurvrZrrs r0rTzRegex.re sa 8888O Xzz$,, ;;88 X #4T\\4DDU!VWW Xs )A-A1c.|jjSr,)rTrrs r0rXzRegex.re_match sww}}r2c(|jdduSNrw)rXrs r0rzRegex.mayReturnEmpty s}}R ,,r2rWcjdjt|jjddS)NzRe:({})z\\\)formatrrurrs r0r#zRegex._generateDefaultName s)T\\ 2 : :64 HIIr2c|j||}|st|||j||j}t |j }|j }|r|jD] \}}|||< ||fSr,)rXrrrr#rl groupdictitems) r.rrr!rr8dkvs r0rLzRegex.parseImpl! s|x- 3 TB Bjjl6<<>*      1A"Cxr2c|j||}|st|||j||j}|j }||fSr,)rXrrrgroupsr.rrr!rr8s r0r{zRegex.parseImplAsGroupList. sIx- 3 TB BjjlmmoCxr2c|j||}|st|||j||j}|}||fSr,)rXrrrrs r0r|zRegex.parseImplAsMatch7 sCx- 3 TB BjjlCxr2replcjr tdjrtr tdjrfd}nfd}j |S)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,|djSr)expand)r`rs r0rzRegex.sub..paU say''--r2cBjj|dSr)rTsub)r`rr.s r0rzRegex.sub..paZ sww{{433r2)rsrrtr-r6)r.rrs`` r0rz Regex.sub@ s]   MN N < 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 )rbrc)z\f )z\r rwNT) quoteCharescCharescQuoteunquoteResults endQuoteCharconvertWhitespaceEscapes quote_charesc_char esc_quote multilineunquote_resultsend_quote_charconvert_whitespace_escapesrrrrrrc t| xs|} | xs|} | xr|} | xs|} | xr|} |xs|}|j}|s td| |} n| j} | s td|_t |_|d_| _t | _ | xsd_ | xsd_ | _ | _ |_d}d}| r ||dtj | dz }d}| r=||dtj | dz }d}tj | d z_t jd kDrI||ddj%fd t't jd z dd Dzdzz }d}tj(d_|rWtj,tj.z_||d t1jd| t1| nddz }n1||d t1jdd| t1| nddz }dj%tj jd|dtj jg_jrjrktj4ddj%dj6Ddtj jdj*_nGtj4dtj jdj*_ tj4j2j*_j2_jj<_djBz_"d_#d_$y#tj@$rtdj2dwxYw)Nz%quote_char cannot be the empty stringz)end_quote_char cannot be the empty stringrrw(?:r|z.)z(.)rc 3K|]M}dtjjd|dtjj|ddOyw)rNz(?!z)))rTrUr)rIrur.s r0rz(QuotedString.__init__.. sYE"))D$5$5bq$9:;3ryyIZIZ[\[]I^?_>``bcEsAArz(?:[^z])z\n\rz)*rc3FK|]}tj|ywr,)rTrU)rIrs r0rz(QuotedString.__init__.. s!D 1"))A, s!z)|(z .)|(\n|.)rvzinvalid pattern z passed to Regexr'FT)%rr1rgrrrF quoteCharLenfirstQuoteCharrendQuoteCharLenrrrrrrTrUescCharReplacePatternrrangerrv MULTILINEDOTALLrrurWws_mapunquote_scan_rerVrrXrZrTrrr)r.rrrrrrrrrrrrrsep inner_patternrs` r0r1zQuotedString.__init__ s" %X(y';O#5~ $ C)C !,*  %%' DE E  %L'--/L !LMM(!$Z#-a=!-$' $5#Mr %^ $2.F%"  S8)<(=Q? ?MC  S7);(>T.. .:dnnh3W((:; ;.t~~.>mDL]L]K^__r2c||jk(xrj||xsd}|st||j|j }|j }j r|jj }t|trjr4djfdjj|D}n1djdjj|D}jr&|j!jj"}||fS)Nrwc3K|]i}|jdrj|jdn5|jdr|jddn|jdkyw)rrdrr'N)rlr)rIrr.s r0rz)QuotedString.parseImpl.. sl" &HE !;;q> EKKN3!;;q>#[[^B/"[[^ , &HsA/A2c3K|]:}|jdr|jddn|jd<yw)rrrdN)rl)rIrs r0rz)QuotedString.parseImpl..! s<"%GE/4kk!n Ar*%++a.P%GsAA)rrXrrrrlrrrrXr&rrrfinditerrrrrs` r0rLzQuotedString.parseImpl s$ SMT00 0 - h,    3 TB Bjjllln   d''4+?+?*?@C#x(00''" &*%9%9%B%B3%G "C''"%)%9%9%B%B3%G"C ==++dmmT5F5FGCCxr2)rwNNFTNTr)r5r:r;rArrr8rrrxr1r#rLrrs@r0rr` s$%LN OF)-*. $/3+/u#(,)-#-1)-u#u#//#&u#??3' u#  u#  u#,u#%)u#u#%u#//#&u#u#ooc*u##'u#n`c` $r2rc \eZdZdZ d dddededededef fd Zd efd Zdd ZxZ S) CharsNotInaToken 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'] rw)notChars not_charsrrDrErc\t|d|_|xs||_t |j|_|dkr t d||_|dkDr||_n t|_|dkDr||_||_d|jz|_ |jdk(|_ d|_ y)NFrzacannot specify a minimum length < 1; use Opt(CharsNotIn()) if zero-length char group is permittedrr')rr1rrr notCharsSetrrRrSrrTrrr)r.rrrDrErrs r0r1zCharsNotIn.__init__B s #!-X t}}- 7K   7DK"DK 19DKDK!DII- "kkQ."r2rWct|j}t|dkDrd|jdddSd|jdS)Nrbz!W:( z...)r)rrrF)r. not_chars_strs r0r#zCharsNotIn._generateDefaultNamee sK24==A }  "$--&12$7 7$--* *r2cH|j}|||vrt|||j||}|dz }t||jzt |}||kr|||vr|dz }||kr|||vr||z |j krt|||j|||||fSrE)rrrrrSrFrR)r.rrr!notcharsrmaxlens r0rLzCharsNotIn.parseImpll s## C=H $ 3 TB B qUT[[(#h-8Flx}H< 1HCFlx}H< ; $ 3 TB BHU3'''r2)rwrrrr) r5r:r;rAr8r|r1r#rLrrs@r0rr- sg, !#!#!#!# !#  !#!#F+c+(r2rc eZdZdZidddddddd d d d d ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*Zd3d+ed,ed-ed.effd/ Zd0efd1Zd4d2Z xZ S)5WhiteaSpecial 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. rzrzrczrzrz zu zu᠎zu z u z u z u z u zu zu zu zu zz z zzzz)u u u​u u u wsrrDrEc8t|_jdj fdj Ddd_djz_|_ |dkDr|_ n t_ |dkDr|_ |_ yy)Nrwc3@K|]}|jvs|ywr,) matchWhite)rIcr.s r0rz!White.__init__.. sJ~!$//1IA~sTrr'r) rr1rrr whiteStrsrrTrrRrSr)r.rrrDrErs` r0r1zWhite.__init__ s  !! GGJt~~J J " #!DII-  7DK"DK 19DKDK r2rWcFdjd|jDS)Nrwc3BK|]}tj|ywr,)rrrIrs r0rz-White._generateDefaultName.. sC?auq)?s)rrrs r0r#zWhite._generateDefaultName swwC4??CCCr2cp|||jvrt|||j||}|dz }||jz}t |t |}||kr-|||jvr|dz }||kr|||jvr||z |j krt|||j|||||fSrE)rrrrSrrFrR)r.rrr!rr6s r0rLzWhite.parseImpl s C= / 3 TB B q$VS]+Flx}? 1HCFlx}? ; $ 3 TB BHU3'''r2)z rrrr) r5r:r;rArr8r|r1r#rLrrs@r0rr} s+ V g f f  f  (  & / + + , , ( ' & "!" '#$! &'/I4 3  s s ,DcD (r2rceZdZfdZxZS) PositionTokenc>t|d|_d|_yr=r rs r0r1zPositionToken.__init__ s ""r2)r5r:r;r1rrs@r0rr s ##r2rcDeZdZdZdeffd ZdededefdZd dZxZ S) GoToColumnzaToken to advance to a specific column of input text; useful for tabular report scraping. colnoc0t|||_yr,)rr1r)r.rrs r0r1zGoToColumn.__init__ s r2rrrWcZt|||jk7rt|}|jr|j||}||krc||j rPt|||jk7r7|dz }||kr-||j rt|||jk7r7|SrE)rrFrrCisspace)r.rrrGs r0rIzGoToColumn.preParse s sH  )8}H**8S9hSM))+X&$((2q hSM))+X&$((2 r2ct||}||jkDrt||d|||jz|z }|||}||fS)NzText not in expected column)rr)r.rrr!thiscolnewlocr8s r0rLzGoToColumn.parseImpl sTc8$ TXX  30MtT Ttxx')s6"s{r2r) r5r:r;rAr|r1r8rIrLrrs@r0rr s3c  3 3 r2rc>eZdZdZfdZdededefdZddZxZ S) LineStartaMatches 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'] ct||jt|jz|_|jj dtj|j|_ d|_ y)NrczExpected start of line) rr1rrrorig_whiteCharsdiscardrrrrrs r0r1zLineStart.__init__s^  "ut6 %w33DOOD . r2rrrWc|dk(r|S|jj||}d|jvr6|||dzdk(r+|jj||dz}|||dzdk(r+|S)Nrrcr)rrIr)r.rrr8s r0rIzLineStart.preParsesy !8J,,''#6Ct+++sS1W-5,,//#'BCsS1W-5Jr2cXt||dk(r|gfSt|||j|rE)rrrrKs r0rLzLineStart.parseImpls/ sH  "7NXsDKK>>r2r) r5r:r;rAr1r8r|rIrLrrs@r0rr s,,/33?r2rc*eZdZdZfdZddZxZS)LineEndzTMatches if current position is at the end of a line within the parse string ct||jjd|j |jdd|_y)NrcFrzExpected end of line)rr1rrrrrs r0r1zLineEnd.__init__$s>  % !!$//!G, r2c|t|kr'||dk(r|dzdfSt|||j||t|k(r|dzgfSt|||j|)NrcrrFrrrKs r0rLzLineEnd.parseImpl*sl X }$Qw}$$XsDKKFF CM !7B;  3 TB Br2rrrs@r0rrs- Cr2rc*eZdZdZfdZddZxZS) StringStartzLMatches if current position is at the beginning of the parse string c0t|d|_y)NzExpected start of textrr1rrs r0r1zStringStart.__init__;s . r2cn|dk7r-||j|dk7rt|||j||gfSr)rIrrrKs r0rLzStringStart.parseImpl?s: !8dmmHa00$XsDKKFFBwr2rrrs@r0rr6s/r2rc*eZdZdZfdZddZxZS)rzG Matches if current position is at the end of the parse string c0t|d|_y)NzExpected end of textrrs r0r1zStringEnd.__init__Ls , r2c|t|krt|||j||t|k(r|dzgfS|t|kDr|gfSt|||j|rErrKs r0rLzStringEnd.parseImplPsg X  3 TB B CM !7B;  3x= 7N 3 TB Br2rrrs@r0rrGs-Cr2rc>eZdZdZefeddedeffdZddZxZS) WordStartaMatches 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_charsrcj|tk(r|n|}t| t||_d|_y)NzNot at the start of a word) printablesrr1rrrr.rrrs r0r1zWordStart.__init__es."+z"9Jy  Y2 r2c|dk7r=||dz |jvs|||jvrt|||j||gfSNrr)rrrrKs r0rLzWordStart.parseImplksL !8q!T^^3C=6$XsDKKFFBwr2r r5r:r;rArr8r1rLrrs@r0rr[s,*4333333 r2rc>eZdZdZefeddedeffdZddZxZS)WordEndaiMatches 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. rrrcx|tk(r|n|}t| t||_d|_d|_y)NFzNot at the end of a word)rrr1rrrrrs r0r1zWordEnd.__init__~s6"+z"9Jy  Y#0 r2ct|}|dkDrB||kr=|||jvs||dz |jvrt|||j||gfSr)rFrrr)r.rrr!rGs r0rLzWordEnd.parseImpls[x= a.s@%$:dH-%sc3dK|]'}t|trj|n|)ywr,)rXr&r)rIr?r.s r0rz+ParseExpression.__init__..s3"4>a3JD,,Q/PQQ"s-0F) rr1rX_generatorTyperr&rrrranyrrr.rrrs` r0r1zParseExpression.__init__s " e^ ,KE eX &2259:DJ""!} -DJ"x (KE@%@@"eDJ "  %!%[ " %#W ! %sC''DDrWc |jddSr,)rrs r0r zParseExpression.recurseszz!}r2cJ|jj|d|_|Sr,)rrrrs r0rzParseExpression.appends! %   r2r ct|||rO|jDcgc]}|jc}|_|jD]}|j||Scc}w)z Extends ``leave_whitespace`` defined in base class, and also invokes ``leave_whitespace`` on all contained expressions. )rrrrr.r r?rs r0rz ParseExpression.leave_whitespaces[  + ,0JJ7Jq!&&(J7DJZZ""9-  8A$ct|||rO|jDcgc]}|jc}|_|jD]}|j||Scc}w)z Extends ``ignore_whitespace`` defined in base class, and also invokes ``leave_whitespace`` on all contained expressions. )rrrrrs r0rz!ParseExpression.ignore_whitespaces[ !), ,0JJ7Jq!&&(J7DJZZ##I.  8rc@t|trN||jvr>t|||j D] }|j |jd"|St|||j D] }|j |jd"|SNr)rXr rrrr)r.rr?rs r0rzParseExpression.ignores eX &D,,,u%AHHT--b12$   GN5 !ZZ))"-.  r2c`|jjdt|jdSNz:(r)rr5r8rrs r0r#z$ParseExpression._generateDefaultNames)..))*"S_,=Q??r2c|jr|St| |jD]}|jt |jdk(re|jd}t ||j r|js|jv|jsj|jdd|jdgz|_d|_ |xj|jzc_ |xj|jzc_ |jd}t ||j r|js|ju|jsi|jdd|jddz|_d|_ |xj|jzc_ |xj|jzc_ dt|z|_|S)Nrdrrrr')rrrrrFrXrrrrrrrr8r)r.r?rrs r0rzParseExpression.streamlinesp   K A LLN tzz?a JJqME5$..1))%%- "[[^tzz!}o= $(!##u';';;#""e&9&99"JJrNE5$..1))%%- !ZZ_u{{1~= $(!##u';';;#""e&9&99"!CI-  r2ctjdtd||ngdd|gz}|jD]}|j ||j gyNr:rdr;)r=rNr>rr@r5)r.r?tmpr?s r0r@zParseExpression.validatesX h  !. 9}r1ENA JJsO R r2ct|}tjt|}|j Dcgc]}|jc}|_|Scc}wr,)rrrrrr)r.r8r?rs r0rzParseExpression.copysHglnkk/3/'+zz2z!QVVXz2  3sAc tjrtj|jvr|jD]}t |t s|js!tj|jvs>tjdjd|t|j|jdt|9||SNzY{}: setting results name {!r} on {} expression collides with {!r} on contained expressionrYr'r;)rLrYrcrrrXrrr=rNrrr5rrr.rTrr?rs r0rzParseExpression._setResultsNames  > >EE**+ZZq-0 #MM//0MMEEKVG  J//MM F $%  $w&t^<.m%K 1a&6&6 rrrFT)rrr4rFrrrrrrrrWrr1r0rrXrrrrrr) r.r)rrrrur skipto_argrs r0r1z And.__init__Wsv&*)_ X&C$U+48#3u:>)4:KK+ega!e .D5%5$  #56*#5k#BC'NJJt$,E!H ) ::"%%K %K"KD djjmU3))JJqM,,"&**Q-"E"E*'+jjm&B&B# !',#!#'D  r2rWc|jrtd|jddDrt}t|jddD]\}}||ur t |t s|js)t |jdt sG|jd|j|dzz|jd<||j|dz<|jDcgc] }||us| c}|_t |!t|j|jddD]\}}t} t||vr|jt|t |tr|j|fd^|j}t!t#|d}|t%j&t(|}t+d|jD|_|Scc}w)Nc3K|]A}t|txr+|jxrt|jdtCywrN)rXrrrr-s r0rz!And.streamline..}sK)A1o.:GG:qwwr{L9:)sAA rrc0t|dt||S)N parent_anchor)setattrr)rrrcur_s r0rz And.streamline..s' /3q!93r2c34K|]}|jywr,r,r-s r0rz!And.streamline..s!GJq!"2"2Jr)rr rr4rXrrrrr5rrQr  IndentedBlockr6r nextrrrrr0r) r.deleted_expr_markerrur?prevrr subs next_firstrs r0rzAnd.streamlinezs ::CR  '.i#%djj"o6DAq// "1o6GG&qwwr{LA&'ggbkDJJq1u4E&E ,? 1q5)7*.TAq@S7SaT   TZZAB8ID#5Dc7d?C!c=1))-0 {{}!$t*d3 %kk-< 9*"!GDJJ!GG ;Us ' G31G3c|jdj|||d\}}d}|jddD]U}t|tjurd}!|r |j|||\}}n|j|||\}}||z }W||fS#t $rt $r!}d|_t j|d}~wt$r"t |t||j|wxYw)NrFrrT) rr'rrrParseSyntaxExceptionr{r_from_exceptionrVrFr) r.rrr! resultlist errorStopr? exprtokensrs r0rLz And.parseImpls **Q-.. c95/ Z ABAAw#..(  &'hhxi&HOC#$((8S)"DZ * $J' (J,)C'+B$.>>rBB!. #h-dsBC/%C.C/ct|tr|j|}t|tstS|j |Sr,rXr&rrrrrs r0__iadd__z And.__iadd__; eX &,,U3E%/! !{{5!!r2cv|dd|gz}|jD]!}|j||jr!yyr,)rr5rr6s r0r5zAnd._checkRecursions;*1-6A  o .##r2cdjd|jD}t|dkDrB|ddt|dz dk(r+|dd}t|dkDr|ddt|dz dk(r+d|zdzS) Nrc32K|]}t|ywr,r.r-s r0rz+And._generateDefaultName..s4AQr.rr{}rrKrL)rrrFr.inners r0r#zAnd._generateDefaultNames444%j1nq':CJN':!;t!C!BKE%j1nq':CJN':!;t!CU{S  r2r)r5r:r;rArrrrrrxr1rrLrFr5r8r#rrs@r0rr=sb"UKO!!7!!CG!!F1M1f:"!c!r2rc~eZdZdZd dej edeffd Zdeffd Z d dZ dZ de fd Z d fd ZxZS) raRequires 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']] rrct||||jrCtd|jD|_t d|jD|_yd|_y)Nc34K|]}|jywr,r,r-s r0rzOr.__init__..r.rc34K|]}|jywr,rr-s r0rzOr.__init__..r.rTrr1rr rr0rrs r0r1z Or.__init__O ) ::"%%K %K"KD "%%K %K"KD "&D r2rWct||jretd|jD|_td|jD|_t d|jD|_|Sd|_|S)Nc34K|]}|jywr,r,r-s r0rz Or.streamline..r.rc34K|]}|jywr,rr-s r0rz Or.streamline..!C 1!,, rc3ZK|]#}|jxrt|t %ywr,rrXrr-s r0rz Or.streamline..,&GQ!  =Au)=%==z)+F)rrrr rrr0rrs r0rz Or.streamlinesu  ::"%%K %K"KD !!C !CCDO"%&GKzz&#D   $DO r2cd}d}g}g}td|jDr|j||}|jD]*} |j||d} |j | |f,|r|jtdd|s|dd} | j|||Sd} |D]@\}}|| dkr| cS |j|||\} }| |k\r| |fcS| | dkDs=| |f} B| dk7r| S|rZt|dkDrE|jd |dj|djk(r|jd |d}||||k(r|j|_|t||d |#t $r.} d| _|| _|j | d}d}Yd} ~ ld} ~ wt$r1} |s$d| _| j|kDr| }| j}Yd} ~ d} ~ wt$r>t||kDr,t|t||j|}t|}YwxYw#t$r/} d| _| j|kDr| }| j}Yd} ~ d} ~ wwxYw) Nrc34K|]}|jywr,)rr-s r0rzOr.parseImpl.. s2z!q~~zrTrer)rreverserr2c|j Sr,rr?s r0rzOr.parseImpl..J 155&r2rcZ|j tt|j fSr,rrFr8parser_elementrcs r0rzOr.parseImpl..L"vC@P@P.c; 1A r.rLrrrs r0r#zOr._generateDefaultNameb%UZZ; ;;;cAAr2c *tjrstj|jvrWt d|j Dr;t jdjd|t|jdt|1||S)Nc3xK|]2}t|txrtj|jv4ywr,rXrrcrXrr-s r0rz%Or._setResultsName..kD$A1c",II++,,$8:{}: 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 GrouprXr'r; rLrXrcrr rr=rNrrr5rrr.rTrrs r0rzOr._setResultsNamee  > >EE**+   239&CT ++3 ! w&t^< [['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']] rrct||||jrCtd|jD|_t d|jD|_yd|_y)Nc34K|]}|jywr,r,r-s r0rz&MatchFirst.__init__..r.rc34K|]}|jywr,rr-s r0rz&MatchFirst.__init__..r.rTrRrs r0r1zMatchFirst.__init__rSr2rWc>|jr|St| |jret d|jD|_t d|jD|_td|jD|_|Sd|_d|_|S)Nc34K|]}|jywr,rWr-s r0rz(MatchFirst.streamline..rXrc34K|]}|jywr,r,r-s r0rz(MatchFirst.streamline..r.rc3ZK|]#}|jxrt|t %ywr,rZr-s r0rz(MatchFirst.streamline..r[r\FT) rrrrr rrr0rrs r0rzMatchFirst.streamlines   K  ::!!C !CCDO"%%K %K"KD "%&GKzz&#D   $DO"&D  r2cd}d}|jD]} |j|||cS|||k(r|j|_ |t ||d|#t$r}d|_||_d}~wt $r'}|j |kDr|}|j }Yd}~d}~wt$r=t||kDr,t |t||j|}t|}YwxYw)Nrrj) rr'rrrhrrrVrFrr) r.rrr!rlrmr?rpras r0rLzMatchFirst.parseImpls  A .xx,  #C#';;    #A4 -' $(!%&"! (77Y&#&L #I .x=9,#1 #h-4$L!$H I  .s*A C"A++ C"7BAC"!C"ct|tr|j|}t|tstS|j |Sr,rErs r0__ior__zMatchFirst.__ior__rGr2cRddjd|jDzdzS)NrKz | c32K|]}t|ywr,r.r-s r0rz2MatchFirst._generateDefaultName..rzr.rLr{rs r0r#zMatchFirst._generateDefaultNamer|r2c *tjrstj|jvrWt d|j Dr;t jdjd|t|jdt|1||S)Nc3xK|]2}t|txrtj|jv4ywr,rr-s r0rz-MatchFirst._setResultsName..rrrrXr'r;rrs r0rzMatchFirst._setResultsNamerr2rr)r5r:r;rArrrrxr1rrLrr8r#rrrs@r0rrsS"'foom<''M #J"BcB==r2rcreZdZdZd dej edeffd ZdZ deffd Z d dZ de fd Z xZS) ralRequires 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 rrct||||jr"td|jD|_nd|_d|_d|_d|_y)Nc34K|]}|jywr,r,r-s r0rz Each.__init__..1r.rT)rr1rr0rrinitExprGroupsrrs r0r1z Each.__init__.sO ) ::"%%K %K"KD "&D ""r2ct|tr|j|}t|tstS|j |Sr,rErs r0__iand__z Each.__iand__8rGr2rWct||jr#td|jD|_|Sd|_|S)Nc34K|]}|jywr,r,r-s r0rz"Each.streamline..Br.rT)rrrr0rrs r0rzEach.streamline?sB  ::"%%K %K"KD  #'D  r2c t|jrtd|jD|_|jDcgc]}t |t s|j !}}|jDcgc]+}|jrt |t ttfs|-}}||z|_ |jDcgc]9}t |tr'|j j|jd;c}|_|jDcgc]9}t |tr'|j j|jd;c}|_|jDcgc] }t |t ttfr|"c}|_|xj"|j z c_d|_|}|j"dd}|jdd} |jdd} g} d} g} g}| r|| z| z}| j%|j%|D]w} |j'||d}| j)|jj+t-||||vr|j/|b|| vsg| j/|yt9| t9|k(rd} | r|rZt9|dkDrE|j;d|d j<|dj<k(r|j;d |d }||r9d j?|Dcgc] }tA|c}}t7||d |d | |jDcgc]$}t |t s|j | vs#|&c}z } tCg}| D]}|jE|||\}}||z }||fScc}wcc}wcc}wcc}wcc}w#t0$r;}d|_||_|j)|| j)|Yd}~d}~wt6$r| j)|YwxYwcc}wcc}w)Nc3lK|],}t|tst|j|f.ywr,)rXrrQrr-s r0rz!Each.parseImpl..Is) )3Az!S7IAFFQs44T)rFr_rc|j Sr,rbrcs r0rz Each.parseImpl..rdr2rercZ|j tt|j fSr,rgrcs r0rz Each.parseImpl..rir2rfz'Missing one or more required elements (r)#rrropt1maprXrrrrrr optionalsrrrmultioptionalsr multirequiredrequiredrrirr1rQremoverrrhrrFrkrrr8r#r')r.rrr!r?opt1opt2tmpLoctmpReqdtmpOptmultis matchOrder keepMatchingfailedrntmpExprsrprumissing total_resultsr;s r0rLzEach.parseImplGs    )- DL%)JJEJq*Q2DAFFJDE#A##Jq3z:R,S#  "D[DN##Aa0'' 'M##D "#Aa+'' 'M#"D   ::%aZCY;W-X:DM MMT// /M"'D --""$$Q'  '&0H LLN LLN)[[6t[LF%%dll&6&6r!ua&@AG|q)f a( 6{c(m+$ +0 6{Q 0 1!9==F1IMM1KK$SKTq IO ii 9AQ 9:G 9'!D  $**X*Q 1c0BqvvQWGWq*XX $R( A88Hc9=LC W $MM!!aF # " ,+%(,C%)*C&MM#&MM!$$%%MM!$%*!:Ys_N4N410N9;>N>>O# OOO P0P5+P5:P5 P-0P  P-,P-cRddjd|jDzdzS)NrKz & c32K|]}t|ywr,r.r-s r0rz,Each._generateDefaultName..rzr.rLr{rs r0r#zEach._generateDefaultNamer|r2r)r5r:r;rArrrrxr1rrrLr8r#rrs@r0rrsK7rfoom<"MU"nBcBr2rceZdZdZddeeefdeffd Zde efdZ ddZ ddedeffd Z ddedeffd Z deffd Zdeffd Zd ZdddZdefdZee dZee dZxZS)ParseElementEnhancezfAbstract subclass of :class:`ParserElement`, for combining and post-processing parsed tokens. rrct||t|trt j t |}t|jtr|j|}nEtt||jr t|}n|jt|}t j t|}||_ ||j|_|j|_|j!|j"|j$|j&|_|j(|_|j*|_|j,j/|j,yy)Nr)rr1rXr&rrr8 issubclassrrrrjrrrrrrrrrrrr )r.rrexpr_strrs r0r1zParseElementEnhance.__init__s  " dH %{{3-H$22E://9DJ(@(@Ax(//0AB{{=$/  !%!3!3D "&"5"5D   % %t/I/I & #'"5"5D "ooDO $ 1 1D     # #D$4$4 5 r2rWc8|j |jgSgSr,rrs r0r zParseElementEnhance.recurses"ii3 {;;r2c|j |jj|||dSt ||d|#t$r}|j|_d}~wwxYw)NFrzNo expression defined)rr'r{rrr)r.rrr!pbes r0rLzParseElementEnhance.parseImplsc 99  yy''#yu'UU !30GN N & ++ s; AAAr ct|||rF|j:|jj|_|jj||Sr,)rrrrr.r rs r0rz$ParseElementEnhance.leave_whitespacesF  + yy$ IINN,  **95 r2ct|||rF|j:|jj|_|jj||Sr,)rrrrrs r0rz%ParseElementEnhance.ignore_whitespacesF !), yy$ IINN,  ++I6 r2cTt|trS||jvrCt|||j (|j j |jd|St|||j (|j j |jd|Sr)rXr rrrrr.rrs r0rzParseElementEnhance.ignores eX &D,,,u%99(II$$T%5%5b%9:   GN5 !yy$   !1!1"!56 r2cpt||j|jj|Sr,)rrrrs r0rzParseElementEnhance.streamlines-  99 II " r2c||vrt||gz|dd|gz}|j|jj|yyr,)RecursiveGrammarExceptionrr5)r.r7r8s r0r5z#ParseElementEnhance._checkRecursionsP # #+,<v,EF F*1-6 99 II % %o 6 !r2ctjdtd|g}|dd|gz}|j|jj ||j gyrr=rNr>rr@r5r.r?rs r0r@zParseElementEnhance.validates_ h   MA$' 99 II  s # R r2c`|jjdt|jdSr)rr5r8rrs r0r#z(ParseElementEnhance._generateDefaultNames)..))*"S^,>r2cyr,r<rs r0rz#ParseElementEnhance.leaveWhitespacerr2cyr,r<rs r0rz$ParseElementEnhance.ignoreWhitespace rr2rrr,rV)r5r:r;rAr rr8rxr1rr rLrrrrr5r@r#r!rrrrs@r0rrs6U=##566$6.<m,<O$-4= } M 7 !?c? &'"("'(#)#r2rcleZdZdZGddeZGddeZdddd ed ed effd Z dd Z xZ S)r8z Expression to match one or more expressions at a given indentation level. Useful for parsing text where structure is implied by indentation (like Python source code). c$eZdZdeffd ZxZS)IndentedBlock._Indentref_colc`t|d|_|jfdy)Nzexpected indent at column c"t||k(Sr,rrrrrs r0rz0IndentedBlock._Indent.__init__..ss1ayG/Cr2rr1rr9r.rrs `r0r1zIndentedBlock._Indent.__init__s+ G  6wi@DK   C Dr2r5r:r;r|r1rrs@r0_Indentrs EC E Er2rc$eZdZdeffd ZxZS)IndentedBlock._IndentGreaterrc`t|d|_|jfdy)Nz'expected indent at column greater than c"t||kDSr,rrs r0rz7IndentedBlock._IndentGreater.__init__.. ss1ay7/Br2rrs `r0r1z%IndentedBlock._IndentGreater.__init__s+ G  CG9MDK   B Cr2rrs@r0_IndentGreaterrs DC D Dr2rFTr groupedrr rcRt||d||_||_d|_y)NTrr)rr1 _recursive_groupedr4)r.rr rrs r0r1zIndentedBlock.__init__"s/ -$ r2c$tj||}|jj|||t ||}|j |}t|z|jz}|j rp|j|}t|j|j |j} | j|j|| _ |t|| zz }|jdtt!|ddj#d|t%|} |j |jt'z} |jrt(} nd} | | t+| zj-|||S)Nrkrzinner @c|Sr,r<rs r0rz)IndentedBlock.parseImpl..Js4r2)rrIrrirrrrr8rr!rr4rr(hexrQrrrGrouprrL) r.rrr! anchor_loc indent_colpeer_detect_expr inner_expr sub_indent nested_blockblocktrailing_undentrs r0rLzIndentedBlock.parseImpl,s[W%%h4  HjYGX. << 3W//$)); ??,,Z8J( T__dmmL  " "4:: .)3L & #j<78 8JfSJ%8%=%C%C%E$Fa |TU*%,,t'9'9:Y[H ==G'G/!::EE j)  r2r) r5r:r;rArrrrrxr1rLrrs@r0r8r8sM E%E DD9>t!15HL! r2r8c>eZdZdZdeeefffd Zdfd ZxZ S) AtStringStartzMatches 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 rc2t||d|_yNFrr1rr.rrs r0r1zAtStringStart.__init__[ !r2cJ|dk7r t||dt| |||S)Nrznot found at string start)rrrLr.rrr!rs r0rLzAtStringStart.parseImpl_s. !8 30KL Lw 3 ::r2r r5r:r;rAr rr8r1rLrrs@r0rrPs("U=##56";;r2rc>eZdZdZdeeefffd Zdfd ZxZ S) AtLineStartaMatches 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'] rc2t||d|_yrrrs r0r1zAtLineStart.__init__|rr2c^t||dk7r t||dt| |||S)Nrznot found at line start)rrrrLrs r0rLzAtLineStart.parseImpls6 sH  " 30IJ Jw 3 ::r2rrrs@r0rres(,"U=##56";;r2rc:eZdZdZdeeefffd ZddZxZ S) FollowedByacLookahead 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']] rc2t||d|_yr1rr1rrs r0r1zFollowedBy.__init__s "r2cV|jj|||\}}|dd=||fS)Nrh)rr')r.rrr!r@r8s r0rLzFollowedBy.parseImpls3!!(C9!E3 FCxr2rrrs@r0rrs#,#U=##56#r2rc\eZdZdZ ddeeefdeje ffd Z ddZ xZ S) PrecededByaLookbehind 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 rretreatct|||jj|_d|_d|_d|_t|tr-tjt|}t|}d|_nt|ttfr|j}d|_nVt|t t"fr'|j$t&k7r|j$}d|_nt|t(r d}d|_||_dt|z|_d|_|j0j3dy)NTFrznot preceded by c8|jtddSr,) __delitem__rrrrs r0rz%PrecededBy.__init__..s eD$>O0Pr2)rr1rrrrrErXr&rrr8rFrjrrr=rrSrrrrrrr)r.rrrs r0r1zPrecededBy.__init__s IIK002 "" dH %;;sD)D$iGDJ w0 1mmGDJ tZ0 1dkkX6MkkGDJ m ,GDJ (3t94 #  PQr2c4|jrX||jkrt|||j||jz }|jj ||\}}||fS|jt z}|td||jz |}t|||j} tdt||jdzdzD](} |j |t|| z \}}||fS| #t$r } | } Yd} ~ =d} ~ wwxYwr) rErrrrr'rrDrrrFr{) r.rrr!rr@r8 test_exprinstring_slice last_exproffsetrs r0rLzPrecededBy.parseImpls ::T\\!$XsDKK@@$,,&EYY%%h6FAs$Cx IK/I%c!S4<<-?&@3GN&xdkkBI3sDLL1,<#=#AB&--&N(;f(DFAs CxC  *$ #I$s!D D DDr,)rT) r5r:r;rAr rr8rrr|r1rLrrs@r0rrs?<PTR-,-R8>8LR4r2rceZdZdZddZy)Locateda 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] c|}|jj|||d\}}t|||g}||d<||d<||d<|jr||gfS||fS)NFr locn_startrlocn_end)rr'r#r)r.rrr!rr`rbs r0rLzLocated.parseImplsxii&&x PU&V V!5&#"67 #( < $ 7!$ :    $ $ ? "r2Nr)r5r:r;rArLr<r2r0rrs 6 #r2rcFeZdZdZdeeefffd ZddZdefdZ xZ S)ra 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(".") rczt||d|_d|_dt |j z|_y)NFTzFound unwanted token, )rr1rrr8rrrs r0r1zNotAny.__init__?s6 $".TYY? r2cv|jj|||rt|||j||gfS)Nrk)rrlrrrKs r0rLzNotAny.parseImplHs9 99 # #Hci # H 3 TB BBwr2rWc8dt|jzdzS)Nz~{rLr8rrs r0r#zNotAny._generateDefaultNameMsc$))n$s**r2r) r5r:r;rAr rr8r1rLr#rrs@r0rr&s10@U=##56@ +c+r2rc eZdZ d dddeeefdejeeefdejeeefffdZdefdZ d d Z d fd Z xZ S)rNrrrrct|||xs|}d|_|}t|tr|j |}|j |yr1)rr1rrXr&rr)r.rrrenderrs r0r1z_MultipleMatch.__init__RsN "7 eX &,,U3E Er2rWcnt|tr|j|}| ||_|Sd|_|Sr,)rXr&r not_ender)r.rs r0rz_MultipleMatch.stopOnas= eX &,,U3E#(#4% ;? r2cj|jj}|j}|jdu}|r|jj}|r ||||||\}} |j } |r ||| r |||} n|} ||| |\}} || z },#t tf$rY||fSwxYwr,)rr'rCrrirrrV) r.rrr!self_expr_parseself_skip_ignorables check_ender try_not_enderr`hasIgnoreExprsr tmptokenss r0rLz_MultipleMatch.parseImplgs))**#33nnD0  NN44M  (C (%hY? V %)%5%5!55N!(C0!1(C@F F!069!MY)# +  F{ s";BB21B2c tjrtj|jvr|jg|jj zD]}t |ts|js!tj|jvs>tjdjd|t|j|jdt|=||Sr)rLrYrcrrr rXrrr=rNrrr5rrr s r0rz_MultipleMatch._setResultsNames  > >EE**+ii[499#4#4#66q-0 #MM//0MMEEKVG  J//MM F $% 7$w&t^<B C&' }c'9!:;  mS&8 9: } 8==r2rceZdZdZdefdZy)rau 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() rWc8dt|jzdzS)NrKz}...rrs r0r#zOneOrMore._generateDefaultNameS^#f,,r2N)r5r:r;rAr8r#r<r2r0rrs6-c-r2rc eZdZdZ d dddeeefdejeeefdejeeefffdZ d fd Z d efd Z xZ S) rap 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` Nrrrrc>t|||xs|d|_y)NrTr)r.rrrrs r0r1zZeroOrMore.__init__s$ f&78"r2c t||||S#ttf$r|t g|j fcYSwxYw)Nr+)rrLrrVr#rrs r0rLzZeroOrMore.parseImplsK @7$XsI> > + @ Rd.>.>?? ? @s (??rWc8dt|jzdzS)NrIz]...rrs r0r#zZeroOrMore._generateDefaultNamer)r2r,r) r5r:r;rAr r8rrrr1rLr#rrs@r0rrs|  ?C# >B #C&'#}c'9!:;# mS&8 9: #@ -c-r2rceZdZ d dddeeefdeeefdedeje deje def fd Z d efd Z xZ S) DelimitedListF)allow_trailing_delimrdelimcombinerrDr0ct|trtj|}t j t|}||dkr t d||||kr t d||_t||_ ||_ ||_ |st||_ |xsd|_ ||_||_|j|j|jz|jdz |jdn|jdz fzz}|jr|t!|jz }|jr t#|}t$|M|dy)aaHelper 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 minTr)rXr&rrrrrcontentr8 raw_delimr1r2r rrDr0rCombinerr1) r.rr1r2rrDr0delim_list_exprrs r0r1zDelimitedList.__init__s46 dH % 44T:D{{=$/ ?Qw !=>> ?39 !LMM U  !%DJ8!$8!,,$**t||*C HHqLHH$D$((Q,H *    $ $ s4:: .O <<%o6O 48r2rWcjdj|jj|jS)Nz{0} [{1} {0}]...)rr4rr5rs r0r#z"DelimitedList._generateDefaultNames&!(()@)@)BDNNSSr2)rFNN) r5r:r;r r8rrxrrr|r1r#rrs@r0r/r/s,/$($( :9&+:9C&':9S-'(:9 :9 __S ! :9 __S ! :9#:9xTcTr2r/ceZdZdZdZy) _NullTokencyrr<rs r0__bool__z_NullToken.__bool__"sr2cyrr<rs r0r,z_NullToken.__str__%sr2N)r5r:r;r<r,r<r2r0r:r:!s r2r:c\eZdZdZeZefdeeefde ffd Z ddZ defdZ xZ S) raO 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) rdefaultczt||d|jj|_||_d|_y)NFrT)rr1rr defaultValuer)r.rr?rs r0r1z Opt.__init__Ss8 .))..#"r2c|j} |j|||d\}}||fS#ttf$rN|j}||j ur,|j rt|g}|||j <n|g}ng}Y||fSwxYw)NFr)rr'rrVrA_Opt__optionalNotMatchedrr#)r.rrr! self_exprr` default_values r0rLz Opt.parseImpl[sII  #**8S)RW*XKCF{ +  --MD$=$==(()=/:F4AF9001+_FF{ s*ABBrWct|j}t|dkDrB|ddt|dz dk(r+|dd}t|dkDr|ddt|dz dk(r+d|zdzS)NrrrKrrIr)r8rrFrLs r0r#zOpt._generateDefaultNameksyDII%j1nq':CJN':!;t!C!BKE%j1nq':CJN':!;t!CU{S  r2r)r5r:r;rAr:rCr rr8rr1rLr#rrs@r0rr)sI%N&<?S#-,-#8;# !c!r2rceZdZdZ d dddeeefdedejeeefdejeeefdejeeeff fd Z d d Z xZ S) ra+ 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)failOnrincluderfail_onrHc$t|||xs|}||j|d|_d|_||_d|_t|tr|j||_ n||_ dt|jz|_ y)NTFzNo match found for )rr1rrr includeMatchrrXr&rrHr8rr)r.rrIrrJrHrs r0r1zSkipTo.__init__s "7   KK ""# fh '226:DK DK+c$))n< r2c|}t|}|jj}|j|jjnd}|j r |j nd}|} | |kr%| ||| rn1| ||| } ||| ddnt|||j|| }|||} t| } |jr||||d\}} | | z } || fS#ttf$r| dz } YnwxYw| |kro)NF)r!r"rr) rFrr'rHrrrIrrVrr#rL) r.rrr!rrGr self_failOn_canParseNext self_preParsetmplocskiptext skipresultr:s r0rLzSkipTo.parseImpls+x=))**(, (?DKK $ $T !*.):):   '3+Hf=(&x8 &EPUV !3 TB BHS)!(+   &xieTHC # JJ)#J/ !   s CC32C3)FNNr) r5r:r;rAr rr8rxrrr1rLrrs@r0rrvs;@=A>B =>B=]C'(==mS&8 9: = }c'9!:; =mS&8 9:=.*r2rceZdZdZddej eeefffd Z ddZ ddZ dfd Z dZ dfd Zdd edefd Zdd edefd Zdefd ZdddZdefdZdeffd Zdfd ZeedZeedZxZS)rmaw 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``. rcrtjdd|_t||dd|_y)NrdrrFr)rr caller_framerr1 lshift_liners r0r1zForward.__init__s5%33! >( ) ) 00D- Q(,S$ -A(B%+k95%%!1!1!33* )' Qd+u-!G" #'Ld8#)d8n $(NDM@,1G,=hU,S))@%i;!,4i @ (*$FJ']R1HkDN $XW #+[-=-=-?#??I* )J!N')999M* )R%&050A(CQU0VW #1&BI1 MXg %&@G?PP+)d8n5' Q* )s~H+!.D:H(E)(H()F H( F  /H(9H+H(H+$H('G<;H(< H HHH((H++H4r cd|_|Srrrs r0rzForward.leave_whitespaces# r2cd|_|Sr1rrs r0rzForward.ignore_whitespaces" r2cx|js-d|_|j|jj|Sr1)rrrrs r0rzForward.streamlines2#D yy$ $$& r2ctjdtd|g}||vr0|dd|gz}|j|jj ||j gyrrrs r0r@zForward.validatesg h   M } $"dV+Cyy$ ""3' R r2cd|_d} |jt|jdd}nd}|jjdz|zS#|jjdz|zccYSxYw)Nz: ...riNonere)rrr8rr5)r. retStrings r0r#zForward._generateDefaultNamesn#  >yy$ N5D1 " >>**T1I= =4>>**T1I= =s 'AA/cZ|jt| St}||z}|Sr,)rrrrm)r.r8rs r0rz Forward.copys. 99 7<> !)C DLCJr2c  tjrctj|jvrG|j;t j djd|t|jdt|-||S)NzO{}: setting results name {!r} on {} expression that has no contained expressionrZr'r;) rLrZrcrrr=rNrrr5rr)r.rTrrs r0rzForward._setResultsNamesu  3 3::**+yy  77=v8$T @S@S8 ! w&t-=>>r2cyr,r<rs r0rzForward.leaveWhitespacerr2cyr,r<rs r0rzForward.ignoreWhitespacerr2r,)rWrmrrrVr)r5r:r;rArrr rr8r1rYr[rrbrLrxrrrr@r#rrr!rrrrs@r0rmrms8 fooeM34F.GH ,  ]Q~$-4=M ! >c >m?&&'"("'(#)#r2rmc4eZdZdZddeeefffd ZxZS)TokenConverterzW Abstract subclass of :class:`ParseExpression`, for converting parsed results. rc2t||d|_yr)rr1rr.rrrs r0r1zTokenConverter.__init__s r2r) r5r:r;rAr rr8r1rrs@r0r}r}s# U=##56  r2r}c peZdZdZ d dddedededejeffdZ d effd Z d Z xZ S) r6aConverter 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_stringadjacentrct||||n|}|r|j||_d|_||_d|_yr1)rr1rrrrr)r.rrrrrs r0r1zCombine.__init__sK #-#9Z{   ! ! #  "$ r2rWcn|jrtj|||St| ||Sr,)rrrrrs r0rzCombine.ignore0s4 ==  u -  GN5 ! r2c|j}|dd=|tdj|j|jg|j z }|j r|jr|gS|S)Nrw)rU)rr#r _asStringListrrrhaskeys)r.rrrPretTokss r0rQzCombine.postParse7sm.." AJ< WWY,,T__= > ?tGXGX      19 Nr2)rwT) r5r:r;rArr8rxrrr1rrQrrs@r0r6r6 s_* ! ,0 !!! ! OOC( !$} r2r6c4eZdZdZddedeffd ZdZxZS)raConverter 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@t||d|_||_yr1)rr1r _asPythonList)r.rrrs r0r1zGroup.__init__Y #r2c|jrBtjt|tr|j St |S|gSr,)rr#rrXrTrrOs r0rQzGroup.postParse^sS   $$i6  " )_  ; r2r r5r:r;rArrxr1rQrrs@r0rrDs ($]$D$ r2rc4eZdZdZddedeffd ZdZxZS)rarConverter 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@t||d|_||_yr1)rr1r _asPythonDict)r.rrrs r0r1z Dict.__init__rr2ct|D]\}}t|dk(r|d}t|trt |j }t|dk(rt d|||<at|dk(r&t|dtst |d|||< |j}|d=t|dk7s t|tr |jrt ||||<t |d|||<|jr-|jr|jgS|jS|jr|gS|S#t$rtd}|dwxYw)Nrrrwrdzdcould not extract dict values from parsed results - Dict expression must contain Grouped expressions)r4rFrXr|r8rgr$r#rrWrrrras_dict) r.rrrPrutokikey dictvaluers r0rQzDict.postParses_ *FAs3x1}q6D$$4y(3x1}"9"a"@ $SQz#a&,'G"9#a&!"D $( # IaLy>Q&y,7I> 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'], {})) <>entering z(line: rfz) z <.zs::+1a v;?ay**33c9HDH ;xjQ ~Rs"QEQTUV V*C :hZwsgSAB   JJ  z(=SI J  s;B(( C1'CC)rr5)rJrs` r0trace_parse_actionrs%2 AA AJ Hr2empty line_startline_end string_start string_endz\\[\\[\]\/\-\*\.\$\+\^\?()~ ]c|ddSrr<r s r0rr,s AaDGr2z\\0?[xX][0-9a-fA-F]+cPtt|djddS)Nrz\0xrb)chrr|rpr s r0rr/sCAaDKK/45r2z \\0[0-7]+c8tt|ddddS)Nrrr()rr|r s r0rr2sCAaDHa()r2z\])rEr(rIrnegatebodyrrcd djfdtj|jDS#t$r }Yd}~yd}~wwxYw)a Helper to easily define string ranges for use in :class:`Word` construction. Borrows syntax from regexp ``'[]'`` string range definitions:: srange("[0-9]") -> "0123456789" srange("[a-z]") -> "abcdefghijklmnopqrstuvwxyz" srange("[a-z$_]") -> "abcdefghijklmnopqrstuvwxyz$_" The input string must be enclosed in []'s, and the returned string is the expanded character set joined into a single string. The values enclosed in the []'s may be: - a single character - an escaped character with a leading backslash (such as ``\-`` or ``\]``) - an escaped hex character with a leading ``'\x'`` (``\x21``, which is a ``'!'`` character) (``\0x##`` is also supported for backwards compatibility) - an escaped octal character with a leading ``'\0'`` (``\041``, which is a ``'!'`` character) - a range of any of the above, separated by a dash (``'a-z'``, etc.) - any combination of the above (``'aeiouy'``, ``'a-zA-Z0-9_$'``, etc.) c t|ts|Sdjdtt |dt |ddzDS)Nrwc32K|]}t|ywr,)rrs r0rz+srange....]sE%DSV%Dr.rr)rXr#rrord)ps r0rzsrange..[sJ!\*F WWEU3qt9c!A$i!m%DE EFr2rwc3.K|] }|ywr,r<)rIpart _expandeds r0rzsrange..`sW3V4y3VsN)r_reBracketExprrrrW)rr?rs @r0sranger@sL6 F wwW>3N3Nq3Q3V3VWWW s6= A Acffd}tdtdj}||_|S)a^Helper to define a parse action by mapping a function to all elements of a :class:`ParseResults` list. If any additional args are passed, they are forwarded to the given function as additional arguments after the token, as in ``hex_integer = Word(hexnums).set_parse_action(token_map(int, 16))``, which will convert the parsed data to an integer using base 16. Example (compare the last to example in :class:`ParserElement.transform_string`:: hex_ints = Word(hexnums)[1, ...].set_parse_action(token_map(int, 16)) hex_ints.run_tests(''' 00 11 22 aa FF 0a 0d 1a ''') upperword = Word(alphas).set_parse_action(token_map(str.upper)) upperword[1, ...].run_tests(''' my kingdom for a horse ''') wd = Word(alphas).set_parse_action(token_map(str.title)) wd[1, ...].set_parse_action(' '.join).run_tests(''' now is the winter of our discontent made glorious summer by this sun of york ''') prints:: 00 11 22 aa FF 0a 0d 1a [0, 17, 34, 170, 255, 10, 13, 26] my kingdom for a horse ['MY', 'KINGDOM', 'FOR', 'A', 'HORSE'] now is the winter of our discontent made glorious summer by this sun of york ['Now Is The Winter Of Our Discontent Made Glorious Summer By This Sun Of York'] c<|Dcgc] }|g c}Scc}wr,r<)rrrtoknrr/s r0rztoken_map..pas%./0adT!D!a000sr5r)rr5)r/rrrs`` r0 token_mapres2J1j'$ *D*M*MNIBK Ir2c0tjj}|ytjt j |}|jjD]4\}}t|ts|jr$|j|6y)zy Utility to simplify mass-naming of parser elements, for generating railroad diagram with named subdiagrams. N) rk _getframef_backrrtypes FrameTypef_localsrrXrrr() calling_framerTvars r0autoname_elementsrsk MMO**MKK?M"++113 c c= )#.. LL 4r2z4"(?:[^"\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""""(?:[^"\\]|""(?!")|"(?!"")|\\.)*rz"""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]rcyr,r<r<r2r0nullDebugActionrrr2cyr,r<r<r2r0traceParseActionrrr2cyr,r<r<r2r0conditionAsParseActionrrr2cyr,r<r<r2r0tokenMaprsr2rV)r'rr) collectionsrosrrrrrrr r r r r rabcrrenumrstringrr=rTrkcollections.abcrrroperatorr functoolsr threadingrpathlibrutilrrrrrrrrrr rr! exceptionsactionsr;r#r$unicoder%maxsizerr8bytesr&rr version_infor)r>rLrcrlrorUrrxr warnoptionsenvironr1sumrFrNrerrrr r0rrDr GeneratorTyper r|ParseImplReturnTypePostParseReturnTyperrrWrrrrascii_uppercaseascii_lowercasealphasLatin1 identcharsidentbodycharsnumshexnumsr!r printable whitespacerr StackSummaryrrrrrrrrrrrjrrrrr$r)r,r=rnrrrrrrrrrrrrrrrrrrrr8rrrrrrrrrr/r:rrrmr}r6rrr rr(rrrrrr4 _escapedPunc_escapedHexChar_escapedOctChar _singleChar _charRangerrrrrdbl_quoted_stringsgl_quoted_stringrorpython_quoted_stringunicode_string alphas8bitpunc8bitrNvaluesrXrsglQuotedStringdblQuotedString quotedString unicodeString lineStartlineEnd stringStart stringEndrrrr)rrs00r0r s       $  $    :& ;;!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!1AQf>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's2aa7a#a#