fix(parser): ignore meaningless newlines

This commit is contained in:
2026-02-05 23:09:49 +01:00
parent 058a57909f
commit 4e69a967b0

View File

@@ -32,10 +32,16 @@ class Parser:
self.length = len(self.tokens) self.length = len(self.tokens)
statements: list[Stmt] = [] statements: list[Stmt] = []
self.skip_newlines()
while not self.is_at_end(): while not self.is_at_end():
self.skip_newlines()
statements.append(self.declaration()) statements.append(self.declaration())
return statements return statements
def skip_newlines(self):
while self.check(TokenType.NEWLINE):
self.advance()
def is_at_end(self) -> bool: def is_at_end(self) -> bool:
return self.current >= self.length return self.current >= self.length