mirror of
https://github.com/aljazceru/turso.git
synced 2026-01-08 02:34:20 +01:00
Merge 'remove UnterminatedBlockComment error' from Lâm Hoàng Phúc
close #3425 Closes #3446
This commit is contained in:
@@ -14,9 +14,6 @@ pub enum Error {
|
||||
/// Missing `]`
|
||||
#[error("non-terminated bracket at {0:?}")]
|
||||
UnterminatedBracket(#[label("here")] miette::SourceSpan),
|
||||
/// Missing `*/`
|
||||
#[error("non-terminated block comment at {0:?}")]
|
||||
UnterminatedBlockComment(#[label("here")] miette::SourceSpan),
|
||||
/// Invalid parameter name
|
||||
#[error("bad variable name at {0:?}")]
|
||||
BadVariableName(#[label("here")] miette::SourceSpan),
|
||||
|
||||
@@ -400,6 +400,9 @@ impl<'a> Lexer<'a> {
|
||||
let start = self.offset;
|
||||
self.eat_and_assert(|b| b == b'/');
|
||||
match self.peek() {
|
||||
// C-style comments begin with "/*" and extend up to and
|
||||
// including the next "*/" character pair or until
|
||||
// the end of input, whichever comes first.
|
||||
Some(b'*') => {
|
||||
self.eat_and_assert(|b| b == b'*');
|
||||
loop {
|
||||
@@ -412,19 +415,11 @@ impl<'a> Lexer<'a> {
|
||||
self.eat_and_assert(|b| b == b'/');
|
||||
break; // End of block comment
|
||||
}
|
||||
None => {
|
||||
return Err(Error::UnterminatedBlockComment(
|
||||
(start, self.offset - start).into(),
|
||||
))
|
||||
}
|
||||
None => break,
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
None => {
|
||||
return Err(Error::UnterminatedBlockComment(
|
||||
(start, self.offset - start).into(),
|
||||
))
|
||||
}
|
||||
None => break,
|
||||
_ => unreachable!(), // We should not reach here
|
||||
}
|
||||
}
|
||||
@@ -1250,6 +1245,21 @@ mod tests {
|
||||
token_type: Some(TokenType::TK_FLOAT),
|
||||
},
|
||||
),
|
||||
// issue 3425
|
||||
(
|
||||
b"/*".as_slice(),
|
||||
Token {
|
||||
value: b"/*".as_slice(),
|
||||
token_type: None,
|
||||
},
|
||||
),
|
||||
(
|
||||
b"/**".as_slice(),
|
||||
Token {
|
||||
value: b"/**".as_slice(),
|
||||
token_type: None,
|
||||
},
|
||||
),
|
||||
];
|
||||
|
||||
for (input, expected) in test_cases {
|
||||
|
||||
Reference in New Issue
Block a user