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
The latest version of pyparsing (2.0.1) requires Python 2.6 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
The latest version of pyparsing (2.0.1) requires Python 2.6 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.1.zip
(1.3 MB
view details)
pyparsing-2.0.1.tar.gz
(1.1 MB
view details)
Built Distributions
pyparsing-2.0.1.win32-py3.3.exe
(226.6 kB
view details)
pyparsing-2.0.1.win32-py3.2.exe
(101.1 kB
view details)
pyparsing-2.0.1.win32-py3.1.exe
(101.1 kB
view details)
pyparsing-2.0.1.win32-py3.0.exe
(101.1 kB
view details)
pyparsing-2.0.1.win32-py2.7.exe
(101.1 kB
view details)
pyparsing-2.0.1.win32-py2.6.exe
(101.1 kB
view details)
File details
Details for the file pyparsing-2.0.1.zip
.
File metadata
- Download URL: pyparsing-2.0.1.zip
- Upload date:
- Size: 1.3 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7e1766ee747cca79fe172b670fd53ef58fc55d2b1804fd6c66d857abb62d143a |
|
MD5 | dc7036a6f1ab01c3baed3d97af8d77c0 |
|
BLAKE2b-256 | d99c1291ec873984c90dd9886b49e58e45306859a5a1c6f9bfbe02e87ee88aad |
File details
Details for the file pyparsing-2.0.1.tar.gz
.
File metadata
- Download URL: pyparsing-2.0.1.tar.gz
- Upload date:
- Size: 1.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0007cd3f008eba4a203f1f6b4b133ddc352552c8808b694c88c23db56416e4e4 |
|
MD5 | 37adec94104b98591507218bc82e7c31 |
|
BLAKE2b-256 | 44c7e2bc51c8aa50b1f5ced031310e2272e883ef2d64f070f882ef1e4301063e |
File details
Details for the file pyparsing-2.0.1.win32-py3.3.exe
.
File metadata
- Download URL: pyparsing-2.0.1.win32-py3.3.exe
- Upload date:
- Size: 226.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ce87c81d6672b239ba0e64bcd2597c8f5a2ec89ed43bd82b859b22f0dea94e8f |
|
MD5 | eeffd123f69eb13985748e5213953267 |
|
BLAKE2b-256 | b1416c638762b6e6ac6e23899774a2fad173bb1d074b829045e4b33e8b10ff9b |
File details
Details for the file pyparsing-2.0.1.win32-py3.2.exe
.
File metadata
- Download URL: pyparsing-2.0.1.win32-py3.2.exe
- Upload date:
- Size: 101.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9b8ca2f046acd1977552cb140c2cd16dd0fd69d088b38002a45dcd50022bb8fe |
|
MD5 | a65f5afb575224e55c3cec133ad3eff2 |
|
BLAKE2b-256 | 5df685d159dce442b0d491b1cfccb88f211cb51ee9f88344942f7d96c6b259fc |
File details
Details for the file pyparsing-2.0.1.win32-py3.1.exe
.
File metadata
- Download URL: pyparsing-2.0.1.win32-py3.1.exe
- Upload date:
- Size: 101.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cf02c4af694a402761a6462958e2d78637515dd3f69d04e0a36150b217e904ac |
|
MD5 | cfeab4a7dbf48b3ccd989e174c6237ca |
|
BLAKE2b-256 | 91f80dc5c13b5406c423e7cbcd02daee18105af1c5fedc7954c904b3128b31b3 |
File details
Details for the file pyparsing-2.0.1.win32-py3.0.exe
.
File metadata
- Download URL: pyparsing-2.0.1.win32-py3.0.exe
- Upload date:
- Size: 101.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 18d8e2b0506395c05d5410cab29c5c67279dae168bfff7a2177ac5c694857b0a |
|
MD5 | 7b580090ef059879deccc0f252ae3ff8 |
|
BLAKE2b-256 | 29b467d18026614e6b5300d4faaabb2729e0c68fe8381db884693fbddbfdb114 |
File details
Details for the file pyparsing-2.0.1.win32-py2.7.exe
.
File metadata
- Download URL: pyparsing-2.0.1.win32-py2.7.exe
- Upload date:
- Size: 101.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0df0417ded92a2ae72cdf762bf84d116f8accb7b13b9bd185966492a00a7ee2b |
|
MD5 | e312e220208383c0b87f3c36996cf47a |
|
BLAKE2b-256 | 2634fd52fe64e1bff3e69bd1e937e1e56d954d5c0862ccf9e76e0b74c13ed8e5 |
File details
Details for the file pyparsing-2.0.1.win32-py2.6.exe
.
File metadata
- Download URL: pyparsing-2.0.1.win32-py2.6.exe
- Upload date:
- Size: 101.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 090d83f491259b16cfabfbd575a7c591f61982707090bfc1512d8b519cda4f44 |
|
MD5 | bcd0f2702bf022b5eb32782b466c413f |
|
BLAKE2b-256 | e5d0b1ab0a5b45c41025c627c0421e628c6f053d61967077ec637bbf9eea03de |