]> Repositorios git - scryer-prolog.git/commitdiff
recognize missing syntax errors (#1354, #1361)
authorMark Thom <[email protected]>
Wed, 23 Mar 2022 04:48:51 +0000 (22:48 -0600)
committerMark Thom <[email protected]>
Wed, 23 Mar 2022 04:48:51 +0000 (22:48 -0600)
src/heap_print.rs
src/parser/lexer.rs
src/read.rs

index 7d00c0d0eca505a0c105d4adfe146168b3dd620c..8ee3ec678fae364cb2519e11319cabe9f1f67030 100644 (file)
@@ -176,15 +176,8 @@ fn char_to_string(is_quoted: bool, c: char) -> String {
         '\'' | '\n' | '\r' | '\t' | '\u{0b}' | '\u{0c}' | '\u{08}' | '\u{07}' | '"' | '\\' => {
             c.to_string()
         }
-        '\u{0}'..='\u{1f}' => format!("\\x{:x}", c as u32), // print all other control characters in hex.
+        '\u{0}'..='\u{1f}' => format!("\\x{:x}\\", c as u32), // print all other control characters in hex.
         _ => c.to_string(),
-        /*
-        '\u{a0}'..='\u{d6}' => c.to_string(),
-        '\u{d8}'..='\u{f6}' => c.to_string(),
-        '\u{f8}'..='\u{74f}' => c.to_string(),
-        '\x20'..='\x7e' => c.to_string(),
-        _ => format!("\\x{:x}\\", c as u32),
-        */
     }
 }
 
index 4696b2269a99c20e6c584842fe6bb0729cd1e2ec..4c541016254e20f0e751bf104279b4c249560bf6 100644 (file)
@@ -367,7 +367,7 @@ impl<'a, R: CharRead> Lexer<'a, R> {
         if hexadecimal_digit_char!(c) {
             self.escape_sequence_to_char(|c| hexadecimal_digit_char!(c), 16)
         } else {
-            Err(ParserError::UnexpectedChar(c, self.line_num, self.col_num))
+            Err(ParserError::IncompleteReduction(self.line_num, self.col_num))
         }
     }
 
@@ -400,11 +400,7 @@ impl<'a, R: CharRead> Lexer<'a, R> {
                 },
             )
         } else {
-            // on failure, restore the token characters and backslash.
-            // self.reader.put_back_all(token.chars().map(Ok));
-            // self.reader.put_back(Ok('\\'));
-
-            Err(ParserError::UnexpectedChar(c, self.line_num, self.col_num))
+            Err(ParserError::IncompleteReduction(self.line_num, self.col_num))
         }
     }
 
index 256d805b221332ac52e75d7c6fd936dd69a5010c..20af4836aa6dcbad11a8a2b2ea8c20cf12483ad9 100644 (file)
@@ -21,8 +21,6 @@ use std::io::{Cursor, Error, ErrorKind, Read};
 
 type SubtermDeque = VecDeque<(usize, usize)>;
 
-// pub(crate) type PrologStream = ParsingStream<Stream>;
-
 impl MachineState {
     pub(crate) fn devour_whitespace(
         &mut self,