]> Repositorios git - scryer-prolog.git/commitdiff
add location to InvalidSingleQuotedCharacter
authorSkgland <[email protected]>
Sat, 24 Jan 2026 01:23:19 +0000 (02:23 +0100)
committerBennet Bleßmann <[email protected]>
Sat, 24 Jan 2026 03:08:40 +0000 (04:08 +0100)
src/parser/ast.rs
src/parser/lexer.rs

index fe28207bca759134e3663feebf992ba11006d9bd..17caae2429903521e1c2e25f8126c427482ea5d8 100644 (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,
         }
     }
 
index ed39e210247376958452af653339cec21161d9ec..7acf76b681adfd0e6448f2169e9baa158dfaa1aa 100644 (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() {