Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
wlanpi-profiler / opt / wlanpi-profiler / lib / python3.7 / site-packages / __pycache__ / pyparsing.cpython-37.pyc
Size: Mime:
B

(rLGPaƀãt@sdZdZdZdZddlZddlmZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlmZddlmZddlZdd	lmZdd
lmZyddlmZWn ek
rÔddlmZYnXydd
lmZWn"ek
rdd
lmZYnXy ddlm Z ddlm!Z!m"Z"Wn2ek
r\ddl
m Z ddl
m!Z!m"Z"YnXyddl
m#Z$WnBek
r°yddl%m#Z$Wnek
rªdZ$YnXYnXyddlm&Z&Wn$ek
ræGdd„dƒZ&YnXe&ƒZ'de'_de'_(e&ƒZ)de)_de)_*de)_+de)_,de)_-de)_.dd„e/e)ƒDƒe)_0dd„Z1e1e)_2ddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dadbdcdddedfdgdhdidjdkdldmdndodpdqdrdsdtdudvdwdxdydzd{d|d}d~dd€dd‚dƒd„d…d†d‡dˆd‰dŠd‹dŒddŽdgtZ3e4e	j5ƒdd…Z6e6ddkZ7e7rˆe	j8Z9e:Z;e<Z=e:Z>e:Z?e@eAeBeCeDe4eEeFeGeHeIgZJnbe	jKZ9eLZMd‘d’„Z?gZJddlNZNxBd“ O¡D]6ZPyeJ QeReNePƒ¡WneSk
râw°YnXq°WeTd”d•„eMd–ƒDƒƒZUd—d˜„ZVejWejXZYd™ZZeZdšZ[eYeZZ\e<d›ƒZ]dœ ^dd•„ej_Dƒ¡Z`dadždŽ„ZaGdŸd9„d9ebƒZcGd d;„d;ecƒZdGd¡d=„d=ecƒZeGd¢d?„d?eeƒZfGd£dB„dBebƒZgGd¤d¥„d¥ehƒZiGd¦d>„d>ehƒZje! kej¡d§dV„Zld¨dg„Zmd©dd„Zndªd«„Zod¬d­„Zpd®d¯„Zqd°dn„Zrdbd²d³„ZsGd´d@„d@ehƒZtGdµd¶„d¶etƒZuGd·dH„dHetƒZvGd¸d(„d(evƒZwGd¹d3„d3evƒZxGdºd0„d0evƒZyGd»d¼„d¼eyƒZzeyZ{eyet_|Gd½d-„d-evƒZ}Gd¾d#„d#eyƒZ~Gd¿d"„d"e}ƒZGdÀd‰„d‰evƒZ€GdÁdK„dKevƒZGdÂdÄdÃeƒZ‚GdÄdO„dOe‚ƒZƒGdÅdC„dCevƒZ„GdÆdA„dAevƒZ…GdÇd$„d$evƒZ†GdÈdJ„dJevƒZ‡GdÉdʄdÊevƒZˆGdËd+„d+eˆƒZ‰GdÌd/„d/eˆƒZŠGdÍd.„d.eˆƒZ‹GdÎdF„dFeˆƒZŒGdÏdE„dEeˆƒZGdÐdM„dMeˆƒZŽGdÑdL„dLeˆƒZGdÒd<„d<etƒZGdÓd!„d!eƒZ‘GdÔd8„d8eƒZ’GdÕd2„d2eƒZ“GdÖd'„d'eƒZ”Gd×d:„d:etƒZ•GdØd)„d)e•ƒZ–GdÙd1„d1e•ƒZ—GdÚd4„d4e•ƒZ˜GdÛd܄dÜe•ƒZ™GdÝd5„d5e™ƒZšGdÞdN„dNe™ƒZ›Gdßdà„dàehƒZœGdád7„d7e•ƒZGdâdD„dDe•ƒZžGdãd*„d*e•ƒZŸGdädI„dIe•ƒZ Gdåd%„d%e ƒZ¡Gdæd,„d,e ƒZ¢Gdçd&„d&e ƒZ£GdèdG„dGe ƒZ¤Gdéd6„d6ehƒZ¥dêd„Z¦dcdìd]„Z§dddídY„Z¨dîdï„Z©dðdl„Zªdñdk„Z«dòdó„Z¬dedôdp„Z­dõd^„Z®dfdöd„„Z¯d÷d…„Z°død‡„Z±ewƒ ²d`¡Z³eŠƒ ²df¡Z´e‹ƒ ²de¡ZµeŒƒ ²d~¡Z¶eƒ ²d}¡Z·ee]dùd±dú ¸dûdü„¡Z¹e„dýƒ ¸dþdü„¡Zºe„dÿƒ ¸ddü„¡Z»e¹eºBe»Be†dd–dúBZ¼e¢e¼e¤dƒe¼ƒZ½eydƒedƒ ¾d¡e¢eše½e¼Bƒƒ ¾d¡dZ¿dd|„Zd	dj„ZPd
dy„Zddw„ZÐddŠ„ZÄeĐd
dü„ƒZÅeĐddü„ƒZÆe¤dƒe¤dƒfdd„Zǐddh„ZȐddi„Zɐdd‚„ZÊehƒeÊ_ːdgddˆ„ZÌe&ƒZÍehƒeÍ_ÎehƒeÍ_Ïe¤dƒe¤dƒfdd†„ZÐeÐZÑe¡e„dƒdƒ ²d¡ZÒe¡e„dƒdƒ ²d¡ZÓe¡e„dƒde„dƒdBƒ ²d ¡ZÔe¡e{d!ƒeԠ¡ƒ ²d"¡ZՐdddeԠ¡fd#dm„Z֐dhd$dƒ„Z×ed%ƒZØed&ƒZÙeÈeeYe\d'ƒ ²d(¡ƒ\ZÚZÛeÜeݐd) O¡d*ƒƒZÞe„d+d, ^eޠߡ¡d-ƒ ²d.¡Zàd/dx„Záe¡e„d0ƒd1ƒ ²d2¡Zâe„d3ƒ ²d4¡Zãe„d5ƒ ä¡ ²d6¡Zåe„d7ƒ ²d8¡Zæe¡e„d0ƒd1eæBƒ ²d9¡ZçeçZèe„d:ƒ ²d;¡Zée¡ešee`dëd<eed=ƒeydëƒe‹ƒƒƒƒ ê¡ ²d>¡Zëe§eeԠ¡eëBdœd?ƒ ²dW¡ZìGd@d‹„d‹ƒZíGdAdB„dBehƒZîGdCd„dehƒZïGdDdŒ„dŒeïƒZðeðjñjòjóeðjñjôjóeðjñjõjóeðjñ_óe7
r˜eöeðdEeðj÷ƒeöeðdFeðjøƒeöeðdGeðjùƒeöeðdHeðjúƒeöeðdIeðjûƒeöeðdJeðjñƒeöeðjñdKeðjñjòƒeöeðjñdLeðjñjõƒeöeðjñdMeðjñjôƒeöeðdNeðjüƒeöeðdOeðjýƒeöeðdPeðjþƒGdQdR„dRƒZÿedSkre~dTƒZe~dUƒZeeYe\dVƒZe§edWddX ¸ešZe¢e§eƒƒ ²dY¡ZdZeBZe§edWddX ¸ešZe¢e§eƒƒ ²d[¡Zed\ƒedYƒeed[ƒZ	e	 
d]¡eíj 
d^¡eíj 
d^¡eíj
 
d_¡ddlZeíj ¸eĐejƒ¡eíj 
d`¡dS(iaË

pyparsing module - Classes and methods to define and execute parsing grammars
=============================================================================

The pyparsing module is an alternative approach to creating and
executing simple grammars, vs. the traditional lex/yacc approach, or the
use of regular expressions.  With pyparsing, you don't need to learn
a new syntax for defining grammars or matching expressions - the parsing
module provides a library of classes that you use to construct the
grammar directly in Python.

Here is a program to parse "Hello, World!" (or any greeting of the form
``"<salutation>, <addressee>!"``), built up using :class:`Word`,
:class:`Literal`, and :class:`And` elements
(the :class:`'+'<ParserElement.__add__>` operators create :class:`And` expressions,
and the strings are auto-converted to :class:`Literal` expressions)::

    from pyparsing import Word, alphas

    # define grammar of a greeting
    greet = Word(alphas) + "," + Word(alphas) + "!"

    hello = "Hello, World!"
    print (hello, "->", greet.parseString(hello))

The program outputs the following::

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

The Python representation of the grammar is quite readable, owing to the
self-explanatory class names, and the use of '+', '|' and '^' operators.

The :class:`ParseResults` object returned from
:class:`ParserElement.parseString` can be
accessed as a nested list, a dictionary, or an object with named
attributes.

The pyparsing module handles some of the problems that are typically
vexing when writing text parsers:

  - extra or missing whitespace (the above program will also handle
    "Hello,World!", "Hello  ,  World  !", etc.)
  - quoted strings
  - embedded comments


Getting Started -
-----------------
Visit the classes :class:`ParserElement` and :class:`ParseResults` to
see the base classes that most other pyparsing
classes inherit from. Use the docstrings for examples of how to:

 - construct literal match expressions from :class:`Literal` and
   :class:`CaselessLiteral` classes
 - construct character word-group expressions using the :class:`Word`
   class
 - see how to create repetitive expressions using :class:`ZeroOrMore`
   and :class:`OneOrMore` classes
 - use :class:`'+'<And>`, :class:`'|'<MatchFirst>`, :class:`'^'<Or>`,
   and :class:`'&'<Each>` operators to combine simple expressions into
   more complex ones
 - associate names with your parsed results using
   :class:`ParserElement.setResultsName`
 - access the parsed data, which is returned as a :class:`ParseResults`
   object
 - find some helpful expression short-cuts like :class:`delimitedList`
   and :class:`oneOf`
 - find more useful common expressions in the :class:`pyparsing_common`
   namespace class
z2.4.7z30 Mar 2020 00:43 UTCz*Paul McGuire <ptmcg@users.sourceforge.net>éN)Úref)Údatetime)Ú
itemgetter)Úwraps)Úcontextmanager)Úfilterfalse)Úifilterfalse)ÚRLock)ÚIterable)ÚMutableMappingÚMapping)ÚOrderedDict)ÚSimpleNamespacec@seZdZdS)rN)Ú__name__Ú
__module__Ú__qualname__©rrú‹/build/wlanpi-profiler-CSvHZ8/wlanpi-profiler-1.0.7~rc2/debian/wlanpi-profiler/opt/wlanpi-profiler/lib/python3.7/site-packages/pyparsing.pyr–sraA
    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 And expression is nested within an Or or MatchFirst; set to
       True to enable bugfix released in pyparsing 2.3.0, or False to preserve
       pre-2.3.0 handling of named results
Ta“
Diagnostic configuration (all default to False)
     - warn_multiple_tokens_in_named_alternation - flag to enable warnings when a results
       name is defined on a MatchFirst or Or expression with one or more And subexpressions
       (only warns if __compat__.collect_all_And_tokens is False)
     - 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 whan a Forward is defined
       with a results name, but has no contents defined
     - warn_on_multiple_string_args_to_oneof - flag to enable warnings whan oneOf is
       incorrectly called with multiple str arguments
     - enable_debug_on_named_expressions - flag to auto-enable debug on all subsequent
       calls to ParserElement.setName()
FcCs$g|]}| d¡s| d¡r|‘qS)Zenable_Zwarn_)Ú
startswith)Ú.0Únmrrrú
<listcomp>¼srcCsdt_dt_dt_dt_dS)NT)Ú__diag__Ú)warn_multiple_tokens_in_named_alternationÚ)warn_ungrouped_named_tokens_in_collectionÚwarn_name_set_on_empty_ForwardÚ%warn_on_multiple_string_args_to_oneofrrrrÚ_enable_all_warnings¾srÚ__version__Ú__versionTime__Ú
__author__Ú
__compat__rÚAndÚCaselessKeywordÚCaselessLiteralÚ
CharsNotInÚCombineÚDictÚEachÚEmptyÚ
FollowedByÚForwardÚ
GoToColumnÚGroupÚKeywordÚLineEndÚ	LineStartÚLiteralÚ
PrecededByÚ
MatchFirstÚNoMatchÚNotAnyÚ	OneOrMoreÚOnlyOnceÚOptionalÚOrÚParseBaseExceptionÚParseElementEnhanceÚParseExceptionÚParseExpressionÚParseFatalExceptionÚParseResultsÚParseSyntaxExceptionÚ
ParserElementÚQuotedStringÚRecursiveGrammarExceptionÚRegexÚSkipToÚ	StringEndÚStringStartÚSuppressÚTokenÚTokenConverterÚWhiteÚWordÚWordEndÚ	WordStartÚ
ZeroOrMoreÚCharÚ	alphanumsÚalphasÚ
alphas8bitÚanyCloseTagÚ
anyOpenTagÚ
cStyleCommentÚcolÚcommaSeparatedListÚcommonHTMLEntityÚcountedArrayÚcppStyleCommentÚdblQuotedStringÚdblSlashCommentÚ
delimitedListÚdictOfÚdowncaseTokensÚemptyÚhexnumsÚhtmlCommentÚjavaStyleCommentÚlineÚlineEndÚ	lineStartÚlinenoÚmakeHTMLTagsÚmakeXMLTagsÚmatchOnlyAtColÚmatchPreviousExprÚmatchPreviousLiteralÚ
nestedExprÚnullDebugActionÚnumsÚoneOfÚopAssocÚoperatorPrecedenceÚ
printablesÚpunc8bitÚpythonStyleCommentÚquotedStringÚremoveQuotesÚreplaceHTMLEntityÚreplaceWithÚ
restOfLineÚsglQuotedStringÚsrangeÚ	stringEndÚstringStartÚtraceParseActionÚ
unicodeStringÚupcaseTokensÚ
withAttributeÚ
indentedBlockÚoriginalTextForÚungroupÚ
infixNotationÚlocatedExprÚ	withClassÚ
CloseMatchÚtokenMapÚpyparsing_commonÚpyparsing_unicodeÚunicode_setÚconditionAsParseActionÚreécCs`t|tƒr|Syt|ƒStk
rZt|ƒ t ¡d¡}tdƒ}| dd„¡| 	|¡SXdS)aDrop-in replacement for str(obj) that tries to be Unicode
        friendly. It first tries str(obj). If that fails with
        a UnicodeEncodeError, then it tries unicode(obj). It then
        < returns the unicode object | encodes it with the default
        encoding | ... >.
        Úxmlcharrefreplacez&#\d+;cSs$dtt|ddd…ƒƒdd…S)Nz\urééÿÿÿÿ)ÚhexÚint)ÚtrrrÚ<lambda>ÿóz_ustr.<locals>.<lambda>N)
Ú
isinstanceÚunicodeÚstrÚUnicodeEncodeErrorÚencodeÚsysÚgetdefaultencodingrDÚsetParseActionÚtransformString)ÚobjÚretZ
xmlcharrefrrrÚ_ustrìs
r¥z6sum len sorted reversed list tuple set any all min maxccs|]
}|VqdS)Nr)rÚyrrrú	<genexpr>sr§écCs>d}dd„d ¡Dƒ}x"t||ƒD]\}}| ||¡}q"W|S)z/Escape &, <, >, ", ', etc. in a string of data.z&><"'css|]}d|dVqdS)ú&ú;Nr)rÚsrrrr§sz_xml_escape.<locals>.<genexpr>zamp gt lt quot apos)ÚsplitÚzipÚreplace)ÚdataÚfrom_symbolsÚ
to_symbolsÚfrom_Úto_rrrÚ_xml_escapes
r´Ú
0123456789ZABCDEFabcdefé\Úccs|]}|tjkr|VqdS)N)ÚstringÚ
whitespace)rÚcrrrr§scs@|dk	r|nd‰|rtnt‰tˆƒ‰tˆƒ‡‡‡fdd„ƒ}|S)Nzfailed user-defined conditioncs tˆ|||ƒƒsˆ||ˆƒ‚dS)N)Úbool)r«Úlr—)Úexc_typeÚfnÚmsgrrÚpa%sz"conditionAsParseAction.<locals>.pa)r>r<Ú_trim_arityr)r¾ÚmessageÚfatalrÀr)r½r¾r¿rr s
c@sPeZdZdZddd„Zedd„ƒZdd	„Zd
d„Zdd
„Z	ddd„Z
dd„ZdS)r:z7base exception class for all parsing runtime exceptionsrNcCs>||_|dkr||_d|_n||_||_||_|||f|_dS)Nr·)Úlocr¿ÚpstrÚ
parserElementÚargs)ÚselfrÅrÄr¿ÚelemrrrÚ__init__0szParseBaseException.__init__cCs||j|j|j|jƒS)z¬
        internal factory method to simplify creating one type of ParseException
        from another - avoids having __init__ signature conflicts among subclasses
        )rÅrÄr¿rÆ)ÚclsÚperrrÚ_from_exception;sz"ParseBaseException._from_exceptioncCsN|dkrt|j|jƒS|dkr,t|j|jƒS|dkrBt|j|jƒSt|ƒ‚dS)zôsupported attributes by name are:
           - lineno - returns the line number of the exception text
           - col - returns the column number of the exception text
           - line - returns the line containing the exception text
        rh)rWÚcolumnreN)rhrÄrÅrWreÚAttributeError)rÈÚanamerrrÚ__getattr__CszParseBaseException.__getattr__cCs^|jr@|jt|jƒkrd}qDd|j|j|jd… dd¡}nd}d|j||j|j|jfS)Nz, found end of textz
, found %rr¨z\\ú\r·z%%s%s  (at char %d), (line:%d, col:%d))rÅrÄÚlenr®r¿rhrÎ)rÈÚfoundstrrrrÚ__str__Rs$zParseBaseException.__str__cCst|ƒS)N)r¥)rÈrrrÚ__repr__\szParseBaseException.__repr__ú>!<cCs<|j}|jd}|r4d |d|…|||d…f¡}| ¡S)z…Extracts the exception line from the input string, and marks
           the location of the exception with a special symbol.
        r¨r·N)rerÎÚjoinÚstrip)rÈÚmarkerStringÚline_strÚline_columnrrrÚ
markInputline^s
z ParseBaseException.markInputlinecCsd ¡tt|ƒƒS)Nzlineno col line)r¬ÚdirÚtype)rÈrrrÚ__dir__hszParseBaseException.__dir__)rNN)r×)rrrÚ__doc__rÊÚclassmethodrÍrÑrÕrÖrÝràrrrrr:,s



c@seZdZdZeddd„ƒZdS)r<a:
    Exception thrown when parse expressions don't match class;
    supported attributes by name are:
    - lineno - returns the line number of the exception text
    - col - returns the column number of the exception text
    - line - returns the line containing the exception text

    Example::

        try:
            Word(nums).setName("integer").parseString("ABC")
        except ParseException as pe:
            print(pe)
            print("column: {}".format(pe.col))

    prints::

       Expected integer (at char 0), (line:1, col:1)
        column: 1

    écCspddl}|dkrt ¡}g}t|tƒrJ| |j¡| d|jdd¡| d t	|ƒj
|¡¡|dkrf|j|j|d}t
ƒ}xât||d…ƒD]Ì\}}|d}|j dd¡}	t|	tƒr|jjd	krÎq–|	|krØq–| |	¡t	|	ƒ}
| d
 |
j|
j
|	¡¡nP|	dk	r.t	|	ƒ}
| d |
j|
j
¡¡n&|j}|jdkrBq–| d
 |j¡¡|d8}|s–Pq–Wd |¡S)ap
        Method to take an exception and translate the Python internal traceback into a list
        of the pyparsing expressions that caused the exception to be raised.

        Parameters:

         - exc - exception raised during parsing (need not be a ParseException, in support
           of Python exceptions that might be raised in a parse action)
         - depth (default=16) - number of levels back in the stack trace to list expression
           and function names; if None, the full stack trace names will be listed; if 0, only
           the failing input line, marker, and exception string will be shown

        Returns a multi-line string listing the ParserElements and/or function names in the
        exception's stack trace.

        Note: the diagnostic output will include string representations of the expressions
        that failed to parse. These representations will be more helpful if you use `setName` to
        give identifiable names to your expressions. Otherwise they will use the default string
        forms, which may be cryptic to read.

        explain() is only supported under Python 3.
        rNú r¨ú^z{0}: {1})ÚcontextrÈ)Ú	parseImplÚ
_parseNoCachez
{0}.{1} - {2}z{0}.{1})Úwrapperz<module>z{0}Ú
)ÚinspectrŸÚgetrecursionlimitršr:ÚappendrerWÚformatrßrÚgetinnerframesÚ
__traceback__ÚsetÚ	enumerateÚf_localsÚgetrAÚf_codeÚco_nameÚaddrrØ)ÚexcÚdepthrër¤ÚcallersÚseenÚiÚffÚfrmÚf_selfÚ	self_typeÚcoderrrÚexplain‚sH




zParseException.explainN)rã)rrrráÚstaticmethodrrrrrr<ksc@seZdZdZdS)r>znuser-throwable exception thrown when inconsistent parse content
       is found; stops all parsing immediatelyN)rrrrárrrrr>Èsc@seZdZdZdS)r@zîjust like :class:`ParseFatalException`, but thrown internally
    when an :class:`ErrorStop<And._ErrorStop>` ('-' operator) indicates
    that parsing is to stop immediately because an unbacktrackable
    syntax error has been found.
    N)rrrrárrrrr@Ísc@s eZdZdZdd„Zdd„ZdS)rCziexception thrown by :class:`ParserElement.validate` if the
    grammar could be improperly recursive
    cCs
||_dS)N)ÚparseElementTrace)rÈÚparseElementListrrrrÊæsz"RecursiveGrammarException.__init__cCs
d|jS)NzRecursiveGrammarException: %s)r)rÈrrrrÕész!RecursiveGrammarException.__str__N)rrrrárÊrÕrrrrrCâsc@s,eZdZdd„Zdd„Zdd„Zdd„Zd	S)
Ú_ParseResultsWithOffsetcCs||f|_dS)N)Útup)rÈÚp1Úp2rrrrÊísz _ParseResultsWithOffset.__init__cCs
|j|S)N)r)rÈrürrrÚ__getitem__ïsz#_ParseResultsWithOffset.__getitem__cCst|jdƒS)Nr)Úreprr)rÈrrrrÖñsz _ParseResultsWithOffset.__repr__cCs|jd|f|_dS)Nr)r)rÈrürrrÚ	setOffsetósz!_ParseResultsWithOffset.setOffsetN)rrrrÊr
rÖrrrrrrìsrc@sªeZdZdZd]dd„Zddddefdd„Zdd	„Zefd
d„Zdd
„Z	dd„Z
dd„Zdd„ZeZ
dd„Zdd„Zdd„Zdd„Zdd„ZerœeZeZeZn$eZeZeZdd„Zd d!„Zd"d#„Zd$d%„Zd&d'„Zd^d(d)„Zd*d+„Zd,d-„Zd.d/„Zd0d1„Z d2d3„Z!d4d5„Z"d6d7„Z#d8d9„Z$d:d;„Z%d<d=„Z&d_d?d@„Z'dAdB„Z(dCdD„Z)dEdF„Z*d`dHdI„Z+dJdK„Z,dLdM„Z-dadOdP„Z.dQdR„Z/dSdT„Z0dUdV„Z1dWdX„Z2dYdZ„Z3e4dbd[d\„ƒZ5dS)cr?aSStructured parse results, to provide multiple means of access to
    the parsed data:

       - as a list (``len(results)``)
       - by list index (``results[0], results[1]``, etc.)
       - by attribute (``results.<resultsName>`` - see :class:`ParserElement.setResultsName`)

    Example::

        integer = Word(nums)
        date_str = (integer.setResultsName("year") + '/'
                        + integer.setResultsName("month") + '/'
                        + integer.setResultsName("day"))
        # equivalent form:
        # date_str = integer("year") + '/' + integer("month") + '/' + integer("day")

        # parseString returns a ParseResults object
        result = date_str.parseString("1999/12/31")

        def test(s, fn=repr):
            print("%s -> %s" % (s, fn(eval(s))))
        test("list(result)")
        test("result[0]")
        test("result['month']")
        test("result.day")
        test("'month' in result")
        test("'minutes' in result")
        test("result.dump()", str)

    prints::

        list(result) -> ['1999', '/', '12', '/', '31']
        result[0] -> '1999'
        result['month'] -> '12'
        result.day -> '31'
        'month' in result -> True
        'minutes' in result -> False
        result.dump() -> ['1999', '/', '12', '/', '31']
        - day: 31
        - month: 12
        - year: 1999
    NTcCs"t||ƒr|St |¡}d|_|S)NT)ršÚobjectÚ__new__Ú_ParseResults__doinit)rËÚtoklistÚnameÚasListÚmodalÚretobjrrrr!s


zParseResults.__new__c
Csd|jrvd|_d|_d|_i|_||_||_|dkr6g}||tƒrP|dd…|_n||tƒrft|ƒ|_n|g|_t	ƒ|_
|dk	r`|r`|s”d|j|<||tƒr¦t|ƒ}||_||t
dƒttfƒrÐ|ddgfks`||tƒrà|g}|r*||tƒrtt|jƒdƒ||<ntt|dƒdƒ||<|||_n6y|d||<Wn$tttfk
r^|||<YnXdS)NFrr·)rÚ_ParseResults__nameÚ_ParseResults__parentÚ_ParseResults__accumNamesÚ_ParseResults__asListÚ_ParseResults__modalÚlistÚ_ParseResults__toklistÚ_generatorTypeÚdictÚ_ParseResults__tokdictr–r¥rßÚ
basestringr?rÚKeyErrorÚ	TypeErrorÚ
IndexError)rÈrrrrršrrrrÊ*sB



$
zParseResults.__init__cCsPt|ttfƒr|j|S||jkr4|j|ddStdd„|j|DƒƒSdS)Nr”rcSsg|]}|d‘qS)rr)rÚvrrrrXsz,ParseResults.__getitem__.<locals>.<listcomp>)ršr–Úslicerrrr?)rÈrürrrr
Qs


zParseResults.__getitem__cCsŒ||tƒr0|j |tƒ¡|g|j|<|d}nD||ttfƒrN||j|<|}n&|j |tƒ¡t|dƒg|j|<|}||tƒrˆt|ƒ|_	dS)Nr)
rrrôrr–r$rr?Úwkrefr)rÈÚkr#ršÚsubrrrÚ__setitem__Zs


"
zParseResults.__setitem__c
CsÆt|ttfƒrºt|jƒ}|j|=t|tƒrH|dkr:||7}t||dƒ}tt| |¡Žƒ}| ¡x^|j	 
¡D]F\}}x<|D]4}x.t|ƒD]"\}\}}	t||	|	|kƒ||<qŠWq|WqnWn|j	|=dS)Nrr¨)
ršr–r$rÓrrÚrangeÚindicesÚreverserÚitemsròr)
rÈrüÚmylenÚremovedrÚoccurrencesÚjr&ÚvalueÚpositionrrrÚ__delitem__gs


$zParseResults.__delitem__cCs
||jkS)N)r)rÈr&rrrÚ__contains__|szParseResults.__contains__cCs
t|jƒS)N)rÓr)rÈrrrÚ__len__szParseResults.__len__cCs
|jS)N)r)rÈrrrÚ__bool__‚szParseResults.__bool__cCs
t|jƒS)N)Úiterr)rÈrrrÚ__iter__†szParseResults.__iter__cCst|jddd…ƒS)Nr”)r7r)rÈrrrÚ__reversed__‰szParseResults.__reversed__cCs$t|jdƒr|j ¡St|jƒSdS)NÚiterkeys)Úhasattrrr:r7)rÈrrrÚ	_iterkeysŒs
zParseResults._iterkeyscs‡fdd„ˆ ¡DƒS)Nc3s|]}ˆ|VqdS)Nr)rr&)rÈrrr§“sz+ParseResults._itervalues.<locals>.<genexpr>)r<)rÈr)rÈrÚ_itervalues’szParseResults._itervaluescs‡fdd„ˆ ¡DƒS)Nc3s|]}|ˆ|fVqdS)Nr)rr&)rÈrrr§–sz*ParseResults._iteritems.<locals>.<genexpr>)r<)rÈr)rÈrÚ
_iteritems•szParseResults._iteritemscCst| ¡ƒS)zVReturns all named result keys (as a list in Python 2.x, as an iterator in Python 3.x).)rr:)rÈrrrÚkeys¬szParseResults.keyscCst| ¡ƒS)zXReturns all named result values (as a list in Python 2.x, as an iterator in Python 3.x).)rÚ
itervalues)rÈrrrÚvalues°szParseResults.valuescCst| ¡ƒS)zfReturns all named result key-values (as a list of tuples in Python 2.x, as an iterator in Python 3.x).)rÚ	iteritems)rÈrrrr,´szParseResults.itemscCs
t|jƒS)zSince keys() returns an iterator, this method is helpful in bypassing
           code that looks for the existence of any defined results names.)r»r)rÈrrrÚhaskeys¸szParseResults.haskeyscOs’|s
dg}x6| ¡D]*\}}|dkr2|d|f}qtd|ƒ‚qWt|dtƒsht|ƒdksh|d|kr‚|d}||}||=|S|d}|SdS)aÁ
        Removes and returns item at specified index (default= ``last``).
        Supports both ``list`` and ``dict`` semantics for ``pop()``. If
        passed no argument or an integer argument, it will use ``list``
        semantics and pop tokens from the list of parsed tokens. If passed
        a non-integer argument (most likely a string), it will use ``dict``
        semantics and pop the corresponding value from any defined results
        names. A second default return value argument is supported, just as in
        ``dict.pop()``.

        Example::

            def remove_first(tokens):
                tokens.pop(0)
            print(OneOrMore(Word(nums)).parseString("0 123 321")) # -> ['0', '123', '321']
            print(OneOrMore(Word(nums)).addParseAction(remove_first).parseString("0 123 321")) # -> ['123', '321']

            label = Word(alphas)
            patt = label("LABEL") + OneOrMore(Word(nums))
            print(patt.parseString("AAB 123 321").dump())

            # Use pop() in a parse action to remove named result (note that corresponding value is not
            # removed from list form of results)
            def remove_LABEL(tokens):
                tokens.pop("LABEL")
                return tokens
            patt.addParseAction(remove_LABEL)
            print(patt.parseString("AAB 123 321").dump())

        prints::

            ['AAB', '123', '321']
            - LABEL: AAB

            ['AAB', '123', '321']
        r”Údefaultrz-pop() got an unexpected keyword argument '%s'r¨N)r,r!ršr–rÓ)rÈrÇÚkwargsr&r#Úindexr¤ÚdefaultvaluerrrÚpop½s%zParseResults.popcCs||kr||S|SdS)a[
        Returns named result matching the given key, or if there is no
        such name, then returns the given ``defaultValue`` or ``None`` if no
        ``defaultValue`` is specified.

        Similar to ``dict.get()``.

        Example::

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

            result = date_str.parseString("1999/12/31")
            print(result.get("year")) # -> '1999'
            print(result.get("hour", "not specified")) # -> 'not specified'
            print(result.get("hour")) # -> None
        Nr)rÈÚkeyÚdefaultValuerrrrôôszParseResults.getcCsZ|j ||¡xF|j ¡D]8\}}x.t|ƒD]"\}\}}t||||kƒ||<q,WqWdS)a
        Inserts new element at location index in the list of parsed tokens.

        Similar to ``list.insert()``.

        Example::

            print(OneOrMore(Word(nums)).parseString("0 123 321")) # -> ['0', '123', '321']

            # use a parse action to insert the parse location in the front of the parsed results
            def insert_locn(locn, tokens):
                tokens.insert(0, locn)
            print(OneOrMore(Word(nums)).addParseAction(insert_locn).parseString("0 123 321")) # -> [0, '0', '123', '321']
        N)rÚinsertrr,ròr)rÈrFÚinsStrrr/r&r1r2rrrrKszParseResults.insertcCs|j |¡dS)aó
        Add single element to end of ParseResults list of elements.

        Example::

            print(OneOrMore(Word(nums)).parseString("0 123 321")) # -> ['0', '123', '321']

            # use a parse action to compute the sum of the parsed integers, and add it to the end
            def append_sum(tokens):
                tokens.append(sum(map(int, tokens)))
            print(OneOrMore(Word(nums)).addParseAction(append_sum).parseString("0 123 321")) # -> ['0', '123', '321', 444]
        N)rrí)rÈÚitemrrrrí s
zParseResults.appendcCs&t|tƒr| |¡n|j |¡dS)a	
        Add sequence of elements to end of ParseResults list of elements.

        Example::

            patt = OneOrMore(Word(alphas))

            # use a parse action to append the reverse of the matched strings, to make a palindrome
            def make_palindrome(tokens):
                tokens.extend(reversed([t[::-1] for t in tokens]))
                return ''.join(tokens)
            print(patt.addParseAction(make_palindrome).parseString("lskdj sdlkjf lksd")) # -> 'lskdjsdlkjflksddsklfjkldsjdksl'
        N)ršr?Ú__iadd__rÚextend)rÈÚitemseqrrrrO/s
zParseResults.extendcCs|jdd…=|j ¡dS)z7
        Clear all elements and results names.
        N)rrÚclear)rÈrrrrQBszParseResults.clearcCs"y||Stk
rdSXdS)Nr·)r )rÈrrrrrÑIszParseResults.__getattr__cCs| ¡}||7}|S)N)Úcopy)rÈÚotherr¤rrrÚ__add__OszParseResults.__add__cs|jrnt|jƒ‰‡fdd„‰|j ¡}‡fdd„|Dƒ}x4|D],\}}|||<t|dtƒr>t|ƒ|d_q>W|j|j7_|j 	|j¡|S)Ncs|dkrˆS|ˆS)Nrr)Úa)Úoffsetrrr˜Wr™z'ParseResults.__iadd__.<locals>.<lambda>c	s4g|],\}}|D]}|t|dˆ|dƒƒf‘qqS)rr¨)r)rr&Úvlistr#)Ú	addoffsetrrrYsz)ParseResults.__iadd__.<locals>.<listcomp>r)
rrÓrr,ršr?r%rrÚupdate)rÈrSÚ
otheritemsÚotherdictitemsr&r#r)rXrVrrNTs


zParseResults.__iadd__cCs&t|tƒr|dkr| ¡S||SdS)Nr)ršr–rR)rÈrSrrrÚ__radd__dszParseResults.__radd__cCsdt|jƒt|jƒfS)Nz(%s, %s))rrr)rÈrrrrÖlszParseResults.__repr__cCsdd dd„|jDƒ¡dS)Nú[z, css(|] }t|tƒrt|ƒnt|ƒVqdS)N)ršr?r¥r)rrürrrr§psz'ParseResults.__str__.<locals>.<genexpr>ú])rØr)rÈrrrrÕoszParseResults.__str__r·cCsPg}xF|jD]<}|r"|r"| |¡t|tƒr:|| ¡7}q| t|ƒ¡qW|S)N)rríršr?Ú
_asStringListr¥)rÈÚsepÚoutrMrrrr_rs

zParseResults._asStringListcCsdd„|jDƒS)ax
        Returns the parse results as a nested list of matching tokens, all converted to strings.

        Example::

            patt = OneOrMore(Word(alphas))
            result = patt.parseString("sldkj lsdkj sldkj")
            # even though the result prints in string-like form, it is actually a pyparsing ParseResults
            print(type(result), result) # -> <class 'pyparsing.ParseResults'> ['sldkj', 'lsdkj', 'sldkj']

            # Use asList() to create an actual list
            result_list = result.asList()
            print(type(result_list), result_list) # -> <class 'list'> ['sldkj', 'lsdkj', 'sldkj']
        cSs"g|]}t|tƒr| ¡n|‘qSr)ršr?r)rÚresrrrrŒsz'ParseResults.asList.<locals>.<listcomp>)r)rÈrrrr}szParseResults.asListcs6tr|j}n|j}‡fdd„‰t‡fdd„|ƒDƒƒS)a¬
        Returns the named parse results as a nested dictionary.

        Example::

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

            result = date_str.parseString('12/31/1999')
            print(type(result), repr(result)) # -> <class 'pyparsing.ParseResults'> (['12', '/', '31', '/', '1999'], {'day': [('1999', 4)], 'year': [('12', 0)], 'month': [('31', 2)]})

            result_dict = result.asDict()
            print(type(result_dict), repr(result_dict)) # -> <class 'dict'> {'day': '1999', 'year': '12', 'month': '31'}

            # even though a ParseResults supports dict-like access, sometime you just need to have a dict
            import json
            print(json.dumps(result)) # -> Exception: TypeError: ... is not JSON serializable
            print(json.dumps(result.asDict())) # -> {"month": "31", "day": "1999", "year": "12"}
        cs6t|tƒr.| ¡r| ¡S‡fdd„|DƒSn|SdS)Ncsg|]}ˆ|ƒ‘qSrr)rr#)ÚtoItemrrr¬sz7ParseResults.asDict.<locals>.toItem.<locals>.<listcomp>)ršr?rCÚasDict)r£)rcrrrc§s

z#ParseResults.asDict.<locals>.toItemc3s|]\}}|ˆ|ƒfVqdS)Nr)rr&r#)rcrrr§°sz&ParseResults.asDict.<locals>.<genexpr>)ÚPY_3r,rBr)rÈÚitem_fnr)rcrrdŽs
	zParseResults.asDictcCs<t|jƒ}t|j ¡ƒ|_|j|_|j |j¡|j|_|S)zG
        Returns a new copy of a :class:`ParseResults` object.
        )	r?rrrr,rrrYr)rÈr¤rrrrR²s
zParseResults.copyFcCsPd}g}tdd„|j ¡Dƒƒ}|d}|s8d}d}d}d}	|dk	rJ|}	n|jrV|j}	|	sf|rbdSd}	|||d|	d	g7}xºt|jƒD]¬\}
}t|tƒrâ|
|krÂ|| ||
|o´|dk||¡g7}n|| d|oÔ|dk||¡g7}q„d}|
|krö||
}|s
|rq„nd}t	t
|ƒƒ}
|||d|d	|
d
|d	g	7}q„W|||d
|	d	g7}d |¡S)z‡
        (Deprecated) Returns the parse results as XML. Tags are created for tokens and lists that have defined results names.
        rêcss(|] \}}|D]}|d|fVqqdS)r¨Nr)rr&rWr#rrrr§Ãsz%ParseResults.asXML.<locals>.<genexpr>z  r·NÚITEMú<ú>z</)rrr,rròrršr?ÚasXMLr´r¥rØ)rÈÚdoctagÚnamedItemsOnlyÚindentÚ	formattedÚnlraÚ
namedItemsÚnextLevelIndentÚselfTagrürbÚresTagÚxmlBodyTextrrrrj½sT


zParseResults.asXMLcCs:x4|j ¡D]&\}}x|D]\}}||kr|SqWqWdS)N)rr,)rÈr'r&rWr#rÄrrrÚ__lookupús
zParseResults.__lookupcCs€|jr|jS|jr.| ¡}|r(| |¡SdSnNt|ƒdkrxt|jƒdkrxtt|j ¡ƒƒdddkrxtt|j ¡ƒƒSdSdS)a
        Returns the results name for this token expression. Useful when several
        different expressions might match at a particular location.

        Example::

            integer = Word(nums)
            ssn_expr = Regex(r"\d\d\d-\d\d-\d\d\d\d")
            house_number_expr = Suppress('#') + Word(nums, alphanums)
            user_data = (Group(house_number_expr)("house_number")
                        | Group(ssn_expr)("ssn")
                        | Group(integer)("age"))
            user_info = OneOrMore(user_data)

            result = user_info.parseString("22 111-22-3333 #221B")
            for item in result:
                print(item.getName(), ':', item[0])

        prints::

            age : 22
            ssn : 111-22-3333
            house_number : 221B
        Nr¨r)rr”)	rrÚ_ParseResults__lookuprÓrÚnextr7rAr?)rÈÚparrrrÚgetNames
zParseResults.getNamercCs~g}d}|r$| |t| ¡ƒ¡n
| d¡|rt| ¡rÖtdd„| ¡Dƒƒ}x€|D]x\}}	|rn| |¡| d|d||f¡t|	tƒrÂ|	r²| |	j||||dd¡qÐ| t|	ƒ¡qX| t	|	ƒ¡qXWnžt
d	d„|Dƒƒrt|}	x„t|	ƒD]x\}
}t|tƒrF| d
|d||
|d|d|j||||ddf¡qø| d
|d||
|d|dt|ƒf¡qøWd |¡S)aF
        Diagnostic method for listing out the contents of
        a :class:`ParseResults`. Accepts an optional ``indent`` argument so
        that this string can be embedded in a nested display of other data.

        Example::

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

            result = date_str.parseString('12/31/1999')
            print(result.dump())

        prints::

            ['12', '/', '31', '/', '1999']
            - day: 1999
            - month: 31
            - year: 12
        rêr·css|]\}}t|ƒ|fVqdS)N)rœ)rr&r#rrrr§Gsz$ParseResults.dump.<locals>.<genexpr>z
%s%s- %s: z  r¨)rmÚfullÚinclude_listÚ_depthcss|]}t|tƒVqdS)N)ršr?)rÚvvrrrr§Ssz
%s%s[%d]:
%s%s%s)
rír¥rrCÚsortedr,ršr?ÚdumprÚanyròrØ)rÈrmrzr{r|raÚNLr,r&r#rür}rrrr)sJ




zParseResults.dumpcOstj| ¡f|ž|ŽdS)a#
        Pretty-printer for parsed results as a list, using the
        `pprint <https://docs.python.org/3/library/pprint.html>`_ module.
        Accepts additional positional or keyword args as defined for
        `pprint.pprint <https://docs.python.org/3/library/pprint.html#pprint.pprint>`_ .

        Example::

            ident = Word(alphas, alphanums)
            num = Word(nums)
            func = Forward()
            term = ident | num | Group('(' + func + ')')
            func <<= ident + Group(Optional(delimitedList(term)))
            result = func.parseString("fna a,b,(fnb c,d,200),100")
            result.pprint(width=40)

        prints::

            ['fna',
             ['a',
              'b',
              ['(', 'fnb', ['c', 'd', '200'], ')'],
              '100']]
        N)Úpprintr)rÈrÇrErrrr‚jszParseResults.pprintcCs.|j|j ¡|jdk	r| ¡p d|j|jffS)N)rrrRrrr)rÈrrrÚ__getstate__†s
zParseResults.__getstate__cCsN|d|_|d\|_}}|_i|_|j |¡|dk	rDt|ƒ|_nd|_dS)Nrr¨)rrrrrYr%r)rÈÚstaterxÚinAccumNamesrrrÚ__setstate__s
zParseResults.__setstate__cCs|j|j|j|jfS)N)rrrr)rÈrrrÚ__getnewargs__—szParseResults.__getnewargs__cCstt|ƒƒt| ¡ƒS)N)rÞrßrr?)rÈrrrràšszParseResults.__dir__cCsvdd„}|gƒ}xJ| ¡D]>\}}t|tƒr@||j||d7}q|||g|||ƒd7}qW|dk	rr||g|d}|S)zã
        Helper classmethod to construct a ParseResults from a dict, preserving the
        name-value relations as results names. If an optional 'name' argument is
        given, a nested ParseResults will be returned
        cSsFyt|ƒWntk
r dSXtr6t|ttfƒSt|tƒSdS)NF)r7Ú	ExceptionreršrœÚbytesr)r£rrrÚis_iterable¤sz+ParseResults.from_dict.<locals>.is_iterable)r)rrN)r,ršrÚ	from_dict)rËrSrrŠr¤r&r#rrrr‹s
zParseResults.from_dict)NNTT)N)r·)NFr·T)r·TTr)N)6rrrrárršrÊr
r(r3r4r5r6Ú__nonzero__r8r9r<r=r>rer?rAr,r:r@rBrCrHrôrKrírOrQrÑrTrNr\rÖrÕr_rrdrRrjrvryrr‚rƒr†r‡ràrâr‹rrrrr?ösl*
	'	
7

$
=(
A
cCsF|}d|krt|ƒkr4nn||ddkr4dS|| dd|¡S)añReturns current column within a string, counting newlines as line separators.
   The first column is number 1.

   Note: the default parsing behavior is to expand tabs in the input string
   before starting the parsing process.  See
   :class:`ParserElement.parseString` for more
   information on parsing strings containing ``<TAB>`` s, and suggested
   methods to maintain a consistent view of the parsed string, the parse
   location, and line and column positions within the parsed string.
   rr¨rê)rÓÚrfind)rÄÚstrgr«rrrrW»scCs| dd|¡dS)aùReturns current line number within a string, counting newlines as line separators.
    The first line is number 1.

    Note - the default parsing behavior is to expand tabs in the input string
    before starting the parsing process.  See :class:`ParserElement.parseString`
    for more information on parsing strings containing ``<TAB>`` s, and
    suggested methods to maintain a consistent view of the parsed string, the
    parse location, and line and column positions within the parsed string.
    rêrr¨)Úcount)rÄrŽrrrrhÉs
cCsF| dd|¡}| d|¡}|dkr2||d|…S||dd…SdS)zfReturns the line of text containing loc within a string, counting newlines as line separators.
       rêrr¨N)rÚfind)rÄrŽÚlastCRÚnextCRrrrreÕs
cCs8tdt|ƒdt|ƒdt||ƒt||ƒfƒdS)NzMatch z at loc z(%d,%d))Úprintr¥rhrW)ÚinstringrÄÚexprrrrÚ_defaultStartDebugActionßsr–cCs$tdt|ƒdt| ¡ƒƒdS)NzMatched z -> )r“r¥rœr)r”ÚstartlocÚendlocr•ÚtoksrrrÚ_defaultSuccessDebugActionâsršcCstdt|ƒƒdS)NzException raised:)r“r¥)r”rÄr•rørrrÚ_defaultExceptionDebugActionåsr›cGsdS)zG'Do-nothing' debug action, to suppress debugging output during parsing.Nr)rÇrrrroèsr“cs҈tkr‡fdd„Sdg‰dg‰tdd…dkrFddd„}dd	d
„‰ntj}tj‰d}|ddd
}|d|d|f‰‡‡‡‡‡‡fdd„}d}ytˆdtˆdƒjƒ}Wntk
rÆtˆƒ}YnX||_|S)Ncsˆ|ƒS)Nr)r«r¼r—)Úfuncrrr˜r™z_trim_arity.<locals>.<lambda>rFr“)r‘écSs8tdkrdnd}tj||dd|}|dd…gS)N)r‘rréýÿÿÿéþÿÿÿr¨)Úlimitr“)Úsystem_versionÚ	tracebackÚ
extract_stack)r rVÚ
frame_summaryrrrr£sz"_trim_arity.<locals>.extract_stackcSs$tj||d}|d}|dd…gS)N)r r”r“)r¢Ú
extract_tb)Útbr Úframesr¤rrrr¥sz_trim_arity.<locals>.extract_tbé)r r”r¨csºx´y ˆ|ˆdd…Ž}dˆd<|Stk
r°ˆdr>‚nNz.t ¡d}ˆ|ddddd…ˆksj‚Wdy~Wntk
rˆYnXXˆdˆkrªˆdd7<w‚YqXqWdS)NrTr”r“)r r¨)r!rŸÚexc_infoÚ	NameError)rÇr¤r¦)r¥Ú
foundArityrœr ÚmaxargsÚpa_call_line_synthrrré!s(z_trim_arity.<locals>.wrapperz<parse action>rÚ	__class__)r)r)	ÚsingleArgBuiltinsr¡r¢r£r¥Úgetattrrrˆrœ)rœr¬r£Ú	LINE_DIFFÚ	this_lineréÚ	func_namer)r¥r«rœr r¬r­rrÁs*
rÁc@s°eZdZdZdZdZedd„ƒZedd„ƒZe	dd	„ƒZ
dŽd
d„Zdd
„Zdd„Z
ddd„Zddd„Zd‘dd„Zdd„Zdd„Zdd„Zdd„Zdd „Zd!d"„Zd’d#d$„Zd%d&„Zd“d'd(„Zd)d*„Zd+d,„ZGd-d.„d.eƒZed/k	røGd0d1„d1eƒZnGd2d1„d1eƒZiZ e!ƒZ"d3d3gZ#d”d4d5„Z$eZ%ed6d7„ƒZ&dZ'ed•d9d:„ƒZ(d–d;d<„Z)e*dfd=d>„Z+d?d@„Z,e*fdAdB„Z-e*dfdCdD„Z.dEdF„Z/dGdH„Z0dIdJ„Z1dKdL„Z2dMdN„Z3dOdP„Z4dQdR„Z5dSdT„Z6dUdV„Z7dWdX„Z8dYdZ„Z9d[d\„Z:d]d^„Z;d_d`„Z<dadb„Z=d—dcdd„Z>dedf„Z?dgdh„Z@didj„ZAdkdl„ZBdmdn„ZCdodp„ZDd˜dqdr„ZEdsdt„ZFdudv„ZGdwdx„ZHdydz„ZId™d{d|„ZJdšd}d~„ZKdd€„ZLdd‚„ZMdƒd„„ZNd…d†„ZOd‡dˆ„ZPd›d‰dŠ„ZQdœdŒd„ZRd/S)rAz)Abstract base level parser element class.z 
	
FcCs
|t_dS)aÆ
        Overrides the default whitespace chars

        Example::

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

            # change to just treat newline as significant
            ParserElement.setDefaultWhitespaceChars(" \t")
            OneOrMore(Word(alphas)).parseString("abc def\nghi jkl")  # -> ['abc', 'def']
        N)rAÚDEFAULT_WHITE_CHARS)ÚcharsrrrÚsetDefaultWhitespaceCharsLsz'ParserElement.setDefaultWhitespaceCharscCs
|t_dS)ah
        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.parseString("1999/12/31")  # -> ['1999', '/', '12', '/', '31']


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

            date_str.parseString("1999/12/31")  # -> ['1999', '12', '31']
        N)rAÚ_literalStringClass)rËrrrÚinlineLiteralsUsing\sz!ParserElement.inlineLiteralsUsingcCsx|jr|j}qW|S)N)Útb_next)rËr¦rrrÚ_trim_tracebackrs
zParserElement._trim_tracebackcCs†tƒ|_d|_d|_d|_||_d|_ttj	ƒ|_
d|_d|_d|_
tƒ|_d|_d|_d|_d|_d|_d|_d|_d|_d|_dS)NTFr·)NNN)rÚparseActionÚ
failActionÚstrReprÚresultsNameÚ
saveAsListÚskipWhitespacerñrAr´Ú
whiteCharsÚcopyDefaultWhiteCharsÚmayReturnEmptyÚkeepTabsÚignoreExprsÚdebugÚstreamlinedÚ
mayIndexErrorÚerrmsgÚmodalResultsÚdebugActionsrÚcallPreparseÚ
callDuringTry)rÈÚsavelistrrrrÊxs(zParserElement.__init__cCs<t |¡}|jdd…|_|jdd…|_|jr8tj|_|S)a/
        Make a copy of this :class:`ParserElement`.  Useful for defining
        different parse actions for the same parsing pattern, using copies of
        the original parse element.

        Example::

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

            print(OneOrMore(integerK | integerM | integer).parseString("5K 100 640K 256M"))

        prints::

            [5120, 100, 655360, 268435456]

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

            integerM = integer().addParseAction(lambda toks: toks[0] * 1024 * 1024) + Suppress("M")
        N)rRr»rÅrÂrAr´rÁ)rÈÚcpyrrrrRs
zParserElement.copycCs$||_d|j|_tjr | ¡|S)a_
        Define name for this expression, makes debugging and exception messages clearer.

        Example::

            Word(nums).parseString("ABC")  # -> Exception: Expected W:(0123...) (at char 0), (line:1, col:1)
            Word(nums).setName("integer").parseString("ABC")  # -> Exception: Expected integer (at char 0), (line:1, col:1)
        z	Expected )rrÉrÚ!enable_debug_on_named_expressionsÚsetDebug)rÈrrrrÚsetName¬s
	zParserElement.setNamecCs| ||¡S)aO
        Define name for referencing matching tokens as a nested attribute
        of the returned parse results.
        NOTE: this returns a *copy* of the original :class:`ParserElement` object;
        this is so that the client can define a basic element, such as an
        integer, and reference it in multiple places with different names.

        You can also set results names using the abbreviated syntax,
        ``expr("name")`` in place of ``expr.setResultsName("name")``
        - see :class:`__call__`.

        Example::

            date_str = (integer.setResultsName("year") + '/'
                        + integer.setResultsName("month") + '/'
                        + integer.setResultsName("day"))

            # equivalent form:
            date_str = integer("year") + '/' + integer("month") + '/' + integer("day")
        )Ú_setResultsName)rÈrÚlistAllMatchesrrrÚsetResultsName»szParserElement.setResultsNamecCs4| ¡}| d¡r"|dd…}d}||_||_|S)NÚ*r”T)rRÚendswithr¾rÊ)rÈrrÔÚnewselfrrrrÓÒs
zParserElement._setResultsNameTcs@|r&|j‰d‡fdd„	}ˆ|_||_nt|jdƒr<|jj|_|S)z§Method to invoke the Python pdb debugger when this element is
           about to be parsed. Set ``breakFlag`` to True to enable, False to
           disable.
        Tcsddl}| ¡ˆ||||ƒS)Nr)ÚpdbÚ	set_trace)r”rÄÚ	doActionsÚcallPreParserÙ)Ú_parseMethodrrÚbreakerâsz'ParserElement.setBreak.<locals>.breakerÚ_originalParseMethod)TT)Ú_parserßr;)rÈÚ	breakFlagrÞr)rÝrÚsetBreakÛs
zParserElement.setBreakcOsVt|ƒdgkrg|_n<tdd„|Dƒƒs0tdƒ‚tttt|ƒƒƒ|_| dd¡|_|S)a’
        Define one or more actions to perform when successfully matching parse element definition.
        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

        If the functions in fns modify the tokens, they can return them as the return
        value from fn, and the modified list of tokens will replace the original.
        Otherwise, fn does not need to return any value.

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

        Optional keyword arguments:
        - callDuringTry = (default= ``False``) indicate if parse action should be run during lookaheads and alternate testing

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

        Example::

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

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

            # use parse action to convert to ints at parse time
            integer = Word(nums).setParseAction(lambda toks: int(toks[0]))
            date_str = integer + '/' + integer + '/' + integer

            # note that integer fields are now ints, not strings
            date_str.parseString("1999/12/31")  # -> [1999, '/', 12, '/', 31]
        Ncss|]}t|ƒVqdS)N)Úcallable)rr¾rrrr§sz/ParserElement.setParseAction.<locals>.<genexpr>zparse actions must be callablerÍF)rr»Úallr!ÚmaprÁrôrÍ)rÈÚfnsrErrrr¡îs(zParserElement.setParseActioncOs4|jtttt|ƒƒƒ7_|jp,| dd¡|_|S)z›
        Add one or more parse actions to expression's list of parse actions. See :class:`setParseAction`.

        See examples in :class:`copy`.
        rÍF)r»rrårÁrÍrô)rÈrærErrrÚaddParseActionszParserElement.addParseActionc
OsJx0|D](}|j t|| d¡| dd¡d¡qW|jpB| dd¡|_|S)a¼Add a boolean predicate function to expression's list of parse actions. See
        :class:`setParseAction` for function call signatures. Unlike ``setParseAction``,
        functions passed to ``addCondition`` need to return boolean success/fail of the condition.

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

        Example::

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

            result = date_str.parseString("1999/12/31")  # -> Exception: Only support years 2000 and later (at char 0), (line:1, col:1)
        rÂrÃF)rÂrÃrÍ)r»rírrôrÍ)rÈrærEr¾rrrÚaddCondition)s

zParserElement.addConditioncCs
||_|S)aDefine action to perform if parsing fails at this expression.
           Fail acton fn is a callable function that takes the arguments
           ``fn(s, loc, expr, err)`` where:
           - s = string being parsed
           - loc = location where expression match was attempted and failed
           - expr = the parse expression that failed
           - err = the exception thrown
           The function returns no value.  It may throw :class:`ParseFatalException`
           if it is desired to stop parsing immediately.)r¼)rÈr¾rrrÚ
setFailActionBs
zParserElement.setFailActionc	CsZd}xP|rTd}xB|jD]8}yx| ||¡\}}d}qWWqtk
rLYqXqWqW|S)NTF)rÅràr<)rÈr”rÄÚ
exprsFoundÚeÚdummyrrrÚ_skipIgnorablesOszParserElement._skipIgnorablescCsL|jr| ||¡}|jrH|j}t|ƒ}x ||krF|||krF|d7}q(W|S)Nr¨)rÅrírÀrÁrÓ)rÈr”rÄÚwtÚinstrlenrrrÚpreParse\szParserElement.preParsecCs|gfS)Nr)rÈr”rÄrÛrrrrçhszParserElement.parseImplcCs|S)Nr)rÈr”rÄÚ	tokenlistrrrÚ	postParsekszParserElement.postParsecCs˜d\}}}|j}|s|jr"|j|r8|j||||ƒyŠ|rR|jrR| ||¡}	n|}	|	}
|jsl|	t|ƒkr®y| ||	|¡\}}WqÀtk
rªt	|t|ƒ|j
|ƒ‚YqÀXn| ||	|¡\}}Wn\tk
r}z<|j|rô|j|||
||ƒ|jr| ||
||¡‚Wdd}~XYnXn|r>|jr>| ||¡}	n|}	|	}
|js\|	t|ƒkr y| ||	|¡\}}Wn*tk
rœt	|t|ƒ|j
|ƒ‚YnXn| ||	|¡\}}| |||¡}t
||j|j|jd}
|jrh|sì|jrh|rÔy˜x’|jD]ˆ}y|||
|
ƒ}Wn6tk
rF}zt	dƒ}||_|‚Wdd}~XYnX|dk	rü||
k	rüt
||j|joxt|t
tfƒ|jd}
qüWWnFtk
rÐ}z&|j|r¾|j|||
||ƒ‚Wdd}~XYnXn”x’|jD]ˆ}y|||
|
ƒ}Wn6tk
r&}zt	dƒ}||_|‚Wdd}~XYnX|dk	rÜ||
k	rÜt
||j|joXt|t
tfƒ|jd}
qÜW|r|j|r|j|||
|||
ƒ||
fS)N)rr¨r“)rrz exception raised in parse action)rÆr¼rËrÌrðrÈrÓrçr"r<rÉrˆròr?r¾r¿rÊr»rÍÚ	__cause__ršr)rÈr”rÄrÛrÜÚTRYÚMATCHÚFAILÚ	debuggingÚprelocÚtokensStartÚtokensÚerrÚ	retTokensr¾Úparse_action_excrørrrrèosŠ



zParserElement._parseNoCachecCs>y|j||dddStk
r8t|||j|ƒ‚YnXdS)NF)rÛr)ràr>r<rÉ)rÈr”rÄrrrÚtryParseÆszParserElement.tryParsec	Cs2y| ||¡Wnttfk
r(dSXdSdS)NFT)rþr<r")rÈr”rÄrrrÚcanParseNextÌs
zParserElement.canParseNextc@seZdZdd„ZdS)zParserElement._UnboundedCachecs~i‰tƒ|_‰‡‡fdd„}‡fdd„}‡fdd„}‡fdd„}t ||¡|_t ||¡|_t ||¡|_t ||¡|_dS)	Ncsˆ |ˆ¡S)N)rô)rÈrI)ÚcacheÚnot_in_cacherrrôÙsz3ParserElement._UnboundedCache.__init__.<locals>.getcs|ˆ|<dS)Nr)rÈrIr1)rrrrñÜsz3ParserElement._UnboundedCache.__init__.<locals>.setcsˆ ¡dS)N)rQ)rÈ)rrrrQßsz5ParserElement._UnboundedCache.__init__.<locals>.clearcstˆƒS)N)rÓ)rÈ)rrrÚ	cache_lenâsz9ParserElement._UnboundedCache.__init__.<locals>.cache_len)r
rÚtypesÚ
MethodTyperôrñrQr5)rÈrôrñrQrr)rrrrÊÕsz&ParserElement._UnboundedCache.__init__N)rrrrÊrrrrÚ_UnboundedCacheÔsrNc@seZdZdd„ZdS)zParserElement._FifoCachecs‚tƒ|_‰tƒ‰‡‡fdd„}‡‡fdd„}‡fdd„}‡fdd„}t ||¡|_t ||¡|_t ||¡|_t ||¡|_dS)	Ncsˆ |ˆ¡S)N)rô)rÈrI)rrrrrôñsz.ParserElement._FifoCache.__init__.<locals>.getcsB|ˆ|<x4tˆƒˆkr<yˆ d¡Wq
tk
r8Yq
Xq
WdS)NF)rÓÚpopitemr )rÈrIr1)rÚsizerrrñôsz.ParserElement._FifoCache.__init__.<locals>.setcsˆ ¡dS)N)rQ)rÈ)rrrrQüsz0ParserElement._FifoCache.__init__.<locals>.clearcstˆƒS)N)rÓ)rÈ)rrrrÿsz4ParserElement._FifoCache.__init__.<locals>.cache_len)	r
rÚ_OrderedDictrrrôrñrQr5)rÈrrôrñrQrr)rrrrrÊìsz!ParserElement._FifoCache.__init__N)rrrrÊrrrrÚ
_FifoCacheësr	c@seZdZdd„ZdS)zParserElement._FifoCachecstƒ|_‰i‰t gˆ¡‰‡‡fdd„}‡‡‡fdd„}‡‡fdd„}‡fdd„}t ||¡|_t ||¡|_t ||¡|_t ||¡|_	dS)	Ncsˆ |ˆ¡S)N)rô)rÈrI)rrrrrôsz.ParserElement._FifoCache.__init__.<locals>.getcs8|ˆ|<x tˆƒˆkr(ˆ ˆ ¡d¡q
Wˆ |¡dS)N)rÓrHÚpopleftrí)rÈrIr1)rÚkey_fiforrrrñsz.ParserElement._FifoCache.__init__.<locals>.setcsˆ ¡ˆ ¡dS)N)rQ)rÈ)rrrrrQsz0ParserElement._FifoCache.__init__.<locals>.clearcstˆƒS)N)rÓ)rÈ)rrrrsz4ParserElement._FifoCache.__init__.<locals>.cache_len)
r
rÚcollectionsÚdequerrrôrñrQr5)rÈrrôrñrQrr)rrrrrrÊ	sz!ParserElement._FifoCache.__init__N)rrrrÊrrrrr	srcCsüd\}}|||||f}tjÖtj}| |¡}	|	|jkrºtj|d7<y| ||||¡}	Wn8tk
r–}
z| ||
j	|
j
Ž¡‚Wdd}
~
XYqîX| ||	d|	d ¡f¡|	Sn4tj|d7<t|	t
ƒrÚ|	‚|	d|	d ¡fSWdQRXdS)N)rr¨r¨r)rAÚpackrat_cache_lockÚ
packrat_cacherôrÚpackrat_cache_statsrèr:rñr®rÇrRršrˆ)rÈr”rÄrÛrÜÚHITÚMISSÚlookuprr1rÌrrrÚ_parseCache+s$


zParserElement._parseCachecCs(tj ¡dgttjƒtjdd…<dS)Nr)rArrQrÓrrrrrÚ
resetCacheDs
zParserElement.resetCacheé€cCs8tjs4dt_|dkr t ¡t_nt |¡t_tjt_dS)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.enablePackrat`.
           For best results, call ``enablePackrat()`` immediately after
           importing pyparsing.

           Example::

               import pyparsing
               pyparsing.ParserElement.enablePackrat()
        TN)rAÚ_packratEnabledrrr	rrà)Úcache_size_limitrrrÚ
enablePackratJszParserElement.enablePackratc
CsÐt ¡|js| ¡x|jD]}| ¡qW|js<| ¡}y<| |d¡\}}|rv| ||¡}t	ƒt
ƒ}| ||¡WnNtk
rÆ}z0tjr”‚n"t
|ddƒdk	r²| |j¡|_|‚Wdd}~XYnX|SdS)aû
        Execute the parse expression with the given string.
        This is the main interface to the client code, once the complete
        expression has been built.

        Returns the parsed data as a :class:`ParseResults` object, which may be
        accessed as a list, or as a dict or object with attributes if the given parser
        includes results names.

        If you want the grammar to require that the entire input string be
        successfully parsed, then set ``parseAll`` to True (equivalent to ending
        the grammar with ``StringEnd()``).

        Note: ``parseString`` implicitly calls ``expandtabs()`` on the input string,
        in order to report proper column numbers in parse actions.
        If the input string contains tabs and
        the grammar uses parse actions that use the ``loc`` argument to index into the
        string being parsed, you can ensure you have a consistent view of the input
        string by:

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

        Example::

            Word('a').parseString('aaaaabaaa')  # -> ['aaaaa']
            Word('a').parseString('aaaaabaaa', parseAll=True)  # -> Exception: Expected end of text
        rrðN)rArrÇÚ
streamlinerÅrÄÚ
expandtabsràrðr)rFr:Úverbose_stacktracer°rºrð)rÈr”ÚparseAllrërÄrúÚserørrrÚparseStringms(!zParserElement.parseStringc
csb|js| ¡x|jD]}| ¡qW|js8t|ƒ ¡}t|ƒ}d}|j}|j}t	 
¡d}	y¬x¦||kr|	|kry |||ƒ}
|||
dd\}}Wntk
r°|
d}Yq`X||krú|	d7}	||
|fV|rô|||ƒ}
|
|krê|}qø|d7}n|}q`|
d}q`WWnTtk
r\}z4t	j
r(‚n$t|ddƒdk	rH| |j¡|_|‚Wdd}~XYnXdS)aq
        Scan the input string for expression matches.  Each match will return the
        matching tokens, start location, and end location.  May be called with optional
        ``maxMatches`` 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:`parseString` for more information on parsing
        strings with embedded tabs.

        Example::

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

        prints::

            sldjf123lsdjjkf345sldkjf879lkjsfd987
            ^^^^^
            sldjf
                    ^^^^^^^
                    lsdjjkf
                              ^^^^^^
                              sldkjf
                                       ^^^^^^
                                       lkjsfd
        rF)rÜr¨rðN)rÇrrÅrÄr¥rrÓrðràrArr<r:rr°rºrð)rÈr”Ú
maxMatchesÚoverlaprërïrÄÚ
preparseFnÚparseFnÚmatchesrøÚnextLocrúÚnextlocrørrrÚ
scanString§sF


zParserElement.scanStringc
Csg}d}d|_yžxh| |¡D]Z\}}}| |||…¡|rrt|tƒrT|| ¡7}nt|tƒrh||7}n
| |¡|}qW| ||d…¡dd„|Dƒ}d tt	t
|ƒƒ¡Stk
rú}z0tj
rȂn"t|ddƒdk	ræ| |j¡|_|‚Wdd}~XYnXdS)a[
        Extension to :class:`scanString`, to modify matching text with modified tokens that may
        be returned from a parse action.  To use ``transformString``, define a grammar and
        attach a parse action to it that modifies the returned token list.
        Invoking ``transformString()`` on a target string will then scan for matches,
        and replace the matched text patterns according to the logic in the parse
        action.  ``transformString()`` returns the resulting transformed string.

        Example::

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

            print(wd.transformString("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.
        rTNcSsg|]}|r|‘qSrr)rÚorrrrsz1ParserElement.transformString.<locals>.<listcomp>r·rð)rÄr'ríršr?rrrØrår¥Ú_flattenr:rArr°rºrð)rÈr”raÚlastEr—r«rërørrrr¢ñs,



zParserElement.transformStringc
Csnytdd„| ||¡DƒƒStk
rh}z0tjr6‚n"t|ddƒdk	rT| |j¡|_|‚Wdd}~XYnXdS)a 
        Another extension to :class:`scanString`, simplifying the access to the tokens found
        to match the given parse expression.  May be called with optional
        ``maxMatches`` 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.searchString("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.searchString("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']
        cSsg|]\}}}|‘qSrr)rr—r«rërrrr7sz.ParserElement.searchString.<locals>.<listcomp>rðN)r?r'r:rArr°rºrð)rÈr”r rørrrÚsearchString!szParserElement.searchStringc	csXd}d}x<|j||dD]*\}}}|||…V|r>|dV|}qW||d…VdS)aR
        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 ``includeSeparators`` argument (default= ``False``), if the separating
        matching text should be included in the split results.

        Example::

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

        prints::

            ['This', ' this', '', ' this sentence', ' is badly punctuated', '']
        r)r N)r')	rÈr”ÚmaxsplitÚincludeSeparatorsÚsplitsÚlastr—r«rërrrr¬As
zParserElement.splitcCsV|tkrt|ƒSt|tƒr$| |¡}t|tƒsJtjdt|ƒt	dddSt
||gƒS)a[
        Implementation of + operator - returns :class:`And`. Adding strings to a ParserElement
        converts them to :class:`Literal`s by default.

        Example::

            greet = Word(alphas) + "," + Word(alphas) + "!"
            hello = "Hello, World!"
            print (hello, "->", greet.parseString(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.
        z4Cannot combine element of type %s with ParserElementr“)Ú
stacklevelN)ÚEllipsisÚ_PendingSkipršrr·rAÚwarningsÚwarnrßÚ
SyntaxWarningr")rÈrSrrrrTZs



zParserElement.__add__cCsZ|tkrt|ƒdƒ|St|tƒr,| |¡}t|tƒsRtjdt|ƒt	dddS||S)z`
        Implementation of + operator when left operand is not a :class:`ParserElement`
        z	_skipped*z4Cannot combine element of type %s with ParserElementr“)r0N)
r1rEršrr·rAr3r4rßr5)rÈrSrrrr\€s



zParserElement.__radd__cCsJt|tƒr| |¡}t|tƒs:tjdt|ƒtdddS|t 	¡|S)zT
        Implementation of - operator, returns :class:`And` with error stop
        z4Cannot combine element of type %s with ParserElementr“)r0N)
ršrr·rAr3r4rßr5r"Ú
_ErrorStop)rÈrSrrrÚ__sub__s



zParserElement.__sub__cCsBt|tƒr| |¡}t|tƒs:tjdt|ƒtdddS||S)z`
        Implementation of - operator when left operand is not a :class:`ParserElement`
        z4Cannot combine element of type %s with ParserElementr“)r0N)ršrr·rAr3r4rßr5)rÈrSrrrÚ__rsub__›s



zParserElement.__rsub__cs|tkrd}n8t|tƒrF|dd…tfkrFd|dd…ddd…}t|tƒr\|d}}nüt|tƒrJtdd	„|Dƒƒ}|d
dd…}|ddkr¢d|df}t|dtƒrú|ddkrú|ddkrÐtˆƒS|ddkrätˆƒSˆ|dtˆƒSnNt|dtƒr,t|dtƒr,|\}}||8}ntdt|dƒt|dƒƒ‚ntdt|ƒƒ‚|dkrjtd
ƒ‚|dkr|tdƒ‚||kr”dkr nntdƒ‚|rô‡‡fdd„‰|rê|dkr҈ˆ|ƒ}nt	ˆg|ƒˆ|ƒ}nˆ|ƒ}n|dkrˆ}nt	ˆg|ƒ}|S)aø
        Implementation of * operator, allows use of ``expr * 3`` in place of
        ``expr + expr + expr``.  Expressions may also me 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¨)r)Nr“rcss|]}|tk	r|ndVqdS)N)r1)rr(rrrr§Ãsz(ParserElement.__mul__.<locals>.<genexpr>)NNz8cannot multiply 'ParserElement' and ('%s', '%s') objectsz0cannot multiply 'ParserElement' and '%s' objectsz/cannot multiply ParserElement by negative valuez@second tuple value must be greater or equal to first tuple valuez,cannot multiply ParserElement by 0 or (0, 0)cs(|dkrtˆˆ|dƒƒStˆƒSdS)Nr¨)r8)Ún)ÚmakeOptionalListrÈrrr:Þsz/ParserElement.__mul__.<locals>.makeOptionalList)
r1ršÚtupler–rOr6r!rßÚ
ValueErrorr")rÈrSÚminElementsÚoptElementsr¤r)r:rÈrÚ__mul__§sN
 





zParserElement.__mul__cCs
| |¡S)N)r?)rÈrSrrrÚ__rmul__ñszParserElement.__rmul__cCsZ|tkrt|ddSt|tƒr(| |¡}t|tƒsNtjdt|ƒt	dddSt
||gƒS)zL
        Implementation of | operator - returns :class:`MatchFirst`
        T)Ú	must_skipz4Cannot combine element of type %s with ParserElementr“)r0N)r1r2ršrr·rAr3r4rßr5r3)rÈrSrrrÚ__or__ôs



zParserElement.__or__cCsBt|tƒr| |¡}t|tƒs:tjdt|ƒtdddS||BS)z`
        Implementation of | operator when left operand is not a :class:`ParserElement`
        z4Cannot combine element of type %s with ParserElementr“)r0N)ršrr·rAr3r4rßr5)rÈrSrrrÚ__ror__	s



zParserElement.__ror__cCsFt|tƒr| |¡}t|tƒs:tjdt|ƒtdddSt||gƒS)zD
        Implementation of ^ operator - returns :class:`Or`
        z4Cannot combine element of type %s with ParserElementr“)r0N)	ršrr·rAr3r4rßr5r9)rÈrSrrrÚ__xor__	s



zParserElement.__xor__cCsBt|tƒr| |¡}t|tƒs:tjdt|ƒtdddS||AS)z`
        Implementation of ^ operator when left operand is not a :class:`ParserElement`
        z4Cannot combine element of type %s with ParserElementr“)r0N)ršrr·rAr3r4rßr5)rÈrSrrrÚ__rxor__	s



zParserElement.__rxor__cCsFt|tƒr| |¡}t|tƒs:tjdt|ƒtdddSt||gƒS)zF
        Implementation of & operator - returns :class:`Each`
        z4Cannot combine element of type %s with ParserElementr“)r0N)	ršrr·rAr3r4rßr5r()rÈrSrrrÚ__and__'	s



zParserElement.__and__cCsBt|tƒr| |¡}t|tƒs:tjdt|ƒtdddS||@S)z`
        Implementation of & operator when left operand is not a :class:`ParserElement`
        z4Cannot combine element of type %s with ParserElementr“)r0N)ršrr·rAr3r4rßr5)rÈrSrrrÚ__rand__3	s



zParserElement.__rand__cCst|ƒS)zH
        Implementation of ~ operator - returns :class:`NotAny`
        )r5)rÈrrrÚ
__invert__?	szParserElement.__invert__cCstd|jjƒ‚dS)Nz%r object is not iterable)r!r®r)rÈrrrr8E	szParserElement.__iter__c	Cs’yt|tƒr|f}t|ƒWntk
r8||f}YnXt|ƒdkrzt d |dd…t|ƒdkrrd t|ƒ¡nd¡¡|t|dd…ƒ}|S)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``.
       r“z.only 1 or 2 index arguments supported ({0}{1})Nrz	... [{0}]r·)	ršrœr7r!rÓr3r4rîr;)rÈrIr¤rrrr
J	s
"zParserElement.__getitem__cCs|dk	r| |¡S| ¡SdS)aý
        Shortcut for :class:`setResultsName`, with ``listAllMatches=False``.

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

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

        Example::

            # these are equivalent
            userdata = Word(alphas).setResultsName("name") + Word(nums + "-").setResultsName("socsecno")
            userdata = Word(alphas)("name") + Word(nums + "-")("socsecno")
        N)rÓrR)rÈrrrrÚ__call__n	s
zParserElement.__call__cCst|ƒS)zŽ
        Suppresses the output of this :class:`ParserElement`; useful to keep punctuation from
        cluttering up returned output.
        )rH)rÈrrrÚsuppress‚	szParserElement.suppresscCs
d|_|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.
        F)rÀ)rÈrrrÚleaveWhitespace‰	szParserElement.leaveWhitespacecCsd|_||_d|_|S)z8
        Overrides the default whitespace chars
        TF)rÀrÁrÂ)rÈrµrrrÚsetWhitespaceChars’	sz ParserElement.setWhitespaceCharscCs
d|_|S)zì
        Overrides default behavior to expand ``<TAB>``s to spaces before parsing the input string.
        Must be called before ``parseString`` when the input grammar contains elements that
        match ``<TAB>`` characters.
        T)rÄ)rÈrrrÚ
parseWithTabs›	szParserElement.parseWithTabscCsLt|tƒrt|ƒ}t|tƒr4||jkrH|j |¡n|j t| ¡ƒ¡|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 = OneOrMore(Word(alphas))
            patt.parseString('ablaj /* comment */ lskjd') # -> ['ablaj']

            patt.ignore(cStyleComment)
            patt.parseString('ablaj /* comment */ lskjd') # -> ['ablaj', 'lskjd']
        )ršrrHrÅrírR)rÈrSrrrÚignore¤	s


zParserElement.ignorecCs"|pt|pt|ptf|_d|_|S)zT
        Enable display of debugging messages while doing pattern matching.
        T)r–ršr›rËrÆ)rÈÚstartActionÚ
successActionÚexceptionActionrrrÚsetDebugActions¼	s
zParserElement.setDebugActionscCs|r| ttt¡nd|_|S)a•
        Enable display of debugging messages while doing pattern matching.
        Set ``flag`` to True to enable, False to disable.

        Example::

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

            # turn on debugging for wd
            wd.setDebug()

            OneOrMore(term).parseString("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:`setDebugActions`. Prior to attempting
        to match the ``wd`` expression, the debugging message ``"Match <exprname> at loc <n>(<line>,<col>)"``
        is shown. Then if the parse succeeds, a ``"Matched"`` message is shown, or an ``"Exception raised"``
        message is shown. Also note the use of :class:`setName` 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 ``setName`` is ``"W:(ABCD...)"``.
        F)rRr–ršr›rÆ)rÈÚflagrrrrÑÆ	s%zParserElement.setDebugcCs|jS)N)r)rÈrrrrÕñ	szParserElement.__str__cCst|ƒS)N)r¥)rÈrrrrÖô	szParserElement.__repr__cCsd|_d|_|S)NT)rÇr½)rÈrrrr÷	szParserElement.streamlinecCsdS)Nr)rÈrrrrÚcheckRecursionü	szParserElement.checkRecursioncCs| g¡dS)zj
        Check defined expressions for valid structure, check for infinite recursive definitions.
        N)rT)rÈÚ
validateTracerrrÚvalidateÿ	szParserElement.validatecCs y| ¡}Wn2tk
r>t|dƒ}| ¡}WdQRXYnXy| ||¡Stk
rš}z0tjrh‚n"t|ddƒdk	r†| |j	¡|_	|‚Wdd}~XYnXdS)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.
        ÚrNrð)
ÚreadrÏÚopenrr:rArr°rºrð)rÈÚfile_or_filenamerÚ
file_contentsÚfrørrrÚ	parseFile
szParserElement.parseFilecCs>||krdSt|tƒr | |¡St|tƒr:t|ƒt|ƒkSdS)NTF)ršrr$rAÚvars)rÈrSrrrÚ__eq__
s


zParserElement.__eq__cCs
||kS)Nr)rÈrSrrrÚ__ne__$
szParserElement.__ne__cCst|ƒS)N)Úid)rÈrrrÚ__hash__'
szParserElement.__hash__cCs||kS)Nr)rÈrSrrrÚ__req__*
szParserElement.__req__cCs
||kS)Nr)rÈrSrrrÚ__rne__-
szParserElement.__rne__cCs0y|jt|ƒ|ddStk
r*dSXdS)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:
         - testString - to test against this expression for a match
         - parseAll - (default= ``True``) - flag to pass to :class:`parseString` when running tests

        Example::

            expr = Word(nums)
            assert expr.matches("100")
        )rTFN)rr¥r:)rÈÚ
testStringrrrrr$0
s
zParserElement.matchesú#c	Csðt|tƒr"tttj| ¡ ¡ƒƒ}t|tƒr4t|ƒ}|dkrBt	j
}|j}	g}
g}d}tdƒ t
dƒ¡ t¡}
d}xt|D]j}|dk	r’| |d¡sš|r¦|s¦| |¡qx|s¬qx|r¾dd |¡nd|g}g}y"|
 | |¡¡}|j||d}Wnôtk
rž}zt|tƒrd	nd}d|krT| t|j|ƒ¡| d
t|j|ƒdd|¡n| d
|jd|¡| d
t|ƒ¡|o†|}|}Wdd}~XYntk
rà}z$| dt|ƒ¡|oÊ|}|}Wdd}~XYnÒX|oì|}|dk	r yR|||ƒ}|dk	r:t|tƒr*| | ¡¡n| t|ƒ¡n| | ¡¡WnRtk
rœ}z2| |j|d¡| d |jt |ƒj|¡¡Wdd}~XYnXn| |j|d¡|rÖ|rÈ| d¡|	d |¡ƒ|
 ||f¡qxW||
fS)as

        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
         - parseAll - (default= ``True``) - flag to pass to :class:`parseString` when running tests
         - comment - (default= ``'#'``) - expression for indicating embedded comments in the test
              string; pass None to disable comment filtering
         - fullDump - (default= ``True``) - dump results as list followed by results names in nested outline;
              if False, only dump nested list
         - printResults - (default= ``True``) prints test output to stdout
         - failureTests - (default= ``False``) indicates if these tests are expected to fail parsing
         - postParse - (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``

        Returns: a (success, results) tuple, where success indicates that all tests succeeded
        (or failed if ``failureTests`` 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.runTests('''
                # 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.runTests('''
                # stray character
                100Z
                # missing leading digit before '.'
                -.100
                # too many '.'
                3.14.159
                ''', failureTests=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.runTest(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'.)
        NTz\nrêuFr·)rz(FATAL)rär¨råzFAIL: zFAIL-EXCEPTION: )rzz{0} failed: {1}: {2})!ršrrrårœrÙÚrstripÚ
splitlinesr1rŸÚstdoutÚwriterçrzrNrwr$rírØr¢Úlstriprr:r>rerÄrWrˆr?rrîrrß)rÈÚtestsrÚcommentÚfullDumpÚprintResultsÚfailureTestsròÚfileÚprint_Ú
allResultsÚcommentsÚsuccessrÚBOMr—raÚresultrÌrÃrøÚpp_valuerërrrÚrunTestsD
sn`



$




0
zParserElement.runTests)F)F)F)T)T)TT)TT)r)F)N)T)N)F)T)TrfTTFNN)Srrrrár´rrr¶r¸rârºrÊrRrÒrÕrÓrâr¡rçrèrérírðrçròrèrþrÿr
rrr	rr	rrrràrrrrÚ_MAX_INTr'r¢r+r¬rTr\r7r8r?r@rBrCrDrErFrGrHr8r
rIrJrKrLrMrNrRrÑrÕrÖrrTrVr]r_r`rbrcrdr$ryrrrrrAGsž


	
1




W

"
:J0 &J$
			

+

	
cs6eZdZd
‡fdd„	Zdd„Zdd„Zdd	„Z‡ZS)r2Fcs>tt|ƒ ¡t|tƒƒ dd¡|_|j|_||_||_	dS)Nr)z...)
Úsuperr2rÊrœr)r®r½rÚanchorrA)rÈr•rA)r®rrrÊê
s
z_PendingSkip.__init__cs\t|ƒ d¡dƒ}ˆjrNdd„}‡fdd„}ˆj|ƒ |¡|ƒ |¡B|Sˆj||S)Nz...z	_skipped*cSs,|jr|j ¡dgkr(|d=| dd¡dS)Nr·rÚ_skipped)r}rrH)r—rrrrAô
sz'_PendingSkip.__add__.<locals>.must_skipcs<|j ¡dd…dgkr8| d¡}dtˆjƒd|d<dS)Nr”r·r}z	missing <ri)r}rrHrr|)r—Úskipped)rÈrrÚ	show_skipø
s
z'_PendingSkip.__add__.<locals>.show_skip)rErÒrAr|rç)rÈrSÚskipperrArr)rÈrrTñ
sz_PendingSkip.__add__cCs|jS)N)r½)rÈrrrrÖsz_PendingSkip.__repr__cGstdƒ‚dS)NzBuse of `...` expression without following SkipTo target expression)rˆ)rÈrÇrrrrçsz_PendingSkip.parseImpl)F)rrrrÊrTrÖrçÚ
__classcell__rr)r®rr2ç
sr2cs eZdZdZ‡fdd„Z‡ZS)rIzYAbstract :class:`ParserElement` subclass, for defining atomic
    matching patterns.
    cstt|ƒjdddS)NF)rÎ)r{rIrÊ)rÈ)r®rrrÊszToken.__init__)rrrrárÊrrr)r®rrIscs eZdZdZ‡fdd„Z‡ZS)r)z'An empty token, will always match.
    cs$tt|ƒ ¡d|_d|_d|_dS)Nr)TF)r{r)rÊrrÃrÈ)rÈ)r®rrrÊszEmpty.__init__)rrrrárÊrrr)r®rr)scs*eZdZdZ‡fdd„Zddd„Z‡ZS)r4z#A token that will never match.
    cs*tt|ƒ ¡d|_d|_d|_d|_dS)Nr4TFzUnmatchable token)r{r4rÊrrÃrÈrÉ)rÈ)r®rrrÊs
zNoMatch.__init__TcCst|||j|ƒ‚dS)N)r<rÉ)rÈr”rÄrÛrrrrç$szNoMatch.parseImpl)T)rrrrárÊrçrrr)r®rr4scs*eZdZdZ‡fdd„Zddd„Z‡ZS)r1aÒToken to exactly match a specified string.

    Example::

        Literal('blah').parseString('blah')  # -> ['blah']
        Literal('blah').parseString('blahfooblah')  # -> ['blah']
        Literal('blah').parseString('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`.
    cs tt|ƒ ¡||_t|ƒ|_y|d|_Wn*tk
rVtj	dt
ddt|_YnXdt
|jƒ|_d|j|_d|_d|_|jdkrœt|ƒtkrœt|_dS)	Nrz2null string passed to Literal; use Empty() insteadr“)r0z"%s"z	Expected Fr¨)r{r1rÊÚmatchrÓÚmatchLenÚfirstMatchCharr"r3r4r5r)r®r¥rrÉrÃrÈrßÚ_SingleCharLiteral)rÈÚmatchString)r®rrrÊ6s

zLiteral.__init__TcCs@|||jkr,| |j|¡r,||j|jfSt|||j|ƒ‚dS)N)r„rr‚rƒr<rÉ)rÈr”rÄrÛrrrrçJszLiteral.parseImpl)T)rrrrárÊrçrrr)r®rr1(s
c@seZdZddd„ZdS)r…TcCs0|||jkr|d|jfSt|||j|ƒ‚dS)Nr¨)r„r‚r<rÉ)rÈr”rÄrÛrrrrçPsz_SingleCharLiteral.parseImplN)T)rrrrçrrrrr…Osr…csLeZdZdZedZd‡fdd„	Zddd	„Z‡fd
d„Ze	dd
„ƒZ
‡ZS)r.aToken to exactly match a specified string as a keyword, that is,
    it must be immediately followed by a non-keyword character.  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:

     - ``identChars`` 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").parseString("start")  # -> ['start']
        Keyword("start").parseString("starting")  # -> Exception

    For case-insensitive matching, use :class:`CaselessKeyword`.
    z_$NFcs®tt|ƒ ¡|dkrtj}||_t|ƒ|_y|d|_Wn$tk
r^t	j
dtddYnXd|j|_d|j|_
d|_d|_||_|r | ¡|_| ¡}t|ƒ|_dS)Nrz2null string passed to Keyword; use Empty() insteadr“)r0z"%s"z	Expected F)r{r.rÊÚDEFAULT_KEYWORD_CHARSr‚rÓrƒr„r"r3r4r5rrÉrÃrÈÚcaselessÚupperÚ
caselessmatchrñÚ
identChars)rÈr†r‹rˆ)r®rrrÊss&

zKeyword.__init__TcCs|jr|||||j… ¡|jkrò|t|ƒ|jksL|||j ¡|jkrò|dksj||d ¡|jkrò||j|jfSnv|||jkrò|jdks¢| |j|¡rò|t|ƒ|jksÈ|||j|jkrò|dksâ||d|jkrò||j|jfSt	|||j
|ƒ‚dS)Nrr¨)rˆrƒr‰rŠrÓr‹r‚r„rr<rÉ)rÈr”rÄrÛrrrrçˆszKeyword.parseImplcstt|ƒ ¡}tj|_|S)N)r{r.rRr‡r‹)rÈrº)r®rrrR›szKeyword.copycCs
|t_dS)z,Overrides the default Keyword chars
        N)r.r‡)rµrrrÚsetDefaultKeywordChars szKeyword.setDefaultKeywordChars)NF)T)rrrrárQr‡rÊrçrRrrŒrrr)r®rr.Xs
cs*eZdZdZ‡fdd„Zddd„Z‡ZS)r$afToken to match a specified string, ignoring case of letters.
    Note: the matched results will always be in the case of the given
    match string, NOT the case of the input text.

    Example::

        OneOrMore(CaselessLiteral("CMD")).parseString("cmd CMD Cmd10") # -> ['CMD', 'CMD', 'CMD']

    (Contrast with example for :class:`CaselessKeyword`.)
    cs6tt|ƒ | ¡¡||_d|j|_d|j|_dS)Nz'%s'z	Expected )r{r$rÊr‰ÚreturnStringrrÉ)rÈr†)r®rrrʱszCaselessLiteral.__init__TcCs@||||j… ¡|jkr,||j|jfSt|||j|ƒ‚dS)N)rƒr‰r‚rr<rÉ)rÈr”rÄrÛrrrrç¸szCaselessLiteral.parseImpl)T)rrrrárÊrçrrr)r®rr$¦s
cs"eZdZdZd‡fdd„	Z‡ZS)r#zÕ
    Caseless version of :class:`Keyword`.

    Example::

        OneOrMore(CaselessKeyword("CMD")).parseString("cmd CMD Cmd10") # -> ['CMD', 'CMD']

    (Contrast with example for :class:`CaselessLiteral`.)
    Ncstt|ƒj||dddS)NT)rˆ)r{r#rÊ)rÈr†r‹)r®rrrÊÇszCaselessKeyword.__init__)N)rrrrárÊrrr)r®rr#½s	cs,eZdZdZd‡fdd„	Zd	dd„Z‡ZS)
rŠaœA variation on :class:`Literal` which matches "close" matches,
    that is, strings with at most 'n' mismatching characters.
    :class:`CloseMatch` takes parameters:

     - ``match_string`` - string to be matched
     - ``maxMismatches`` - (``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.parseString("ATCATCGAAXGGA") # -> (['ATCATCGAAXGGA'], {'mismatches': [[9]], 'original': ['ATCATCGAATGGA']})
        patt.parseString("ATCAXCGAAXGGA") # -> Exception: Expected 'ATCATCGAATGGA' (with up to 1 mismatches) (at char 0), (line:1, col:1)

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

        # close match allowing up to 2 mismatches
        patt = CloseMatch("ATCATCGAATGGA", maxMismatches=2)
        patt.parseString("ATCAXCGAAXGGA") # -> (['ATCAXCGAAXGGA'], {'mismatches': [[4, 9]], 'original': ['ATCATCGAATGGA']})
    r¨csBtt|ƒ ¡||_||_||_d|j|jf|_d|_d|_dS)Nz&Expected %r (with up to %d mismatches)F)	r{rŠrÊrÚmatch_stringÚ
maxMismatchesrÉrÈrÃ)rÈrŽr)r®rrrÊëszCloseMatch.__init__TcCsÈ|}t|ƒ}|t|jƒ}||kr´|j}d}g}	|j}
x|tt|||…|ƒƒD]0\}}|\}}
||
krN|	 |¡t|	ƒ|
krNPqNW|d}t|||…gƒ}||d<|	|d<||fSt|||j|ƒ‚dS)Nrr¨ÚoriginalÚ
mismatches)	rÓrŽrròr­rír?r<rÉ)rÈr”rÄrÛÚstartrïÚmaxlocrŽÚmatch_stringlocr‘rÚs_mÚsrcÚmatÚresultsrrrrçôs( 
zCloseMatch.parseImpl)r¨)T)rrrrárÊrçrrr)r®rrŠÊs 	cs8eZdZdZd
‡fdd„	Zdd	d
„Z‡fdd„Z‡ZS)rLaX	Token for matching words composed of allowed character sets.
    Defined with string containing all allowed initial characters, an
    optional string containing allowed body characters (if omitted,
    defaults to the initial character set), 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. An optional ``excludeChars`` parameter can
    list characters that might be found in the input ``bodyChars``
    string; useful to define a word of all printables except for one or
    two characters, for instance.

    :class:`srange` is useful for defining custom character set strings
    for defining ``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)

    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, excludeChars=",")
    Nr¨rFcsätt|ƒ ¡ˆrNtˆƒ‰d ‡fdd„|Dƒ¡}|rNd ‡fdd„|Dƒ¡}||_t|ƒ|_|rt||_t|ƒ|_n||_t|ƒ|_|dk|_	|dkržt
dƒ‚||_|dkr´||_nt
|_|dkrÎ||_||_t|ƒ|_d|j|_d	|_||_d
|j|jkrà|dkrà|dkrà|dkrà|j|jkr@dt|jƒ|_nHt|jƒdkrndt |j¡t|jƒf|_nd
t|jƒt|jƒf|_|jr d|jd|_yt |j¡|_Wntk
rÎd|_YnX|jj|_t|_dS)Nr·c3s|]}|ˆkr|VqdS)Nr)rrº)ÚexcludeCharsrrr§Hsz Word.__init__.<locals>.<genexpr>c3s|]}|ˆkr|VqdS)Nr)rrº)r™rrr§Jsrr¨zZcannot specify a minimum length < 1; use Optional(Word()) if zero-length word is permittedz	Expected Fräz[%s]+z%s[%s]*z	[%s][%s]*z\b)r{rLrÊrñrØÚ
initCharsOrigÚ	initCharsÚ
bodyCharsOrigÚ	bodyCharsÚmaxSpecifiedr<ÚminLenÚmaxLenrzr¥rrÉrÈÚ	asKeywordÚ_escapeRegexRangeCharsÚreStringrÓrÚescapeÚcompilerˆr‚Úre_matchÚ
_WordRegexr®)rÈr›rÚminÚmaxÚexactr¡r™)r®)r™rrÊDsV



0

z
Word.__init__Tc	Cs|||jkrt|||j|ƒ‚|}|d7}t|ƒ}|j}||j}t||ƒ}x ||krl|||krl|d7}qNWd}|||jkr†d}nV|jr¦||kr¦|||kr¦d}n6|j	rÜ|dkrÄ||d|ksØ||krÜ|||krÜd}|rðt|||j|ƒ‚||||…fS)Nr¨FTr)
r›r<rÉrÓrr r¨rŸržr¡)	rÈr”rÄrÛr’rïÚ	bodycharsr“ÚthrowExceptionrrrrç}s,

zWord.parseImplcstytt|ƒ ¡Stk
r"YnX|jdkrndd„}|j|jkr^d||jƒ||jƒf|_nd||jƒ|_|jS)NcSs$t|ƒdkr|dd…dS|SdS)Néz...)rÓ)r«rrrÚ
charsAsStr¡sz Word.__str__.<locals>.charsAsStrz
W:(%s, %s)zW:(%s))r{rLrÕrˆr½ršrœ)rÈr®)r®rrrՙs
zWord.__str__)Nr¨rrFN)T)rrrrárÊrçrÕrrr)r®rrLs49
c@seZdZddd„ZdS)r§TcCs4| ||¡}|s t|||j|ƒ‚| ¡}|| ¡fS)N)r¦r<rÉÚendÚgroup)rÈr”rÄrÛrwrrrrç¯s
z_WordRegex.parseImplN)T)rrrrçrrrrr§®sr§cs"eZdZdZd‡fdd„	Z‡ZS)rPz“A short-cut class for defining ``Word(characters, exact=1)``,
    when defining a match of any single character in a string of
    characters.
    FNcsZtt|ƒj|d||ddtd |j¡ƒ|_|r>d|j|_t |j¡|_|jj	|_
dS)Nr¨)rªr¡r™z[%s]r·z\b%s\b)r{rPrÊr¢rØr›r£rr¥r‚r¦)rÈÚcharsetr¡r™)r®rrrʽsz
Char.__init__)FN)rrrrárÊrrr)r®rrP¸scsTeZdZdZd‡fdd„	Zddd„Zdd	d
„Zddd„Z‡fd
d„Zdd„Z	‡Z
S)rDahToken for matching strings that match a given regular
    expression. Defined with string specifying the regular expression in
    a form recognized by the stdlib Python  `re module <https://docs.python.org/3/library/re.html>`_.
    If the given regex contains named groups (defined using ``(?P<name>...)``),
    these will be preserved as named parse results.

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

    Example::

        realnum = Regex(r"[+-]?\d+\.\d*")
        date = Regex(r'(?P<year>\d{4})-(?P<month>\d\d?)-(?P<day>\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})")

        # use regex module instead of stdlib re module to construct a Regex using
        # a compiled regular expression
        import regex
        parser = pp.Regex(regex.compile(r'[0-9]'))

    rFcs$tt|ƒ ¡t|tƒr†|s,tjdtdd||_||_	yt
 |j|j	¡|_
|j|_Wq¾t
jk
r‚tjd|tdd‚Yq¾Xn8t|dƒr¶t|dƒr¶||_
|j|_|_||_	ntdƒ‚|j
j|_t|ƒ|_d|j|_d	|_| d
¡dk	|_||_||_|jr|j|_|jr |j|_dS)aThe parameters ``pattern`` and ``flags`` are passed
        to the ``re.compile()`` function as-is. See the Python
        `re module <https://docs.python.org/3/library/re.html>`_ module for an
        explanation of the acceptable patterns and flags.
        z0null string passed to Regex; use Empty() insteadr“)r0z$invalid pattern (%s) passed to RegexÚpatternr‚zCRegex may only be constructed with a string or a compiled RE objectz	Expected Fr·N)r{rDrÊršrr3r4r5r²Úflagsrr¥r£Ú
sre_constantsÚerrorr;r!r‚r¦r¥rrÉrÈrÃÚasGroupListÚasMatchÚparseImplAsGroupListrçÚparseImplAsMatch)rÈr²r³r¶r·)r®rrrÊÞs<






zRegex.__init__Tc	Csf| ||¡}|s t|||j|ƒ‚| ¡}t| ¡ƒ}| ¡}|r^x| ¡D]\}}|||<qJW||fS)N)r¦r<rÉr¯r?r°Ú	groupdictr,)	rÈr”rÄrÛrwr¤Údr&r#rrrrç
szRegex.parseImplcCs8| ||¡}|s t|||j|ƒ‚| ¡}| ¡}||fS)N)r¦r<rÉr¯Úgroups)rÈr”rÄrÛrwr¤rrrr¸
szRegex.parseImplAsGroupListcCs4| ||¡}|s t|||j|ƒ‚| ¡}|}||fS)N)r¦r<rÉr¯)rÈr”rÄrÛrwr¤rrrr¹!
szRegex.parseImplAsMatchcsDytt|ƒ ¡Stk
r"YnX|jdkr>dt|jƒ|_|jS)NzRe:(%s))r{rDrÕrˆr½rr²)rÈ)r®rrrÕ*
s
z
Regex.__str__cslˆjrtjdtddtƒ‚ˆjr@tˆƒr@tjdtddtƒ‚ˆjrT‡fdd„}n‡‡fdd„}ˆ |¡S)a‰
        Return Regex with an attached parse action to transform the parsed
        result as if called using `re.sub(expr, repl, string) <https://docs.python.org/3/library/re.html#re.sub>`_.

        Example::

            make_html = Regex(r"(\w+):(.*?):").sub(r"<\1>\2</\1>")
            print(make_html.transformString("h1:main title:"))
            # prints "<h1>main title</h1>"
        z-cannot use sub() with Regex(asGroupList=True)r“)r0z9cannot use sub() with a callable with Regex(asMatch=True)cs|d ˆ¡S)Nr)Úexpand)rú)ÚreplrrrÀK
szRegex.sub.<locals>.pacsˆj ˆ|d¡S)Nr)rr')rú)r¾rÈrrrÀN
s)r¶r3r4r5ÚSyntaxErrorr·rãrç)rÈr¾rÀr)r¾rÈrr'5
s

z	Regex.sub)rFF)T)T)T)rrrrárÊrçr¸r¹rÕr'rrr)r®rrDÆs-

	
	cs8eZdZdZd‡fdd„	Zddd„Z‡fd	d
„Z‡ZS)
rBa&
    Token for matching strings that are delimited by quoting characters.

    Defined with the following parameters:

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

    Example::

        qs = QuotedString('"')
        print(qs.searchString('lsjdf "This is the quote" sldjf'))
        complex_qs = QuotedString('{{', endQuoteChar='}}')
        print(complex_qs.searchString('lsjdf {{This is the "quote"}} sldjf'))
        sql_qs = QuotedString('"', escQuote='""')
        print(sql_qs.searchString('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']]
    NFTc
sXttˆƒ ¡| ¡}|s0tjdtddtƒ‚|dkr>|}n"| ¡}|s`tjdtddtƒ‚|ˆ_t	|ƒˆ_
|dˆ_|ˆ_t	|ƒˆ_
|ˆ_|ˆ_|ˆ_|ˆ_|rètjtjBˆ_dt ˆj¡tˆjdƒ|dk	rÜt|ƒpÞdfˆ_n<dˆ_dt ˆj¡tˆjdƒ|dk	rt|ƒpdfˆ_t	ˆjƒd	krpˆjd
d ‡fdd
„tt	ˆjƒd	ddƒDƒ¡d7_|rŽˆjdt |¡7_|r¾ˆjdt |¡7_t ˆj¡dˆ_ˆjdt ˆj¡7_y(t ˆjˆj¡ˆ_ˆjˆ_ˆjjˆ_Wn0t j!k
r0tjdˆjtdd‚YnXt"ˆƒˆ_#dˆj#ˆ_$dˆ_%dˆ_&dS)Nz$quoteChar cannot be the empty stringr“)r0z'endQuoteChar cannot be the empty stringrz%s(?:[^%s%s]r·z%s(?:[^%s\n\r%s]r¨z|(?:z)|(?:c3s4|],}dt ˆjd|…¡tˆj|ƒfVqdS)z%s[^%s]N)rr¤ÚendQuoteCharr¢)rrü)rÈrrr§¡
sz(QuotedString.__init__.<locals>.<genexpr>r”ú)z|(?:%s)z|(?:%s.)z(.)z)*%sz$invalid pattern (%s) passed to Regexz	Expected FT)'r{rBrÊrÙr3r4r5r¿Ú	quoteCharrÓÚquoteCharLenÚfirstQuoteCharrÀÚendQuoteCharLenÚescCharÚescQuoteÚunquoteResultsÚconvertWhitespaceEscapesrÚ	MULTILINEÚDOTALLr³r¤r¢r²rØr)ÚescCharReplacePatternr¥r£r‚r¦r´rµr¥rrÉrÈrÃ)rÈrÂrÆrÇÚ	multilinerÈrÀrÉ)r®)rÈrrÊy
sd


6

zQuotedString.__init__c	CsÖ|||jkr| ||¡pd}|s2t|||j|ƒ‚| ¡}| ¡}|jrÎ||j|j…}t	|t
ƒrÎd|kr¢|jr¢dddddœ}x | ¡D]\}}| 
||¡}qŠW|jr¸t |jd|¡}|jrÎ| 
|j|j¡}||fS)NrÒú	rêúú
)z\tz\nz\fz\rz\g<1>)rÄr¦r<rÉr¯r°rÈrÃrÅršrrÉr,r®rÆrr'rÌrÇrÀ)	rÈr”rÄrÛrwr¤Úws_mapÚwslitÚwscharrrrrçº
s(
zQuotedString.parseImplcsFytt|ƒ ¡Stk
r"YnX|jdkr@d|j|jf|_|jS)Nz.quoted string, starting with %s ending with %s)r{rBrÕrˆr½rÂrÀ)rÈ)r®rrrÕÝ
s
zQuotedString.__str__)NNFTNT)T)rrrrárÊrçrÕrrr)r®rrBR
s
&@
#cs8eZdZdZd‡fdd„	Zddd„Z‡fd	d
„Z‡ZS)
r%aüToken for matching words composed of characters *not* in a given
    set (will include whitespace in matched characters if not listed in
    the provided exclusion set - see example). Defined with string
    containing all disallowed characters, and an optional minimum,
    maximum, and/or exact length.  The default value for ``min`` is
    1 (a minimum value < 1 is not valid); the default values for
    ``max`` and ``exact`` are 0, meaning no maximum or exact
    length restriction.

    Example::

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

    prints::

        ['dkls', 'lsdkjf', 's12 34', '@!#', '213']
    r¨rcs†tt|ƒ ¡d|_||_|dkr*tdƒ‚||_|dkr@||_nt|_|dkrZ||_||_t	|ƒ|_
d|j
|_|jdk|_d|_
dS)NFr¨zfcannot specify a minimum length < 1; use Optional(CharsNotIn()) if zero-length char group is permittedrz	Expected )r{r%rÊrÀÚnotCharsr<rŸr rzr¥rrÉrÃrÈ)rÈrÔr¨r©rª)r®rrrÊý
s 
zCharsNotIn.__init__TcCs”|||jkrt|||j|ƒ‚|}|d7}|j}t||jt|ƒƒ}x ||krd|||krd|d7}qFW|||jkr„t|||j|ƒ‚||||…fS)Nr¨)rÔr<rÉr¨r rÓrŸ)rÈr”rÄrÛr’ÚnotcharsÚmaxlenrrrrçszCharsNotIn.parseImplcsdytt|ƒ ¡Stk
r"YnX|jdkr^t|jƒdkrRd|jdd…|_nd|j|_|jS)Nr­z
!W:(%s...)z!W:(%s))r{r%rÕrˆr½rÓrÔ)rÈ)r®rrrÕ&s
zCharsNotIn.__str__)r¨rr)T)rrrrárÊrçrÕrrr)r®rr%é
s
cs`eZdZdZdddddddd	d
ddd
ddddddddddddœZd"‡fdd„	Zd#d d!„Z‡ZS)$rKa™Special matching class for matching whitespace.  Normally,
    whitespace is ignored by pyparsing grammars.  This class is included
    when some whitespace structures are significant.  Define with
    a string containing the whitespace characters to be matched; default
    is ``" \t\r\n"``.  Also takes optional ``min``,
    ``max``, and ``exact`` arguments, as defined for the
    :class:`Word` class.
    z<SP>z<TAB>z<LF>z<CR>z<FF>z<NBSP>z<OGHAM_SPACE_MARK>z<MONGOLIAN_VOWEL_SEPARATOR>z	<EN_QUAD>z	<EM_QUAD>z
<EN_SPACE>z
<EM_SPACE>z<THREE-PER-EM_SPACE>z<FOUR-PER-EM_SPACE>z<SIX-PER-EM_SPACE>z<FIGURE_SPACE>z<PUNCTUATION_SPACE>z<THIN_SPACE>z<HAIR_SPACE>z<ZERO_WIDTH_SPACE>z<NNBSP>z<MMSP>z<IDEOGRAPHIC_SPACE>)rärÎrêrÐrÏõ u u᠎u u u u u u u u u u u u​u u u ú 	
r¨rcs’ttˆƒ ¡|ˆ_ˆ d ‡fdd„ˆjDƒ¡¡d dd„ˆjDƒ¡ˆ_dˆ_dˆjˆ_	|ˆ_
|dkrt|ˆ_ntˆ_|dkrŽ|ˆ_|ˆ_
dS)Nr·c3s|]}|ˆjkr|VqdS)N)Ú
matchWhite)rrº)rÈrrr§Ysz!White.__init__.<locals>.<genexpr>css|]}tj|VqdS)N)rKÚ	whiteStrs)rrºrrrr§[sTz	Expected r)
r{rKrÊrÙrLrØrÁrrÃrÉrŸr rz)rÈÚwsr¨r©rª)r®)rÈrrÊVs zWhite.__init__TcCs”|||jkrt|||j|ƒ‚|}|d7}||j}t|t|ƒƒ}x"||krd|||jkrd|d7}qDW|||jkr„t|||j|ƒ‚||||…fS)Nr¨)rÙr<rÉr r¨rÓrŸ)rÈr”rÄrÛr’r“rrrrçjs
zWhite.parseImpl)rØr¨rr)T)rrrrárÚrÊrçrrr)r®rrK4s4cseZdZ‡fdd„Z‡ZS)Ú_PositionTokencs(tt|ƒ ¡|jj|_d|_d|_dS)NTF)r{rÜrÊr®rrrÃrÈ)rÈ)r®rrrÊ{s
z_PositionToken.__init__)rrrrÊrrr)r®rrÜzsrÜcs2eZdZdZ‡fdd„Zdd„Zd	dd„Z‡ZS)
r,zaToken to advance to a specific column of input text; useful for
    tabular report scraping.
    cstt|ƒ ¡||_dS)N)r{r,rÊrW)rÈÚcolno)r®rrrʅszGoToColumn.__init__cCs`t||ƒ|jkr\t|ƒ}|jr*| ||¡}x0||krZ|| ¡rZt||ƒ|jkrZ|d7}q,W|S)Nr¨)rWrÓrÅríÚisspace)rÈr”rÄrïrrrrð‰s&zGoToColumn.preParseTcCsDt||ƒ}||jkr"t||d|ƒ‚||j|}|||…}||fS)NzText not in expected column)rWr<)rÈr”rÄrÛÚthiscolÚnewlocr¤rrrrç’s

zGoToColumn.parseImpl)T)rrrrárÊrðrçrrr)r®rr,s	cs*eZdZdZ‡fdd„Zddd„Z‡ZS)r0a±Matches if current position is at the beginning of a line within
    the parse string

    Example::

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

        for t in (LineStart() + 'AAA' + restOfLine).searchString(test):
            print(t)

    prints::

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

    cstt|ƒ ¡d|_dS)NzExpected start of line)r{r0rÊrÉ)rÈ)r®rrrʱszLineStart.__init__TcCs*t||ƒdkr|gfSt|||j|ƒ‚dS)Nr¨)rWr<rÉ)rÈr”rÄrÛrrrrçµszLineStart.parseImpl)T)rrrrárÊrçrrr)r®rr0›scs*eZdZdZ‡fdd„Zddd„Z‡ZS)r/zTMatches if current position is at the end of a line within the
    parse string
    cs,tt|ƒ ¡| tj dd¡¡d|_dS)Nrêr·zExpected end of line)r{r/rÊrLrAr´r®rÉ)rÈ)r®rrrʾszLineEnd.__init__TcCsb|t|ƒkr6||dkr$|ddfSt|||j|ƒ‚n(|t|ƒkrN|dgfSt|||j|ƒ‚dS)Nrêr¨)rÓr<rÉ)rÈr”rÄrÛrrrrçÃszLineEnd.parseImpl)T)rrrrárÊrçrrr)r®rr/ºscs*eZdZdZ‡fdd„Zddd„Z‡ZS)rGzLMatches if current position is at the beginning of the parse
    string
    cstt|ƒ ¡d|_dS)NzExpected start of text)r{rGrÊrÉ)rÈ)r®rrrÊÒszStringStart.__init__TcCs0|dkr(|| |d¡kr(t|||j|ƒ‚|gfS)Nr)rðr<rÉ)rÈr”rÄrÛrrrrçÖszStringStart.parseImpl)T)rrrrárÊrçrrr)r®rrGÎscs*eZdZdZ‡fdd„Zddd„Z‡ZS)rFzBMatches if current position is at the end of the parse string
    cstt|ƒ ¡d|_dS)NzExpected end of text)r{rFrÊrÉ)rÈ)r®rrrÊàszStringEnd.__init__TcCs^|t|ƒkrt|||j|ƒ‚n<|t|ƒkr6|dgfS|t|ƒkrJ|gfSt|||j|ƒ‚dS)Nr¨)rÓr<rÉ)rÈr”rÄrÛrrrrçäszStringEnd.parseImpl)T)rrrrárÊrçrrr)r®rrFÝscs.eZdZdZef‡fdd„	Zddd„Z‡ZS)rNayMatches if the current position is at the beginning of a Word,
    and is not preceded by any character in a given set of
    ``wordChars`` (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.
    cs"tt|ƒ ¡t|ƒ|_d|_dS)NzNot at the start of a word)r{rNrÊrñÚ	wordCharsrÉ)rÈrá)r®rrrÊ÷s
zWordStart.__init__TcCs@|dkr8||d|jks(|||jkr8t|||j|ƒ‚|gfS)Nrr¨)rár<rÉ)rÈr”rÄrÛrrrrçüs
zWordStart.parseImpl)T)rrrrártrÊrçrrr)r®rrNîscs.eZdZdZef‡fdd„	Zddd„Z‡ZS)rMa_Matches if the current position is at the end of a Word, and is
    not followed by any character in a given set of ``wordChars``
    (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.
    cs(tt|ƒ ¡t|ƒ|_d|_d|_dS)NFzNot at the end of a word)r{rMrÊrñrárÀrÉ)rÈrá)r®rrrÊs
zWordEnd.__init__TcCsPt|ƒ}|dkrH||krH|||jks8||d|jkrHt|||j|ƒ‚|gfS)Nrr¨)rÓrár<rÉ)rÈr”rÄrÛrïrrrrçszWordEnd.parseImpl)T)rrrrártrÊrçrrr)r®rrMscszeZdZdZd‡fdd„	Zdd„Zdd„Z‡fd	d
„Z‡fdd„Z‡fd
d„Z	ddd„Z
‡fdd„Zd‡fdd„	Z‡Z
S)r=z]Abstract subclass of ParserElement, for combining and
    post-processing parsed tokens.
    FcsÈttˆƒ |¡t|tƒr"t|ƒ}t|tƒr<ˆ |¡gˆ_n‚t|t	ƒrP|gˆ_nnt|t
ƒr’t|ƒ}tdd„|Dƒƒr†‡fdd„|Dƒ}t|ƒˆ_n,yt|ƒˆ_Wntk
r¼|gˆ_YnXdˆ_
dS)Ncss|]}t|tƒVqdS)N)ršr)rr•rrrr§*sz+ParseExpression.__init__.<locals>.<genexpr>c3s&|]}t|tƒrˆ |¡n|VqdS)N)ršrr·)rrë)rÈrrr§+sF)r{r=rÊršrrrr·ÚexprsrAr
r€r!rÌ)rÈrârÎ)r®)rÈrrÊs"




zParseExpression.__init__cCs|j |¡d|_|S)N)rârír½)rÈrSrrrrí4szParseExpression.appendcCs4d|_dd„|jDƒ|_x|jD]}| ¡q W|S)z€Extends ``leaveWhitespace`` defined in base class, and also invokes ``leaveWhitespace`` on
           all contained expressions.FcSsg|]}| ¡‘qSr)rR)rrërrrr=sz3ParseExpression.leaveWhitespace.<locals>.<listcomp>)rÀrârK)rÈrërrrrK9s
zParseExpression.leaveWhitespacecszt|tƒrF||jkrvtt|ƒ |¡xP|jD]}| |jd¡q,Wn0tt|ƒ |¡x|jD]}| |jd¡q^W|S)Nr”)ršrHrÅr{r=rNrâ)rÈrSrë)r®rrrNBs

zParseExpression.ignorecsLytt|ƒ ¡Stk
r"YnX|jdkrFd|jjt|jƒf|_|jS)Nz%s:(%s))	r{r=rÕrˆr½r®rr¥râ)rÈ)r®rrrÕNs
zParseExpression.__str__cs.tt|ƒ ¡x|jD]}| ¡qWt|jƒdkr|jd}t||jƒr¤|js¤|jdkr¤|j	s¤|jdd…|jdg|_d|_
|j|jO_|j|jO_|jd}t||jƒr|js|jdkr|j	s|jdd…|jdd…|_d|_
|j|jO_|j|jO_dt
|ƒ|_|S)Nr“rr¨r”z	Expected )r{r=rrârÓršr®r»r¾rÆr½rÃrÈr¥rÉ)rÈrërS)r®rrrXs0


zParseExpression.streamlineNcCsF|dk	r|ngdd…|g}x|jD]}| |¡q&W| g¡dS)N)rârVrT)rÈrUÚtmprërrrrVzszParseExpression.validatecs$tt|ƒ ¡}dd„|jDƒ|_|S)NcSsg|]}| ¡‘qSr)rR)rrërrrr‚sz(ParseExpression.copy.<locals>.<listcomp>)r{r=rRrâ)rÈr¤)r®rrrR€szParseExpression.copycsZtjrHx@|jD]6}t|tƒr|jrtjd d|t	|ƒj
|j¡ddqWtt|ƒ 
||¡S)Nz]{0}: setting results name {1!r} on {2} expression collides with {3!r} on contained expressionrr‘)r0)rrrâršrAr¾r3r4rîrßrr{r=rÓ)rÈrrÔrë)r®rrrÓ…szParseExpression._setResultsName)F)N)F)rrrrárÊrírKrNrÕrrVrRrÓrrr)r®rr=s	
"
cs`eZdZdZGdd„deƒZd‡fdd„	Z‡fdd„Zdd	d
„Zdd„Z	d
d„Z
dd„Z‡ZS)r"a
    Requires all given :class:`ParseExpression` s to be found in the given order.
    Expressions may be separated by whitespace.
    May be constructed using the ``'+'`` operator.
    May also be constructed using the ``'-'`` operator, which will
    suppress backtracking.

    Example::

        integer = Word(nums)
        name_expr = OneOrMore(Word(alphas))

        expr = And([integer("id"), name_expr("name"), integer("age")])
        # more easily written as:
        expr = integer("id") + name_expr("name") + integer("age")
    cseZdZ‡fdd„Z‡ZS)zAnd._ErrorStopcs&ttj|ƒj||Žd|_| ¡dS)Nú-)r{r"r6rÊrrK)rÈrÇrE)r®rrrʦszAnd._ErrorStop.__init__)rrrrÊrrr)r®rr6¥sr6Tcsät|ƒ}|r’t|kr’g}xlt|ƒD]`\}}|tkrx|t|ƒdkrntƒ||djd}| t|ƒdƒ¡q‚tdƒ‚q"| |¡q"W||dd…<t	t
|ƒ ||¡tdd„|jDƒƒ|_
| |jdj¡|jdj|_d|_dS)	Nr¨r”z	_skipped*z0cannot construct And with sequence ending in ...css|]}|jVqdS)N)rÃ)rrërrrr§ºszAnd.__init__.<locals>.<genexpr>rT)rr1ròrÓr)rârírErˆr{r"rÊrärÃrLrÁrÀrÌ)rÈrârÎrãrür•Ú
skipto_arg)r®rrrÊ«s 
zAnd.__init__csÒ|jrªtdd„|jdd…Dƒƒrªxtt|jdd…ƒD]^\}}|dkrHq6t|tƒr6|jr6t|jdtƒr6|jd|j|d|jd<d|j|d<q6Wdd„|jDƒ|_tt|ƒ ¡t	dd„|jDƒƒ|_
|S)Ncss.|]&}t|tƒo$|jo$t|jdtƒVqdS)r”N)ršr=râr2)rrërrrr§Âsz!And.streamline.<locals>.<genexpr>r”r¨cSsg|]}|dk	r|‘qS)Nr)rrërrrrËsz"And.streamline.<locals>.<listcomp>css|]}|jVqdS)N)rÃ)rrërrrr§Îs)râr€ròršr=r2r{r"rrärÃ)rÈrürë)r®rrr¿s
zAnd.streamlinec	Cs|jdj|||dd\}}d}xØ|jdd…D]Æ}t|tjƒrFd}q0|rÐy| |||¡\}}Wqâtk
rv‚Yqâtk
r¦}zd|_t |¡‚Wdd}~XYqât	k
rÌt|t
|ƒ|j|ƒ‚YqâXn| |||¡\}}|sî| ¡r0||7}q0W||fS)NrF)rÜr¨T)
râràršr"r6r@r:rðrÍr"rÓrÉrC)	rÈr”rÄrÛÚ
resultlistÚ	errorStoprëÚ
exprtokensrÌrrrrçÑs(z
And.parseImplcCst|tƒr| |¡}| |¡S)N)ršrr·rí)rÈrSrrrrNês

zAnd.__iadd__cCs8|dd…|g}x |jD]}| |¡|jsPqWdS)N)rârTrÃ)rÈrÚsubRecCheckListrërrrrTïs

zAnd.checkRecursioncCs@t|dƒr|jS|jdkr:dd dd„|jDƒ¡d|_|jS)NrÚ{räcss|]}t|ƒVqdS)N)r¥)rrërrrr§ûszAnd.__str__.<locals>.<genexpr>Ú})r;rr½rØrâ)rÈrrrrÕös


 zAnd.__str__)T)T)
rrrrár)r6rÊrrçrNrTrÕrrr)r®rr"“s
cs^eZdZdZd‡fdd„	Z‡fdd„Zddd	„Zd
d„Zdd
„Zdd„Z	d‡fdd„	Z
‡ZS)r9a¿Requires 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.searchString("123 3.1416 789"))

    prints::

        [['123'], ['3.1416'], ['789']]
    Fcs:tt|ƒ ||¡|jr0tdd„|jDƒƒ|_nd|_dS)Ncss|]}|jVqdS)N)rÃ)rrërrrr§szOr.__init__.<locals>.<genexpr>T)r{r9rÊrâr€rÃ)rÈrârÎ)r®rrrÊszOr.__init__cs.tt|ƒ ¡tjr*tdd„|jDƒƒ|_|S)Ncss|]}|jVqdS)N)r¿)rrërrrr§sz Or.streamline.<locals>.<genexpr>)r{r9rr!Úcollect_all_And_tokensr€râr¿)rÈ)r®rrrsz
Or.streamlineTcCsÆd}d}g}x¤|jD]š}y| ||¡}Wnvtk
rd}	zd|	_|	j|krT|	}|	j}Wdd}	~	XYqtk
ržt|ƒ|kršt|t|ƒ|j|ƒ}t|ƒ}YqX| ||f¡qW|rœ|j	t
dƒdd|sè|dd}
|
 |||¡Sd}x |D]˜\}}
||dkr|Sy|
 |||¡\}}Wn@tk
rb}	z d|	_|	j|krR|	}|	j}Wdd}	~	XYqòX||krv||fS||dkrò||f}qòW|dkrœ|S|dk	r´|j|_|‚nt||d|ƒ‚dS)Nr”rT)rIr+r¨)r”Nz no defined alternatives to match)
rârþr<rðrÄr"rÓrÉríÚsortrràr¿)rÈr”rÄrÛÚ	maxExcLocÚmaxExceptionr$rëÚloc2rûÚ	best_exprÚlongestÚloc1Úexpr1r™rrrrçsT



zOr.parseImplcCst|tƒr| |¡}| |¡S)N)ršrr·rí)rÈrSrrrÚ__ixor__[s

zOr.__ixor__cCs@t|dƒr|jS|jdkr:dd dd„|jDƒ¡d|_|jS)Nrrêz ^ css|]}t|ƒVqdS)N)r¥)rrërrrr§eszOr.__str__.<locals>.<genexpr>rë)r;rr½rØrâ)rÈrrrrÕ`s


 z
Or.__str__cCs0|dd…|g}x|jD]}| |¡qWdS)N)rârT)rÈrrérërrrrTiszOr.checkRecursioncsPtjs>tjr>tdd„|jDƒƒr>tjd d|t	|ƒj
¡ddtt|ƒ 
||¡S)Ncss|]}t|tƒVqdS)N)ršr")rrërrrr§qsz%Or._setResultsName.<locals>.<genexpr>z–{0}: setting results name {1!r} on {2} expression may only return a single token for an And alternative, in future will return the full list of tokensrr‘)r0)r!rìrrr€râr3r4rîrßrr{r9rÓ)rÈrrÔ)r®rrrÓnszOr._setResultsName)F)T)F)rrrrárÊrrçrõrÕrTrÓrrr)r®rr9s
=	cs^eZdZdZd‡fdd„	Z‡fdd„Zddd	„Zd
d„Zdd
„Zdd„Z	d‡fdd„	Z
‡ZS)r3a¸Requires that at least one :class:`ParseExpression` is found. If
    two expressions match, the first one listed is the one that will
    match. May be constructed using the ``'|'`` operator.

    Example::

        # construct MatchFirst using '|' operator

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

        # put more selective expression first
        number = Combine(Word(nums) + '.' + Word(nums)) | Word(nums)
        print(number.searchString("123 3.1416 789")) #  Better -> [['123'], ['3.1416'], ['789']]
    Fcs:tt|ƒ ||¡|jr0tdd„|jDƒƒ|_nd|_dS)Ncss|]}|jVqdS)N)rÃ)rrërrrr§sz&MatchFirst.__init__.<locals>.<genexpr>T)r{r3rÊrâr€rÃ)rÈrârÎ)r®rrrʌszMatchFirst.__init__cs.tt|ƒ ¡tjr*tdd„|jDƒƒ|_|S)Ncss|]}|jVqdS)N)r¿)rrërrrr§–sz(MatchFirst.streamline.<locals>.<genexpr>)r{r3rr!rìr€râr¿)rÈ)r®rrr“szMatchFirst.streamlineTc	CsÄd}d}x¶|jD]ˆ}y| |||¡}|Stk
r\}z|j|krL|}|j}Wdd}~XYqtk
r–t|ƒ|kr’t|t|ƒ|j|ƒ}t|ƒ}YqXqW|dk	r²|j|_|‚nt||d|ƒ‚dS)Nr”z no defined alternatives to match)râràr<rÄr"rÓrÉr¿)	rÈr”rÄrÛrîrïrër¤rûrrrrç™s$
zMatchFirst.parseImplcCst|tƒr| |¡}| |¡S)N)ršrr·rí)rÈrSrrrÚ__ior__±s

zMatchFirst.__ior__cCs@t|dƒr|jS|jdkr:dd dd„|jDƒ¡d|_|jS)Nrrêz | css|]}t|ƒVqdS)N)r¥)rrërrrr§»sz%MatchFirst.__str__.<locals>.<genexpr>rë)r;rr½rØrâ)rÈrrrrÕ¶s


 zMatchFirst.__str__cCs0|dd…|g}x|jD]}| |¡qWdS)N)rârT)rÈrrérërrrrT¿szMatchFirst.checkRecursioncsPtjs>tjr>tdd„|jDƒƒr>tjd d|t	|ƒj
¡ddtt|ƒ 
||¡S)Ncss|]}t|tƒVqdS)N)ršr")rrërrrr§Çsz-MatchFirst._setResultsName.<locals>.<genexpr>z–{0}: setting results name {1!r} on {2} expression may only return a single token for an And alternative, in future will return the full list of tokensrr‘)r0)r!rìrrr€râr3r4rîrßrr{r3rÓ)rÈrrÔ)r®rrrÓÄszMatchFirst._setResultsName)F)T)F)rrrrárÊrrçrörÕrTrÓrrr)r®rr3{s
	csHeZdZdZd
‡fdd„	Z‡fdd„Zddd„Zd	d
„Zdd„Z‡Z	S)r(asRequires 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 = oneOf("RED ORANGE YELLOW GREEN BLUE PURPLE BLACK WHITE BROWN")
        shape_type = oneOf("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 & Optional(color_attr) & Optional(size_attr)

        shape_spec.runTests('''
            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
    Tcs>tt|ƒ ||¡tdd„|jDƒƒ|_d|_d|_d|_dS)Ncss|]}|jVqdS)N)rÃ)rrërrrr§sz Each.__init__.<locals>.<genexpr>T)	r{r(rÊrärârÃrÀÚinitExprGroupsr¿)rÈrârÎ)r®rrrÊ
s
z
Each.__init__cs(tt|ƒ ¡tdd„|jDƒƒ|_|S)Ncss|]}|jVqdS)N)rÃ)rrërrrr§sz"Each.streamline.<locals>.<genexpr>)r{r(rrärârÃ)rÈ)r®rrrszEach.streamlinec	sú|jr’tdd„|jDƒƒ|_dd„|jDƒ}dd„|jDƒ}|||_dd„|jDƒ|_dd„|jDƒ|_dd„|jDƒ|_|j|j7_d	|_|}|jdd…}|jdd…‰g}d
}	x¶|	rp|ˆ|j|j}
g}x~|
D]v}y| ||¡}Wn t	k
r| 
|¡YqàX| 
|j t|ƒ|¡¡||krD| 
|¡qà|ˆkràˆ 
|¡qàWt|ƒt|
ƒkr¼d	}	q¼W|rœd dd„|Dƒ¡}
t	||d
|
ƒ‚|‡fdd„|jDƒ7}g}x*|D]"}| |||¡\}}| 
|¡q¾Wt|tgƒƒ}||fS)Ncss&|]}t|tƒrt|jƒ|fVqdS)N)ršr8rar•)rrërrrr§sz!Each.parseImpl.<locals>.<genexpr>cSsg|]}t|tƒr|j‘qSr)ršr8r•)rrërrrrsz"Each.parseImpl.<locals>.<listcomp>cSs$g|]}|jrt|ttfƒs|‘qSr)rÃršr8rD)rrërrrrscSsg|]}t|tƒr|j‘qSr)ršrOr•)rrërrrrscSsg|]}t|tƒr|j‘qSr)ršr6r•)rrërrrrscSs g|]}t|tttfƒs|‘qSr)ršr8rOr6)rrërrrrsFTz, css|]}t|ƒVqdS)N)r¥)rrërrrr§9sz*Missing one or more required elements (%s)cs$g|]}t|tƒr|jˆkr|‘qSr)ršr8r•)rrë)ÚtmpOptrrr=s)r÷rrâÚopt1mapÚ	optionalsÚmultioptionalsÚ
multirequiredÚrequiredrþr<rírôraÚremoverÓrØràÚsumr?)rÈr”rÄrÛÚopt1Úopt2ÚtmpLocÚtmpReqdÚ
matchOrderÚkeepMatchingÚtmpExprsÚfailedrëÚmissingrær˜ÚfinalResultsr)rørrçsP



zEach.parseImplcCs@t|dƒr|jS|jdkr:dd dd„|jDƒ¡d|_|jS)Nrrêz & css|]}t|ƒVqdS)N)r¥)rrërrrr§LszEach.__str__.<locals>.<genexpr>rë)r;rr½rØrâ)rÈrrrrÕGs


 zEach.__str__cCs0|dd…|g}x|jD]}| |¡qWdS)N)rârT)rÈrrérërrrrTPszEach.checkRecursion)T)T)
rrrrárÊrrçrÕrTrrr)r®rr(Ñs8
1	csjeZdZdZd‡fdd„	Zddd„Zdd	„Z‡fd
d„Z‡fdd
„Zdd„Z	ddd„Z
‡fdd„Z‡ZS)r;zfAbstract subclass of :class:`ParserElement`, for combining and
    post-processing parsed tokens.
    Fcsštt|ƒ |¡t|tƒr@t|jtƒr2| |¡}n| t|ƒ¡}||_	d|_
|dk	r–|j|_|j|_| 
|j¡|j|_|j|_|j|_|j |j¡dS)N)r{r;rÊršrÚ
issubclassr·rIr1r•r½rÈrÃrLrÁrÀr¿rÌrÅrO)rÈr•rÎ)r®rrrÊZs
zParseElementEnhance.__init__TcCs2|jdk	r|jj|||ddStd||j|ƒ‚dS)NF)rÜr·)r•ràr<rÉ)rÈr”rÄrÛrrrrçls
zParseElementEnhance.parseImplcCs*d|_|j ¡|_|jdk	r&|j ¡|S)NF)rÀr•rRrK)rÈrrrrKrs


z#ParseElementEnhance.leaveWhitespacecsrt|tƒrB||jkrntt|ƒ |¡|jdk	rn|j |jd¡n,tt|ƒ |¡|jdk	rn|j |jd¡|S)Nr”)ršrHrÅr{r;rNr•)rÈrS)r®rrrNys



zParseElementEnhance.ignorecs&tt|ƒ ¡|jdk	r"|j ¡|S)N)r{r;rr•)rÈ)r®rrr…s

zParseElementEnhance.streamlinecCsB||krt||gƒ‚|dd…|g}|jdk	r>|j |¡dS)N)rCr•rT)rÈrrérrrrT‹s

z"ParseElementEnhance.checkRecursionNcCsB|dkrg}|dd…|g}|jdk	r4|j |¡| g¡dS)N)r•rVrT)rÈrUrãrrrrV’s
zParseElementEnhance.validatecsVytt|ƒ ¡Stk
r"YnX|jdkrP|jdk	rPd|jjt|jƒf|_|jS)Nz%s:(%s))	r{r;rÕrˆr½r•r®rr¥)rÈ)r®rrr՚szParseElementEnhance.__str__)F)T)N)
rrrrárÊrçrKrNrrTrVrÕrrr)r®rr;Vs

cs*eZdZdZ‡fdd„Zddd„Z‡ZS)r*abLookahead 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, stopOn=label).setParseAction(' '.join))

        OneOrMore(attr_expr).parseString("shape: SQUARE color: BLACK posn: upper left").pprint()

    prints::

        [['shape', 'SQUARE'], ['color', 'BLACK'], ['posn', 'upper left']]
    cstt|ƒ |¡d|_dS)NT)r{r*rÊrÃ)rÈr•)r®rrrÊ»szFollowedBy.__init__TcCs(|jj|||d\}}|dd…=||fS)N)rÛ)r•rà)rÈr”rÄrÛÚ_r¤rrrrç¿s
zFollowedBy.parseImpl)T)rrrrárÊrçrrr)r®rr*¥scs,eZdZdZd	‡fdd„	Zd
dd„Z‡ZS)r2apLookbehind 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, Literal, Keyword, or
    a Word or 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

    NcsÎtt|ƒ |¡| ¡ ¡|_d|_d|_d|_t|t	ƒrJt
|ƒ}d|_nVt|ttfƒrf|j
}d|_n:t|ttfƒrŒ|jtkrŒ|j}d|_nt|tƒr d}d|_||_dt	|ƒ|_d|_|j dd„¡dS)NTFrznot preceded by cSs| tddƒ¡S)N)r3r$)r«r¼r—rrrr˜ùr™z%PrecededBy.__init__.<locals>.<lambda>)r{r2rÊr•rKrÃrÈrªršrœrÓr1r.rƒrLr%r rzrÜÚretreatrÉrÀr»rí)rÈr•r)r®rrrÊäs*

zPrecededBy.__init__rTcCsä|jr<||jkrt|||jƒ‚||j}|j ||¡\}}n |jtƒ}|td||jƒ|…}t|||jƒ}	xltdt	||jdƒdƒD]J}
y| |t
|ƒ|
¡\}}Wn&tk
rÐ}z|}	Wdd}~XYqŠXPqŠW|	‚||fS)Nrr¨)rªrr<rÉr•ràrFr©r)r¨rÓr:)rÈr”rÄrÛr’rr¤Ú	test_exprÚinstring_sliceÚ	last_exprrVÚpberrrrçûs 

 zPrecededBy.parseImpl)N)rT)rrrrárÊrçrrr)r®rr2Èscs2eZdZdZ‡fdd„Zd	dd„Zdd„Z‡ZS)
r5a¹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 = Optional(NOT) + ident

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

        # integers that are followed by "." are actually floats
        integer = Word(nums) + ~Char(".")
    cs0tt|ƒ |¡d|_d|_dt|jƒ|_dS)NFTzFound unwanted token, )r{r5rÊrÀrÃr¥r•rÉ)rÈr•)r®rrrÊ*szNotAny.__init__TcCs&|j ||¡rt|||j|ƒ‚|gfS)N)r•rÿr<rÉ)rÈr”rÄrÛrrrrç1szNotAny.parseImplcCs4t|dƒr|jS|jdkr.dt|jƒd|_|jS)Nrz~{rë)r;rr½r¥r•)rÈrrrrÕ6s


zNotAny.__str__)T)rrrrárÊrçrÕrrr)r®rr5s
cs>eZdZd‡fdd„	Zdd„Zd
dd„Zd‡fd
d„	Z‡ZS)Ú_MultipleMatchNcs<tt|ƒ |¡d|_|}t|tƒr.| |¡}| |¡dS)NT)r{rrÊr¿ršrr·ÚstopOn)rÈr•rÚender)r®rrrÊ@s

z_MultipleMatch.__init__cCs,t|tƒr| |¡}|dk	r"|nd|_|S)N)ršrr·Ú	not_ender)rÈrrrrrHs

z_MultipleMatch.stopOnTc	CsÂ|jj}|j}|jdk	}|r$|jj}|r2|||ƒ||||dd\}}yZ|j}	xJ|rb|||ƒ|	rr|||ƒ}
n|}
|||
|ƒ\}}|s’| ¡rT||7}qTWWnttfk
r¸YnX||fS)NF)rÜ)	r•ràrírrþrÅrCr<r")rÈr”rÄrÛÚself_expr_parseÚself_skip_ignorablesÚcheck_enderÚ
try_not_enderrúÚhasIgnoreExprsrøÚ	tmptokensrrrrçNs,



z_MultipleMatch.parseImplFcsjtjrXxP|jgt|jdgƒD]6}t|tƒr|jrtjd 	d|t
|ƒj|j¡ddqWtt
|ƒ ||¡S)Nrâz]{0}: setting results name {1!r} on {2} expression collides with {3!r} on contained expressionrr‘)r0)rrr•r°ršrAr¾r3r4rîrßrr{rrÓ)rÈrrÔrë)r®rrrÓksz_MultipleMatch._setResultsName)N)T)F)rrrrÊrrçrÓrrr)r®rr?s
rc@seZdZdZdd„ZdS)r6ajRepetition of one or more of the given expression.

    Parameters:
     - expr - expression that must match one or more times
     - stopOn - (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).setParseAction(' '.join))

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

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

        # could also be written as
        (attr_expr * (1,)).parseString(text).pprint()
    cCs4t|dƒr|jS|jdkr.dt|jƒd|_|jS)Nrrêz}...)r;rr½r¥r•)rÈrrrrՓs


zOneOrMore.__str__N)rrrrárÕrrrrr6yscs8eZdZdZd
‡fdd„	Zd‡fdd„	Zdd	„Z‡ZS)rOakOptional repetition of zero or more of the given expression.

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

    Example: similar to :class:`OneOrMore`
    Ncstt|ƒj||dd|_dS)N)rT)r{rOrÊrÃ)rÈr•r)r®rrrʧszZeroOrMore.__init__Tc	s6ytt|ƒ |||¡Sttfk
r0|gfSXdS)N)r{rOrçr<r")rÈr”rÄrÛ)r®rrrç«szZeroOrMore.parseImplcCs4t|dƒr|jS|jdkr.dt|jƒd|_|jS)Nrr]z]...)r;rr½r¥r•)rÈrrrrÕ±s


zZeroOrMore.__str__)N)T)rrrrárÊrçrÕrrr)r®rrOœs
c@s eZdZdd„ZeZdd„ZdS)Ú
_NullTokencCsdS)NFr)rÈrrrr6¼sz_NullToken.__bool__cCsdS)Nr·r)rÈrrrrÕ¿sz_NullToken.__str__N)rrrr6rŒrÕrrrrr»srcs<eZdZdZeƒZef‡fdd„	Zd	dd„Zdd„Z‡Z	S)
r8aGOptional 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) + Optional('-' + Word(nums, exact=4)))
        zip.runTests('''
            # 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)
    cs.tt|ƒj|dd|jj|_||_d|_dS)NF)rÎT)r{r8rÊr•r¿rJrÃ)rÈr•rD)r®rrrÊés
zOptional.__init__Tc	Cs|y|jj|||dd\}}WnVttfk
rr|j|jk	rj|jjr`t|jgƒ}|j||jj<qn|jg}ng}YnX||fS)NF)rÜ)r•ràr<r"rJÚ_Optional__optionalNotMatchedr¾r?)rÈr”rÄrÛrúrrrrçïs

zOptional.parseImplcCs4t|dƒr|jS|jdkr.dt|jƒd|_|jS)Nrr]r^)r;rr½r¥r•)rÈrrrrÕýs


zOptional.__str__)T)
rrrrárrrÊrçrÕrrr)r®rr8Âs
$
cs,eZdZdZd	‡fdd„	Zd
dd„Z‡ZS)rEaø	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 - (default= ``False``) if True, the target expression is also parsed
          (the skipped text and target expression are returned as a 2-element list).
     - ignore - (default= ``None``) used to define grammars (typically quoted strings and
          comments) that might contain false matches to the target expression
     - failOn - (default= ``None``) define expressions that are not allowed to be
          included in the skipped test; if found before the target expression is found,
          the 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=quotedString)
        string_data.setParseAction(tokenMap(str.strip))
        ticket_expr = (integer("issue_num") + SEP
                      + string_data("sev") + SEP
                      + string_data("desc") + SEP
                      + integer("days_open"))

        for tkt in ticket_expr.searchString(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
    FNcs`tt|ƒ |¡||_d|_d|_||_d|_t|t	ƒrF| 
|¡|_n||_dt|j
ƒ|_dS)NTFzNo match found for )r{rErÊÚ
ignoreExprrÃrÈÚincludeMatchr¿ršrr·ÚfailOnr¥r•rÉ)rÈrSÚincluderNr)r®rrrÊ@s
zSkipTo.__init__Tc	Cs,|}t|ƒ}|j}|jj}|jdk	r,|jjnd}|jdk	rB|jjnd}	|}
xœ|
|krÖ|dk	rh|||
ƒrhP|	dk	rœx*y|	||
ƒ}
Wqrtk
r–PYqrXqrWy|||
dddWn tt	fk
rÐ|
d7}
YqLXPqLWt|||j
|ƒ‚|
}|||…}t|ƒ}|jr$||||dd\}}
||
7}||fS)NF)rÛrÜr¨)rÜ)
rÓr•ràrrÿrrþr:r<r"rÉr?r)rÈr”rÄrÛr—rïr•Ú
expr_parseÚself_failOn_canParseNextÚself_ignoreExpr_tryParseÚtmplocÚskiptextÚ
skipresultr—rrrrçMs<

zSkipTo.parseImpl)FNN)T)rrrrárÊrçrrr)r®rrEs9
csneZdZdZd‡fdd„	Zdd„Zdd„Zd	d
„Zdd„Zdd
d„Z	dd„Z
‡fdd„Zd‡fdd„	Z‡Z
S)r+a_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::

        fwdExpr << a | b | c

    will actually be evaluated as::

        (fwdExpr << 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``::

        fwdExpr << (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``.
    Ncstt|ƒj|dddS)NF)rÎ)r{r+rÊ)rÈrS)r®rrrʗszForward.__init__cCsjt|tƒr| |¡}||_d|_|jj|_|jj|_| |jj¡|jj	|_	|jj
|_
|j |jj¡|S)N)
ršrr·r•r½rÈrÃrLrÁrÀr¿rÅrO)rÈrSrrrÚ
__lshift__šs





zForward.__lshift__cCs||>S)Nr)rÈrSrrrÚ__ilshift__§szForward.__ilshift__cCs
d|_|S)NF)rÀ)rÈrrrrKªszForward.leaveWhitespacecCs$|js d|_|jdk	r |j ¡|S)NT)rÇr•r)rÈrrrr®s


zForward.streamlinecCsJ|dkrg}||kr<|dd…|g}|jdk	r<|j |¡| g¡dS)N)r•rVrT)rÈrUrãrrrrVµs
zForward.validatecCslt|dƒr|jS|jdk	r |jSd|_d}z&|jdk	rJt|jƒdd…}nd}Wd|jjd||_X|jS)Nrz: ...z...ièÚNonez: )r;rr½r•r¥r®r)rÈÚ	retStringrrrrÕ¿s


zForward.__str__cs.|jdk	rtt|ƒ ¡Stƒ}||K}|SdS)N)r•r{r+rR)rÈr¤)r®rrrRÓs

zForward.copyFcs@tjr.|jdkr.tjd d|t|ƒj¡ddtt	|ƒ 
||¡S)NzR{0}: setting results name {0!r} on {1} expression that has no contained expressionrr‘)r0)rrr•r3r4rîrßrr{r+rÓ)rÈrrÔ)r®rrrÓÛs

zForward._setResultsName)N)N)F)rrrrárÊr'r(rKrrVrÕrRrÓrrr)r®rr+|s


cs"eZdZdZd‡fdd„	Z‡ZS)rJzW
    Abstract subclass of :class:`ParseExpression`, for converting parsed results.
    Fcstt|ƒ |¡d|_dS)NF)r{rJrÊr¿)rÈr•rÎ)r®rrrÊêszTokenConverter.__init__)F)rrrrárÊrrr)r®rrJæscs6eZdZdZd
‡fdd„	Z‡fdd„Zdd	„Z‡ZS)r&aÕConverter to concatenate all matching tokens to a single string.
    By default, the matching patterns must also be contiguous in the
    input string; this can be disabled by specifying
    ``'adjacent=False'`` in the constructor.

    Example::

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

        real = Combine(Word(nums) + '.' + Word(nums))
        print(real.parseString('3.1416')) # -> ['3.1416']
        # no match when there are internal spaces
        print(real.parseString('3. 1416')) # -> Exception: Expected W:(0123...)
    r·Tcs8tt|ƒ |¡|r| ¡||_d|_||_d|_dS)NT)r{r&rÊrKÚadjacentrÀÚ
joinStringrÌ)rÈr•r,r+)r®rrrÊszCombine.__init__cs(|jrt ||¡ntt|ƒ |¡|S)N)r+rArNr{r&)rÈrS)r®rrrN
szCombine.ignorecCsP| ¡}|dd…=|td | |j¡¡g|jd7}|jrH| ¡rH|gS|SdS)Nr·)r)rRr?rØr_r,rÊr¾rC)rÈr”rÄrñÚretToksrrrròs
"zCombine.postParse)r·T)rrrrárÊrNròrrr)r®rr&îs
cs(eZdZdZ‡fdd„Zdd„Z‡ZS)r-aConverter to return the matched tokens as a list - useful for
    returning tokens of :class:`ZeroOrMore` and :class:`OneOrMore` expressions.

    Example::

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

        func = ident + Group(Optional(delimitedList(term)))
        print(func.parseString("fn a, b, 100"))  # -> ['fn', ['a', 'b', '100']]
    cstt|ƒ |¡d|_dS)NT)r{r-rÊr¿)rÈr•)r®rrrÊ*szGroup.__init__cCs|gS)Nr)rÈr”rÄrñrrrrò.szGroup.postParse)rrrrárÊròrrr)r®rr-scs(eZdZdZ‡fdd„Zdd„Z‡ZS)r'a?Converter to return a repetitive expression as a list, but also
    as a dictionary. Each element can also be referenced using the first
    token in the expression as its key. Useful for tabular report
    scraping when the first column can be used as a item key.

    Example::

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

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

        # print attributes as plain groups
        print(OneOrMore(attr_expr).parseString(text).dump())

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

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

    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.
    cstt|ƒ |¡d|_dS)NT)r{r'rÊr¿)rÈr•)r®rrrÊXsz
Dict.__init__cCsòxÜt|ƒD]Ð\}}t|ƒdkr q
|d}t|tƒrBt|dƒ ¡}t|ƒdkr^td|ƒ||<q
t|ƒdkrŒt|dtƒsŒt|d|ƒ||<q
| ¡}|d=t|ƒdks¸t|tƒrÈ| 	¡rÈt||ƒ||<q
t|d|ƒ||<q
W|j
rê|gS|SdS)Nrr¨r·r“)ròrÓršr–r¥rÙrr?rRrCr¾)rÈr”rÄrñrüÚtokÚikeyÚ	dictvaluerrrrò\s$
zDict.postParse)rrrrárÊròrrr)r®rr'1s&c@s eZdZdZdd„Zdd„ZdS)rHa[Converter for ignoring the results of a parsed expression.

    Example::

        source = "a, b, c,d"
        wd = Word(alphas)
        wd_list1 = wd + ZeroOrMore(',' + wd)
        print(wd_list1.parseString(source))

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

    prints::

        ['a', ',', 'b', ',', 'c', ',', 'd']
        ['a', 'b', 'c', 'd']

    (See also :class:`delimitedList`.)
    cCsgS)Nr)rÈr”rÄrñrrrrò‹szSuppress.postParsecCs|S)Nr)rÈrrrrJŽszSuppress.suppressN)rrrráròrJrrrrrHusc@s(eZdZdZdd„Zdd„Zdd„ZdS)	r7zDWrapper for parse actions, to ensure they are only called once.
    cCst|ƒ|_d|_dS)NF)rÁrãÚcalled)rÈÚ
methodCallrrrrʕs
zOnlyOnce.__init__cCs.|js| |||¡}d|_|St||dƒ‚dS)NTr·)r1rãr<)rÈr«r¼r—r˜rrrrI˜s
zOnlyOnce.__call__cCs
d|_dS)NF)r1)rÈrrrÚresetžszOnlyOnce.resetN)rrrrárÊrIr3rrrrr7’scs:tˆƒ‰‡fdd„}yˆj|_Wntk
r4YnX|S)aqDecorator for debugging parse actions.

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

    Example::

        wd = Word(alphas)

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

        wds = OneOrMore(wd).setParseAction(remove_duplicate_chars)
        print(wds.parseString("slkdjs sld sldd sdlf sdljf"))

    prints::

        >>entering remove_duplicate_chars(line: 'slkdjs sld sldd sdlf sdljf', 0, (['slkdjs', 'sld', 'sldd', 'sdlf', 'sdljf'], {}))
        <<leaving remove_duplicate_chars (ret: 'dfjkls')
        ['dfjkls']
    c
s´ˆj}|dd…\}}}t|ƒdkr8|djjd|}tj d|t||ƒ||f¡yˆ|Ž}Wn8tk
rš}ztj d||f¡‚Wdd}~XYnXtj d||f¡|S)Nržr‘rÚ.z">>entering %s(line: '%s', %d, %r)
z<<leaving %s (exception: %s)
z<<leaving %s (ret: %r)
)rrÓr®rŸÚstderrrjrerˆ)ÚpaArgsÚthisFuncr«r¼r—r¤rø)r\rrÚz»sztraceParseAction.<locals>.z)rÁrrÏ)r\r8r)r\rr€¡s
ú,cCs`t|ƒdt|ƒdt|ƒd}|rBt|t||ƒƒ |¡S|tt|ƒ|ƒ |¡SdS)aÎHelper to define a delimited list of expressions - the delimiter
    defaults to ','. By default, the list elements and delimiters can
    have intervening whitespace, and comments, but this can be
    overridden by passing ``combine=True`` in the constructor. If
    ``combine`` is set to ``True``, the matching tokens are
    returned as a single token string, with the delimiters included;
    otherwise, the matching tokens are returned as a list of tokens,
    with the delimiters suppressed.

    Example::

        delimitedList(Word(alphas)).parseString("aa,bb,cc") # -> ['aa', 'bb', 'cc']
        delimitedList(Word(hexnums), delim=':', combine=True).parseString("AA:BB:CC:DD:EE") # -> ['AA:BB:CC:DD:EE']
    z [räz]...N)r¥r&rOrÒrH)r•ÚdelimÚcombineÚdlNamerrrr^Ñs$csjtƒ‰‡‡fdd„}|dkr0ttƒ dd„¡}n| ¡}| d¡|j|dd|ˆ d	tˆƒd
¡S)a>Helper to define a counted list of expressions.

    This helper defines a pattern of the form::

        integer expr expr expr...

    where the leading integer tells how many expr expressions follow.
    The matched tokens returns the array of expr tokens as a list - the
    leading count token is suppressed.

    If ``intExpr`` is specified, it should be a pyparsing expression
    that produces an integer value.

    Example::

        countedArray(Word(alphas)).parseString('2 ab cd ef')  # -> ['ab', 'cd']

        # in this parser, the leading integer value is given in binary,
        # '10' indicating that 2 values are in the array
        binaryConstant = Word('01').setParseAction(lambda t: int(t[0], 2))
        countedArray(Word(alphas), intExpr=binaryConstant).parseString('10 ab cd ef')  # -> ['ab', 'cd']
    cs.|d}ˆ|r ttˆg|ƒƒp&ttƒ>gS)Nr)r-r"ra)r«r¼r—r9)Ú	arrayExprr•rrÚcountFieldParseActionþs"z+countedArray.<locals>.countFieldParseActionNcSst|dƒS)Nr)r–)r—rrrr˜r™zcountedArray.<locals>.<lambda>ÚarrayLenT)rÍz(len) z...)r+rLrpr¡rRrÒrçr¥)r•ÚintExprr>r)r=r•rrZæs
cCs:g}x0|D](}t|tƒr(| t|ƒ¡q
| |¡q
W|S)N)ršrrOr)rí)ÚLr¤rürrrr)
s

r)cs6tƒ‰‡fdd„}|j|ddˆ dt|ƒ¡ˆS)a4Helper to define an expression that is indirectly defined from
    the tokens matched in a previous expression, that is, it looks for
    a 'repeat' of a previous expression.  For example::

        first = Word(nums)
        second = matchPreviousLiteral(first)
        matchExpr = first + ":" + second

    will match ``"1:1"``, but not ``"1:2"``.  Because this
    matches a previous literal, will also match the leading
    ``"1:1"`` in ``"1:10"``. If this is not desired, use
    :class:`matchPreviousExpr`. Do *not* use with packrat parsing
    enabled.
    csP|rBt|ƒdkrˆ|d>qLt| ¡ƒ}ˆtdd„|Dƒƒ>n
ˆtƒ>dS)Nr¨rcss|]}t|ƒVqdS)N)r1)rÚttrrrr§*szDmatchPreviousLiteral.<locals>.copyTokenToRepeater.<locals>.<genexpr>)rÓr)rr"r))r«r¼r—Útflat)ÚreprrÚcopyTokenToRepeater#sz1matchPreviousLiteral.<locals>.copyTokenToRepeaterT)rÍz(prev) )r+rçrÒr¥)r•rEr)rDrrms

csFtƒ‰| ¡}ˆ|K‰‡fdd„}|j|ddˆ dt|ƒ¡ˆS)aTHelper to define an expression that is indirectly defined from
    the tokens matched in a previous expression, that is, it looks for
    a 'repeat' of a previous expression.  For example::

        first = Word(nums)
        second = matchPreviousExpr(first)
        matchExpr = first + ":" + second

    will match ``"1:1"``, but not ``"1:2"``.  Because this
    matches by expressions, will *not* match the leading ``"1:1"``
    in ``"1:10"``; the expressions are evaluated first, and then
    compared, so ``"1"`` is compared with ``"10"``. Do *not* use
    with packrat parsing enabled.
    cs*t| ¡ƒ‰‡fdd„}ˆj|dddS)Ncs$t| ¡ƒ}|ˆkr tdddƒ‚dS)Nr·r)r)rr<)r«r¼r—ÚtheseTokens)ÚmatchTokensrrÚmustMatchTheseTokensEszLmatchPreviousExpr.<locals>.copyTokenToRepeater.<locals>.mustMatchTheseTokensT)rÍ)r)rr¡)r«r¼r—rH)rD)rGrrECsz.matchPreviousExpr.<locals>.copyTokenToRepeaterT)rÍz(prev) )r+rRrçrÒr¥)r•Úe2rEr)rDrrl1scCs>xdD]}| |t|¡}qW| dd¡}| dd¡}t|ƒS)Nz\^-[]rêz\nrÎz\t)r®Ú_bslashr¥)r«rºrrrr¢Ns

r¢csöt|tƒrtjddd|r:dd„}dd„}|r4tnt‰ndd„}dd„}|rRtnt‰g}t|tƒrn| ¡}n$t|t	ƒr‚t
|ƒ}ntjd	tdd|sœtƒS|s2d
}xŠ|t
|ƒdkr0||}xjt||dd…ƒD]J\}	}
||
|ƒrü|||	d=PqØ|||
ƒrØ|||	d=| ||
¡PqØW|d7}q¨W|sÔ|sÔ|rÔyht
|ƒt
d
 |¡ƒkr†tdd
 dd„|Dƒ¡ƒ d |¡¡Std dd„|Dƒ¡ƒ d |¡¡SWn&tk
rÒtjdtddYnXt‡fdd„|Dƒƒ d |¡¡S)aƒHelper to quickly define a set of alternative Literals, and makes
    sure to do longest-first testing when there is a conflict,
    regardless of the input order, but returns
    a :class:`MatchFirst` for best performance.

    Parameters:

     - strs - a string of space-delimited literals, or a collection of
       string literals
     - caseless - (default= ``False``) - treat all literals as
       caseless
     - useRegex - (default= ``True``) - as an optimization, will
       generate a Regex object; otherwise, will generate
       a :class:`MatchFirst` object (if ``caseless=True`` or ``asKeyword=True``, or if
       creating a :class:`Regex` raises an exception)
     - asKeyword - (default=``False``) - enforce Keyword-style matching on the
       generated expressions

    Example::

        comp_oper = oneOf("< = > <= >= !=")
        var = Word(alphas)
        number = Word(nums)
        term = var | number
        comparison_expr = term + comp_oper + term
        print(comparison_expr.searchString("B = 12  AA=23 B<=AA AA>12"))

    prints::

        [['B', '=', '12'], ['AA', '=', '23'], ['B', '<=', 'AA'], ['AA', '>', '12']]
    z_More than one string argument passed to oneOf, pass choices as a list or space-delimited stringr“)r0cSs| ¡| ¡kS)N)r‰)rUÚbrrrr˜{r™zoneOf.<locals>.<lambda>cSs| ¡ | ¡¡S)N)r‰r)rUrKrrrr˜|r™cSs||kS)Nr)rUrKrrrr˜r™cSs
| |¡S)N)r)rUrKrrrr˜€r™z6Invalid argument to oneOf, expected string or iterablerr¨Nr·z[%s]css|]}t|ƒVqdS)N)r¢)rÚsymrrrr§£szoneOf.<locals>.<genexpr>z | ú|css|]}t |¡VqdS)N)rr¤)rrLrrrr§¥sz7Exception creating Regex for oneOf, building MatchFirstc3s|]}ˆ|ƒVqdS)Nr)rrL)ÚparseElementClassrrr§«s)ršrr3r4r#r$r.r1r¬r
rr5r4rÓròrKrØrDrÒrˆr3)ÚstrsrˆÚuseRegexr¡ÚisequalÚmasksÚsymbolsrüÚcurr0rSr)rNrrqVsR 







((cCsttt||ƒƒƒS)aéHelper to easily and clearly define a dictionary by specifying
    the respective patterns for the key and value.  Takes care of
    defining the :class:`Dict`, :class:`ZeroOrMore`, and
    :class:`Group` tokens in the proper order.  The key pattern
    can include delimiting markers or punctuation, as long as they are
    suppressed, thereby leaving the significant key text.  The value
    pattern can include named results, so that the :class:`Dict` results
    can include named token fields.

    Example::

        text = "shape: SQUARE posn: upper left color: light blue texture: burlap"
        attr_expr = (label + Suppress(':') + OneOrMore(data_word, stopOn=label).setParseAction(' '.join))
        print(OneOrMore(attr_expr).parseString(text).dump())

        attr_label = label
        attr_value = Suppress(':') + OneOrMore(data_word, stopOn=label).setParseAction(' '.join)

        # similar to Dict, but simpler call format
        result = dictOf(attr_label, attr_value).parseString(text)
        print(result.dump())
        print(result['shape'])
        print(result.shape)  # object attribute access works too
        print(result.asDict())

    prints::

        [['shape', 'SQUARE'], ['posn', 'upper left'], ['color', 'light blue'], ['texture', 'burlap']]
        - color: light blue
        - posn: upper left
        - shape: SQUARE
        - texture: burlap
        SQUARE
        SQUARE
        {'color': 'light blue', 'shape': 'SQUARE', 'posn': 'upper left', 'texture': 'burlap'}
    )r'r6r-)rIr1rrrr_­s%cCs^tƒ dd„¡}| ¡}d|_|dƒ||dƒ}|r@dd„}ndd„}| |¡|j|_|S)	a—Helper to return the original, untokenized text for a given
    expression.  Useful to restore the parsed fields of an HTML start
    tag into the raw tag text itself, or to revert separate tokens with
    intervening whitespace back to the original matching input text. By
    default, returns astring containing the original parsed text.

    If the optional ``asString`` argument is passed as
    ``False``, then the return value is
    a :class:`ParseResults` containing any results names that
    were originally matched, and a single token containing the original
    matched text from the input string.  So if the expression passed to
    :class:`originalTextFor` contains expressions with defined
    results names, you must set ``asString`` to ``False`` if you
    want to preserve those results name values.

    Example::

        src = "this is test <b> bold <i>text</i> </b> normal text "
        for tag in ("b", "i"):
            opener, closer = makeHTMLTags(tag)
            patt = originalTextFor(opener + SkipTo(closer) + closer)
            print(patt.searchString(src)[0])

    prints::

        ['<b> bold <i>text</i> </b>']
        ['<i>text</i>']
    cSs|S)Nr)r«rÄr—rrrr˜ñr™z!originalTextFor.<locals>.<lambda>FÚ_original_startÚ
_original_endcSs||j|j…S)N)rUrV)r«r¼r—rrrr˜ör™cSs&|| d¡| d¡…g|dd…<dS)NrUrV)rH)r«r¼r—rrrÚextractTextøsz$originalTextFor.<locals>.extractText)r)r¡rRrÌrÅ)r•ÚasStringÚ	locMarkerÚendlocMarkerÚ	matchExprrWrrrr…Ôs

cCst|ƒ dd„¡S)zkHelper to undo pyparsing's default grouping of And expressions,
    even if all but one are non-empty.
    cSs|dS)Nrr)r—rrrr˜r™zungroup.<locals>.<lambda>)rJrç)r•rrrr†þscCs4tƒ dd„¡}t|dƒ|dƒ| ¡ ¡dƒƒS)a±Helper to decorate a returned token with its starting and ending
    locations in the input string.

    This helper adds the following results names:

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

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

    Example::

        wd = Word(alphas)
        for match in locatedExpr(wd).searchString("ljsdf123lksdjjf123lkkjj1222"):
            print(match)

    prints::

        [[0, 'ljsdf', 5]]
        [[8, 'lksdjjf', 15]]
        [[18, 'lkkjj', 23]]
    cSs|S)Nr)r«r¼r—rrrr˜r™zlocatedExpr.<locals>.<lambda>Ú
locn_startr1Úlocn_end)r)r¡r-rRrK)r•Úlocatorrrrrˆsz\[]-*.$+^?()~ )rªcCs|ddS)Nrr¨r)r«r¼r—rrrr˜(r™r˜z\\0?[xX][0-9a-fA-F]+cCstt|d d¡dƒƒS)Nrz\0xrã)Úunichrr–rk)r«r¼r—rrrr˜)r™z	\\0[0-7]+cCstt|ddd…dƒƒS)Nrr¨é)r_r–)r«r¼r—rrrr˜*r™z\]rär]råÚnegateÚbodyr^csBdd„‰y d ‡fdd„t |¡jDƒ¡Stk
r<dSXdS)aHelper to easily define string ranges for use in 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.)
    cSs<t|tƒs|Sd dd„tt|dƒt|dƒdƒDƒ¡S)Nr·css|]}t|ƒVqdS)N)r_)rrºrrrr§Isz+srange.<locals>.<lambda>.<locals>.<genexpr>rr¨)ršr?rØr)Úord)Úprrrr˜Ir™zsrange.<locals>.<lambda>r·c3s|]}ˆ|ƒVqdS)Nr)rÚpart)Ú	_expandedrrr§Kszsrange.<locals>.<genexpr>N)rØÚ_reBracketExprrrbrˆ)r«r)rfrr}/s
 cs‡fdd„}|S)zoHelper method for defining parse actions that require matching at
    a specific column in the input text.
    cs"t||ƒˆkrt||dˆƒ‚dS)Nzmatched token not at column %d)rWr<)rŽÚlocnr™)r9rrÚ	verifyColSsz!matchOnlyAtCol.<locals>.verifyColr)r9rir)r9rrkOscs‡fdd„S)aµHelper method for common parse actions that simply return
    a literal value.  Especially useful when used with
    :class:`transformString<ParserElement.transformString>` ().

    Example::

        num = Word(nums).setParseAction(lambda toks: int(toks[0]))
        na = oneOf("N/A NA").setParseAction(replaceWith(math.nan))
        term = na | num

        OneOrMore(term).parseString("324 234 N/A 234") # -> [324, 234, nan, 234]
    csˆgS)Nr)r«r¼r—)ÚreplStrrrr˜er™zreplaceWith.<locals>.<lambda>r)rjr)rjrrzXs
cCs|ddd…S)aHelper parse action for removing quotation marks from parsed
    quoted strings.

    Example::

        # by default, quotation marks are included in parsed results
        quotedString.parseString("'Now is the Winter of our Discontent'") # -> ["'Now is the Winter of our Discontent'"]

        # use removeQuotes to strip quotation marks from parsed results
        quotedString.setParseAction(removeQuotes)
        quotedString.parseString("'Now is the Winter of our Discontent'") # -> ["Now is the Winter of our Discontent"]
    rr¨r”r)r«r¼r—rrrrxgs
csN‡‡fdd„}ytˆdtˆdƒjƒ}Wntk
rBtˆƒ}YnX||_|S)aLHelper to define a parse action by mapping a function to all
    elements of a 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).setParseAction(tokenMap(int, 16))``,
    which will convert the parsed data to an integer using base 16.

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

        hex_ints = OneOrMore(Word(hexnums)).setParseAction(tokenMap(int, 16))
        hex_ints.runTests('''
            00 11 22 aa FF 0a 0d 1a
            ''')

        upperword = Word(alphas).setParseAction(tokenMap(str.upper))
        OneOrMore(upperword).runTests('''
            my kingdom for a horse
            ''')

        wd = Word(alphas).setParseAction(tokenMap(str.title))
        OneOrMore(wd).setParseAction(' '.join).runTests('''
            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']
    cs‡‡fdd„|DƒS)Ncsg|]}ˆ|fˆžŽ‘qSrr)rÚtokn)rÇrœrrr›sz(tokenMap.<locals>.pa.<locals>.<listcomp>r)r«r¼r—)rÇrœrrrÀšsztokenMap.<locals>.parr®)r°rrˆrœ)rœrÇrÀr³r)rÇrœrr‹vs$cCst|ƒ ¡S)N)r¥r‰)r—rrrr˜¦r™cCst|ƒ ¡S)N)r¥Úlower)r—rrrr˜ªr™rhrics~t|tƒr|‰t||d}n|j‰tttdƒ}|rŽt ¡ 	t
¡}||dƒttt
|tdƒ|ƒƒƒtddgddƒ 	d	d
„¡|}nlt ¡ 	t
¡ttddB}||dƒttt
| 	t¡ttdƒ|ƒƒƒƒtddgddƒ 	d
d
„¡|}ttdƒ|ddd}| dˆ¡| ‡fdd
„¡|dd ˆ dd¡ ¡ ¡¡ƒ dˆ¡}ˆ|_ˆ|_t|ƒƒ|_||fS)zRInternal helper to construct opening and closing tag expressions, given a tag name)rˆz_-:Útagú=ú/F)rDracSs|ddkS)Nrror)r«r¼r—rrrr˜¾r™z_makeTags.<locals>.<lambda>ri)r™cSs|ddkS)Nrror)r«r¼r—rrrr˜Ær™z</)r+z<%s>c	s*| dd ˆ dd¡ ¡ ¡¡| ¡¡S)Nr’r·ú:rä)r(rØr®Útitler¬rR)r—)Úresnamerrr˜Ìr™r¯r·rpräz</%s>)ršrr.rrLrRrQr\rRr¡rxr'rOr-rHr8rwrtr`r&Ú_LrÒrçrØr®rqr¬rmrEÚtag_body)ÚtagStrÚxmlÚsuppress_LTÚsuppress_GTÚtagAttrNameÚtagAttrValueÚopenTagÚcloseTagr)rrrÚ	_makeTags®s$
JR,r}cCs
t|dƒS)aKHelper to construct opening and closing tag expressions for HTML,
    given a tag name. Matches tags in either upper or lower case,
    attributes with namespaces and with quoted or unquoted values.

    Example::

        text = '<td>More info at the <a href="https://github.com/pyparsing/pyparsing/wiki">pyparsing</a> wiki page</td>'
        # makeHTMLTags returns pyparsing expressions for the opening and
        # closing tags as a 2-tuple
        a, a_end = makeHTMLTags("A")
        link_expr = a + SkipTo(a_end)("link_text") + a_end

        for link in link_expr.searchString(text):
            # attributes in the <A> tag (like "href" shown here) are
            # also accessible as named results
            print(link.link_text, '->', link.href)

    prints::

        pyparsing -> https://github.com/pyparsing/pyparsing/wiki
    F)r})rurrrriÓscCs
t|dƒS)z»Helper to construct opening and closing tag expressions for XML,
    given a tag name. Matches tags only in the given upper/lower case.

    Example: similar to :class:`makeHTMLTags`
    T)r})rurrrrjëscs8|r|dd…‰n| ¡‰dd„ˆDƒ‰‡fdd„}|S)a7Helper to create a validating parse action to be used with start
    tags created with :class:`makeXMLTags` or
    :class:`makeHTMLTags`. Use ``withAttribute`` to qualify
    a starting tag with a required attribute value, to avoid false
    matches on common tags such as ``<TD>`` or ``<DIV>``.

    Call ``withAttribute`` with a series of attribute names and
    values. Specify the list of filter attributes names and values as:

     - keyword arguments, as in ``(align="right")``, or
     - as an explicit dict with ``**`` operator, when an attribute
       name is also a Python reserved word, as in ``**{"class":"Customer", "align":"right"}``
     - a list of name-value tuples, as in ``(("ns1:class", "Customer"), ("ns2:align", "right"))``

    For attribute names with a namespace prefix, you must use the second
    form.  Attribute names are matched insensitive to upper/lower case.

    If just testing for ``class`` (with or without a namespace), use
    :class:`withClass`.

    To verify that the attribute exists, but without specifying a value,
    pass ``withAttribute.ANY_VALUE`` as the value.

    Example::

        html = '''
            <div>
            Some text
            <div type="grid">1 4 0 1 0</div>
            <div type="graph">1,3 2,3 1,1</div>
            <div>this has no type</div>
            </div>

        '''
        div,div_end = makeHTMLTags("div")

        # only match div tag having a type attribute with value "grid"
        div_grid = div().setParseAction(withAttribute(type="grid"))
        grid_expr = div_grid + SkipTo(div | div_end)("body")
        for grid_header in grid_expr.searchString(html):
            print(grid_header.body)

        # construct a match with any div tag having a type attribute, regardless of the value
        div_any_type = div().setParseAction(withAttribute(type=withAttribute.ANY_VALUE))
        div_expr = div_any_type + SkipTo(div | div_end)("body")
        for div_header in div_expr.searchString(html):
            print(div_header.body)

    prints::

        1 4 0 1 0

        1 4 0 1 0
        1,3 2,3 1,1
    NcSsg|]\}}||f‘qSrr)rr&r#rrrr/sz!withAttribute.<locals>.<listcomp>cs^xXˆD]P\}}||kr&t||d|ƒ‚|tjkr|||krt||d||||fƒ‚qWdS)Nzno matching attribute z+attribute '%s' has value '%s', must be '%s')r<rƒÚ	ANY_VALUE)r«r¼rúÚattrNameÚ	attrValue)ÚattrsrrrÀ0szwithAttribute.<locals>.pa)r,)rÇÚattrDictrÀr)rrrƒós8cCs|rd|nd}tf||iŽS)aÉSimplified version of :class:`withAttribute` when
    matching on a div class - made difficult because ``class`` is
    a reserved word in Python.

    Example::

        html = '''
            <div>
            Some text
            <div class="grid">1 4 0 1 0</div>
            <div class="graph">1,3 2,3 1,1</div>
            <div>this &lt;div&gt; has no class</div>
            </div>

        '''
        div,div_end = makeHTMLTags("div")
        div_grid = div().setParseAction(withClass("grid"))

        grid_expr = div_grid + SkipTo(div | div_end)("body")
        for grid_header in grid_expr.searchString(html):
            print(grid_header.body)

        div_any_type = div().setParseAction(withClass(withAttribute.ANY_VALUE))
        div_expr = div_any_type + SkipTo(div | div_end)("body")
        for div_header in div_expr.searchString(html):
            print(div_header.body)

    prints::

        1 4 0 1 0

        1 4 0 1 0
        1,3 2,3 1,1
    z%s:classÚclass)rƒ)Ú	classnameÚ	namespaceÚ	classattrrrrr‰:s#ú(rÁcCs¶Gdd„dtƒ}tƒ}||||B}x€t|ƒD]r\}}|ddd…\}	}
}}|
dkrdd|	nd|	}
|
dkr˜|	dksˆt|	ƒd	krtd
ƒ‚|	\}}tƒ |
¡}|tjkrx|
dkrÖ|||	ƒt|t	|	ƒƒ}n |
d	kr.|	dk	r|||	|ƒt|t	|	|ƒƒ}n|||ƒt|t	|ƒƒ}nH|
dkrn||||||ƒt|t	||||ƒƒ}ntdƒ‚nì|tj
kr\|
dkr¾t|	tƒs¢t|	ƒ}	||	j
|ƒt|	|ƒ}nœ|
d	kr|	dk	rø|||	|ƒt|t	|	|ƒƒ}n|||ƒt|t	|ƒƒ}nD|
dkrR||||||ƒt|||||ƒ}ntdƒ‚ntd
ƒ‚|rt|ttfƒr†|j|Žn
| |¡|| |
¡|BK}|}q2W||K}|S)al
Helper method for constructing grammars of expressions made up of
    operators working in a precedence hierarchy.  Operators may be unary
    or binary, left- or right-associative.  Parse actions can also be
    attached to operator expressions. The generated parser will also
    recognize the use of parentheses to override operator precedences
    (see example below).

    Note: if you define a deep operator list, you may see performance
    issues when using infixNotation. See
    :class:`ParserElement.enablePackrat` for a mechanism to potentially
    improve your parser performance.

    Parameters:
     - baseExpr - expression representing the most basic element for the
       nested
     - opList - list of tuples, one for each operator precedence level
       in the expression grammar; each tuple is of the form ``(opExpr,
       numTerms, rightLeftAssoc, parseAction)``, where:

       - opExpr is the pyparsing expression for the operator; may also
         be a string, which will be converted to a Literal; if numTerms
         is 3, opExpr is a tuple of two expressions, for the two
         operators separating the 3 terms
       - numTerms is the number of terms for this operator (must be 1,
         2, or 3)
       - rightLeftAssoc is the indicator whether the operator is right
         or left associative, using the pyparsing-defined constants
         ``opAssoc.RIGHT`` and ``opAssoc.LEFT``.
       - parseAction is the parse action to be associated with
         expressions matching this operator expression (the parse action
         tuple member may be omitted); if the parse action is passed
         a tuple or list of functions, this is equivalent to calling
         ``setParseAction(*fn)``
         (:class:`ParserElement.setParseAction`)
     - lpar - expression for matching left-parentheses
       (default= ``Suppress('(')``)
     - rpar - expression for matching right-parentheses
       (default= ``Suppress(')')``)

    Example::

        # simple example of four-function arithmetic with ints and
        # variable names
        integer = pyparsing_common.signed_integer
        varname = pyparsing_common.identifier

        arith_expr = infixNotation(integer | varname,
            [
            ('-', 1, opAssoc.RIGHT),
            (oneOf('* /'), 2, opAssoc.LEFT),
            (oneOf('+ -'), 2, opAssoc.LEFT),
            ])

        arith_expr.runTests('''
            5+3*6
            (5+3)*6
            -2--11
            ''', fullDump=False)

    prints::

        5+3*6
        [[5, '+', [3, '*', 6]]]

        (5+3)*6
        [[[5, '+', 3], '*', 6]]

        -2--11
        [[['-', 2], '-', ['-', 11]]]
    c@seZdZddd„ZdS)zinfixNotation.<locals>._FBTcSs|j ||¡|gfS)N)r•rþ)rÈr”rÄrÛrrrrç­sz$infixNotation.<locals>._FB.parseImplN)T)rrrrçrrrrÚ_FB¬srˆ)NNr­r‘z%s termz	%s%s termr“z@if numterms=3, opExpr must be a tuple or list of two expressionsr¨z6operator must be unary (1), binary (2), or ternary (3)z2operator must indicate right or left associativity)r*r+ròrÓr<rÒrrÚLEFTr-r6ÚRIGHTršr8r•r;rr¡)ÚbaseExprÚopListÚlparÚrparrˆr¤ÚlastExprrüÚoperDefÚopExprÚarityÚrightLeftAssocrÀÚtermNameÚopExpr1ÚopExpr2ÚthisExprr[rrrr‡dsZH

&
 



&


z4"(?:[^"\n\r\\]|(?:"")|(?:\\(?:[^x]|x[0-9a-fA-F]+)))*ú"z string enclosed in double quotesz4'(?:[^'\n\r\\]|(?:'')|(?:\\(?:[^x]|x[0-9a-fA-F]+)))*ú'z string enclosed in single quotesz*quotedString using single or double quotesÚuzunicode string literalcCsž||krtdƒ‚|dkr*t|tƒr"t|tƒr"t|ƒdkr¨t|ƒdkr¨|dk	r‚tt|t||tjddƒƒ 	dd„¡}n$t
 ¡t||tjƒ 	dd„¡}nx|dk	rìtt|t|ƒt|ƒttjddƒƒ 	dd„¡}n4ttt|ƒt|ƒttjddƒƒ 	d	d„¡}ntd
ƒ‚t
ƒ}|dk	rd|tt|ƒt||B|Bƒt|ƒƒK}n$|tt|ƒt||Bƒt|ƒƒK}| d||f¡|S)a—	Helper method for defining nested lists enclosed in opening and
    closing delimiters ("(" and ")" are the default).

    Parameters:
     - opener - opening character for a nested list
       (default= ``"("``); can also be a pyparsing expression
     - closer - closing character for a nested list
       (default= ``")"``); can also be a pyparsing expression
     - content - expression for items within the nested lists
       (default= ``None``)
     - ignoreExpr - expression for ignoring opening and closing
       delimiters (default= :class:`quotedString`)

    If an expression is not provided for the content argument, the
    nested expression will capture all whitespace-delimited content
    between delimiters as a list of separate values.

    Use the ``ignoreExpr`` argument to define expressions that may
    contain opening or closing characters that should not be treated as
    opening or closing characters for nesting, such as quotedString or
    a comment expression.  Specify multiple expressions using an
    :class:`Or` or :class:`MatchFirst`. The default is
    :class:`quotedString`, but if no expressions are to be ignored, then
    pass ``None`` for this argument.

    Example::

        data_type = oneOf("void int short long char float double")
        decl_data_type = Combine(data_type + Optional(Word('*')))
        ident = Word(alphas+'_', alphanums+'_')
        number = pyparsing_common.number
        arg = Group(decl_data_type + ident)
        LPAR, RPAR = map(Suppress, "()")

        code_body = nestedExpr('{', '}', ignoreExpr=(quotedString | cStyleComment))

        c_function = (decl_data_type("type")
                      + ident("name")
                      + LPAR + Optional(delimitedList(arg), [])("args") + RPAR
                      + code_body("body"))
        c_function.ignore(cStyleComment)

        source_code = '''
            int is_odd(int x) {
                return (x%2);
            }

            int dec_to_hex(char hchar) {
                if (hchar >= '0' && hchar <= '9') {
                    return (ord(hchar)-ord('0'));
                } else {
                    return (10+ord(hchar)-ord('A'));
                }
            }
        '''
        for func in c_function.searchString(source_code):
            print("%(name)s (%(type)s) args: %(args)s" % func)


    prints::

        is_odd (int) args: [['int', 'x']]
        dec_to_hex (int) args: [['char', 'hchar']]
    z.opening and closing strings cannot be the sameNr¨)rªcSs|d ¡S)Nr)rÙ)r—rrrr˜;r™znestedExpr.<locals>.<lambda>cSs|d ¡S)Nr)rÙ)r—rrrr˜@r™cSs|d ¡S)Nr)rÙ)r—rrrr˜Gr™cSs|d ¡S)Nr)rÙ)r—rrrr˜Lr™zOopening and closing arguments must be strings if no content expression is givenznested %s%s expression)r<ršrrÓr&r6r%rAr´r¡rarRr1r+r-rHrOrÒ)ÚopenerÚcloserÚcontentrr¤rrrrnïs6A
,&
*$cs&ˆdd…‰‡‡fdd„‰‡fdd„}‡fdd„}‡fdd	„}ttƒ d
¡ ¡tƒd}tƒtƒ |¡ d¡}tƒ |¡ d
¡}tƒ |¡ d¡}	|rÌtt	|ƒ|t|t|ƒt	|ƒtƒd|	ƒ}
n.tt	|ƒt|t|ƒt	|ƒtƒd|	ƒ}
|
 
‡fdd„¡| ttƒ¡|
 d¡S)aæHelper method for defining space-delimited indentation blocks,
    such as those used to define block statements in Python source code.

    Parameters:

     - blockStatementExpr - expression defining syntax of statement that
       is repeated within the indented block
     - indentStack - list created by caller to manage indentation stack
       (multiple statementWithIndentedBlock expressions within a single
       grammar should share a common indentStack)
     - indent - boolean indicating whether block must be indented beyond
       the current level; set to False for block of left-most
       statements (default= ``True``)

    A valid block must contain at least one ``blockStatement``.

    Example::

        data = '''
        def A(z):
          A1
          B = 100
          G = A2
          A2
          A3
        B
        def BB(a,b,c):
          BB1
          def BBA():
            bba1
            bba2
            bba3
        C
        D
        def spam(x,y):
             def eggs(z):
                 pass
        '''


        indentStack = [1]
        stmt = Forward()

        identifier = Word(alphas, alphanums)
        funcDecl = ("def" + identifier + Group("(" + Optional(delimitedList(identifier)) + ")") + ":")
        func_body = indentedBlock(stmt, indentStack)
        funcDef = Group(funcDecl + func_body)

        rvalue = Forward()
        funcCall = Group(identifier + "(" + Optional(delimitedList(rvalue)) + ")")
        rvalue << (funcCall | identifier | Word(nums))
        assignment = Group(identifier + "=" + rvalue)
        stmt << (funcDef | assignment | identifier)

        module_body = OneOrMore(stmt)

        parseTree = module_body.parseString(data)
        parseTree.pprint()

    prints::

        [['def',
          'A',
          ['(', 'z', ')'],
          ':',
          [['A1'], [['B', '=', '100']], [['G', '=', 'A2']], ['A2'], ['A3']]],
         'B',
         ['def',
          'BB',
          ['(', 'a', 'b', 'c', ')'],
          ':',
          [['BB1'], [['def', 'BBA', ['(', ')'], ':', [['bba1'], ['bba2'], ['bba3']]]]]],
         'C',
         'D',
         ['def',
          'spam',
          ['(', 'x', 'y', ')'],
          ':',
          [[['def', 'eggs', ['(', 'z', ')'], ':', [['pass']]]]]]]
    Ncsˆˆdd…<dS)Nrr)Úbackup_stackÚindentStackrrÚreset_stackªsz"indentedBlock.<locals>.reset_stackcsN|t|ƒkrdSt||ƒ}|ˆdkrJ|ˆdkr>t||dƒ‚t||dƒ‚dS)Nr”zillegal nestingznot a peer entry)rÓrWr<)r«r¼r—ÚcurCol)rŸrrÚcheckPeerIndent­s
z&indentedBlock.<locals>.checkPeerIndentcs2t||ƒ}|ˆdkr"ˆ |¡nt||dƒ‚dS)Nr”znot a subentry)rWrír<)r«r¼r—r¡)rŸrrÚcheckSubIndentµs
z%indentedBlock.<locals>.checkSubIndentcsJ|t|ƒkrdSt||ƒ}ˆr&|ˆks2t||dƒ‚|ˆdkrFˆ ¡dS)Nznot an unindentr”)rÓrWr<rH)r«r¼r—r¡)rŸrrÚ
checkUnindent¼s
z$indentedBlock.<locals>.checkUnindentz	 )rÚINDENTr·ÚUNINDENTcsˆƒS)Nr)rUrKrºr»)r rrr˜Ñr™zindentedBlock.<locals>.<lambda>zindented block)
r6r/rLrJrFr)r¡rÒr-r8rérNrJ)ÚblockStatementExprrŸrmr¢r£r¤rr¥ÚPEERÚUNDENTÚsmExprr)ržrŸr rr„Ws"Q2,z#[\0xc0-\0xd6\0xd8-\0xf6\0xf8-\0xff]z[\0xa1-\0xbf\0xd7\0xf7]z_:zany tagzgt lt amp nbsp quot aposz><& "'z&(?P<entity>rMz);zcommon HTML entitycCst |j¡S)zRHelper parser action to replace common HTML entities with their special characters)Ú_htmlEntityMaprôÚentity)r—rrrryÛsz/\*(?:[^*]|\*(?!/))*z*/zC style commentz<!--[\s\S]*?-->zHTML commentz.*zrest of linez//(?:\\\n|[^\n])*z
// commentzC++ style commentz#.*zPython style comment)r™z 	Ú	commaItem)rDc@s¨eZdZdZeeƒZeeƒZe	e
ƒ d¡ e¡Z
e	eƒ d¡ eedƒ¡Zedƒ d¡ e¡Zeƒ e¡deƒ e¡ d¡Ze d	d
„¡eeeedƒ ¡eƒB d¡Ze e¡ed
ƒ d¡ e¡Zedƒ d¡ e¡ZeeBeB ¡Zedƒ d¡ e¡Ze	ededƒ d¡Zedƒ d¡Z edƒ d¡Z!e!de!d d¡Z"ee!de!dƒdee!de!dƒ d¡Z#e# $dd
„¡d e  d!¡Z%e&e"e%Be#B d"¡ƒ d"¡Z'ed#ƒ d$¡Z(e)d=d&d'„ƒZ*e)d>d)d*„ƒZ+ed+ƒ d,¡Z,ed-ƒ d.¡Z-ed/ƒ d0¡Z.e/ ¡e0 ¡BZ1e)d1d2„ƒZ2e&e3e4d3ƒe5ƒe	e6d3d4ee7d5ƒƒƒƒ ¡ d6¡Z8e9ee: ;¡e8Bd7d8ƒ d9¡Z<e)ed:d
„ƒƒZ=e)ed;d
„ƒƒZ>d<S)?rŒaHere are some common low-level expressions that may be useful in
    jump-starting parser development:

     - numeric forms (:class:`integers<integer>`, :class:`reals<real>`,
       :class:`scientific notation<sci_real>`)
     - common :class:`programming identifiers<identifier>`
     - network addresses (:class:`MAC<mac_address>`,
       :class:`IPv4<ipv4_address>`, :class:`IPv6<ipv6_address>`)
     - ISO8601 :class:`dates<iso8601_date>` and
       :class:`datetime<iso8601_datetime>`
     - :class:`UUID<uuid>`
     - :class:`comma-separated list<comma_separated_list>`

    Parse actions:

     - :class:`convertToInteger`
     - :class:`convertToFloat`
     - :class:`convertToDate`
     - :class:`convertToDatetime`
     - :class:`stripHTMLTags`
     - :class:`upcaseTokens`
     - :class:`downcaseTokens`

    Example::

        pyparsing_common.number.runTests('''
            # any int or real number, returned as the appropriate type
            100
            -100
            +100
            3.14159
            6.02e23
            1e-12
            ''')

        pyparsing_common.fnumber.runTests('''
            # any int or real number, returned as float
            100
            -100
            +100
            3.14159
            6.02e23
            1e-12
            ''')

        pyparsing_common.hex_integer.runTests('''
            # hex numbers
            100
            FF
            ''')

        pyparsing_common.fraction.runTests('''
            # fractions
            1/2
            -3/4
            ''')

        pyparsing_common.mixed_integer.runTests('''
            # mixed fractions
            1
            1/2
            -3/4
            1-3/4
            ''')

        import uuid
        pyparsing_common.uuid.setParseAction(tokenMap(uuid.UUID))
        pyparsing_common.uuid.runTests('''
            # uuid
            12345678-1234-5678-1234-567812345678
            ''')

    prints::

        # any int or real number, returned as the appropriate type
        100
        [100]

        -100
        [-100]

        +100
        [100]

        3.14159
        [3.14159]

        6.02e23
        [6.02e+23]

        1e-12
        [1e-12]

        # any int or real number, returned as float
        100
        [100.0]

        -100
        [-100.0]

        +100
        [100.0]

        3.14159
        [3.14159]

        6.02e23
        [6.02e+23]

        1e-12
        [1e-12]

        # hex numbers
        100
        [256]

        FF
        [255]

        # fractions
        1/2
        [0.5]

        -3/4
        [-0.75]

        # mixed fractions
        1
        [1]

        1/2
        [0.5]

        -3/4
        [-0.75]

        1-3/4
        [1.75]

        # uuid
        12345678-1234-5678-1234-567812345678
        [UUID('12345678-1234-5678-1234-567812345678')]
    Úintegerzhex integerrãz[+-]?\d+zsigned integerroÚfractioncCs|d|dS)Nrr”r)r—rrrr˜¤r™zpyparsing_common.<lambda>räz"fraction or mixed integer-fractionz[+-]?(?:\d+\.\d*|\.\d+)zreal numberz@[+-]?(?:\d+(?:[eE][+-]?\d+)|(?:\d+\.\d*|\.\d+)(?:[eE][+-]?\d+)?)z$real number with scientific notationz[+-]?\d+\.?\d*([eE][+-]?\d+)?ÚfnumberrÚ
identifierzK(25[0-5]|2[0-4][0-9]|1?[0-9]{1,2})(\.(25[0-5]|2[0-4][0-9]|1?[0-9]{1,2})){3}zIPv4 addressz[0-9a-fA-F]{1,4}Úhex_integerrpézfull IPv6 address)rr¨z::zshort IPv6 addresscCstdd„|DƒƒdkS)Ncss|]}tj |¡rdVqdS)r¨N)rŒÚ
_ipv6_partr$)rrBrrrr§Äsz,pyparsing_common.<lambda>.<locals>.<genexpr>r`)rÿ)r—rrrr˜Är™z::ffff:zmixed IPv6 addresszIPv6 addressz:[0-9a-fA-F]{2}([:.-])[0-9a-fA-F]{2}(?:\1[0-9a-fA-F]{2}){4}zMAC addressú%Y-%m-%dcs‡fdd„}|S)aÝ
        Helper to create a parse action for converting parsed date string to Python datetime.date

        Params -
         - fmt - format to be passed to datetime.strptime (default= ``"%Y-%m-%d"``)

        Example::

            date_expr = pyparsing_common.iso8601_date.copy()
            date_expr.setParseAction(pyparsing_common.convertToDate())
            print(date_expr.parseString("1999-12-31"))

        prints::

            [datetime.date(1999, 12, 31)]
        c
sLyt |dˆ¡ ¡Stk
rF}zt||t|ƒƒ‚Wdd}~XYnXdS)Nr)rÚstrptimeÚdater<r<rœ)r«r¼r—Úve)ÚfmtrrÚcvt_fnÞsz.pyparsing_common.convertToDate.<locals>.cvt_fnr)r¹rºr)r¹rÚ
convertToDateÌszpyparsing_common.convertToDateú%Y-%m-%dT%H:%M:%S.%fcs‡fdd„}|S)aHelper to create a parse action for converting parsed
        datetime string to Python datetime.datetime

        Params -
         - fmt - format to be passed to datetime.strptime (default= ``"%Y-%m-%dT%H:%M:%S.%f"``)

        Example::

            dt_expr = pyparsing_common.iso8601_datetime.copy()
            dt_expr.setParseAction(pyparsing_common.convertToDatetime())
            print(dt_expr.parseString("1999-12-31T23:59:59.999"))

        prints::

            [datetime.datetime(1999, 12, 31, 23, 59, 59, 999000)]
        c
sHyt |dˆ¡Stk
rB}zt||t|ƒƒ‚Wdd}~XYnXdS)Nr)rr¶r<r<rœ)r«r¼r—r¸)r¹rrrº÷sz2pyparsing_common.convertToDatetime.<locals>.cvt_fnr)r¹rºr)r¹rÚconvertToDatetimeåsz"pyparsing_common.convertToDatetimez7(?P<year>\d{4})(?:-(?P<month>\d\d)(?:-(?P<day>\d\d))?)?zISO8601 datez†(?P<year>\d{4})-(?P<month>\d\d)-(?P<day>\d\d)[T ](?P<hour>\d\d):(?P<minute>\d\d)(:(?P<second>\d\d(\.\d*)?)?)?(?P<tz>Z|[+-]\d\d:?\d\d)?zISO8601 datetimez2[0-9a-fA-F]{8}(-[0-9a-fA-F]{4}){3}-[0-9a-fA-F]{12}ÚUUIDcCstj |d¡S)aParse action to remove HTML tags from web page HTML source

        Example::

            # strip HTML links from normal text
            text = '<td>More info at the <a href="https://github.com/pyparsing/pyparsing/wiki">pyparsing</a> wiki page</td>'
            td, td_end = makeHTMLTags("TD")
            table_text = td + SkipTo(td_end).setParseAction(pyparsing_common.stripHTMLTags)("body") + td_end
            print(table_text.parseString(text).body)

        Prints::

            More info at the pyparsing wiki page
        r)rŒÚ_html_stripperr¢)r«r¼rúrrrÚ
stripHTMLTagsszpyparsing_common.stripHTMLTagsr9)r™z 	r­r·)rDzcomma separated listcCst|ƒ ¡S)N)r¥r‰)r—rrrr˜#r™cCst|ƒ ¡S)N)r¥rl)r—rrrr˜&r™N)rµ)r¼)?rrrrár‹r–ÚconvertToIntegerÚfloatÚconvertToFloatrLrprÒr¡r®rbr²rDÚsigned_integerr¯rçr8rJÚ
mixed_integerrÿÚrealÚsci_realrÚnumberr°rRrQr±Úipv4_addressr´Ú_full_ipv6_addressÚ_short_ipv6_addressrèÚ_mixed_ipv6_addressr&Úipv6_addressÚmac_addressrr»r½Úiso8601_dateÚiso8601_datetimeÚuuidrUrTr¿rÀr6r1r/rtrKÚ
_commasepitemr^rwrRÚcomma_separated_listr‚r`rrrrrŒþsT""
,8
c@seZdZdd„Zdd„ZdS)Ú_lazyclasspropertycCs||_|j|_|j|_dS)N)r¾rár)rÈr¾rrrrÊ+sz_lazyclassproperty.__init__cslˆdkrt|ƒ‰tˆdƒr:t‡fdd„ˆjdd…Dƒƒr@iˆ_|jj}|ˆjkrb| ˆ¡ˆj|<ˆj|S)NÚ_internc3s |]}ˆjt|dgƒkVqdS)rÕN)rÕr°)rÚ
superclass)rËrrr§3sz-_lazyclassproperty.__get__.<locals>.<genexpr>r¨)rßr;r€Ú__mro__rÕr¾r)rÈr£rËÚattrnamer)rËrÚ__get__0s
z_lazyclassproperty.__get__N)rrrrÊrÙrrrrrÔ*srÔc@sPeZdZdZgZedd„ƒZedd„ƒZedd„ƒZ	edd	„ƒZ
ed
d„ƒZdS)
rŽa×
    A set of Unicode characters, for language-specific strings for
    ``alphas``, ``nums``, ``alphanums``, and ``printables``.
    A unicode_set is defined by a list of ranges in the Unicode character
    set, in a class attribute ``_ranges``, such as::

        _ranges = [(0x0020, 0x007e), (0x00a0, 0x00ff),]

    A unicode set can also be defined using multiple inheritance of other unicode sets::

        class CJK(Chinese, Japanese, Korean):
            pass
    cCs`g}xD|jD]:}|tkrPx*|jD] }| t|d|ddƒ¡q"WqWdd„tt|ƒƒDƒS)Nrr”r¨cSsg|]}t|ƒ‘qSr)r_)rrºrrrrTsz5unicode_set._get_chars_for_ranges.<locals>.<listcomp>)r×rŽÚ_rangesrOr)r~rñ)rËr¤ÚccÚrrrrrÚ_get_chars_for_rangesLs$z!unicode_set._get_chars_for_rangescCsd ttj| ¡ƒ¡S)z+all non-whitespace characters in this ranger·)rØrr›rÞrÝ)rËrrrrtVszunicode_set.printablescCsd ttj| ¡ƒ¡S)z'all alphabetic characters in this ranger·)rØÚfilterr›ÚisalpharÝ)rËrrrrR[szunicode_set.alphascCsd ttj| ¡ƒ¡S)z*all numeric digit characters in this ranger·)rØrÞr›ÚisdigitrÝ)rËrrrrp`szunicode_set.numscCs|j|jS)z)all alphanumeric characters in this range)rRrp)rËrrrrQeszunicode_set.alphanumsN)rrrrárÚrârÝrÔrtrRrprQrrrrrŽ<s

c@sðeZdZdZdejfgZGdd„deƒZGdd„deƒZ	Gdd„deƒZ
Gd	d
„d
eƒZGdd„deƒZGd
d„deƒZ
Gdd„deƒZGdd„deƒZGdd„de
eeƒZGdd„deƒZGdd„deƒZGdd„deƒZGdd„deƒZdS)rzF
    A namespace class for defining common language unicode_sets.
    é c@seZdZdZddgZdS)zpyparsing_unicode.Latin1z/Unicode set for Latin-1 Unicode Character Range)ráé~)é éÿN)rrrrárÚrrrrÚLatin1qsråc@seZdZdZdgZdS)zpyparsing_unicode.LatinAz/Unicode set for Latin-A Unicode Character Range)éiN)rrrrárÚrrrrÚLatinAusrçc@seZdZdZdgZdS)zpyparsing_unicode.LatinBz/Unicode set for Latin-B Unicode Character Range)i€iON)rrrrárÚrrrrÚLatinBysrèc@s6eZdZdZdddddddd	d
ddd
dddddgZdS)zpyparsing_unicode.Greekz.Unicode set for Greek Unicode Character Ranges)ipiÿ)ii)ii)i iE)iHiM)iPiW)iY)i[)i])i_i})i€i´)i¶iÄ)iÆiÓ)iÖiÛ)iÝiï)iòiô)iöiþN)rrrrárÚrrrrÚGreek}s
réc@seZdZdZdgZdS)zpyparsing_unicode.Cyrillicz0Unicode set for Cyrillic Unicode Character Range)iiÿN)rrrrárÚrrrrÚCyrillic…srêc@seZdZdZddgZdS)zpyparsing_unicode.Chinesez/Unicode set for Chinese Unicode Character Range)iNiÿŸ)i0i?0N)rrrrárÚrrrrÚChinese‰srëc@sDeZdZdZgZGdd„deƒZGdd„deƒZGdd„deƒZdS)	zpyparsing_unicode.Japanesez`Unicode set for Japanese Unicode Character Range, combining Kanji, Hiragana, and Katakana rangesc@seZdZdZddgZdS)z pyparsing_unicode.Japanese.Kanjiz-Unicode set for Kanji Unicode Character Range)iNi¿Ÿ)i0i?0N)rrrrárÚrrrrÚKanji‘srìc@seZdZdZdgZdS)z#pyparsing_unicode.Japanese.Hiraganaz0Unicode set for Hiragana Unicode Character Range)i@0iŸ0N)rrrrárÚrrrrÚHiragana•sríc@seZdZdZdgZdS)z#pyparsing_unicode.Japanese.Katakanaz1Unicode set for Katakana  Unicode Character Range)i 0iÿ0N)rrrrárÚrrrrÚKatakana™srîN)	rrrrárÚrŽrìrírîrrrrÚJapaneses
rïc@s eZdZdZddddddgZdS)	zpyparsing_unicode.Koreanz.Unicode set for Korean Unicode Character Range)i¬i¯×)iiÿ)i01i1)i`©i©)i°×iÿ×)i0i?0N)rrrrárÚrrrrÚKoreansrðc@seZdZdZdS)zpyparsing_unicode.CJKzTUnicode set for combined Chinese, Japanese, and Korean (CJK) Unicode Character RangeN)rrrrárrrrÚCJK¡srñc@seZdZdZddgZdS)zpyparsing_unicode.Thaiz,Unicode set for Thai Unicode Character Range)ii:)i?i[N)rrrrárÚrrrrÚThai¥sròc@seZdZdZdddgZdS)zpyparsing_unicode.Arabicz.Unicode set for Arabic Unicode Character Range)ii)iiÿ)iiN)rrrrárÚrrrrÚArabic©sróc@seZdZdZdgZdS)zpyparsing_unicode.Hebrewz.Unicode set for Hebrew Unicode Character Range)iiÿN)rrrrárÚrrrrÚHebrew­srôc@seZdZdZddgZdS)zpyparsing_unicode.Devanagariz2Unicode set for Devanagari Unicode Character Range)i	i	)ià¨iÿ¨N)rrrrárÚrrrrÚ
Devanagari±srõN)rrrrárŸÚ
maxunicoderÚrŽrårçrèrérêrërïrðrñròrórôrõrrrrrksuالعربيةu中文uкириллицаuΕλληνικάuעִברִיתu	日本語u漢字uカタカナuひらがなu	한국어u	ไทยuदेवनागरीc@s,eZdZdZGdd„dƒZGdd„dƒZdS)Úpyparsing_testzB
    namespace class for classes useful in writing unit tests
    c@s8eZdZdZdd„Zdd„Zdd„Zdd	„Zd
d„ZdS)
z&pyparsing_test.reset_pyparsing_contextax
        Context manager to be used when writing unit tests that modify pyparsing config values:
         - packrat parsing
         - default whitespace characters.
         - default keyword characters
         - literal string auto-conversion class
         - __diag__ settings

        Example:
            with reset_pyparsing_context():
                # test that literals used to construct a grammar are automatically suppressed
                ParserElement.inlineLiteralsUsing(Suppress)

                term = Word(alphas) | Word(nums)
                group = Group('(' + term[...] + ')')

                # assert that the '()' characters are not included in the parsed tokens
                self.assertParseAndCheckLisst(group, "(abc 123 def)", ['abc', '123', 'def'])

            # after exiting context manager, literals are converted to Literal expressions again
        cCs
i|_dS)N)Ú
_save_context)rÈrrrrÊåsz/pyparsing_test.reset_pyparsing_context.__init__cCsftj|jd<tj|jd<tj|jd<tj|jd<tj|jd<dd„tj	Dƒ|jd<d	t
ji|jd
<|S)NÚdefault_whitespaceÚdefault_keyword_charsÚliteral_string_classÚpackrat_enabledÚ
packrat_parsecSsi|]}tt|ƒ|“qSr)r°r)rrrrrú
<dictcomp>ðsz?pyparsing_test.reset_pyparsing_context.save.<locals>.<dictcomp>rrìr!)rAr´rør.r‡r·rràrÚ
_all_namesr!rì)rÈrrrÚsaveèsz+pyparsing_test.reset_pyparsing_context.savecCsŒtj|jdkr t |jd¡|jdt_t |jd¡x&|jd ¡D]\}}tt	||ƒqLW|jdt_
|jdt_|jdt_
dS)Nrùrúrûrrürýr!)rAr´rør¶r.r‡r¸r,Úsetattrrrràr!rì)rÈrr1rrrÚrestoreøsz.pyparsing_test.reset_pyparsing_context.restorecCs| ¡S)N)r)rÈrrrÚ	__enter__sz0pyparsing_test.reset_pyparsing_context.__enter__cGs| ¡S)N)r)rÈrÇrrrÚ__exit__sz/pyparsing_test.reset_pyparsing_context.__exit__N)	rrrrárÊrrrrrrrrÚreset_pyparsing_contextÎsrc@sJeZdZdZddd„Zddd„Zddd	„Zdd
d„Zee	dfdd
„ƒZ
dS)z&pyparsing_test.TestParseResultsAssertszk
        A mixin class to add parse results assertion methods to normal unittest.TestCase classes.
        NcCs<|dk	r|j|| ¡|d|dk	r8|j|| ¡|ddS)zÀ
            Unit test assertion to compare a ParseResults object with an optional expected_list,
            and compare any defined results names with an optional expected_dict.
            N)r¿)ÚassertEqualrrd)rÈrwÚ
expected_listÚ
expected_dictr¿rrrÚassertParseResultsEqualssz?pyparsing_test.TestParseResultsAsserts.assertParseResultsEqualsTcCs2|j|dd}|rt| ¡ƒ|j|||ddS)z¾
            Convenience wrapper assert to test a parser element and input string, and assert that
            the resulting ParseResults.asList() is equal to the expected_list.
            T)r)rr¿N)rr“rr	)rÈr•Útest_stringrr¿ÚverboserwrrrÚassertParseAndCheckList!sz>pyparsing_test.TestParseResultsAsserts.assertParseAndCheckListcCs2|j|dd}|rt| ¡ƒ|j|||ddS)z¾
            Convenience wrapper assert to test a parser element and input string, and assert that
            the resulting ParseResults.asDict() is equal to the expected_dict.
            T)r)rr¿N)rr“rr	)rÈr•r
rr¿rrwrrrÚassertParseAndCheckDict-sz>pyparsing_test.TestParseResultsAsserts.assertParseAndCheckDictc
Cs|\}}|dk	rðdd„t||ƒDƒ}xÊ|D]Â\}}}	tdd„|	Dƒdƒ}
tdd„|	Dƒdƒ}|dk	r’|j||
pp|dt|tƒr†|‚WdQRXq*tdd„|	Dƒdƒ}td	d„|	Dƒdƒ}
||
fd
krÞ|j|||
|
pÖ|dq*td |¡ƒq*W|j||dk	r|nd
ddS)aP
            Unit test assertion to evaluate output of ParserElement.runTests(). If a list of
            list-dict tuples is given as the expected_parse_results argument, then these are zipped
            with the report tuples returned by runTests and evaluated using assertParseResultsEquals.
            Finally, asserts that the overall runTests() success value is True.

            :param run_tests_report: tuple(bool, [tuple(str, ParseResults or Exception)]) returned from runTests
            :param expected_parse_results (optional): [tuple(str, list, dict, Exception)]
            NcSs"g|]\}}|d|d|f‘qS)rr¨r)rÚrptÚexpectedrrrrIszOpyparsing_test.TestParseResultsAsserts.assertRunTestResults.<locals>.<listcomp>css|]}t|tƒr|VqdS)N)ršrœ)rÚexprrrr§QszNpyparsing_test.TestParseResultsAsserts.assertRunTestResults.<locals>.<genexpr>css&|]}t|tƒrt|tƒr|VqdS)N)ršrßr
rˆ)rrrrrr§Us)Úexpected_exceptionr¿css|]}t|tƒr|VqdS)N)ršr)rrrrrr§cscss|]}t|tƒr|VqdS)N)ršr)rrrrrr§fs)NN)rrr¿zno validation for {!r}zfailed runTests)r¿)	r­rwÚassertRaisesršrˆr	r“rîÚ
assertTrue)rÈÚrun_tests_reportÚexpected_parse_resultsr¿Úrun_test_successÚrun_test_resultsÚmergedr
rwrÚfail_msgrrrrrrÚassertRunTestResults9s:
z;pyparsing_test.TestParseResultsAsserts.assertRunTestResultsc	cs$|j||ddVWdQRXdS)N)r¿)r)rÈr½r¿rrrÚassertRaisesParseExceptionxszApyparsing_test.TestParseResultsAsserts.assertRaisesParseException)NNN)NT)NT)NN)rrrrár	rr
rrr<rrrrrÚTestParseResultsAssertss



>rN)rrrrárrrrrrr÷ÉsCr÷Ú__main__ÚselectÚfromz_$r4)r;ÚcolumnsrÖZtablesÚcommandaK
        # '*' as column list and dotted table name
        select * from SYS.XYZZY

        # caseless match on "SELECT", and casts back to "select"
        SELECT * from XYZZY, ABC

        # list of column names, and mixed case SELECT keyword
        Select AA,BB,CC from Sys.dual

        # multiple tables
        Select A, B, C from Sys.dual, Table2

        # invalid SELECT keyword - should fail
        Xelect A, B, C from Sys.dual

        # incomplete command - should fail
        Select

        # invalid column name - should fail
        Select ^^^ frox Sys.dual

        z]
        100
        -100
        +100
        3.14159
        6.02e23
        1e-12
        z 
        100
        FF
        z6
        12345678-1234-5678-1234-567812345678
        )NF)r“)r9F)N)FTF)T)r·)T(rárrr r¸Úweakrefrr%rRrŸr3rr´rr‚r¢rrÚoperatorrÚ	itertoolsÚ	functoolsrÚ
contextlibrrÚImportErrorrÚ_threadr	Ú	threadingÚcollections.abcr
rrr
rZordereddictrr!rìrrrrrrÐr^rÿrÚenable_all_warningsÚ__all__r;Úversion_infor¡reÚmaxsizerzrœrÚchrr_r›r¥rÿrÓr~Úreversedrrñr€rär¨r©r¯ZmaxintÚxranger)Ú__builtin__r¬Úfnamerír°rÏrßrr´Úascii_uppercaseÚascii_lowercaserRrprbrQrJrØÚ	printablertrrˆr:r<r>r@rCr
rr?ÚregisterrWrhrer–ršr›rorÁrAr2rIr)r4r1r…rsr·r.r$r#rŠrLr§rPrDrBr%rKrÜr,r0r/rGrFrNrMr=r"r9r3r(r;r*r2r5rr6rOrr8rEr+rJr&r-r'rHr7r€r^rZr)rmrlr¢rqr_r…r†rˆrÒrargrfrr~r¡Ú_escapedPuncÚ_escapedHexCharÚ_escapedOctCharÚ_singleCharÚ
_charRangerÕrgr}rkrzrxr‹r‚r`r}rirjrƒr~r‰rrr‰rŠr‡rsr\r|rwrrnr„rSrurUrTrr­r«r?rYryrVrcrKr{r]r[rdrvrrÒrXrŒrÔrŽrrïrìrÚrírîrrórërêrérôrðròrõr÷rZselectTokenZ	fromTokenÚidentZ
columnNameZcolumnNameListZ
columnSpecZ	tableNameZ
tableNameListZ	simpleSQLryrÈr°r²rÑr¾rrrrÚ<module>`s\









?]

H

D+!
'N
E 

KFym{VO#K,:#Dvj-D0$	W'*:
 
	


0#


E&h~

 (
 0 ./L"6,