Skip to main content

Paramath v3 compiler

Project description

The Paramath Programming Language, ver 3.

Paramath is a Domain-Specific Language (DSL) that transforms procedural math code into mathematical expressions. Paramath compiles into math expressions with operations commonly found on standard scientific calculators, allowing evaluation of logical code on mathematical hardware.

All this, powered by Python.

Why the name "Paramath"?
The word "paramath" comes from the portmanteau of "parenthesis" and "mathematics".

Features

  • Infix + prefix syntax: Arithmetic and comparators are infix; other operations are function-style prefix calls
  • Automatic optimization: Simplification and duplicate subexpression extraction
  • Loop unrolling: Compile-time iteration for performance
  • Flexible output: Display and/or write compiled expressions to files

Documentation

Installation

Method 1 (PyPI)

Generic PyPI install (virtual environment)

python -m venv .venv
source .venv/bin/activate
pip install paramath3

Run the compiler:

paramath3 --version

Recommended on Arch Linux: use pipx

Arch enforces Python's externally managed environment (PEP 668), so global pip install may fail. Use pipx instead:

sudo pacman -S --needed python-pipx
pipx ensurepath

Restart your shell, then install Paramath:

pipx install paramath3

Method 2 (Direct Git Clone)

Clone the repository:

git clone https://github.com/kaemori/paramath3.git
cd paramath3

Run directly from source:

python cli.py --version

Install as a local package (recommended):

pip install -e .
paramath3 --version

Optional dependencies:

pip install -e .[full]

Usage

The compiler can be run with:

python cli.py [-h] [-V] [-o FILE] [-d] [-v] [-s] [-S] [-O] [-m] [-t] [-L FILE] [-p] [--no-color] [filepath]

Options:

  • filepath input Paramath file
  • -h, --help show help and exit
  • -V, --version print Paramath version and exit
  • -o, --output FILE output file (default: math.txt)
  • -d, --debug enable debug output
  • -v, --verbose enable verbose output
  • -s, --suppress suppress non-error output
  • -S, --silent suppress all output
  • -O, --print-output print compiled output
  • -m, --math-output format output for calculators (^, implicit multiplication, ANS)
  • -t, --trust allow compile-time Python eval (:=)
  • -L, --logfile FILE write logs to file
  • -p, --progress show parsing/processing progress bars
  • --no-color disable colored CLI output

Testing

Test layout:

  • paramath_test/ contains .pm3 fixture programs
  • tests/ contains Python test modules (.py)

Run the Paramath v3 suite:

python -m unittest tests/pm_test_suite.py -v

The fixture set in paramath_test/ is a file-for-file (1:1) conversion of _for_ref/paramath/paramath_tests into Paramath v3 syntax, including examples/number_test.

License

This project is licensed under the MIT License.

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

paramath3-3.2.3.tar.gz (21.6 kB view details)

Uploaded Source

Built Distribution

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

paramath3-3.2.3-py3-none-any.whl (22.2 kB view details)

Uploaded Python 3

File details

Details for the file paramath3-3.2.3.tar.gz.

File metadata

  • Download URL: paramath3-3.2.3.tar.gz
  • Upload date:
  • Size: 21.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for paramath3-3.2.3.tar.gz
Algorithm Hash digest
SHA256 57074810104c8b2c89692ad27e9c7db5f4bef7edcac7e04ec90808ef8d7c48c7
MD5 2222143df5178cc164f71ef78dd9e2f7
BLAKE2b-256 d9de0ca1de92c294aa20b984615bc9ed9cf72a3046016e04d69c530e66d35a98

See more details on using hashes here.

File details

Details for the file paramath3-3.2.3-py3-none-any.whl.

File metadata

  • Download URL: paramath3-3.2.3-py3-none-any.whl
  • Upload date:
  • Size: 22.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for paramath3-3.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 06fcb84bee9918b8b9bc417194e50c6f508b7d242aa5cd3d609ff9b7ddb4a3f6
MD5 e6eaa0bb142627e6219b96c93cf3d4ae
BLAKE2b-256 e26216ca10e03152143a5d7d373caa309523b1bfd518c3901a5be4d272b38422

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