XylotrechusZ
U
�Qabw� � i @ s� d Z dZdZdZddlZddlmZ ddlZddl Z ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlmZ zddlmZ W n ek
r� ddlmZ Y nX zdd lmZ dd
lmZ W n, ek
r� dd l
mZ dd
l
mZ Y nX zddl
mZ W nB ek
�rF zddlmZ W n ek
�r@ dZY nX Y nX dd
ddddddddddddddddddd 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`dadbdcdddedfdgdhdidjdkdldmdndodpdqdrdsdtgiZee j�ddu� Zed dukZ e �rpe j!Z"e#Z$e%Z&e#Z'e(e)e*e+e,ee-e.e/e0e1gZ2n`e j3Z"e4Z5dvdw� Z'g Z2ddl6Z6dx�7� D ]8Z8ze2�9e:e6e8�� W n e;k
�r� Y �q�Y nX �q�e<dydz� e5d{�D ��Z=d|d}� Z>G d~d� de?�Z@ejAejB ZCd�ZDeDd� ZEeCeD ZFe%d��ZGd��Hd�dz� ejID ��ZJG d�d#� d#eK�ZLG d�d%� d%eL�ZMG d�d'� d'eL�ZNG d�d)� d)eN�ZOG d�d,� d,eK�ZPG d�d�� d�e?�ZQG d�d(� d(e?�ZRe�SeR� d�d?� ZTd�dP� ZUd�dM� ZVd�d�� ZWd�d�� ZXd�d�� ZYd�dW� ZZ�d/d�d��Z[G d�d*� d*e?�Z\G d�d2� d2e\�Z]G d�d� de]�Z^G d�d� de]�Z_G d�d� de]�Z`e`Zae`e\_bG d�d� de]�ZcG d�d� de`�ZdG d�d
� d
ec�ZeG d�dr� dre]�ZfG d�d5� d5e]�ZgG d�d-� d-e]�ZhG d�d+� d+e]�ZiG d�d� de]�ZjG d�d4� d4e]�ZkG d�d�� d�e]�ZlG d�d� del�ZmG d�d� del�ZnG d�d� del�ZoG d�d0� d0el�ZpG d�d/� d/el�ZqG d�d7� d7el�ZrG d�d6� d6el�ZsG d�d&� d&e\�ZtG d�d� det�ZuG d�d"� d"et�ZvG d�d� det�ZwG d�d� det�ZxG d�d$� d$e\�ZyG d�d� dey�ZzG d�d� dey�Z{G d�d�� d�ey�Z|G d�d� de|�Z}G d�d8� d8e|�Z~G d�d�� d�e?�Ze� Z�G d�d!� d!ey�Z�G d�d.� d.ey�Z�G d�d� dey�Z�G d�dÄ d�e��Z�G d�d3� d3ey�Z�G d�d� de��Z�G d�d� de��Z�G d�d� de��Z�G d�d1� d1e��Z�G d�d � d e?�Z�d�dh� Z��d0d�dF�Z��d1d�dB�Z�d�dЄ Z�d�dU� Z�d�dT� Z�d�dԄ Z��d2d�dY�Z�d�dG� Z��d3d�dm�Z�d�dn� Z�d�dp� Z�e^� ��dI�Z�en� ��dO�Z�eo� ��dN�Z�ep� ��dg�Z�eq� ��df�Z�egeGd�d�d܍��d�dބ �Z�ehd߃��d�dބ �Z�ehd���d�dބ �Z�e�e�B e�B ejd�d{d܍B Z�e�e�e�d� e� �Z�e`d�e�d���d� e�e}e�e�B ����d� d� Z�d�de� Z�d�dS� Z�d�db� Z�d�d`� Z�d�ds� Z�e�d�dބ �Z�e�d�dބ �Z�d�d� Z�d�dQ� Z�d�dR� Z�d�dk� Z�e?� e�_��d4d�dq�Z�e@� Z�e?� e�_�e?� e�_�e�d��e�d��fd�do�Z�e�Z�e�ehd��d� ���d��Z�e�ehd��d� ���d��Z�e�ehd��d� ehd��d� B ����d �Z�e�ea�d�e��� ����d�Z�d�d�de��� f�ddV�Z��d5�ddl�Z�e��d�Z�e��d�Z�e�egeCeF�d ����d��\Z�Z�e�ed �7� �d
��Z�eh�d�d�Heàġ � �d
����d�ZŐdda� Z�e�eh�d��d ����d�Z�eh�d����d�Z�eh�d��ɡ ���d�Z�eh�d����d�Z�e�eh�d��d e�B ����d�Z�e�Z�eh�d����d�Z�e�e}egeJdːd�e�eg�d�e`d˃ eo� � ���ϡ ���d�Z�e�e�e��� e�B d��d����d@�Z�G �d dt� dt�Z�eӐd!k�r�ed�d"�Z�ed�d#�Z�egeCeF�d$ �Z�e�ed%dՐd&���e��Z�e�e�e׃����d'�Zؐd(e�B Z�e�ed%dՐd&���e��Z�e�e�eڃ����d)�Z�eԐd*�eِd'� e� eېd)� Z�eܠݐd+� e�jޠݐd,� e�jߠݐd,� e�j�ݐd-� ddl�Z�e�je�e�j�� e�j�ݐd.� dS (6 a�
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
C{"<salutation>, <addressee>!"}), built up using L{Word}, L{Literal}, and L{And} elements
(L{'+'<ParserElement.__add__>} operator gives L{And} expressions, strings are auto-converted to
L{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 L{ParseResults} object returned from L{ParserElement.parseString<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 L{ParserElement} and L{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 L{Literal} and L{CaselessLiteral} classes
- construct character word-group expressions using the L{Word} class
- see how to create repetitive expressions using L{ZeroOrMore} and L{OneOrMore} classes
- use L{'+'<And>}, L{'|'<MatchFirst>}, L{'^'<Or>}, and L{'&'<Each>} operators to combine simple expressions into more complex ones
- associate names with your parsed results using L{ParserElement.setResultsName}
- find some helpful expression short-cuts like L{delimitedList} and L{oneOf}
- find more useful common expressions in the L{pyparsing_common} namespace class
z2.2.1z18 Sep 2018 00:49 UTCz*Paul McGuire <[email protected]>� N)�ref)�datetime)�RLock)�Iterable)�MutableMapping)�OrderedDict�And�CaselessKeyword�CaselessLiteral�
CharsNotIn�Combine�Dict�Each�Empty�
FollowedBy�Forward�
GoToColumn�Group�Keyword�LineEnd� LineStart�Literal�
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� 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� c C sf t | t�r| S z
t| �W S tk
r` t| ��t�� d�}td�}|�dd� � |� |� Y S X dS )a Drop-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+;c S s$ dt t| d dd� ��dd � S )Nz\ur � ���)�hex�int��t� ry �@/usr/lib/python3.8/site-packages/setuptools/_vendor/pyparsing.py�<lambda>� � z_ustr.<locals>.<lambda>N)
�
isinstanceZunicode�str�UnicodeEncodeError�encode�sys�getdefaultencodingr) �setParseAction�transformString)�obj�retZ
xmlcharrefry ry rz �_ustr� s
r� z6sum len sorted reversed list tuple set any all min maxc c s | ]
}|V qd S �Nry )�.0�yry ry rz � <genexpr>� s r� � c C s: d}dd� d� � D �}t||�D ]\}}| �||�} q | S )z/Escape &, <, >, ", ', etc. in a string of data.z&><"'c s s | ]}d | d V qdS )�&�;Nry )r� �sry ry rz r� � s z_xml_escape.<locals>.<genexpr>zamp gt lt quot apos)�split�zip�replace)�dataZfrom_symbolsZ
to_symbolsZfrom_Zto_ry ry rz �_xml_escape� s
r� c @ s e Zd ZdS )�
_ConstantsN)�__name__�
__module__�__qualname__ry ry ry rz r� � s r� �
0123456789ZABCDEFabcdef�\ � c c s | ]}|t jkr|V qd S r� )�stringZ
whitespace�r� �cry ry rz r� � s
c @ sP e Zd ZdZddd�Zedd� �Zdd � Zd
d� Zdd
� Z ddd�Z
dd� ZdS )r z7base exception class for all parsing runtime exceptionsr Nc C s>