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.6 or later.)
Or corresponding commands using pip, easy_install, or wheel:
pip install pyparsing
easy_install pyparsing
wheel install pyparsing
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.6 or later.)
Or corresponding commands using pip, easy_install, or wheel:
pip install pyparsing
easy_install pyparsing
wheel install pyparsing
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 Distribution
pyparsing-2.2.0.tar.gz
(1.2 MB
view details)
Built Distributions
pyparsing-2.2.0.win32-py3.5.exe
(517.5 kB
view details)
pyparsing-2.2.0.win32-py3.4.exe
(248.1 kB
view details)
pyparsing-2.2.0.win32-py3.3.exe
(248.1 kB
view details)
pyparsing-2.2.0.win32-py2.7.exe
(253.3 kB
view details)
pyparsing-2.2.0.win32-py2.6.exe
(253.3 kB
view details)
File details
Details for the file pyparsing-2.2.0.tar.gz
.
File metadata
- Download URL: pyparsing-2.2.0.tar.gz
- Upload date:
- Size: 1.2 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
0832bcf47acd283788593e7a0f542407bd9550a55a8a8435214a1960e04bcb04
|
|
MD5 |
0214e42d63af850256962b6744c948d9
|
|
BLAKE2b-256 |
3ceca94f8cf7274ea60b5413df054f82a8980523efd712ec55a59e7c3357cf7c
|
File details
Details for the file pyparsing-2.2.0.win32-py3.5.exe
.
File metadata
- Download URL: pyparsing-2.2.0.win32-py3.5.exe
- Upload date:
- Size: 517.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
e4d45427c6e20a59bf4f88c639dcc03ce30d193112047f94012102f235853a58
|
|
MD5 |
855002f511d806ce830958f7f541af02
|
|
BLAKE2b-256 |
5f9b8818b69b5cdbe2852106ecca849bdf990c4fc7cb1fb1bc8813bf117be19c
|
File details
Details for the file pyparsing-2.2.0.win32-py3.4.exe
.
File metadata
- Download URL: pyparsing-2.2.0.win32-py3.4.exe
- Upload date:
- Size: 248.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
8f1e18d3fd36c6795bb7e02a39fd05c611ffc2596c1e0d995d34d67630426c18
|
|
MD5 |
756f1d0378f437c5693e901811f0ef47
|
|
BLAKE2b-256 |
002aa7a10fb073d3744c134297236263ede6ce67fec3e40839dda5d56fe86a5c
|
File details
Details for the file pyparsing-2.2.0.win32-py3.3.exe
.
File metadata
- Download URL: pyparsing-2.2.0.win32-py3.3.exe
- Upload date:
- Size: 248.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
b8b3117ed9bdf45e14dcc89345ce638ec7e0e29b2b579fa1ecf32ce45ebac8a5
|
|
MD5 |
f2a7560c3f0e25d679f6dad04467f613
|
|
BLAKE2b-256 |
2271a8354e9f5f58f3dd6a2c7e0ef47d31164ec5785ad737f58f3e51fe6c0e14
|
File details
Details for the file pyparsing-2.2.0.win32-py2.7.exe
.
File metadata
- Download URL: pyparsing-2.2.0.win32-py2.7.exe
- Upload date:
- Size: 253.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
281683241b25fe9b80ec9d66017485f6deff1af5cde372469134b56ca8447a07
|
|
MD5 |
19de1501641e97a0c2d0b8567c13f227
|
|
BLAKE2b-256 |
81af21aa186ef834f9fa046392ca2493b298e6258d6401d291e7deb020ecf383
|
File details
Details for the file pyparsing-2.2.0.win32-py2.6.exe
.
File metadata
- Download URL: pyparsing-2.2.0.win32-py2.6.exe
- Upload date:
- Size: 253.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
9e8143a3e15c13713506886badd96ca4b579a87fbdf49e550dbfc057d6cb218e
|
|
MD5 |
1e695ab24f2c8620a1bbb0f1e76b339f
|
|
BLAKE2b-256 |
81a39907cbc922b76a9086388c0f822737f1d87f2debae8e3ff2f6dd998f97c2
|
File details
Details for the file pyparsing-2.2.0-py2.py3-none-any.whl
.
File metadata
- Download URL: pyparsing-2.2.0-py2.py3-none-any.whl
- Upload date:
- Size: 56.4 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
fee43f17a9c4087e7ed1605bd6df994c6173c1e977d7ade7b651292fab2bd010
|
|
MD5 |
7247e7896688eff4bc8c7fc5d0cdd2b0
|
|
BLAKE2b-256 |
6a8a718fd7d3458f9fab8e67186b00abdd345b639976bc7fb3ae722e1b026a50
|