Updated the tokenizer to include a method to replace variable tokens with the values provided in a list.

This commit is contained in:
2020-04-13 09:10:14 -05:00
parent 7605bcdf68
commit c75905d13c
3 changed files with 25 additions and 14 deletions
+10 -8
View File
@@ -4,22 +4,24 @@ import expression
import calc_engine
import json
fileLocation = input('File Path to JSON: ')
#fileLocation = input('File Path to JSON: ')
#json = json.loads(open(fileLocation).read())
#userInput = input('Enter your formula: ')
tokens = tokenizer.get_tokens_from_expression_string("2 + 6 / 2")
with open("expression.json", "r") as f:
j = json.load(f)
exp = expression.Expression(json.loads(j))
print(exp)
userInput = input('Enter your formula: ')
tokens = tokenizer.get_tokens_from_expression_string(userInput)
#with open("expression.json", "r") as f:
# j = json.load(f)
# exp = expression.Expression(json.loads(j))
# print(exp)
#results = calc_engine.calculate_results(tokens.copy())
#print(results)
tokens = tokenizer.replace_variables(tokens, [23, 46, 89])
for t in tokens:
print("%s (%s) " %(t.value, token.TokenType.get_token_type_name(t.type)), end = "")
print()
def factors(factor_object, starting_point, variable_type)
#def factors(factor_object, starting_point, variable_type)