Skip to main content

Parsita

Build status Code coverage Latest PyPI version License Supported Python versions

The executable grammar of parser combinators made available in the executable pseudocode of Python.

Parsita is a parser combinator library written in Python. Parser combinators provide an easy way to define a grammar using code so that the grammar itself effectively parses the source. They are not the fastest at parsing, but they are the easiest to write.

Like all good parser combinator libraries, Parsita abuses operators to provide a clean grammar-like syntax. The __or__ method is defined so that | tests between two alternatives. The __and__ method is defined so that & tests two parsers in sequence. Other operators are used as well.

In a technique that I think is new to Python, Parsita uses metaclass magic to allow for forward declarations of values. This is important for parser combinators because grammars are often recursive or mutually recursive, meaning that some components must be used in the definition of others before they themselves are defined.

See the Documentation for the full user guide.

Installation

The recommended means of installation is with pip from PyPI.

pip install parsita

Hello world

The following is a very basic parser for extracting the name from a Hello, {name}! string.

from parsita import *


class HelloWorldParsers(ParserContext, whitespace=r"[ ]*"):
    hello_world = lit("Hello") >> "," >> reg(r"[A-Z][a-z]*") << "!"


# A successful parse produces the parsed value
name = HelloWorldParsers.hello_world.parse("Hello, David!").unwrap()
assert name == "David"

# A parsing failure produces a useful error message
name = HelloWorldParsers.hello_world.parse("Hello David!").unwrap()
# parsita.state.ParseError: Expected ',' but found 'David'
# Line 1, character 7
#
# Hello David!
#       ^

Metadata

Release files for parsita 2.3.1

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

Source distribution (sdist)

Source distribution for parsita 2.3.1
File Size Uploaded Provenance Actions
parsita-2.3.1.tar.gz 20.4 kB With provenance Details for parsita-2.3.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for parsita 2.3.1
File Interpreter ABI Platform Actions
parsita-2.3.1-py3-none-any.whl Python 3 none any Details for parsita-2.3.1-py3-none-any.whl

Total release size: 49.9 kB

Release files / parsita-2.3.1.tar.gz

Download URL parsita-2.3.1.tar.gz
Size 20.4 kB
Tags Source
SHA-256 checksum
How to use checksums
24e93da8a249c0cdcf44b7cd07dda24251c7199453792fd0cb6e147555fe3636
BLAKE2b-256 checksum
How to use checksums
455a8c8d98dfa924a83f9ba811621f827e7d7e91537915c19903655a2f3047d8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.

Transparency log

Release files / parsita-2.3.1-py3-none-any.whl

Download URL parsita-2.3.1-py3-none-any.whl
Size 29.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
61f56dd9811a404588ab7eb51d24e9ee5dd7327e1b6e5123dc2904f8f54ad2be
BLAKE2b-256 checksum
How to use checksums
aa3f2ac0c725ce18185166e273ad2a440ad9eec7b9b2708dbb181197a4dd8a35
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.

Transparency log

Security for parsita 2.3.1

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for parsita-2.3.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.

Transparency log

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

2.3.1 This release

2 release files Full 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