Skip to main content

Arithmetic calculator which uses a Pratt parser

Project description

Introduction

An arithmetic expression calculator in Python, demoing the Pratt parsing algorithm.

This takes inspiration from this 2010 blog post by Eli Bendersky, as well as a few other sources:

  1. Simple but Powerful Pratt Parsing
  2. Pratt Parsers: Expression Parsing Made Easy
  3. Compiling Expressions (Chapter 17 of Crafting Interpreters

Requirements

Requires Python 3.13 or greater.

Installation

pipx install pratt-calc

In some cases it may be necessary to specify the Python version manually:

PIPX_DEFAULT_PYTHON=python3.13 pipx install pratt-calc

Or, if you have uv installed:

uvx pipx install pratt-calc

Contributing

Install uv, then do:

git clone https://github.com/BrandonIrizarry/pratt-calc
cd pratt-calc
uv sync --locked

Usage

pratt-calc $EXPRESSION

Example:

pratt-calc 3-4*5

This should print -17 at the console.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pratt_calc-0.1.1.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pratt_calc-0.1.1-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file pratt_calc-0.1.1.tar.gz.

File metadata

  • Download URL: pratt_calc-0.1.1.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pratt_calc-0.1.1.tar.gz
Algorithm Hash digest
SHA256 af96f0e66672b416aae6709e5ac0b485cb972905ece965bd731e08844a75b0b7
MD5 1f65637f29d2fa45152aef5f896208cf
BLAKE2b-256 8ebe2e166a2cdec60abc8003a2b63f6b5e1fe3bfe3aa9cb4bf9727a58608d8c2

See more details on using hashes here.

Provenance

The following attestation bundles were made for pratt_calc-0.1.1.tar.gz:

Publisher: publish-to-test-pypi.yml on BrandonIrizarry/pratt-calc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pratt_calc-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: pratt_calc-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pratt_calc-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d17a7d723f2c1a0125a80e2e4c0c9fae9a3567051df57ac05b47931af9bfeb04
MD5 415a8336368adc25cf295898f3e649d1
BLAKE2b-256 bad9e44f31c5ad55a80c1951094d1f859c9e012f41238a791175416be8a9dae4

See more details on using hashes here.

Provenance

The following attestation bundles were made for pratt_calc-0.1.1-py3-none-any.whl:

Publisher: publish-to-test-pypi.yml on BrandonIrizarry/pratt-calc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page