0

I want to use Prolog in SublimeREPL. I set up correctly the interpreter (swipl or gprolog) in the config file of SublimeREPL and everything works fine except for one thing: the start character "?-" of the line never show up, an if a get a result like "X=1" when I press Enter what happen in the terminal is print a dot "X=1." and make a new line starting with "?-". In SublimeREPL there is no dot and the new line doesn't start with anything. Is there a solution for have the same behavior of the terminal?

BhavikKama
  • 8,566
  • 12
  • 94
  • 164

1 Answers1

0

I have partial success with Sublime Text 2 running on MacOS X by using the following Main.sublime-menu file contents:

[
     {
        "id": "tools",
        "children":
        [{
            "caption": "SublimeREPL",
            "mnemonic": "r",
            "id": "SublimeREPL",
            "children":
            [
                {"command": "repl_open", 
                 "caption": "Prolog",
                 "id": "repl_prolog",
                 "mnemonic": "l",
                 "args": {
                    "type": "subprocess",
                    "encoding": "utf8",
                    "cmd": ["gprolog"],
                    "cwd": "$file_path",
                    "external_id": "prolog",
                    "syntax": "Packages/Logtalk/Logtalk.tmLanguage"
                    }
                }
            ]   
        }]
    }
]

I get the GNU Prolog startup banner and I can type queries and get the query results. But there's an issue that I have not yet solved with the handling of new lines: when typing ; to ask the Prolog interpreter for the next proof, I cannot get the last one. For example:

GNU Prolog 1.4.4 (64 bits)
Compiled Apr 23 2013, 17:24:33 with /opt/local/bin/gcc-apple-4.2
By Daniel Diaz
Copyright (C) 1999-2013 Daniel Diaz
| ?- member(X, [1,2,3]).


X = 1 ? ;
;

X = 2 ? 

yes
| ?- 

Seems to be a problem handling echo and new lines. The first ; is echoed but then I don't get a chance to type a second ; after getting the second solution.

Paulo Moura
  • 18,373
  • 3
  • 23
  • 33
  • Using SWI-Prolog as the interpreter, I also don't get a prompt but there's no problem with `;` when going through all the solutions. – Paulo Moura Aug 31 '13 at 11:38
  • I have tried with your settings but nothing changes (I'm using Linux Mint). – Chiara Doppiomalto Aug 31 '13 at 13:47
  • Which GNU Prolog and SWI-Prolog versions are you using? I used GNU Prolog 1.4.4 and SWI-Prolog 6.5.2 in my tests. – Paulo Moura Aug 31 '13 at 14:03
  • GNU Prolog 1.3.0 and swipl 5.10.4 (those are the version that I have installed through apt-get) – Chiara Doppiomalto Aug 31 '13 at 14:12
  • Those are very old versions. It may be worth installing the latest ones by compiling from sources and try again. – Paulo Moura Aug 31 '13 at 14:47
  • Upgrading to gprolog 1.4.2 nothing changes. The problem is not the old version. – Chiara Doppiomalto Aug 31 '13 at 16:04
  • @PauloMoura can you please tell me how to configure sublimeREPL on windows ?, i have downloaded this for windows http://www.swi-prolog.org/download/stable but i don't know how to set it to the sublimeREPL, besides i have downloaded the prolog plugin on ST2 and couldn't find the way to interpreter it. – Tarek Oct 05 '13 at 04:49
  • I'm not a Windows user but I assume that the configuration will be similar to the one I posted above. You will likely need to ensure that the SWI-Prolog executable can be found using the system PATH variable. Not sure about what you mean by "interpreting" the plug-in, however. The plug-in is a directory and inside it you should find the Prolog syntax file whose path goes into the REPL configuration. – Paulo Moura Oct 05 '13 at 18:52