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, which I'll touch on in a future blog post.

Installation

Using uv

  1. Make sure uv is installed in your system.

  2. git clone https://github.com/BrandonIrizarry/pratt_calc && cd !$

  3. uv sync

Conventional

  1. git clone https://github.com/BrandonIrizarry/pratt_calc && cd !$

  2. python -m venv venv

  3. source venv/bin/activate

  4. pip install .

Usage

./pratt_calc $EXPRESSION

Example:

./pratt_calc '3-4*5'

This should print -17 at the console.

TODO

  • add support for running the tests.
  • CI?

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.0.tar.gz (3.3 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.0-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pratt_calc-0.1.0.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for pratt_calc-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0964aca9a32ed3dfd84422d6c7b7059821c9d8adc7c47bb2be4a89e7e32ede40
MD5 48948556dd3f00a86dda1a019a412b87
BLAKE2b-256 060e094d966f26817b9fd5bbd4e150c8c60701b25ec71293d0fcb9466dd2cfd6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pratt_calc-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for pratt_calc-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7254643166e07068168f774ffd16911bebd1ac95509092486c5a1b410f1d837f
MD5 8c8257123ccdaa0b3807a95f6e885401
BLAKE2b-256 9e3b11e4ee0236587e442b93bd430f39dba6a6b5a8d4b24d8c894bf786ef7daf

See more details on using hashes here.

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