Parsematic
A math expression parser written in Python that supports arithmetic, comparison, and mathematical functions.
Parsematic
A basic math parser that can parse and evaluate mathematical expressions.
Features
- Integers, floats, and constants (PI, TAU, E, INF)
- Basic arithmetic (+, -, *, /, **, //, %)
- Comparison operators (==, !=, <, >, <=, >=)
- Mathematical functions (sin, cos, tan, abs, sqrt, log, fact, gcd, lcm)
- Parentheses for grouping
Installation
pip install parsematic
Usage
from math_parser import MathParser
parser = MathParser()
result = parser.parse("2 + 3 * (4 - 1)")
print(result) # Output: 11
Or from the command line:
python -m parsematic "2 + 3 * (4 - 1)"