Adding a tuprolog REPL

All questions and suggestions about the plugin system
Post Reply
dunmatt
Posts: 22
Joined: Sat 28. Jul 2012, 02:36

Adding a tuprolog REPL

Post by dunmatt » Wed 2. Oct 2013, 01:43

Hello all. I'm working with a robot simulator that is visualized in jReality. The experience is great, I have it bound so that from the PythonConsole I can access the relevant java objects and interact with the simulated robot at the API level. :D

Now that the time has come to add symbolic reasoning to the robot I'm integrating tuProlog, and it would be really nice if I could use a plugin like the python REPL that would instead allow me to interact with the prolog instance. How hard would that be to build? Trying to understand the source of PythonConsole.java given the docs at http://www3.math.tu-berlin.de/jreality/ ... ng_started has left me with quite a few scary unknowns. Are there other relevant docs somewhere that I haven't found yet? Do you happen to know what I'd have to do to pull this off?

sechel
Posts: 69
Joined: Tue 2. Oct 2007, 09:20

Re: Adding a tuprolog REPL

Post by sechel » Wed 2. Oct 2013, 18:17

Hi,
thanks for using jReality and the recently integrated Python support. Actually I'm not getting what you are trying to achieve. Please provide more information about this tuProlog gadget. What is it and how do you want to use it? How does it integrate with native Python? What is REPL?
Best
Stefan

dunmatt
Posts: 22
Joined: Sat 28. Jul 2012, 02:36

Re: Adding a tuprolog REPL

Post by dunmatt » Wed 2. Oct 2013, 21:30

Ah, sorry, I should have been more clear. REPL is Read Eval Print Loop. If you open a terminal and type "python" it will take you into the Python REPL, similarly, if in jReality you've added the PythonConsole plugin and you open the bottom slot you find yourself in a Jython REPL.

tuProlog is a pure-Java implementation of the Prolog langauge. It has the nice feature that it can be used as a Java library to add logic programming capabilities to any Java program. What I'd like to do is create a Prolog REPL plugin, so that I can interact with Prolog from inside a jReality Viewer's bottom slot.

The difficulty I'm running into is that it's not obvious to me how de.jreality.plugin.scripting.PythonConsole attaches to jReality. For example, how does the keyboard input get to the PythonInterpreter object? How do the results from interpreting the entered code appear in the JTextPane? Etc.

Or, if it would be easier, could I implement de.jtem.jterm.StringEvaluator and somehow use that as a plugin?

dunmatt
Posts: 22
Joined: Sat 28. Jul 2012, 02:36

Re: Adding a tuprolog REPL

Post by dunmatt » Wed 2. Oct 2013, 23:40

Just to follow up, this turned out to be much simpler than I had expected. Using StringEvaluator and JTerm works beautifully. To see my plugin in action (or if you want to add symbolic reasoning to your own jReality applications) check out https://github.com/dunmatt/tujr

Post Reply