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
-
Make sure
uvis installed in your system. -
git clone https://github.com/BrandonIrizarry/pratt_calc && cd !$ -
uv sync
Conventional
-
git clone https://github.com/BrandonIrizarry/pratt_calc && cd !$ -
python -m venv venv -
source venv/bin/activate -
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0964aca9a32ed3dfd84422d6c7b7059821c9d8adc7c47bb2be4a89e7e32ede40
|
|
| MD5 |
48948556dd3f00a86dda1a019a412b87
|
|
| BLAKE2b-256 |
060e094d966f26817b9fd5bbd4e150c8c60701b25ec71293d0fcb9466dd2cfd6
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7254643166e07068168f774ffd16911bebd1ac95509092486c5a1b410f1d837f
|
|
| MD5 |
8c8257123ccdaa0b3807a95f6e885401
|
|
| BLAKE2b-256 |
9e3b11e4ee0236587e442b93bd430f39dba6a6b5a8d4b24d8c894bf786ef7daf
|