docs & python:

This commit is contained in:
Vitor Santos Costa
2018-05-30 21:54:12 +01:00
parent 9afb5b07b2
commit bbd0122fc3
6 changed files with 78 additions and 47 deletions

View File

@@ -69,16 +69,14 @@ argi(N,I,I1) :-
I1 is I+1.
python_query( Caller, String ) :-
writeln(String),
atomic_to_term( String, Goal, VarNames ),
query_to_answer( Goal, VarNames, Status, Bindings),
Caller.q.port := Status,
% := print( gc.get_referrers(Caller.port)),
atomic_to_term( String, Goal, VarNames ),
query_to_answer( Goal, VarNames, Status, Bindings),
atom_to_string( Status, SStatus ),
Caller.q.port := SStatus,
write_query_answer( Bindings ),
nl(user_error),
Caller.q.answer := {},
maplist(in_dict(Caller.q.answer), Bindings).
% := print( "b", gc.get_referrers(Caller.answer)).
in_dict(Dict, var([V0,V|Vs])) :- !,
Dict[V] := V0,

View File

@@ -70,17 +70,14 @@ class Query:
def __next__(self):
if not self.q:
raise StopIteration()
if self.port == "exit":
self.close()
return
if self.q.next():
rc = self.answer
return rc
else:
if self.q:
self.close()
raise RuntimeError()
if self.port == "exit":
return
else:
if self.q.next():
return self.port,self.answer
else:
self.close()
def close( self ):
if self.q:
@@ -140,7 +137,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
#import pdb; 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
@@ -156,15 +153,13 @@ class YAPShell:
g.release()
g = python_query(self, query)
self.q = Query( engine, g )
print(self.q.port)
for bind in self.q:
print(bind,self.q.port)
for port,bind in self.q:
bindings += [bind]
if port == "exit":
break
if loop:
continue
if self.q.port == "exit":
break
s = input("more(;), all(*), no(\\n), python(#) ?").lstrip()
s = input("more(;), all(*), no(\\n), python(#)? ").lstrip()
if s.startswith(';') or s.startswith('y'):
continue
elif s.startswith('#'):