treat unexpected EOF as incomplete reduction in bracketed_comment
This commit is contained in:
@@ -117,7 +117,7 @@ impl<R: Read> CharReader<R> {
|
|||||||
// Branch using `>=` instead of the more correct `==`
|
// Branch using `>=` instead of the more correct `==`
|
||||||
// to tell the compiler that the pos..cap slice is always valid.
|
// to tell the compiler that the pos..cap slice is always valid.
|
||||||
if self.pos >= self.buf.len() {
|
if self.pos >= self.buf.len() {
|
||||||
debug_assert!(self.pos == self.buf.len());
|
debug_assert!(self.pos >= self.buf.len());
|
||||||
|
|
||||||
self.buf.clear();
|
self.buf.clear();
|
||||||
|
|
||||||
|
|||||||
@@ -168,17 +168,32 @@ impl<'a, R: CharRead> Lexer<'a, R> {
|
|||||||
|
|
||||||
let mut c = self.lookahead_char()?;
|
let mut c = self.lookahead_char()?;
|
||||||
|
|
||||||
loop {
|
let mut comment_loop = || {
|
||||||
while !comment_2_char!(c) {
|
loop {
|
||||||
|
while !comment_2_char!(c) {
|
||||||
|
self.skip_char(c);
|
||||||
|
c = self.lookahead_char()?;
|
||||||
|
}
|
||||||
|
|
||||||
self.skip_char(c);
|
self.skip_char(c);
|
||||||
c = self.lookahead_char()?;
|
c = self.lookahead_char()?;
|
||||||
|
|
||||||
|
if comment_1_char!(c) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.skip_char(c);
|
Ok(())
|
||||||
c = self.lookahead_char()?;
|
};
|
||||||
|
|
||||||
if comment_1_char!(c) {
|
match comment_loop() {
|
||||||
break;
|
Err(ParserError::UnexpectedEOF) => {
|
||||||
|
return Err(ParserError::IncompleteReduction(self.line_num, self.col_num));
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
return Err(e);
|
||||||
|
}
|
||||||
|
Ok(_) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user