PGPC
Overview
PGPC is a parser combinator library. Its name is an acronym, which stands for Python Generator based Parser Combinator library.
The library was heavily influenced by the Parsec monadic parser combinator library,
so the transition from Parsec (and other parser combinators) to PGPC should be relatively easy.
The original idea of the library is emulating the do-notation with the yield Python keyword.
Quick start
The @topology decorator over a function allows the yield keyword work with parsers in a do-notation-like fashion:
- install the package:
pip install pgpc - save the following code into
main.py:
from pgpc.scanner import TextScanner
from pgpc.parser import Parser, topology, char, position, content
@topology
def parse_hello_world():
start = yield position()
for c in "Hello":
yield char(c)
yield char(",")
yield char(" ")
for c in "World":
yield char(c)
yield char("!")
end = yield position()
source = yield content()
return f"Parsed '{source[start.offset:end.offset]}' which started at {start} and ended at {end}"
if __name__ == '__main__':
text = "Hello, World!"
hw_parser: Parser[str] = parse_hello_world()
result = hw_parser(TextScanner(text))
print(result)
- run
main.py:python main.py
Metadata
Release files for pgpc 0.0.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 |
|---|---|---|---|---|
| pgpc-0.0.4.tar.gz | 8.2 kB | Without provenance | Details for pgpc-0.0.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pgpc-0.0.4-py3-none-any.whl | Python 3 | none | any | Details for pgpc-0.0.4-py3-none-any.whl |
Total release size: 17.5 kB
Release files / pgpc-0.0.4.tar.gz
| Download URL | pgpc-0.0.4.tar.gz |
|---|---|
| Size | 8.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0aee1541d06204ca4df60ae939b1603a68c3cd8cde472bc05c00378547234580
|
|
BLAKE2b-256 checksum How to use checksums |
e382218dc670b4cd48ef28bcf5b3b9efe418e8072deef884a2ab7705ebd82fba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.17
|
Release files / pgpc-0.0.4-py3-none-any.whl
| Download URL | pgpc-0.0.4-py3-none-any.whl |
|---|---|
| Size | 9.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8a64e35057d5dd8339f98ee0a023737735a1dd5266bf4d9a70a13325825e1630
|
|
BLAKE2b-256 checksum How to use checksums |
bc4e55fe0ece125dfe0b28ee8c928b30da5a08ec886aa108bf4856afb14142cd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.17
|
Security for pgpc 0.0.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.