A mathematical expression parser and evaluator.
Project description
meth: A mathematical expression parser.
A python package to parse and evaluate mathematical expressions.
Installation
pip install meth
or install it from source:
git clone https://github.com/sertdfyguhi/meth/
cd meth
python3 -m build
pip install dist/*.whl
Examples
More examples in the examples/ directory.
import meth
# tokenizing equations
meth.tokenize("5 + 2") # INT(5), PLUS, INT(2)
# parsing equations
meth.parse("2 * 10") # BinaryOpNode(INT(2), MUL, INT(10))
# evaluating equations
meth.evaluate("2 + 2") # 4
meth.evaluate("sqrt(9)") # 3
# evaluation with variables
evaluator = meth.Evaluator()
evaluator.evaluate("x = 5")
evaluator.evaluate("x") # 5
Todo
- Lexer
- Parser
- Bracketing
- Multiplication using brackets
- Negative Numbers
- Variables
- Functions
- Interpreter
- Binary Operations
- Unary Operations
- Variables
- Functions
- Add mathematical functions
- Accurate float calculations
- Simplify an expression
- Expand an expression
- AST to Equation String
- Documentation
- Publish to PyPI
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
meth-1.2.1.tar.gz
(21.2 kB
view details)
Built Distribution
meth-1.2.1-py3-none-any.whl
(24.0 kB
view details)
File details
Details for the file meth-1.2.1.tar.gz
.
File metadata
- Download URL: meth-1.2.1.tar.gz
- Upload date:
- Size: 21.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | abd8e09b61d67b565bad4af6cdb20ed3f56900e8d45739289d3324c6fe1cf7b3 |
|
MD5 | 1116d246b23c04d1022cc9ee81840d63 |
|
BLAKE2b-256 | c557811cbe8e72a898fdf8b85903a04a7fcdc5a2369a2154dcf2781be664edc6 |
File details
Details for the file meth-1.2.1-py3-none-any.whl
.
File metadata
- Download URL: meth-1.2.1-py3-none-any.whl
- Upload date:
- Size: 24.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e6a1644775bec71fbaab451de96162f245f57942028504d12cbdea92bf757ba3 |
|
MD5 | 17071f9990f6212363e01416b6d711eb |
|
BLAKE2b-256 | 15dbecdeda02dfc20c668eebf9165231cb4bf36308afe70482d99d90822514b8 |