diff --git a/core/parser.py b/core/parser.py index e33062e..f112200 100644 --- a/core/parser.py +++ b/core/parser.py @@ -26,10 +26,14 @@ def advance(self): def expect(self, token_type): tok = self.peek() - if tok and tok.type == token_type: - self.advance() - return tok - raise SyntaxError(f'Expected {token_type}, got {tok.type}') + if tok: + if tok.type == token_type: + self.advance() + return tok + else: + raise SyntaxError(f'Expected {token_type}, got {tok.type}') + else: + raise SyntaxError(f'Unexpected end of file. Expected {token_type}') def parse(self):