debugging

This commit is contained in:
Vitor Santos Costa
2018-05-24 12:00:10 +01:00
parent ebe4ba266e
commit bb2d06fac9
19 changed files with 106 additions and 106 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
@@ -148,12 +147,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'):
@@ -168,13 +167,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")
print(dir(e))
return False, None
@@ -209,7 +210,7 @@ class YAPShell:
def __init__(self, engine, **kwargs):
self.engine = engine
self.live(engine)
self.q = None
def main():