Scanner - Add the EOF token

This commit is contained in:
Emmanuel BENOîT 2022-12-31 00:02:41 +01:00
parent ed03d565ea
commit aab0e0a591
2 changed files with 6 additions and 1 deletions

View file

@ -62,6 +62,11 @@ impl Scanner {
self.start = self.current; self.start = self.current;
self.scan_token(err_hdl); self.scan_token(err_hdl);
} }
self.tokens.push(Token {
token_type: TokenType::EOF,
lexeme: String::from(""),
line: self.line,
});
self.tokens self.tokens
} }

View file

@ -43,7 +43,7 @@ pub enum TokenType {
Var, Var,
While, While,
_EOF, EOF,
} }
/// Full information about a token. /// Full information about a token.