R`i#TdZddlmZGddeZedddddZdZej ZeZd Zdd l dd l dd l dd l m Z mZdd ldd l dd l mZdd ldd lmZdd lmZmZmZddlmZddlmZmZdevreZdevreZdevreZeeezz ZgdZy)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 ``", !"``), built up using :class:`Word`, :class:`Literal`, and :class:`And` elements (the :meth:`'+'` operators create :class:`And` expressions, and the strings are auto-converted to :class:`Literal` expressions):: from pip._vendor.pyparsing import Word, alphas # define grammar of a greeting greet = Word(alphas) + "," + Word(alphas) + "!" hello = "Hello, World!" print(hello, "->", greet.parse_string(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 :class:`'+'`, :class:`'|'`, :class:`'^'` and :class:`'&'` operators. The :class:`ParseResults` object returned from :class:`ParserElement.parse_string` 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:`'+'`, :class:`'|'`, :class:`'^'`, and :class:`'&'` operators to combine simple expressions into more complex ones - associate names with your parsed results using :class:`ParserElement.set_results_name` - access the parsed data, which is returned as a :class:`ParseResults` object - find some helpful expression short-cuts like :class:`DelimitedList` and :class:`one_of` - find more useful common expressions in the :class:`pyparsing_common` namespace class ) NamedTuplec\eZdZUeed<eed<eed<eed<eed<edZdZdZ y ) version_infomajorminormicro releaselevelserialc|jd|jd|j|jddk(rdnd|jd|jdf|jdk(zS)N.rcrfinal)rrrr r selfs /builddir/build/BUILDROOT/alt-python312-pip-23.3.1-3.el8.x86_64/opt/alt/python312/lib/python3.12/site-packages/pip/_vendor/pyparsing/__init__.py __version__zversion_info.__version__jszzl!DJJt?P?PQR?S>TUYU`U`Tab7*, , c:td|jdtS)N z / )__name__r__version_time__rs r__str__zversion_info.__str__ts"1T--.c2B1CDDrc tdt|jddjdt|j|DdS)Nr (z, c3:K|]}dj|yw)z{}={!r}N)format).0nvs r z(version_info.__repr__..xs")*)__diag__ __compat__)_builtin_exprs) unicode_setUnicodeRangeListpyparsing_unicode)pyparsing_test)pyparsing_commonr4r7r9r8)rr __author__r3r2And AtLineStart AtStringStartCaselessKeywordCaselessLiteral CharsNotIn CloseMatchCombine DelimitedListDictEachEmpty FollowedByForward GoToColumnGroup IndentedBlockKeywordLineEnd LineStartLiteralLocated PrecededBy MatchFirstNoMatchNotAny OneOrMoreOnlyOnceOpAssocOptOptionalOrParseBaseExceptionParseElementEnhanceParseExceptionParseExpressionParseFatalException ParseResultsParseSyntaxException ParserElement PositionToken QuotedStringRecursiveGrammarExceptionRegexSkipTo StringEnd StringStartSuppressTokenTokenConverterWhiteWordWordEnd WordStart ZeroOrMoreChar alphanumsalphas alphas8bit any_close_tag any_open_tagautoname_elementsc_style_commentcolcommon_html_entitycondition_as_parse_action counted_arraycpp_style_commentdbl_quoted_stringdbl_slash_commentdelimited_listdict_ofemptyhexnums html_comment identcharsidentbodycharsinfix_notationjava_style_commentlineline_end line_startlinenomake_html_tags make_xml_tagsmatch_only_at_colmatch_previous_exprmatch_previous_literal nested_exprnull_debug_actionnumsone_oforiginal_text_for printablespunc8bitr9r8r7python_style_comment quoted_string remove_quotes replace_withreplace_html_entity rest_of_linesgl_quoted_stringsrange string_end string_start token_maptrace_parse_actionungroupr5unicode_stringwith_attribute with_class__versionTime__ anyCloseTag anyOpenTag cStyleCommentcommonHTMLEntityconditionAsParseAction countedArraycppStyleCommentdblQuotedStringdblSlashComment delimitedListdictOf htmlComment indentedBlock infixNotationjavaStyleCommentlineEnd lineStart locatedExpr makeHTMLTags makeXMLTagsmatchOnlyAtColmatchPreviousExprmatchPreviousLiteral nestedExprnullDebugActiononeOfopAssocoriginalTextForpythonStyleComment quotedString removeQuotesreplaceHTMLEntity replaceWith restOfLinesglQuotedString stringEnd stringStarttokenMaptraceParseAction unicodeString withAttribute withClassN)__doc__typingrr__version_info__rrrr:util exceptionsactionscorer2r3resultsr4core_builtin_exprshelpershelper_builtin_exprsunicoder5r6r7testingr8commonr9common_builtin_exprsglobals__all__r.rrrs2F Ny:y0 1a!4*** " : &6;PP. gi'WY&79$N*-AAAe r