]> Repositorios git - scryer-prolog.git/commitdiff
Enhanced the implementation
authornotoria <[email protected]>
Wed, 1 Jul 2020 11:14:12 +0000 (13:14 +0200)
committernotoria <[email protected]>
Wed, 1 Jul 2020 11:14:12 +0000 (13:14 +0200)
The restriction has been removed by using read_library_path from
cfd15f4e027b4df216e723bbd35facac28a09a1c.

src/lib/tabling.pl
src/lib/tabling/batched_worklist.pl
src/lib/tabling/table_data_structure.pl
src/lib/tabling/table_link_manager.pl
src/machine/toplevel.rs

index dfe4c429113474fdf257cfd4fb95e8d5eafddb49..703da8e3dd5655ccea780d373b1ae708f2609398 100644 (file)
@@ -8,12 +8,12 @@
            op(1150, fx, table)
          ]).
 
-:- use_module(library('tabling/double_linked_list')).
-:- use_module(library('tabling/table_data_structure')).
-:- use_module(library('tabling/batched_worklist')).
-:- use_module(library('tabling/wrapper')).
-:- use_module(library('tabling/global_worklist')).
-:- use_module(library('tabling/table_link_manager')).
+:- use_module(library(tabling/double_linked_list)).
+:- use_module(library(tabling/table_data_structure)).
+:- use_module(library(tabling/batched_worklist)).
+:- use_module(library(tabling/wrapper)).
+:- use_module(library(tabling/global_worklist)).
+:- use_module(library(tabling/table_link_manager)).
 
 :- use_module(library(cont)).
 :- use_module(library(lists)).
index 7cef4f13d636de84ea148a48146bb90cf768732e..f39f8422877d892f9d64a29a3f7a90aac1e6db16 100644 (file)
@@ -45,8 +45,8 @@
            wkl_worklist_work_done/1                    % +WorkList
          ]).
 
-:- use_module(library('tabling/global_worklist')).
-:- use_module(library('tabling/double_linked_list')).
+:- use_module(library(tabling/global_worklist)).
+:- use_module(library(tabling/double_linked_list)).
 
 :- use_module(library(atts)).
 :- use_module(library(lists)).
index 107a7a00b69cc4eeb42325fbe010f2df79d2ec22..0ce989daa06c641c2c34f755654ae59f53d445ea 100644 (file)
@@ -15,8 +15,8 @@
            get_nb_identifiers/3                % +Table, -NbWorklistID, -NbAnswerTreeID
          ]).
 
-:- use_module(library('tabling/table_link_manager')).
-:- use_module(library('tabling/trie')).
+:- use_module(library(tabling/table_link_manager)).
+:- use_module(library(tabling/trie)).
 
 /*  Part of SWI-Prolog
 
@@ -53,7 +53,7 @@
     POSSIBILITY OF SUCH DAMAGE.
 */
 
-:- use_module(library('tabling/batched_worklist')).
+:- use_module(library(tabling/batched_worklist)).
 
 :- use_module(library(atts)).
 :- use_module(library(gensym)).
index 1195680c864efcae4081fca40e345de3ae18b76e..ec88f1057be10a6a2d3da2c0a27794e06d389e4a 100644 (file)
@@ -47,7 +47,7 @@
 :- use_module(library(iso_ext)).
 :- use_module(library(terms)).
 
-:- use_module(library('tabling/trie')).
+:- use_module(library(tabling/trie)).
 
 :- attribute trie_table_link/1.
 
index 9937fffe4570e6ab0e685ff653b3d7582daef5f6..eaa176918f05e0fcc066ac4da4950c54b06f2a99 100644 (file)
@@ -340,16 +340,37 @@ fn setup_module_decl(
     }
 }
 
-fn setup_use_module_decl(mut terms: Vec<Box<Term>>) -> Result<ModuleSource, ParserError> {
+fn read_library_path(
+    term: Term,
+    atom_tbl: TabledData<Atom>,
+) -> Option<ClauseName> {
+    match term {
+        Term::Constant(_, Constant::Atom(atom, _)) => {
+            Some(atom.defrock_brackets())
+        }
+        _ => {
+            let mut atoms = vec![];
+
+            for term in unfold_by_str(term, "/") {
+                match term {
+                    Term::Constant(_, Constant::Atom(atom, _)) => {
+                        atoms.push(atom.as_str().to_owned());
+                    }
+                    _ => return None,
+                }
+            }
+
+            Some(clause_name!(atoms.join("/"), atom_tbl))
+        }
+    }
+}
+
+fn setup_use_module_decl(mut terms: Vec<Box<Term>>, atom_tbl: TabledData<Atom>) -> Result<ModuleSource, ParserError> {
     match *terms.pop().unwrap() {
         Term::Clause(_, ref name, ref mut terms, None)
             if name.as_str() == "library" && terms.len() == 1 =>
         {
-            terms
-                .pop()
-                .unwrap()
-                .to_constant()
-                .and_then(|c| c.to_atom())
+            read_library_path(*terms.pop().unwrap(), atom_tbl)
                 .map(|c| ModuleSource::Library(c))
                 .ok_or(ParserError::InvalidUseModuleDecl)
         }
@@ -396,11 +417,7 @@ fn setup_qualified_import(
         Term::Clause(_, ref name, ref mut terms, None)
             if name.as_str() == "library" && terms.len() == 1 =>
         {
-            terms
-                .pop()
-                .unwrap()
-                .to_constant()
-                .and_then(|c| c.to_atom())
+            read_library_path(*terms.pop().unwrap(), atom_tbl.clone())
                 .map(|c| ModuleSource::Library(c))
                 .ok_or(ParserError::InvalidUseModuleDecl)
         }
@@ -685,7 +702,7 @@ fn setup_declaration<'a, 'b, 'c>(
                     }
                 }
                        ("use_module", 1) => {
-                           Ok(Declaration::UseModule(setup_use_module_decl(terms)?))
+                           Ok(Declaration::UseModule(setup_use_module_decl(terms, indices.atom_tbl())?))
                 }
                        ("use_module", 2) => {
                            let (name, exports) = setup_qualified_import(terms, indices.atom_tbl())?;