From 8275b186ba75b5e75a4108105c1ea3bfdbe6ada2 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Thu, 7 Jan 2021 16:13:18 +0100 Subject: =?UTF-8?q?Remove=20star-slash=20token=20=E2=9D=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/parse/parser.rs | 5 +---- src/parse/tokens.rs | 6 +++--- 2 files changed, 4 insertions(+), 7 deletions(-) (limited to 'src/parse') diff --git a/src/parse/parser.rs b/src/parse/parser.rs index f6acff6e..974bf521 100644 --- a/src/parse/parser.rs +++ b/src/parse/parser.rs @@ -80,10 +80,7 @@ impl<'s> Parser<'s> { let before = self.next_start; if let Some(found) = self.eat() { let after = self.last_end; - self.diag(match found { - Token::Invalid(_) => error!(before .. after, "invalid token"), - _ => error!(before .. after, "unexpected {}", found.name()), - }); + self.diag(error!(before .. after, "unexpected {}", found.name())); } } diff --git a/src/parse/tokens.rs b/src/parse/tokens.rs index dee92168..77c39a4c 100644 --- a/src/parse/tokens.rs +++ b/src/parse/tokens.rs @@ -68,7 +68,7 @@ impl<'s> Iterator for Tokens<'s> { // Comments. '/' if self.s.eat_if('/') => self.line_comment(), '/' if self.s.eat_if('*') => self.block_comment(), - '*' if self.s.eat_if('/') => Token::StarSlash, + '*' if self.s.eat_if('/') => Token::Invalid(self.s.eaten_from(start)), // Functions and blocks. '[' => Token::LeftBracket, @@ -770,8 +770,8 @@ mod tests { #[test] fn test_tokenize_invalid() { // Test invalidly closed block comments. - t!(Both: "*/" => StarSlash); - t!(Both: "/**/*/" => BlockComment(""), StarSlash); + t!(Both: "*/" => Token::Invalid("*/")); + t!(Both: "/**/*/" => BlockComment(""), Token::Invalid("*/")); // Test invalid expressions. t!(Header: r"\" => Invalid(r"\")); -- cgit v1.2.3