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.0.zip
(1.3 MB
view details)
pyparsing-2.0.0.tar.gz
(1.1 MB
view details)
Built Distributions
pyparsing-2.0.0.win32-py3.3.exe
(225.8 kB
view details)
pyparsing-2.0.0.win32-py3.2.exe
(100.4 kB
view details)
pyparsing-2.0.0.win32-py3.1.exe
(100.4 kB
view details)
pyparsing-2.0.0.win32-py3.0.exe
(100.4 kB
view details)
File details
Details for the file pyparsing-2.0.0.zip
.
File metadata
- Download URL: pyparsing-2.0.0.zip
- Upload date:
- Size: 1.3 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3f3784293789a0ecd4877a5df1be86ad10eeb4c712d8b5ca095879eabc871e5a |
|
MD5 | f9bc56d9f6c977085001db49a63d7bb9 |
|
BLAKE2b-256 | b524e267a8f83eb95051504843bd1721c6e55c8f364ef0e58a76ce6f915f6459 |
File details
Details for the file pyparsing-2.0.0.tar.gz
.
File metadata
- Download URL: pyparsing-2.0.0.tar.gz
- Upload date:
- Size: 1.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 36916527202d6e19c1f0e968109ccec52aaba835a935a58186147556c51027b6 |
|
MD5 | 97b95184cb41edcd7bd162b1fa1f45ee |
|
BLAKE2b-256 | ea326b33b76b5a34c5ff29f11ef35fe79cc864331b00e8461208a06a603b6726 |
File details
Details for the file pyparsing-2.0.0.win32-py3.3.exe
.
File metadata
- Download URL: pyparsing-2.0.0.win32-py3.3.exe
- Upload date:
- Size: 225.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fce2cdcd1305c0372fe79e1375a103ba52d1e44fe2cdc281cc5f0cf055458f73 |
|
MD5 | 380800a14f44ad6435184e6e14c14ba1 |
|
BLAKE2b-256 | c9a63356b92e9df8ce4629fc80d410ce55e11e13044aa0cd923495393bee31e1 |
File details
Details for the file pyparsing-2.0.0.win32-py3.2.exe
.
File metadata
- Download URL: pyparsing-2.0.0.win32-py3.2.exe
- Upload date:
- Size: 100.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9fbf8539a74e4b0e7c264a80f1be3fec1266df38f4c9889bdc7a50450b6d97be |
|
MD5 | 2f9ee82158715137065753653cafad19 |
|
BLAKE2b-256 | b674b8e7bbaf8aaf64aa6c47238906857e57713d912213f8265b88e61987d7ff |
File details
Details for the file pyparsing-2.0.0.win32-py3.1.exe
.
File metadata
- Download URL: pyparsing-2.0.0.win32-py3.1.exe
- Upload date:
- Size: 100.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c4dd78688b78312b35496f37cada39744fa2e5f5ecb1ab404f4026aa0d145d1a |
|
MD5 | 50f0e4fec454d6e401d9b780480c8092 |
|
BLAKE2b-256 | b94bb9ad171c2f1e53ce9e5d028284365136faa4d157a7755fda96b7ec1e52af |
File details
Details for the file pyparsing-2.0.0.win32-py3.0.exe
.
File metadata
- Download URL: pyparsing-2.0.0.win32-py3.0.exe
- Upload date:
- Size: 100.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 04f8d8663dfccfdfd28201e42885fd3db59d73fa27a21cccf6f9cc442fa6f4fe |
|
MD5 | 62afffa3047bdd991040b20a3f58a09b |
|
BLAKE2b-256 | be85038c547b6557be8d485edbb42da326680c293f5e0339bb2fc3cd30817af7 |