Skip to main content

Paramath v3 compiler

Project description

The Paramath Programming Language

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.1.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.1.3-py3-none-any.whl (22.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: paramath3-3.1.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.1.3.tar.gz
Algorithm Hash digest
SHA256 6768cbd275d19e63534b40246f43649ac47b7a020de57e83a3ab41731a619abc
MD5 397d574eeb9adf14fc422b3c8f5e93cb
BLAKE2b-256 70c103d697ea7df122bff42a66261abe59eccecfa7007d4fc7b13631863ca8a1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: paramath3-3.1.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.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 909896ce92e816cd40688b5d539ca9cc602c805385879f6e26570655b7509442
MD5 00bf861a12c21f27da65cb6ce222aefd
BLAKE2b-256 ea965d7b132e3fa47ff35eb771ab06385f4e57ed86731f3a8e3ad43d43e91dbc

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