users-prolog
[Top][All Lists]
Advanced

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

interfacing a gprolog process on Windows (with LINEDIT=...)


From: Florian Brulhart
Subject: interfacing a gprolog process on Windows (with LINEDIT=...)
Date: Wed, 25 Jan 2006 11:18:12 +0100

Hi,

I'm trying to write a plugin for Eclipse dedicated to GNU prolog programming. In this context, I start GNU prolog as a separate process, writing commands to the interpreter (e.g. compilations with consult(...)), and reading the results (e.g. parsing error messages). I'm working on Windows, so I set the LINEDIT environment variable to "gui=no".

It works for simple commands. But there seems to be a difference in the behavior of gprolog between an interactive command-line and a separate process : when there is multiple answers, I getan endless loop with the prompt

 Action (; for next solution, a for all solutions, RET to stop) ?

while I do not send any character on the pipe.

Any hint about that problem would be welcome.

Here is a small Java program as an illustration of my problem.

Note that the problem only happens on Windows; on Solaris, it seems to work (but the "| ?-" prompt also disappears...why ?).

Thanks in advance.

--------------------------------------------------------------------------
--------------------  Java program
--------------------------------------------------------------------------
import java.io.*;
public class CallingProlog {
 static InputStreamReader fromProlog;
 static OutputStream      toProlog;
// ----------------------------------------------------------------------
 public static void main (String [] args) throws IOException{
   startProlog();
   while(true) {
     if (fromProlog.ready()) {  // something to read from gprolog process
       System.out.write( (char)(fromProlog.read()));
       System.out.flush();
     }
     if (System.in.available()>0) { // something to read from stdin
       toProlog.write((char)(System.in.read()));
       toProlog.flush();
     }
   }
 }
 // ----------------------------------------------------------------------
 public static void startProlog() throws IOException {
   String Cmd = "gprolog";
   Process prcss = Runtime.getRuntime().exec(Cmd);
   fromProlog = new InputStreamReader(prcss.getInputStream());
   toProlog = prcss.getOutputStream();
 }
}

--------------------------------------------------------------------------
--------------------  Execution
--------------------------------------------------------------------------
E:\java CallingProlog
GNU Prolog 1.2.16
By Daniel Diaz
Copyright (C) 1999-2002 Daniel Diaz
append([],A,[]).

A = []

yes
append(A,B,C).

A = []
C = B ?
Action (; for next solution, a for all solutions, RET to stop) ?
Action (; for next solution, a for all solutions, RET to stop) ?
Action (; for next solution, a for all solutions, RET to stop) ?
...

_________________________________________________________________
Sur MSN vous trouverez les réponses à toutes les questions que vous posez!!! http://search.fr.msn.ch/





reply via email to

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