bg#^dZddlmZGddeZedddddZdZejZeZd Zd d l Td d l Td d l Td d l m Z mZd d lTd d l Td d l mZd d lTd d lmZd dlmZmZmZd dlmZd dlmZmZdevreZdevreZdevreZeeezz ZgdZdS)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 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.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:`'+'`, :class:`'|'`, :class:`'^'`, and :class:`'&'` 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 ) NamedTuplecdeZdZUeed<eed<eed<eed<eed<edZdZdZ d S) version_infomajorminormicro releaselevelserialcd|j|j|jd|jddkrdnd|jd|jdf|jdkzS)Nz{}.{}.{}z{}{}{}rcrfinal)formatrrrr r selfs c/builddir/build/BUILD/cloudlinux-venv-1.0.7/venv/lib/python3.11/site-packages/pyparsing/__init__.py __version__zversion_info.__version__js   dj$*dj A A,Q/366CCB%a(K  7*, , cNdt|jtS)Nz {} {} / {})r__name__r__version_time__rs r__str__zversion_info.__str__xs""8T-=?OPPPrc dtt|jddt |j|DS)Nz {}.{}({})z, c3*K|]}dj|VdS)z{}={!r}N)r).0nvs r z(version_info.__repr__..s-NN&i&+NNNNNNr)rrtypejoinzip_fieldsrs r__repr__zversion_info.__repr__{sS!!  JJ  IINNc$,6M6MNNN N N   rN) r __module__ __qualname__int__annotations__strpropertyrrr#rrrrcs JJJ JJJ JJJ KKK    X  QQQ     rr rz05 May 2022 07:02 UTCz+Paul McGuire )*)__diag__ __compat__)_builtin_exprs) unicode_setUnicodeRangeListpyparsing_unicode)pyparsing_test)pyparsing_commonr1r4r6r5)rr __author__r0r/And AtLineStart AtStringStartCaselessKeywordCaselessLiteral CharsNotInCombineDictEachEmpty FollowedByForward GoToColumnGroup IndentedBlockKeywordLineEnd LineStartLiteralLocated PrecededBy MatchFirstNoMatchNotAny OneOrMoreOnlyOnceOpAssocOptOptionalOrParseBaseExceptionParseElementEnhanceParseExceptionParseExpressionParseFatalException ParseResultsParseSyntaxException ParserElement PositionToken QuotedStringRecursiveGrammarExceptionRegexSkipTo StringEnd StringStartSuppressTokenTokenConverterWhiteWordWordEnd WordStart ZeroOrMoreChar alphanumsalphas alphas8bit any_close_tag any_open_tagc_style_commentcolcommon_html_entity counted_arraycpp_style_commentdbl_quoted_stringdbl_slash_commentdelimited_listdict_ofemptyhexnums html_comment identcharsidentbodycharsjava_style_commentlineline_end line_startlinenomake_html_tags make_xml_tagsmatch_only_at_colmatch_previous_exprmatch_previous_literal nested_exprnull_debug_actionnumsone_of printablespunc8bitpython_style_comment quoted_string remove_quotes replace_withreplace_html_entity rest_of_linesgl_quoted_stringsrange string_end string_starttrace_parse_actionunicode_stringwith_attribute indentedBlockoriginal_text_forungroupinfix_notation locatedExpr with_class CloseMatch token_mapr6r4r2condition_as_parse_actionr5__versionTime__ anyCloseTag anyOpenTag cStyleCommentcommonHTMLEntity countedArraycppStyleCommentdblQuotedStringdblSlashComment delimitedListdictOf htmlCommentjavaStyleCommentlineEnd lineStart makeHTMLTags makeXMLTagsmatchOnlyAtColmatchPreviousExprmatchPreviousLiteral nestedExprnullDebugActiononeOfopAssocpythonStyleComment quotedString removeQuotesreplaceHTMLEntity replaceWith restOfLinesglQuotedString stringEnd stringStarttraceParseAction unicodeString withAttributeroriginalTextFor infixNotationr withClasstokenMapconditionAsParseActionautoname_elementsN)__doc__typingrr__version_info__rrrr7util exceptionsactionscorer/r0resultsr1core_builtin_exprshelpershelper_builtin_exprsunicoder2r3r4testingr5commonr6common_builtin_exprsglobals__all__r*rrrs2F N     :   @ <1a!44** " : &&&&&&&&666666;;;;;;PPPPPPPPPP...... ggii''WWYY&&7799$$N*-AAAf f f r