Fix subtract operator
This commit is contained in:
parent
f6e03b934c
commit
fece98a748
2
lexer.py
2
lexer.py
|
@ -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)
|
||||
|
|
|
@ -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))
|
||||
|
||||
|
|
Loading…
Reference in New Issue