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
+5 -5
View File
@@ -244,19 +244,19 @@ def operate(n1, n2, tokenType):
n2 = float(n2)
if tokenType == token.TokenType.add:
print("Adding %d and %d to get %d." %(n1, n2, n1 + n2))
#print("Adding %d and %d to get %d." %(n1, n2, n1 + n2))
return n1 + n2
elif tokenType == token.TokenType.subtract:
print("Subtracting %d and %d to get %d." %(n1, n2, n1 - n2))
#print("Subtracting %d and %d to get %d." %(n1, n2, n1 - n2))
return n1 - n2
elif tokenType == token.TokenType.multiply:
print("Multiplying %d and %d to get %d" %(n1, n2, n1 * n2))
#print("Multiplying %d and %d to get %d" %(n1, n2, n1 * n2))
return n1 * n2
elif tokenType == token.TokenType.divide:
print("Dividing %d and %d to get %d" %(n1, n2, n1 / n2))
#print("Dividing %d and %d to get %d" %(n1, n2, n1 / n2))
return n1 / n2
elif tokenType == token.TokenType.power:
print("Raising %d to the power of %d to get %d" %(n1, n2, n1**n2))
#print("Raising %d to the power of %d to get %d" %(n1, n2, n1**n2))
return n1 ** n2
else:
raise TypeError("Invalid operator value " + str(tokenType) + ".", tokenType)