From aab0e0a59114cf68040b07a5ab6248b40068bcb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emmanuel=20Beno=C3=AEt?= Date: Sat, 31 Dec 2022 00:02:41 +0100 Subject: [PATCH] Scanner - Add the EOF token --- src/scanner.rs | 5 +++++ src/tokens.rs | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/scanner.rs b/src/scanner.rs index 981b0c9..0098e14 100644 --- a/src/scanner.rs +++ b/src/scanner.rs @@ -62,6 +62,11 @@ impl Scanner { self.start = self.current; self.scan_token(err_hdl); } + self.tokens.push(Token { + token_type: TokenType::EOF, + lexeme: String::from(""), + line: self.line, + }); self.tokens } diff --git a/src/tokens.rs b/src/tokens.rs index 565265d..f9a91ea 100644 --- a/src/tokens.rs +++ b/src/tokens.rs @@ -43,7 +43,7 @@ pub enum TokenType { Var, While, - _EOF, + EOF, } /// Full information about a token.