fix(parser): ignore meaningless newlines
This commit is contained in:
@@ -32,10 +32,16 @@ class Parser:
|
||||
self.length = len(self.tokens)
|
||||
|
||||
statements: list[Stmt] = []
|
||||
self.skip_newlines()
|
||||
while not self.is_at_end():
|
||||
self.skip_newlines()
|
||||
statements.append(self.declaration())
|
||||
return statements
|
||||
|
||||
def skip_newlines(self):
|
||||
while self.check(TokenType.NEWLINE):
|
||||
self.advance()
|
||||
|
||||
def is_at_end(self) -> bool:
|
||||
return self.current >= self.length
|
||||
|
||||
|
||||
Reference in New Issue
Block a user