Fixed a bug in the calc_engine where an expression '(a)^(b), where 'a' and 'b' are any float, would cause a crash and patched the tokenizer to better handle negative numbers.
This commit is contained in:
+8
-3
@@ -27,14 +27,19 @@ def get_tokens_from_expression_string(expression_string):
|
||||
|
||||
elif c == '-' and not parsing_number:
|
||||
if expression_string[i + 1] == '.' or expression_string[i + 1].isdigit():
|
||||
if tokens[-1].type == token.TokenType.exp_end:
|
||||
if token.TokenType.get_operator(tokens[-1].value) == token.TokenType.unknown:#tokens[-1].type == token.TokenType
|
||||
print(tokens[-1].value)
|
||||
tokens.append(token.Token('+', token.TokenType.add))
|
||||
parsing_number = True
|
||||
tmp = "-"
|
||||
'''if tokens[-1].type == token.TokenType.exp_end:
|
||||
tokens.append(token.Token(c, token.TokenType.get_operator(c)))
|
||||
parsing_number = False
|
||||
tmp = ""
|
||||
else:
|
||||
tokens.append(token.Token('+', token.TokenType.add))
|
||||
#tokens.append(token.Token('+', token.TokenType.add))
|
||||
tmp = "-"
|
||||
parsing_number = True
|
||||
parsing_number = True'''
|
||||
else:
|
||||
tokens.append(token.Token(c, token.TokenType.get_operator(c)))
|
||||
parsing_number = False
|
||||
|
||||
Reference in New Issue
Block a user