fix(parser): ignore meaningless newlines
This commit is contained in:
@@ -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
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user