使用 Sublime text 3 构建 SWI 序言项目

Using Sublime text 3 to build SWI prolog projects

我可以在 windows 上使用 SWI prolog 在 sublime text 中构建吗?

我尝试过的: 我使用包控制在这里安装 Prolog 包: https://github.com/alnkpa/sublimeprolog 我安装了 SWI 序言,但无法构建。可能swi的文件路径或名称有误?

提前致谢!

/杰西

我收到这个错误:

    [WinError 2] File not found (Det går inte att hitta filen)
    [cmd: ['swipl', '-f', '', '-t', 'main', '--quiet']]
    [dir: C:\Program Files\Sublime Text 3]
    [path: C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files\MATLAB\R2014b\runtime\win64;C:\Program Files\MATLAB\R2014b\bin;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files\Microsoft Data Protection Manager\DPM\bin\VDDK\bin\]
    [Finished]

更新----------------------------------------- --------------------------

根据 Danilo 的建议,我确保我有一个包含主要功能的保存文件。但我仍然遇到同样的错误。有什么想法吗?

[WinError 2] File not found
[cmd: ['swipl', '-f', 'testa.pl', '-t', 'main', '--quiet']]
[dir: C:\Users\psyk-jcr\Documents\Forskning\Prolog meta-analys\Kod]
[path: C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files\MATLAB\R2014b\runtime\win64;C:\Program Files\MATLAB\R2014b\bin;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files\Microsoft Data Protection Manager\DPM\bin\VDDK\bin\]
[Finished]

您似乎还没有将程序保存到文件中。看这里

[cmd: ['swipl', '-f', '', '-t', 'main', '--quiet']]

您的 sublime 构建系统准备与子句 main/0 统一。所以你的程序入口点应该是这样的

main :-
    write("hello, world!\n").

发生这种情况是因为构建文件没有正确放置,您需要从包管理器安装 (PackageResourceviewer) 然后: 1- 从工具选项卡 select 命令调色板或 (ctrl+shift+p) 2- 搜索:PackageResourceviewer: open resource and select it 3- 在我们的案例序言中搜索您的包并 select 它 4- select prolog.sublime-构建 5-

{
    "cmd": ["swipl", "-f", "$file_name", "-t", "main", "--quiet"],
    "working_dir": "$file_path",
    "file_regex": "^Warning: (.+):([0-9]+)",
    "selector": "source.prolog"
}

将swipl更改为swiple编译器的主目录 您需要在开头添加 main:-

main:-
    likes("Name", "Another").
    likes("Name","Another") :- likes("Ahmed", "Another").

我终于设法解决了我的问题。正如@Ahmed Elkady 所建议的,我用 swipl 的路径更新了我的 prolog.sublime-build。就我而言:

{
    "cmd": ["C:\Program Files\swipl\bin\swipl", "-f", "$file_name", "-t", "main", "--quiet"],
    "working_dir": "$file_path",
    "file_regex": "^Warning: (.+):([0-9]+)",
    "selector": "source.prolog"
}