Python parsing module
Project description
====================================
PyParsing -- A Python Parsing Module
====================================
Introduction
============
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. The pyparsing module provides a library of classes
that client code uses to construct the grammar directly in Python code.
Here is a program to parse "Hello, World!" (or any greeting of the form
"<salutation>, <addressee>!"):
from pyparsing import Word, alphas
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 '^' operator
definitions.
The parsed results returned from 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
The .zip file includes examples of a simple SQL parser, simple CORBA IDL
parser, a config file parser, a chemical formula parser, and a four-
function algebraic notation parser. It also includes a simple how-to
document, and a UML class diagram of the library's classes.
Installation
============
Do the usual:
python setup.py install
(pyparsing requires Python 2.3.2 or later.)
Documentation
=============
See:
HowToUsePyparsing.html
License
=======
MIT License. See header of pyparsing.py
History
=======
See CHANGES file.
PyParsing -- A Python Parsing Module
====================================
Introduction
============
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. The pyparsing module provides a library of classes
that client code uses to construct the grammar directly in Python code.
Here is a program to parse "Hello, World!" (or any greeting of the form
"<salutation>, <addressee>!"):
from pyparsing import Word, alphas
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 '^' operator
definitions.
The parsed results returned from 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
The .zip file includes examples of a simple SQL parser, simple CORBA IDL
parser, a config file parser, a chemical formula parser, and a four-
function algebraic notation parser. It also includes a simple how-to
document, and a UML class diagram of the library's classes.
Installation
============
Do the usual:
python setup.py install
(pyparsing requires Python 2.3.2 or later.)
Documentation
=============
See:
HowToUsePyparsing.html
License
=======
MIT License. See header of pyparsing.py
History
=======
See CHANGES file.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
pyparsing-2.0.2.zip
(1.3 MB
view details)
pyparsing-2.0.2.tar.gz
(1.1 MB
view details)
Built Distributions
pyparsing-2.0.2.win32-py3.4.exe
(232.5 kB
view details)
pyparsing-2.0.2.win32-py3.3.exe
(232.5 kB
view details)
pyparsing-2.0.2.win32-py3.2.exe
(232.5 kB
view details)
pyparsing-2.0.2.win32-py3.1.exe
(232.5 kB
view details)
pyparsing-2.0.2.win32-py3.0.exe
(232.5 kB
view details)
pyparsing-2.0.2.win32-py2.7.exe
(232.5 kB
view details)
pyparsing-2.0.2.win32-py2.6.exe
(232.5 kB
view details)
File details
Details for the file pyparsing-2.0.2.zip
.
File metadata
- Download URL: pyparsing-2.0.2.zip
- Upload date:
- Size: 1.3 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d61cce2ef4bc4eb27d99bc5130e30be1bfbe59fe41e804255f06061cbec0388f |
|
MD5 | e0e49d73cfb9e79954b4a1c553dfae44 |
|
BLAKE2b-256 | ca15f11ad041560a392ffa16638a2b500f6cdf4ba873609318187184919f9453 |
File details
Details for the file pyparsing-2.0.2.tar.gz
.
File metadata
- Download URL: pyparsing-2.0.2.tar.gz
- Upload date:
- Size: 1.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 17e43d6b17588ed5968735575b3983a952133ec4082596d214d7090b56d48a06 |
|
MD5 | b170c5d153d190df1a536988d88e95c1 |
|
BLAKE2b-256 | 518671f91a7eb610a925a7b94ac3153c36e72cec85d29d572fc4fd4929d7b255 |
File details
Details for the file pyparsing-2.0.2.win32-py3.4.exe
.
File metadata
- Download URL: pyparsing-2.0.2.win32-py3.4.exe
- Upload date:
- Size: 232.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7145b41ff85f2428e365f2b9bd16b69bd68f1150c3f8d05528273505ede15abe |
|
MD5 | 5f5b50e47e53cc92ab0d9170d5d502ad |
|
BLAKE2b-256 | 08e8ce1e2d195c0f80565bf48a0fbab49a703acdbda837e15bb64d32153bb541 |
File details
Details for the file pyparsing-2.0.2.win32-py3.3.exe
.
File metadata
- Download URL: pyparsing-2.0.2.win32-py3.3.exe
- Upload date:
- Size: 232.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1584a093537c6f0add04a514b91b55fda93e2331de7e5140f835d7d8662ea291 |
|
MD5 | 3af3caa9caef7081e46e98b87c3d3987 |
|
BLAKE2b-256 | 427eb4f6c3ba34a7a1230897697d1f25c5ab4646bb62a1d2b65f006bb8a2d4a8 |
File details
Details for the file pyparsing-2.0.2.win32-py3.2.exe
.
File metadata
- Download URL: pyparsing-2.0.2.win32-py3.2.exe
- Upload date:
- Size: 232.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3a203a88fc0f0b3c21909de3367ade6b51b2f32abb4e6932bcbf197273593f72 |
|
MD5 | 7b6495636c6a1bff1bd6370b067d3b34 |
|
BLAKE2b-256 | ed66b1499cfbab6dbadb8893e0df432772ecafbff5540bbc8ed444506d2e9d22 |
File details
Details for the file pyparsing-2.0.2.win32-py3.1.exe
.
File metadata
- Download URL: pyparsing-2.0.2.win32-py3.1.exe
- Upload date:
- Size: 232.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4dda9208817b3a1fe7d500408e4d5ebbb8e4549ba377e6a259ab2552e1275b0b |
|
MD5 | 8536b07be1e6227395d1825635aa8b3e |
|
BLAKE2b-256 | bd01dbb7bfd17b480160400661d78501a2621719e3054a55d4372d6e4d5a72be |
File details
Details for the file pyparsing-2.0.2.win32-py3.0.exe
.
File metadata
- Download URL: pyparsing-2.0.2.win32-py3.0.exe
- Upload date:
- Size: 232.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1039385c4702ba1834f1d5d6a832c3acdb499c7a8ffdd460ba6d381df3c30cda |
|
MD5 | d78cf4ffb8a6393b96a864aadd92a6ea |
|
BLAKE2b-256 | b6c7cb021d3fc6769f249a1b7e192f241143a3a7458607cfb9dd55c352af47b4 |
File details
Details for the file pyparsing-2.0.2.win32-py2.7.exe
.
File metadata
- Download URL: pyparsing-2.0.2.win32-py2.7.exe
- Upload date:
- Size: 232.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a4c2134b09d85dc250422cdd1ab1c4bc4603dd5016f881c2a987c472778a9a14 |
|
MD5 | a56ae0f440c8da6fc384b6b8e0533461 |
|
BLAKE2b-256 | 5f198027f10c38e03fa09bf976cf38444d90daf7998cbaf99cd54cbaa3abd920 |
File details
Details for the file pyparsing-2.0.2.win32-py2.6.exe
.
File metadata
- Download URL: pyparsing-2.0.2.win32-py2.6.exe
- Upload date:
- Size: 232.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8e395e5c5c7d95e62b4a6a5311afbf8644b6d5f8280e033aebfca38d1f637486 |
|
MD5 | b0ff69d0c233f38c759aab13dc7d69bf |
|
BLAKE2b-256 | afb4d455cddef1ef474f350f900116b3ee51f660ad9a58a23b5ce6543eb9bc4c |