Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/glubs9/plus-minus-interpreter
a maths interpreter that handles addition, subtraction and brackets.
https://github.com/glubs9/plus-minus-interpreter
Last synced: about 21 hours ago
JSON representation
a maths interpreter that handles addition, subtraction and brackets.
- Host: GitHub
- URL: https://github.com/glubs9/plus-minus-interpreter
- Owner: Glubs9
- Created: 2020-02-29T04:10:39.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-02-29T04:34:34.000Z (almost 5 years ago)
- Last Synced: 2024-11-09T13:40:40.691Z (about 2 months ago)
- Language: Python
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# plus-minus-interpreter
a maths interpreter that handles addition, subtraction and brackets.# To-Do
add comments
make code neater, faster and more understandable.
make multiplication and division?# How to use
download maths.py and run the program with python3.# how it works
The maths string is input, the spacecs are removed and all of the different tokens/symbols are separated (the function that does this also handles multiple digit numbers being separated).
The token list is then fed into a function that converts all of the numbers into members of the num class.
the list of tokens and number is then fed into a function that separates the brackets into separate lists within the list that holds all the tokens.
then this structure is fed into a function that converts all of the functions in the equation into instances of func_node.
the structure returned from this is the equivalent to an ast in an interpreter.
the ast is then 'run' by calling the get_value function on the return value of the previous function.