Skip to main content

A lightweight and basic maths interpreter

Project description

mathterpreter

A lightweight and basic maths interpreter

Example usage

Basic usage

from mathterpreter import interpret

print(interpret("54-3*(2+1)-3"))

Step by step

from mathterpreter import Lexer, Parser

lexer = Lexer("54-3*(2+1)-3")
tokens = lexer.tokenize()
parser = Parser(tokens)
tree = parser.parse()
result = tree.evaluate()
print(result)

Command line

python3 -m mathterpreter 54-3*(2+1)-3
# or
echo 54-3*(2+1)-3 | python3 -m mathterpreter

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

mathterpreter-1.0.2.tar.gz (4.5 kB view hashes)

Uploaded Source

Built Distribution

mathterpreter-1.0.2-py3-none-any.whl (7.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page