Robinson Crusoe's parsing package.
Project description
Peglet
Peglet extends Python’s regular expressions to handle recursive grammars. For example, to parse a tiny subset of HTML:
>>> from peglet import Parser >>> a_little_html = Parser(r""" ... parts = part parts | ... part = <(\w+)> parts </\w+> group ... | ([^<]+) ... """, group=lambda *values: values) >>> a_little_html("Hello. <p><em>Nesting</em> for <i>the win</i>.</p>") ('Hello. ', ('p', ('em', 'Nesting'), ' for ', ('i', 'the win'), '.'))
The goal was to make a parsing library
pleasant enough to use;
simple to adapt or rewrite from scratch if I’m faced with some new situation like a new programming language;
with code easy enough to follow that it could introduce people to parsing.
So it came down to one page of clear code not using combinators. (And then ballooned to 200+ lines from documentation and a few extras.) Some bits that couldn’t fit the latter two constraints went into a combinator library, parson.
For more, see the examples or the module doc in the code.
Installing it
pip install peglet, or else download then python setup.py install.
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
Built Distribution
File details
Details for the file Peglet-0.1.1.tar.gz
.
File metadata
- Download URL: Peglet-0.1.1.tar.gz
- Upload date:
- Size: 31.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | feb169c28e71f26e313dd0fdb8d9e82e78452e5bda7e5519a3332c873d431be9 |
|
MD5 | 515929428d0d69de9664198494fed9f6 |
|
BLAKE2b-256 | 270649c901c159792984892b98af28360a58b3c77fc5fc1936e0716278c47dcd |
File details
Details for the file Peglet-0.1.1.cygwin-1.7.17-i686.exe
.
File metadata
- Download URL: Peglet-0.1.1.cygwin-1.7.17-i686.exe
- Upload date:
- Size: 60.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | df2210cb119231dbc293b8b44c9287275fa22990a7be6d515cefa69d4ee562d3 |
|
MD5 | 162540cd8fadf774bc72211d6c89fc5e |
|
BLAKE2b-256 | d90405b70dffec4ecc11e19d2890f0d7b0dd3b06901be3f39bf7638c5d85e39c |