2bi# ` S r SSKJr " S S\5 r\" SSSSS5 rSr\R r\rS rSS
K 7 SS
K
7 SS
K7 SSKJ
r
Jr SS
K7 SS
K7 SSKJr SS
K7 SSKJr SS
KJrJrJr SSKJr SSKJrJr S\" 5 ; a \rS\" 5 ; a \rS\" 5 ; a \r\\\- -
r/ SQrg)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 d \ rS rSr% \\S' \\S' \\S' \\S' \\S' \S 5 rS r S r
S
rg)version_infoc majorminormicroreleaselevelserialc U R SU R SU R 3U R S S:X a SOS U R S U R 3S4U R S:H - $ )N.r cr final)r r r r
r selfs ڐ/builddir/build/BUILDROOT/alt-python313-pip-23.3.1-3.el8.x86_64/opt/alt/python313/lib/python3.13/site-packages/pip/_vendor/pyparsing/__init__.py__version__version_info.__version__j s zzl!DJJt?P?PQR?S>TUYU`U`Tab 7*,
,
c : [ SU R S[ 3$ )N z / )__name__r __version_time__r s r __str__version_info.__str__t s" 1T--.c2B1CDDr c [ S[ U 5 R SSR S [ U R U 5 5 5 S3$ )Nr
(z, c 3 @ # U H nS R " U6 v M g7f)z{}={!r}N)format).0nvs r (version_info.__repr__..x s