관리-도구
편집 파일: pyparsing.cpython-310.pyc
o ~�Rex� � @ s� d Z dZdZdZddlZddlmZ ddlZddl Z ddl Z ddlZddlZddl Z ddlZddlZddlZddlmZ zddlmZ W n eyS ddlmZ Y nw zdd lmZ dd lmZ W n eyw dd l mZ dd l mZ Y nw zddl mZ W n ey� zddlmZ W n ey� dZY nw Y nw g d�Zee j�dd � Zed d kZ e r�e j!Z"e#Z$e%Z&e#Z'e(e)e*e+e,ee-e.e/e0e1gZ2n)e j3Z"e4Z5dd� Z'g Z2ddl6Z6d�7� D ]Z8z e2�9e:e6e8�� W q� e;y� Y q�w e<dd� e5d�D ��Z=dd� Z>G dd� de?�Z@ejAejB ZCdZDeDd ZEeCeD ZFe%d�ZGd�Hdd� ejID ��ZJG dd� deK�ZLG dd � 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-d.� ZUd/d0� ZVd1d2� ZWd3d4� ZXd5d6� ZYd7d8� ZZ �dd:d;�Z[G d<d=� d=e?�Z\G d>d?� d?e\�Z]G d@dA� dAe]�Z^G dBdC� dCe]�Z_G dDdE� dEe]�Z`e`Zae`e\_bG dFdG� dGe]�ZcG dHdI� dIe`�ZdG dJdK� dKec�ZeG dLdM� dMe]�ZfG dNdO� dOe]�ZgG dPdQ� dQe]�ZhG dRdS� dSe]�ZiG dTdU� dUe]�ZjG dVdW� dWe]�ZkG dXdY� dYe]�ZlG dZd[� d[el�ZmG d\d]� d]el�ZnG d^d_� d_el�ZoG d`da� dael�ZpG dbdc� dcel�ZqG ddde� deel�ZrG dfdg� dgel�ZsG dhdi� die\�ZtG djdk� dket�ZuG dldm� dmet�ZvG dndo� doet�ZwG dpdq� dqet�ZxG drds� dse\�ZyG dtdu� duey�ZzG dvdw� dwey�Z{G dxdy� dyey�Z|G dzd{� d{e|�Z}G d|d}� d}e|�Z~G d~d� de?�Ze� Z�G d�d�� d�ey�Z�G d�d�� d�ey�Z�G d�d�� d�ey�Z�G d�d�� d�e��Z�G d�d�� d�ey�Z�G d�d�� d�e��Z�G d�d�� d�e��Z�G d�d�� d�e��Z�G d�d�� d�e��Z�G d�d�� d�e?�Z�d�d�� Z��dd�d��Z��dd�d��Z�d�d�� Z�d�d�� Z�d�d�� Z�d�d�� Z��dd�d��Z�d�d�� Z��dd�d��Z�d�d�� Z�d�d�� Z�e^� ��d��Z�en� ��d��Z�eo� ��d��Z�ep� ��d��Z�eq� ��d��Z�egeGd�d9d����d�d�� �Z�ehd����d�d�� �Z�ehd����d�d�� �Z�e�e�B e�B ejd�dd��B Z�e�e�e�d�� e� �Z�e`d��e�d����d�� e�e}e�e�B ����d�� d� Z�d�dĄ Z�d�dƄ Z�d�dȄ Z�d�dʄ Z�d�d̄ Z�e�d�d�� �Z� e�d�d�� �Z� d�dЄ Z�d�d҄ Z�d�dԄ Z�d�dք Z�e?� e�_��dd�dZ�e@� Z�e?� e�_�e?� e�_�e�dكe�dڃfd�d܄Z�e�Z� e�ehd݃d� ���dߡZ�e�ehd�d� ���d�Z�e�ehd݃d� ehd�d� B ���d�Z�e�ead�e��� ���d�Z�d�d�de��� fd�d�Z��dd�d�Z�e�d�Z�e�d�Z�e�egeCeFd� ���d��\Z�Z�e�e�d�7� d��Z�ehd�d�Heàġ � d� ���d�Z�d�d�� Z�e�ehd��d� ���d��Z� ehd����d��Z� ehd���ɡ ��d��Z�ehd����d��Z� e�ehd��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�d� �d�Z�eӐd k�rhed�d �Z�ed�d�Z�egeCeF�d �Z�e�ed d��d���e��Z�e�e�e׃����d�Zؐde�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 dS ( 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 <ptmcg@users.sourceforge.net>� N)�ref)�datetime)�RLock)�Iterable)�MutableMapping)�OrderedDict)i�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 s` t | t�r| S zt| �W S ty/ t| ��t�� d�}td�}|�dd� � |� |� Y S w )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 ��/builddir/build/BUILDROOT/alt-python310-setuptools-58.3.0-2.el8.x86_64/opt/alt/python310/lib/python3.10/site-packages/setuptools/_vendor/pyparsing.py�<lambda>� � $ z_ustr.<locals>.<lambda>) � isinstance�unicode�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� � � � z_xml_escape.<locals>.<genexpr>zamp gt lt quot apos)�split�zip�replace)�data�from_symbols� to_symbols�from_�to_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 jvr|V qd S r� )�string� whitespace�r� �cry ry rz r� � � � 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>