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.4.zip
(1.3 MB
view details)
pyparsing-2.0.4.tar.gz
(1.1 MB
view details)
Built Distributions
pyparsing-2.0.4.win32-py3.5.exe
(235.1 kB
view details)
pyparsing-2.0.4.win32-py3.4.exe
(235.1 kB
view details)
pyparsing-2.0.4.win32-py3.3.exe
(235.1 kB
view details)
pyparsing-2.0.4.win32-py2.7.exe
(235.1 kB
view details)
pyparsing-2.0.4.win32-py2.6.exe
(104.6 kB
view details)
File details
Details for the file pyparsing-2.0.4.zip
.
File metadata
- Download URL: pyparsing-2.0.4.zip
- Upload date:
- Size: 1.3 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d0a9a14b7d75e31d7ffcde08ef7d4559eac07777fb800943eb940e83d666006c |
|
MD5 | 8cdbf6d6e52934f79473443d335e7cb1 |
|
BLAKE2b-256 | 1324b72c92417397a2bdf988ae99a7413f82805c7bd9a6ead77195ccdaa6b4e6 |
File details
Details for the file pyparsing-2.0.4.tar.gz
.
File metadata
- Download URL: pyparsing-2.0.4.tar.gz
- Upload date:
- Size: 1.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c43c9f1395975bf2b032c20e6b149d6b698cdabf9291079bcaf0131709e95f59 |
|
MD5 | f6db9de718e25d60208dd7ad306933a2 |
|
BLAKE2b-256 | 669e3a4e42da29d488838c21b52be6b82584ac5b4d605f347c75230e01380468 |
File details
Details for the file pyparsing-2.0.4.win32-py3.5.exe
.
File metadata
- Download URL: pyparsing-2.0.4.win32-py3.5.exe
- Upload date:
- Size: 235.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e3375fc37df267a61563f4f92cd07871089de6258f177c1a1012eea4a549f82b |
|
MD5 | 4c1f2b5be710d4f864320880400d7628 |
|
BLAKE2b-256 | 19c8a09b9ab22844147f6d9f32a6f6b78d4dc24e607747f8444efe15773a9a90 |
File details
Details for the file pyparsing-2.0.4.win32-py3.4.exe
.
File metadata
- Download URL: pyparsing-2.0.4.win32-py3.4.exe
- Upload date:
- Size: 235.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6e4da28af8213a5c7c2a353b3e21d3ff065cb325b9db144cfd11715cdd0a483f |
|
MD5 | 9436a8b1f3ed4b64778e73165fa1f355 |
|
BLAKE2b-256 | 1102c2a0d378df14d647a318b8f84b627c957e59a3f8c9b457c522fd12634b9f |
File details
Details for the file pyparsing-2.0.4.win32-py3.3.exe
.
File metadata
- Download URL: pyparsing-2.0.4.win32-py3.3.exe
- Upload date:
- Size: 235.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1174e46764b758959ec06bed25b013814e18b9e07449dcdb151bcc08b5a7421e |
|
MD5 | 98d01987b65b6d43b47d36750cbce938 |
|
BLAKE2b-256 | 24d0726960998b110d7c0e79f9f9fe45fd5cab5ea1131bd42897add0411cccf0 |
File details
Details for the file pyparsing-2.0.4.win32-py2.7.exe
.
File metadata
- Download URL: pyparsing-2.0.4.win32-py2.7.exe
- Upload date:
- Size: 235.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 820e8234e93b6219e2f79282cc5c7af6582ece83b93c718b3c7f7244b06933df |
|
MD5 | dbe29e002115f46aafea2949106af28b |
|
BLAKE2b-256 | 0e91a8490c7f6efb2da1136fcb380dc6c8975ecb729c7caac6faa2058b21354c |
File details
Details for the file pyparsing-2.0.4.win32-py2.6.exe
.
File metadata
- Download URL: pyparsing-2.0.4.win32-py2.6.exe
- Upload date:
- Size: 104.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ed0ceef0cf8a9bf19115cc47fbc3b00ec33793c872e9869644047a15ec7efd06 |
|
MD5 | b1eb1c9d4f9655f685d43135d0eb88e7 |
|
BLAKE2b-256 | ab7ba80acfd3dfca4f2ffe05b35fcc35c839f98645adf3947d68cfb00309f302 |
File details
Details for the file pyparsing-2.0.4-py2.py3-none-any.whl
.
File metadata
- Download URL: pyparsing-2.0.4-py2.py3-none-any.whl
- Upload date:
- Size: 38.3 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e5c2f4914ec227882874d75180ecbe1fc7cc425b6c35c8c37ed64c307d00b2b5 |
|
MD5 | 13b9539b210d86b6781f28cde96e2a26 |
|
BLAKE2b-256 | 3d9ae4159cf9a43d87784291acd56910e86cb246b5660e7170ae774eadf7314b |