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
2016-07-31 10:09:21 -05:00

48 lines
876 B
Python

# 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