From bd233fedfd6ef10743bee2035176d13c561d7274 Mon Sep 17 00:00:00 2001 From: Skgland Date: Sat, 24 Jan 2026 02:23:19 +0100 Subject: [PATCH] add location to InvalidSingleQuotedCharacter --- src/parser/ast.rs | 7 +++---- src/parser/lexer.rs | 5 ++++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/parser/ast.rs b/src/parser/ast.rs index fe28207b..17caae24 100644 --- a/src/parser/ast.rs +++ b/src/parser/ast.rs @@ -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 { 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, } } diff --git a/src/parser/lexer.rs b/src/parser/lexer.rs index ed39e210..7acf76b6 100644 --- a/src/parser/lexer.rs +++ b/src/parser/lexer.rs @@ -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() { -- 2.54.0