This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
yap-6.3/packages/python/yutils.py

48 lines
876 B
Python
Raw Normal View History

2016-07-31 16:09:21 +01:00
# 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