summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2021-01-07 16:13:18 +0100
committerLaurenz <laurmaedje@gmail.com>2021-01-07 16:13:18 +0100
commit8275b186ba75b5e75a4108105c1ea3bfdbe6ada2 (patch)
tree14c813ddd3dfd9d4e9bd06a5b049623dcbc666cb
parent59d811aeba4491d54d2b0220109fd21a8f838b9b (diff)
Remove star-slash token ❌
-rw-r--r--src/parse/parser.rs5
-rw-r--r--src/parse/tokens.rs6
-rw-r--r--src/syntax/token.rs4
3 files changed, 5 insertions, 10 deletions
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"\"));
diff --git a/src/syntax/token.rs b/src/syntax/token.rs
index 9a7379ca..78519962 100644
--- a/src/syntax/token.rs
+++ b/src/syntax/token.rs
@@ -17,8 +17,6 @@ pub enum Token<'s> {
///
/// The comment can contain nested block comments.
BlockComment(&'s str),
- /// An end of a block comment that was not started.
- StarSlash,
/// A left bracket: `[`.
LeftBracket,
@@ -129,7 +127,6 @@ impl<'s> Token<'s> {
Self::LineComment(_) => "line comment",
Self::BlockComment(_) => "block comment",
- Self::StarSlash => "end of block comment",
Self::LeftBracket => "opening bracket",
Self::RightBracket => "closing bracket",
@@ -163,6 +160,7 @@ impl<'s> Token<'s> {
Self::Hex(_) => "hex value",
Self::Str { .. } => "string",
+ Self::Invalid("*/") => "end of block comment",
Self::Invalid(_) => "invalid token",
}
}