Skip to main content

megaparsy

Build Status Latest PyPI version

Python 3.6 Python 3.7 Python 3.8

Work In Progress - ignore for now ;)

Initial motivation for this project was to build an indentation-sensitive parser. This is problematic for any parser library which is limited to expressing context-free grammars (which is most of them), unless you use a separate pre-processing step (like e.g. the parser for the Python language does).

Googling around this topic I came upon https://markkarpov.com/tutorial/megaparsec.html#indentationsensitive-parsing

So in Haskell-land we can find ‘Monadic Parser Combinators’, which do not have this restriciton to CFGs. And the Megaparsec library defines many useful combinators, including some which designed specifically to help with building indentation-sensitive parsers.

But… it was difficult for me to learn to make a parser for the first time and learn Haskell simultaneously. So I looked around for a Python option and found the brilliant Parsy library. It provides an implementation of ‘Monadic Parser Combinators’ in Python.

Nicely and simply explained here:

Functional or Combinator Parsing explained by Professor Graham Hutton.

Functional or Combinator Parsing explained by Professor Graham Hutton.

So in Megaparsy I have ported a bunch of the Megaparsec combinators over to Parsy. It is surprising how smoothly it went and how similar they come out - this is testament to the genius of Parsy, which is where all the clever part is.

(I haven’t done all of them yet, but the indentation-sensitive ones are here)

I’ve also roughly translated across the property-based tests from their Haskell QuickCheck originals into Python Hypothesis ones.

Metadata

Release files for megaparsy 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for megaparsy 0.1.4
File Size Uploaded Provenance Actions
megaparsy-0.1.4.tar.gz 7.4 kB Without provenance Details for megaparsy-0.1.4.tar.gz

Release files / megaparsy-0.1.4.tar.gz

Download URL megaparsy-0.1.4.tar.gz
Size 7.4 kB
Tags Source
SHA-256 checksum
How to use checksums
2b5001a7c9322976e9b38b5baa64af93888a1dab943f6162d3d80afb25763fd6
BLAKE2b-256 checksum
How to use checksums
5ef5495b4da4f27aced864854e77eacbe86f5e33682bf26d8f532aa0f3050e5b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

Security for megaparsy 0.1.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.

Release history Release notifications | RSS feed

This release

0.1.4 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page