Merge /home/vsc/yap

This commit is contained in:
Vítor Santos Costa
2018-05-24 21:48:08 +01:00
20 changed files with 116 additions and 115 deletions

View File

@@ -66,7 +66,7 @@ argi(N,I,I1) :-
I1 is I+1.
python_query( Caller, String ) :-
atomic_to_term( String, Goal, VarNames ),
atomic_to_term( String, Goal, VarNames ),
query_to_answer( Goal, VarNames, Status, Bindings),
Caller.port := Status,
% := print( gc.get_referrers(Caller.port)),

View File

@@ -1,33 +0,0 @@
import imp
import os
import ctypes
import glob
import os.path
import platform
import sys
global yap_lib_path
yap_lib_path = "/usr/local/lib"
if platform.system() == 'Windows':
def load( dll ):
dll = glob.glob(os.path.join(yap_lib_path,dll))[0]
dll = os.path.abspath(dll)
ctypes.WinDLL(dll)
elif platform.system() == 'Darwin':
def load( dll ):
dll = glob.glob(os.path.join(os.path.dirname(__file__),dll))[0]
dll = os.path.abspath(dll)
ctypes.CDLL(dll)
print('loaded ',dll)
# try:
# load( '_yap*.so' )
# except:
# load( '_yap*.dylib' )
else:
def load( dll ):
dll = glob.glob(os.path.join(os.path.dirname(__file__),dll))[0]
dll = os.path.abspath(dll)
ctypes.CDLL(dll)
#load('_yap*.so')

View File

@@ -72,8 +72,7 @@ class Query:
if self.q.next():
rc = self.answer
if self.port == "exit":
self.close()
return rc
return rc
else:
if self:
self.close()
@@ -106,7 +105,7 @@ class v(YAPVarTerm,v0):
class YAPShell:
def numbervars( self ):
Dict = {}
self.engine.goal(show_answer( self, Dict))
@@ -135,7 +134,7 @@ class YAPShell:
# # vs is the list of variables
# you can print it out, the left-side is the variable name,
# the right side wraps a handle to a variable
# pdb.set_trace()
import pdb; pdb.set_trace()
# #pdb.set_trace()
# atom match either symbols, or if no symbol exists, sttrings, In this case
# variable names should match strings
@@ -149,12 +148,12 @@ class YAPShell:
bindings = []
loop = False
g = python_query(self, query)
self.q = Query( engine, g )
for bind in self.q:
q = Query( engine, g )
for bind in q:
bindings += [bind]
if loop:
continue
if not self.q.port == "exit":
if not q.port == "exit":
break
s = input("more(;), all(*), no(\\n), python(#) ?").lstrip()
if s.startswith(';') or s.startswith('y'):
@@ -169,13 +168,15 @@ class YAPShell:
continue
else:
break
if self.q:
if q:
self.os = query
if bindings:
return True,bindings
print("No (more) answers")
return False, None
except Exception as e:
if not q:
return False, None
print("Exception")
return False, None
@@ -210,7 +211,7 @@ class YAPShell:
self.engine = engine
self.live(engine)
self.q = None
def main():