new version of python interface

This commit is contained in:
Vitor Santos Costa
2016-07-31 10:09:21 -05:00
parent 728edb6b0a
commit ee03af37fb
20 changed files with 4425 additions and 3798 deletions

47
packages/python/yutils.py Normal file
View File

@@ -0,0 +1,47 @@
# python commands
import sys
# import collections
# generated by swig
import yap
# make sure Python knows about engine
engine = None
# Mappings between functors and types
#
# they are used to have the same type f1or several occurences
# of the same functor, and to ensure that an object is indeed
# a Prolog compound term.
#
dictF2P = {}
class A:
"""Represents a non-interned Prolog atom"""
def __init__(self, s):
self.a = s
def __repr__(self):
return "A(" + self.a + ")"
def __str__(self):
return self.a
class V:
"""Wraps a term, or a reference to a logical variables"""
def __init__(self, t):
print(type(t))
self.v = t
def __repr__(self):
return "V(" + str(self.v) + ")"
def __str__(self):
return engine.getTerm(self.v).text()
def handle(self):
return self.v