also derete this #3
|
@ -106,9 +106,8 @@ proc done(self: Parser): bool =
|
||||||
## end of the file. Note that the
|
## end of the file. Note that the
|
||||||
## parser expects an explicit
|
## parser expects an explicit
|
||||||
## EOF token to signal the end
|
## EOF token to signal the end
|
||||||
## of the file (unless the token
|
## of the file
|
||||||
## list is empty)
|
result = self.peek().kind == EndOfFile
|
||||||
result = self.tokens.len() == 0 or self.peek().kind == EndOfFile
|
|
||||||
|
|
||||||
|
|
||||||
proc step(self: Parser, n: int = 1): Token =
|
proc step(self: Parser, n: int = 1): Token =
|
||||||
|
@ -172,7 +171,7 @@ proc match(self: Parser, kind: openarray[TokenType]): bool =
|
||||||
|
|
||||||
proc expect(self: Parser, kind: TokenType, message: string = "") =
|
proc expect(self: Parser, kind: TokenType, message: string = "") =
|
||||||
## Behaves like self.match(), except that
|
## Behaves like self.match(), except that
|
||||||
## when a token doesn't match an error
|
## when a token doesn't match, an error
|
||||||
## is raised. If no error message is
|
## is raised. If no error message is
|
||||||
## given, a default one is used
|
## given, a default one is used
|
||||||
if not self.match(kind):
|
if not self.match(kind):
|
||||||
|
|
Loading…
Reference in New Issue