Fix subtract operator

This commit is contained in:
Pavle Portic 2019-05-19 00:31:12 +02:00
parent f6e03b934c
commit fece98a748
Signed by: TheEdgeOfRage
GPG Key ID: 6758ACE46AA2A849
2 changed files with 6 additions and 3 deletions

View File

@ -74,7 +74,7 @@ class Lexer():
elif self.current_char == '-':
self.advance()
if self.current_char.isdigit():
if self.current_char is not None and self.current_char.isdigit():
return Token(NUMBER, -self.number())
return Token(MINUS, operator.sub)

View File

@ -13,8 +13,11 @@ from constants import DEC
def print_stack(interpreter, stack):
for item in stack:
if interpreter.mode == DEC and item.is_integer():
print(int(item))
if interpreter.mode == DEC:
if item.is_integer():
print(int(item))
else:
print(round(float(item), 4))
else:
print(interpreter.mode_func(item))