sertdfyguhi / meth

A Python library to parse and evaluate mathematical equations.

Home Page:https://pypi.org/project/meth/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

About

A Python library to parse and evaluate mathematical equations.

https://pypi.org/project/meth/

License:GNU General Public License v3.0


Languages

Language:Python 100.0%