summaryrefslogtreecommitdiff
path: root/prolog/engine.py
diff options
context:
space:
mode:
authorTimotej Lazar <timotej.lazar@araneo.org>2014-12-10 13:07:45 +0100
committerAleš Smodiš <aless@guru.si>2015-08-11 14:26:00 +0200
commit9999cc8c54f5307baca61a1178e97e94dfa932ac (patch)
treed73d4f37f3958e8bad16073136a6da181c6696b9 /prolog/engine.py
parent4e7198a9c75e3c3839c73de295a9227dfb13d69b (diff)
Load prolog/lib.pl during PrologEngine init
This is always required for the safe_goal/1 predicate.
Diffstat (limited to 'prolog/engine.py')
-rw-r--r--prolog/engine.py8
1 files changed, 3 insertions, 5 deletions
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))