[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to add predicates to the gnu-prolog engine at runtime from C?

From: tvetunge
Subject: How to add predicates to the gnu-prolog engine at runtime from C?
Date: Wed, 19 Mar 2003 01:14:51 +0100


This question has been up before, almost. Only the answer presumed the 
in question were known at compile-time. This is not the case for me.

I want to write an environment (virtual world) with support for dynamic changes
of rules and facts of the environment while the environment is running.
Imagine one window where the intended user can move about and interact, and
one beside it where the rules are listed and can be changed.

For this I need a function like 
c_assert(  "at(tree,apple)."  );       
c_retract(  "at(tree,apple)."  );

My problem in this is that I see no function in the c-interface supporting
To be able to do it at all, it would seem I'd have to write my own prolog-parser
that then translates the predicates 


into PlTerms == WamWords == longs, which gnu-prolog uses for passing predicates
back and forth between engine and c.

For this I've been searching the sourcecode, in the hope that in there such
a parser were already present. It appears to be, but in Prolog, not C.. so
I have trouble reading it.

I am looking for a predicate that translates an input string to an output

If I had such a predicate, I could use a Pl_Query_Call to make use of it
like suggested by Vic Bancroft earlier. 
( )

And then, with WamWord in hand, another query could be made that did what
I wanted.

It seems code_generation/5 in /src/Pl2Wam/ might do this, but
I'm not sure, and I don't know how to use it. My attempts failed :]

So what I'm basically looking for is information on which function in the
source that provides translation from string predicates to PlTerms as the
interface understands them.

Also ideas on how to tackle multiple-line assertions would be most welcome.
Many predicates are pretty long.

Regards, Uffe Wassmann.

Få din egen webmail på - gratis og med dig overalt!
Træt af virus? Få gratis beskyttelse her:

reply via email to

[Prev in Thread] Current Thread [Next in Thread]