관리-도구
편집 파일: pyparsing.cpython-36.pyc
3 3E�\l� � � @ s� d Z dZdZdZddlZddlmZ ddlZddl Z ddl Z ddlZddlZddl Z ddlZddlZddlZddlmZ yddlmZ W n ek r� dd lmZ Y nX ydd lmZ W n ek r� dd lmZ Y nX yddlmZ ddlmZ W n. ek �r& ddl mZ ddl mZ Y nX ydd l mZ W nB ek �rz ydd lmZ W n ek �rt dZY nX Y nX yddlmZ W n$ ek �r� G dd� d�ZY nX e� Z de _ de _!dddddddddddddd 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�gqZ"e#e j$�dd�� Z%e%d d�kZ&e&�r e j'Z(e)Z*e+Z,e)Z-e)Z.e/e0e1e2e3e#e4e5e6e7e8gZ9nbe j:Z(e;Z<d�d�� Z.g Z9ddl=Z=xBd�j>� D ]6Z?ye9j@eAe=e?�� W n eBk �rZ �w(Y nX �q(W eCd�d�� e<d��D ��ZDd�d�� ZEejFejG ZHd�ZIeId� ZJeHeI ZKe+d��ZLd�jMd�d�� ejND ��ZOG d�d/� d/eP�ZQG d�d1� d1eQ�ZRG d�d3� d3eQ�ZSG d�d5� d5eS�ZTG d�d8� d8eP�ZUG d�d�� d�eV�ZWG d�d4� d4eV�ZXejYeX� d�dL� ZZd�d]� Z[d�dZ� Z\d�d�� Z]d�d�� Z^d�d�� Z_d�dd� Z`�dMd�d��ZaG d�d6� d6eV�ZbG d�d>� d>eb�ZcG d�d� dec�ZdG d�d)� d)ec�ZeG d�d&� d&ec�ZfefZgefeb_hG d�d#� d#ec�ZiG d�d� def�ZjG d�d� dei�ZkG d�d� dec�ZlG d�dA� dAec�ZmG d�dE� dEem�ZnG d�d9� d9ec�ZoG d�d7� d7ec�ZpG d�d� dec�ZqG d�d@� d@ec�ZrG d�d�� d�ec�ZsG d�d!� d!es�ZtG d�d%� d%es�ZuG d�d$� d$es�ZvG d�d<� d<es�ZwG d�d;� d;es�ZxG d�dC� dCes�ZyG d�dB� dBes�ZzG d�d2� d2eb�Z{G d�d� de{�Z|G d�d.� d.e{�Z}G d�d(� d(e{�Z~G d�d� de{�ZG d�d0� d0eb�Z�G d�d� de��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�dD� dDe��Z�G d�d̈́ d�eV�Z�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�G d�d� de��Z�G d�d"� d"e��Z�G d�d� de��Z�G d�d=� d=e��Z�G d�d,� d,eV�Z�d�du� Z��dNd�dS�Z��dOd�dO�Z�d�d݄ Z�d�db� Z�d�da� Z�d�d� Z��dPd�df�Z�d�dT� Z��dQd�dz�Z�d�d{� Z�d�d}� Z�ed� j�dV�Z�eu� j�d\�Z�ev� j�d[�Z�ew� j�dt�Z�ex� j�ds�Z�emeLd�d�d�j�d�d� �Z�eod�j�d�d� �Z�eod�j�d�d� �Z�e�e�B e�B eqd�d�d�B Z�e�e�e�d� e� �Z�efd�e�d�j�d� e�e�e�e�B ��j�d� d� Z�d�dr� Z�d�d`� Z�d�do� Z�d�dm� Z�d�d�� Z�e�d�d� �Z�e�d�d� �Z�e�d��e�d��fd��d �Z��dd^� Z��dd_� Z��ddx� Z�eV� e�_��dR�dd~�Z�e� Z�eV� e�_�eV� e�_�e��d�e��d�f�dd|�Z�e�Z�e�eo�d��d �j��d �Z�e�eo�d��d �j��d �Z�e�eo�d��d eo�d��d B �j��d�Z�e�eg�d�e�j� �j��d�Z��d�dde�j� f�ddc�ZdS�ddy�Z�e��d�Z�e��d�Z�e�emeHeK�d �j��d��\Z�Z�e�eɐdj>� �d��Z�eo�d�djMe�j˃ � �d �j��d�Z̐ddn� Z�e�eo�d��d �j��d �Z�eo�d!�j��d"�Z�eo�d#�jЃ j��d$�Z�eo�d%�j��d&�Z�e�eo�d��d e�B �j��d'�Z�e�Z�eo�d(�j��d)�Z�e�e�emeOdؐd*�e�em�d+�efd ev� � ��jփ j��d,�Z�e�e�e�j� e�B d��d-��j�dM�Z�G �d.d�� d��Z�G �d/�d0� �d0eV�Z�G �d1d�� d�eV�Z�G �d2d�� d�eۃZ�e�j�j�j�e�j�j�j� e�j�j�j� e�j�_�e&�r�e�eܐd3e�j� e�eܐd4e�j� e�eܐd5e�j� e�eܐd6e�j� e�eܐd7e�j� e�eܐd8e�j݃ e�e�jݐd9e�j�jރ e�e�jݐd:e�j�j� e�e�jݐd;e�j�j� e�eܐd<e�j� e�eܐd=e�j� e�eܐd>e�j� e�d?k� r�ej�d@�Z�ej�dA�Z�emeHeK�dB �Z�e�e�dCd�dD�j�e��Z�e�e�e��j��dE�Z�dFe�B Z�e�e�dCd�dD�j�e��Z�e�e�e��j��dG�Z�e�dH�e�dE� e� e�dG� Z�e�j��dI� e�j�j��dJ� e�j�j��dJ� e�j�j��dK� ddl�Z�e�j�j�e�e�j��� e�j�j��dL� dS (T ay 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` - 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.0z07 Apr 2019 18:28 UTCz*Paul McGuire <ptmcg@users.sourceforge.net>� N)�ref)�datetime)�filterfalse)�ifilterfalse)�RLock)�Iterable)�MutableMapping)�OrderedDict)�SimpleNamespacec @ s e Zd ZdS )r N)�__name__� __module__�__qualname__� r r �-/usr/lib/python3.6/site-packages/pyparsing.pyr � s r a 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 to be released in pyparsing 2.4 T�__version__�__versionTime__� __author__� __compat__�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� c C s` t | t�r| S yt| �S tk rZ t| �jtj� d�}td�}|jdd� � |j |�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)�tr r r �<lambda>� s z_ustr.<locals>.<lambda>N) � isinstance�unicode�str�UnicodeEncodeError�encode�sys�getdefaultencodingr6 �setParseAction�transformString)�obj�retZ xmlcharrefr r r �_ustr� s r� z6sum len sorted reversed list tuple set any all min maxc c s | ] }|V qd S )Nr )�.0�yr r r � <genexpr>� s r� r� c C s>