tl:dr - I have a single line of prolog, that works fine in one version of Prolog (SWI) but not in another (TuProlog).
I'm porting a script from SWI prolog, to Tuprolog. (TuProlog recently did a big update and I get the same behaviour on both versions)
When I put the script into TuProlog using the java setup below I get the error "The enitire string could not be read as one term".
So I cut down the script (effectively using binary search) until I reduce the script to:
iterm3(Term) --> "'", notquote(Cs), "'", { name(Term1,Cs), Term = q(Term1) }.
Which goes though swipl fine, with the following output...
cobrakai:~ josephreddington$ swipl -s /Users/josephreddington/Documents/workspace/com.plancomps.prolog.helloworld/caml-light-dynamics/Tools/Prolog/temp.pl% library(swi_hooks) compiled into pce_swi_hooks 0.00 sec, 3,992 bytes% /Users/josephreddington/Documents/workspace/com.plancomps.prolog.helloworld/caml-light-dynamics/Tools/Prolog/temp.pl compiled 0.00 sec, 1,720 bytes
Welcome to SWI-Prolog (Multi-threaded, 64 bits, Version 5.10.5)
Copyright (c) 1990-2011 University of Amsterdam, VU Amsterdam
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to redistribute it under certain conditions.
Please visit http://www.swi-prolog.org for details.
For help, use ?- help(Topic). or ?- apropos(Word).
?-
But still returns "The enitire string could not be read as one term" in Tuprolog - can anyone tell me why this might be happening?
APPENDIX: CODE USED:
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import alice.tuprolog.NoMoreSolutionException;
import alice.tuprolog.NoSolutionException;
import alice.tuprolog.Prolog;
import alice.tuprolog.SolveInfo;
import alice.tuprolog.Theory;
public class EntireStringForStackOverflow {
public static void main(String[] args) throws Exception {
Prolog engine = new Prolog();
engine.loadLibrary("alice.tuprolog.lib.DCGLibrary");
engine.addTheory(new Theory(readFile("temp.pl")));
}
private static String readFile(String file) throws IOException {
BufferedReader reader = new BufferedReader(new FileReader(file));
String line = null;
StringBuilder stringBuilder = new StringBuilder();
String ls = System.getProperty("line.separator");
while ((line = reader.readLine()) != null) {
stringBuilder.append(line);
stringBuilder.append(ls);
}
return stringBuilder.toString();
}
}