Metadata-Version: 2.4
Name: meth
Version: 2.1.0
Summary: A mathematical expression parser and evaluator.
Project-URL: Homepage, https://github.com/sertdfyguhi/meth
Project-URL: Source, https://github.com/sertdfyguhi/meth
Project-URL: Bug Tracker, https://github.com/sertdfyguhi/meth/issues
Author: sertdfyguhi
License-File: LICENSE
Keywords: evaluator,math,math evaluator,math parser,mathematical,parser,parsing
Classifier: Development Status :: 5 - Production/Stable
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.15
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Topic :: Scientific/Engineering :: Mathematics
Classifier: Typing :: Typed
Requires-Python: >=3.0
Description-Content-Type: text/markdown

# meth: A mathematical expression evaluator.

A python package to parse and evaluate mathematical expressions.

# Installation

```sh
pip install meth
```

or install it from source:

```sh
git clone https://github.com/sertdfyguhi/meth/
cd meth
python3 -m build
pip install dist/*.whl
```

# Examples

> _More examples in the [examples/](https://github.com/sertdfyguhi/meth/tree/master/examples) directory._

```py
import meth

# tokenizing expression
meth.tokenize("5 + 2") # [Token(TokenType.NUMBER, 5), Token(TokenType.ADD), Token(TokenType.NUMBER, 2)]

# parsing expression
meth.parse("7 * 2") # BinaryOp(Number(7), TokenType.MUL, Number(2))

# evaluating expression
meth.evaluate("4 ^ 2") # 16
meth.evaluate("3(1 + 2)") # 9
meth.evaluate("sqrt(9)") # 3

# evaluation with variables
evaluator = meth.Evaluator()
evaluator.evaluate("x = 5")
evaluator.evaluate("x") # 5
```
