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:
+5
-5
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user