From 9999cc8c54f5307baca61a1178e97e94dfa932ac Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Wed, 10 Dec 2014 13:07:45 +0100 Subject: Load prolog/lib.pl during PrologEngine init This is always required for the safe_goal/1 predicate. --- prolog/engine.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'prolog') diff --git a/prolog/engine.py b/prolog/engine.py index 2878933..f94a6ab 100644 --- a/prolog/engine.py +++ b/prolog/engine.py @@ -93,6 +93,9 @@ class PrologEngine(object): } self.err_flags = PL_Q_NODEBUG|PL_Q_CATCH_EXCEPTION + # Load the sandbox and compatibility library. + self.call('consult/1', [Term(Atom('prolog/lib.pl'))]) + # Increase memory limits. self.call('set_prolog_stack/2', [Term('global'), Term('limit(2*10**9)')]) self.call('set_prolog_stack/2', [Term('local'), Term('limit(2*10**9)')]) @@ -128,9 +131,6 @@ class PrologEngine(object): PL_cut_query(qid) return True - def consult(self, filename): - return self.call('consult/1', [Term(Atom(filename))]) - # Get up to [n] solutions to query [q]. def query(self, q, module=None, n=1): if module is not None: @@ -229,8 +229,6 @@ class PrologEngine(object): # Basic sanity check. if __name__ == '__main__': engine = PrologEngine() - engine.consult('prolog/lib.pl') - engine.load_solution(0, 'a(2). a(2). a(3). ') result = engine.test(0, 0, 'a(2). ', ['a(X)', 'a(Y), Y=X']) print('{}: {}'.format(i, result)) -- cgit v1.2.1