|
@@ -19,9 +19,7 @@ class Interpreter():
|
|
|
self._skip()
|
|
|
continue
|
|
|
if self._current_char.isdigit():
|
|
|
- char = self._current_char
|
|
|
- self._forward()
|
|
|
- return Token(TokenType.INTEGER, char)
|
|
|
+ return Token(TokenType.INTEGER, self._integer())
|
|
|
if self._current_char == "+":
|
|
|
char = self._current_char
|
|
|
self._forward()
|
|
@@ -44,6 +42,13 @@ class Interpreter():
|
|
|
while self._current_char and self._current_char == " ":
|
|
|
self._forward()
|
|
|
|
|
|
+ def _integer(self):
|
|
|
+ result: list = []
|
|
|
+ while self._current_char and self._current_char.isdigit():
|
|
|
+ result += self._current_char
|
|
|
+ self._forward()
|
|
|
+ return "".join(result)
|
|
|
+
|
|
|
def _check_token_type(self, type_: TokenType):
|
|
|
if self._current_token.type_ == type_:
|
|
|
self._current_token = self._next_token()
|