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

"Florian Brulhart" <[email protected]>
Newsgroups gmane.comp.gnu.prolog.general
Message-ID <[email protected]>
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/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.