PPeg
PPeg is a pattern matching library for Python, based on Parsing Expression Grammars (PEGs). It’s a port of the LPeg library from Lua.
Usage
Unlike the re module [1], PPeg patterns can handle balanced sequences
>>> from _ppeg import Pattern as P
>>> pattern = P.Grammar('(' + ( (P(1)-P.Set('()')) | P.Var(0) )**0 + ')')
>>> pattern('(foo(bar()baz))').pos
15
>>> pattern('(foo(bar(baz)').pos
-1
>>> capture = P.Cap(pattern)
>>> capture('(foo(bar()baz))').captures
['(foo(bar()baz))']
This example corresponds roughly to the following LPeg example
> lpeg = require "lpeg"
> pattern = lpeg.P{ "(" * ((1 - lpeg.S"()") + lpeg.V(1))^0 * ")" }
> pattern:match("(foo(bar()baz))") -- Lua indexes begin at 1
16
> pattern:match("(foo(bar(baz)")
nil
> capture = lpeg.C(pattern)
> capture:match("(foo(bar()baz))")
"(foo(bar()baz))"
Modules
_cpeg.c
- _ppeg.c
includes lpeg.c
Metadata
Release files for PPeg 0.9.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| PPeg-0.9.4.tar.gz | 46.6 kB | Without provenance | Details for PPeg-0.9.4.tar.gz |
Release files / PPeg-0.9.4.tar.gz
| Download URL | PPeg-0.9.4.tar.gz |
|---|---|
| Size | 46.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
674632f08c4a1f2f9515a1080c7d5814dae5f3d44c2522df469345e9374c11f0
|
|
BLAKE2b-256 checksum How to use checksums |
4d5dbe7be7c5219051df1f4afdbdbf48bd4ed90a87cbcfd39942e02f1f82a307
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for PPeg 0.9.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.