Fixed some lexer/parser bugs related to lexer errors.
This commit is contained in:
parent
6ac075ffd0
commit
4e3f1677be
@ -118,11 +118,10 @@ impl<'a> Lexer<'a> {
|
||||
}
|
||||
}
|
||||
if !terminated {
|
||||
return Some(Err(LexerError::new(
|
||||
self.position,
|
||||
end,
|
||||
LexerErrorKind::UnterminatedString,
|
||||
)));
|
||||
let err =
|
||||
LexerError::new(self.position, end, LexerErrorKind::UnterminatedString);
|
||||
self.position = end;
|
||||
return Some(Err(err));
|
||||
}
|
||||
(end, TokenKind::String)
|
||||
} else {
|
||||
@ -137,11 +136,13 @@ impl<'a> Lexer<'a> {
|
||||
}
|
||||
|
||||
if prefix.len() == 0 {
|
||||
return Some(Err(LexerError::new(
|
||||
let err = LexerError::new(
|
||||
self.position,
|
||||
self.position + 1,
|
||||
LexerErrorKind::UnrecognizedCharacter(chunk.chars().next().unwrap()),
|
||||
)));
|
||||
);
|
||||
self.position += 1;
|
||||
return Some(Err(err));
|
||||
}
|
||||
|
||||
let token_kind = match prefix.as_str() {
|
||||
|
||||
@ -1166,7 +1166,20 @@ impl<'a> Parser<'a> {
|
||||
}
|
||||
|
||||
fn expression(&mut self) -> MaybeParseResult<Expression> {
|
||||
if self.current.is_some() {
|
||||
if matches_expression_first!(self.current.as_ref().unwrap().kind()) {
|
||||
self.bitwise_or_expression()
|
||||
} else {
|
||||
let diagnostic = Self::get_expected_but_found(
|
||||
&EXPRESSION_FIRSTS,
|
||||
self.current.as_ref().unwrap(),
|
||||
);
|
||||
MaybeParseResult::none(vec![diagnostic])
|
||||
}
|
||||
} else {
|
||||
let diagnostic = Self::get_expected_but_found_eoi(&EXPRESSION_FIRSTS, 0);
|
||||
MaybeParseResult::none(vec![diagnostic])
|
||||
}
|
||||
}
|
||||
|
||||
fn bitwise_or_expression(&mut self) -> MaybeParseResult<Expression> {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user