Metadata-Version: 2.4
Name: expr-lib-sania
Version: 0.2.0
Summary: Convert and evaluate infix, prefix, and postfix arithmetic expressions (multi-digit numbers, variables, functions, unary minus)
Author: Sania
License: MIT
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# expr-lib-sania

Convert and evaluate arithmetic expressions in infix, prefix, and postfix
notation — no need to rewrite stack/precedence logic every time.

## Install (local dev)

```bash
pip install -e .
```

## Usage

```python
from expr_lib import (
    infix_to_postfix,
    infix_to_prefix,
    prefix_to_postfix,
    postfix_to_prefix,
    evaluate_postfix,
    evaluate_prefix,
    evaluate_infix,
)

# Conversions (tokens are space-separated)
infix_to_postfix("12+340*2")          # '12 340 2 * +'
infix_to_prefix("A+B*C")              # '+ A * B C'

# Direct evaluation
evaluate_infix("12+340*2")                          # 692
evaluate_infix("total+tax*rate", {"total": 100, "tax": 5, "rate": 2})  # 110
evaluate_infix("sqrt(16)+2")                         # 6
evaluate_infix("-5+3")                               # -2

# Evaluate an already-converted postfix/prefix string
evaluate_postfix("A B * ", {"A": 2, "B": 5})         # 10
evaluate_prefix("+ A B", {"A": 4, "B": 5})           # 9
```

## Features

- Multi-digit numbers: `12 + 340`
- Multi-character variable names: `total + tax`
- Functions: `sqrt`, `sin`, `cos`, `tan`, `log`, `ln`
- Unary minus: `-5 + 3`, `-x * 2`
- Standard precedence (`^` is right-associative)
- Division-by-zero raises `ZeroDivisionError`
- Malformed expressions raise `expr_lib.ExprError`

## Known limitations

- No implicit multiplication (`2x` must be written `2*x`)
- No exponent shorthand like `2x^2` — use explicit `*`
- Single-expression only (no equations, no multiple statements)

## License

MIT
