]> Repositorios git - scryer-prolog.git/commitdiff
split error classification
authorMark Thom <[email protected]>
Thu, 30 Aug 2018 03:20:56 +0000 (21:20 -0600)
committerMark Thom <[email protected]>
Thu, 30 Aug 2018 03:20:56 +0000 (21:20 -0600)
src/prolog/ast.rs
src/prolog/parser
src/prolog/read.rs

index f8e0a3854f198459e4799216b9593f5f6953f1d9..693c98e63af9789727ce22201539751b43798b95 100644 (file)
@@ -499,6 +499,7 @@ pub enum ParserError
     InvalidUseModuleDecl,
     InvalidModuleResolution,
     MissingQuote,
+    NonPrologChar,
     ParseBigInt,
     ParseFloat,
     Utf8Conversion(Utf8Error)
index f367d551e23d22b9514abecff7dc8182b7e04055..0df920d5a89da22921423f35263f4b61ce576c28 160000 (submodule)
@@ -1 +1 @@
-Subproject commit f367d551e23d22b9514abecff7dc8182b7e04055
+Subproject commit 0df920d5a89da22921423f35263f4b61ce576c28
index 1e37d79980498e18abfa55b6d54cf44f3ff5efff..ced9bd2d1e269d79b608e3d3650785ab7a767b33 100644 (file)
@@ -31,14 +31,19 @@ impl<'a> Reader<'a> {
         let mut buffer = String::new();
 
         let stdin = stdin();
-        stdin.read_line(&mut buffer).unwrap();
-
-        let atom_tbl = self.machine_st.atom_tbl.clone();
-        let string_tbl = self.machine_st.string_tbl.clone();
         let flags = self.machine_st.machine_flags();
-        
-        let mut parser = Parser::new(buffer.as_bytes(), atom_tbl, string_tbl, flags);
-        Ok(self.write_term_to_heap(parser.read_term(op_dir)?))
+
+        loop {
+            stdin.read_line(&mut buffer).unwrap();
+            let mut parser = Parser::new(buffer.as_bytes(), self.machine_st.atom_tbl.clone(),
+                                         self.machine_st.string_tbl.clone(), flags);
+
+            match parser.read_term(op_dir) {
+                Err(ParserError::UnexpectedEOF) => continue,
+                Err(e) => return Err(e),
+                Ok(term) => return Ok(self.write_term_to_heap(term))
+            };
+        }
     }
 
     fn push_stub_addr(&mut self) {
@@ -66,7 +71,7 @@ impl<'a> Reader<'a> {
             let h = self.machine_st.heap.h;
 
             match &term {
-                &TermRef::Cons(lvl, ..) => {                    
+                &TermRef::Cons(lvl, ..) => {
                     queue.push_back((2, h+1));
                     self.machine_st.heap.push(HeapCellValue::Addr(Addr::Lis(h+1)));
 
@@ -105,12 +110,12 @@ impl<'a> Reader<'a> {
                         } else {
                             var_dict.insert(var.clone(), Addr::HeapCell(site_h));
                         }
-                        
+
                         if arity > 1 {
                             queue.push_front((arity - 1, site_h + 1));
                         }
                     }
-                        
+
                     continue;
                 },
                 _ => {}