A Parser Library for Python 3 (and 2.6): Recursive Descent; Full Backtracking
Project description
LEPL is a recursive descent parser, written in Python, which has a a friendly, easy-to-use syntax. The underlying implementation includes several features that make it more powerful than might be expected.
For example, it is not limited by the Python stack, because it uses trampolining and co-routines. Multiple parses can be found for ambiguous grammars and it can also handle left-recursive grammars.
The aim is a powerful, extensible parser that will also give solid, reliable results to first-time users.
Release 2.3 provides optimisation via regular expressions. A detailed example shows the benefits. Release 2.3.4 fixes a packaging error (I hope - this release has been a complete disaster so far).
Features
Parsers are Python code, defined in Python itself. No separate grammar is necessary.
Friendly syntax using Python’s operators.
Built-in AST support (a generic Node class). Improved support for the visitor pattern and tree re–writing.
Well documented and easy to extend.
Unlimited recursion depth. The underlying algorithm is recursive descent, which can exhaust the stack for complex grammars and large data sets. LEPL avoids this problem by using Python generators as coroutines (aka “trampolining”).
Support for ambiguous grammars (complete backtracking). A parser can return more than one result (aka “parse forests”).
Packrat parsing. Parsers can be made much more efficient with automatic memoisation.
Parser rewriting. The parser can itself be manipulated by Python code. This gives unlimited opportunities for future expansion and optimisation.
Left recursive grammars. Memoisation can detect and control left–recursive grammars. Together with LEPL’s support for ambiguity this means that “any” grammar can be supported.
Pluggable trace and resource management, including “deepest match” diagnostics and the ability to limit backtracking.
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
File details
Details for the file LEPL-2.3.4.zip
.
File metadata
- Download URL: LEPL-2.3.4.zip
- Upload date:
- Size: 87.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2a0d44d683897966f074b1ff8cd8ee4ce96a3d4e98d874ee739edb2d95d8735e |
|
MD5 | d1930c9848bfd41e894dcb10b958f931 |
|
BLAKE2b-256 | b0bc624fbcff9de6fd296eb8a6e865cb2fdd9a33b3972adc278d9d96195849e3 |
File details
Details for the file LEPL-2.3.4.tar.gz
.
File metadata
- Download URL: LEPL-2.3.4.tar.gz
- Upload date:
- Size: 70.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 147b2465ea165b8a62aae436a2de64fc956acb3d1d9dd3d171fc084df6455834 |
|
MD5 | 93bde3affdf0f79b23f21aa82db0cc52 |
|
BLAKE2b-256 | c31de4e22506b8623c375a91367bd3cab86e49519ea5e8e54012376c6abea914 |