new version of python interface
This commit is contained in:
47
packages/python/yutils.py
Normal file
47
packages/python/yutils.py
Normal 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
|
||||
|
Reference in New Issue
Block a user