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.1.3.tar.gz
(1.1 MB
view details)
Built Distributions
pyparsing-2.1.3.win32-py3.5.exe
(236.1 kB
view details)
pyparsing-2.1.3.win32-py3.4.exe
(236.1 kB
view details)
pyparsing-2.1.3.win32-py3.3.exe
(236.1 kB
view details)
pyparsing-2.1.3.win32-py2.7.exe
(236.1 kB
view details)
pyparsing-2.1.3.win32-py2.6.exe
(105.6 kB
view details)
File details
Details for the file pyparsing-2.1.3.tar.gz
.
File metadata
- Download URL: pyparsing-2.1.3.tar.gz
- Upload date:
- Size: 1.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 07ed062c8e38c682ddc728e7aa42fab44612744fce33812bc533f93ea53c9347 |
|
MD5 | 3ac54fb8c71a1536648183f24695ed1f |
|
BLAKE2b-256 | 382ce2f2562a7568c0234f600f5257ae077deb7b87cd8ce75a29f2653844952a |
File details
Details for the file pyparsing-2.1.3.win32-py3.5.exe
.
File metadata
- Download URL: pyparsing-2.1.3.win32-py3.5.exe
- Upload date:
- Size: 236.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2aa77f3c1737661af3b1d54334a20042dd9b8b13e7af19392e2178c927042e59 |
|
MD5 | d6e5ac39f72fae53e854a4167e90a12b |
|
BLAKE2b-256 | fd98b4205d85243044421f457fd2f01519092ff886957d041d99ca86c622b815 |
File details
Details for the file pyparsing-2.1.3.win32-py3.4.exe
.
File metadata
- Download URL: pyparsing-2.1.3.win32-py3.4.exe
- Upload date:
- Size: 236.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5dc07afdb8c21ff769a0b45ae4ebc18dc02d69a612faf74bf6d6033386954100 |
|
MD5 | b56903148c5c9156bccd7aa9e2ded213 |
|
BLAKE2b-256 | fd025b46483631e63a97177042b8bcde4662a84279029b695a323e1c8a365a97 |
File details
Details for the file pyparsing-2.1.3.win32-py3.3.exe
.
File metadata
- Download URL: pyparsing-2.1.3.win32-py3.3.exe
- Upload date:
- Size: 236.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5fea0c3f5188eda7de52a9bef5502611c2e4c2c260edc70556d476aba25a56da |
|
MD5 | 86c0f3dbdd83e5646e44b6717d6d5893 |
|
BLAKE2b-256 | 43d477c31cad24de4b36ee0d010fc073afe452120ad2950b97e03a5a0952fe01 |
File details
Details for the file pyparsing-2.1.3.win32-py2.7.exe
.
File metadata
- Download URL: pyparsing-2.1.3.win32-py2.7.exe
- Upload date:
- Size: 236.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2dfb49c39cd3f39279dfc5639b4aaedd386961693f01e3f9682bd849a87b822b |
|
MD5 | 54be9221f78ee7d8361eef11eecf4b66 |
|
BLAKE2b-256 | ebcc6e0c745ec906d0f79139294cfabbfd5be6cf6711f9a949b52fee944e470b |
File details
Details for the file pyparsing-2.1.3.win32-py2.6.exe
.
File metadata
- Download URL: pyparsing-2.1.3.win32-py2.6.exe
- Upload date:
- Size: 105.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f2760e5303df417c43b26b0ca14870ed2b8f5807bbd3ef3083197a3ffc89291c |
|
MD5 | 3b995a5e18714a28dbf9578d348b61f4 |
|
BLAKE2b-256 | ca2e15229236001ce0142d8270a3e88ffe5bb718b2ef80392f5d33cabc1534e7 |
File details
Details for the file pyparsing-2.1.3-py2.py3-none-any.whl
.
File metadata
- Download URL: pyparsing-2.1.3-py2.py3-none-any.whl
- Upload date:
- Size: 39.3 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3fcd048fc92e5e8317e753b7f207c0a88f9b79c47cd17e491fd3cc669989d133 |
|
MD5 | 261acb0ee56039df52ac66d823e280cb |
|
BLAKE2b-256 | 2226b56673d1578cfeafe915d946d3075bdbfaeb434a2a5cef4b530c4d1d4d7c |