Tested the Factor Engine, first round of testing passed. Fixed a bug in the JSON_Generator to stop expression variables from being added in reverse.

This commit is contained in:
2020-04-20 00:49:32 -05:00
parent 08bb51d68e
commit 7507db75b3
4 changed files with 16 additions and 8 deletions
+1
View File
@@ -30,6 +30,7 @@ class Variable:
@staticmethod
def get_variable_type(variable_name):
print(variable_name[0])
if len(variable_name) == 0:
return "Unknown"
if not variable_name[0] in Variable.VARIABLE_TYPES:
+4 -1
View File
@@ -2,6 +2,7 @@ import tokenizer
import ctoken
import expression
import jsonpickle
import copy
variables = {}
def print_vars(vars):
@@ -62,8 +63,10 @@ try:
except ValueError:
print("The anwser must be numeric! Will not be included in output file.")
tokens = tokenizer.get_tokens_from_expression_string(exp)
rev_tokens = copy.deepcopy(tokens)
rev_tokens.reverse()
for t in tokens:
for t in rev_tokens:
if t.type == ctoken.TokenType.variable:
variables[t.value] = expression.Variable(t.value, expression.Variable.get_variable_type(t.value))