add location to InvalidSingleQuotedCharacter

This commit is contained in:
Skgland
2026-01-24 02:23:19 +01:00
committed by Bennet Bleßmann
parent 083546442d
commit bd233fedfd
2 changed files with 7 additions and 5 deletions

View File

@@ -452,7 +452,7 @@ pub enum ParserError {
IO(IOError),
IncompleteReduction(Location),
InfiniteFloat(Location),
InvalidSingleQuotedCharacter(char),
InvalidSingleQuotedCharacter(char, Location),
LexicalError(lexical::Error),
MissingQuote(Location),
NonPrologChar(Location),
@@ -466,6 +466,7 @@ impl ParserError {
pub fn location(&self) -> Option<Location> {
match self {
ParserError::BackQuotedString(location)
| ParserError::InvalidSingleQuotedCharacter(_, location)
| ParserError::IncompleteReduction(location)
| ParserError::InfiniteFloat(location)
| ParserError::MissingQuote(location)
@@ -473,9 +474,7 @@ impl ParserError {
| ParserError::ParseBigInt(location)
| ParserError::UnexpectedChar(_, location) => Some(location.clone()),
ParserError::Utf8Error(location) => location.as_ref().cloned(),
ParserError::IO(_)
| ParserError::LexicalError(_)
| ParserError::InvalidSingleQuotedCharacter(_) => None,
ParserError::IO(_) | ParserError::LexicalError(_) => None,
}
}

View File

@@ -632,7 +632,10 @@ impl<'a, R: CharRead> Lexer<'a, R> {
}
}
} else {
return Err(ParserError::InvalidSingleQuotedCharacter(c));
return Err(ParserError::InvalidSingleQuotedCharacter(
c,
self.location.clone(),
));
}
} else {
match self.get_back_quoted_string() {