This commit is contained in:
Vitor Santos Costa
2018-06-01 08:37:25 +01:00
parent 7325407d23
commit 725a0a692a
10 changed files with 205 additions and 218 deletions

View File

@@ -73,7 +73,6 @@ python_query( Caller, String ) :-
query_to_answer( Goal, VarNames, Status, Bindings),
atom_to_string( Status, SStatus ),
Caller.port := SStatus,
start_low_level_trace,
write_query_answer( Bindings ),
nl(user_error),
Caller.answer := {},
@@ -88,4 +87,4 @@ in_dict(Dict, nonvar([V0|Vs],G)) :- !,
Dict[V0] := G,
in_dict( Dict, nonvar(Vs, G) ).
in_dict(_Dict, nonvar([],_G)) :- !.
in_dict(_, _).
in_dict(_, _)

View File

@@ -66,17 +66,10 @@ class Query (YAPQuery):
return self
def __next__(self):
if self.port == "exit" or self.port == "fail":
return
else:
if self.next():
return self.port,self.answer
else:
self.close()
def close( self ):
self.engine.reSet()
if self.port == "fail":
raise IndexError()
return self.next()
def name( name, arity):
try:
if arity > 0 and name.isidentifier(): # and not keyword.iskeyword(name):
@@ -141,13 +134,11 @@ class YAPShell:
engine = self.engine
bindings = []
loop = False
if g:
g.release()
g = python_query(self, query)
self.q = Query( engine, g )
for port,bind in self.q:
bindings += [bind]
if port == "exit":
while self.q.next():
bindings += [self.q.answer]
if self.q.port == "exit":
break
if loop:
continue
@@ -189,7 +180,6 @@ class YAPShell:
if not s:
continue
else:
print(s)
self.query_prolog(s)
except SyntaxError as err:
print("Syntax Error error: {0}".format(err))