【发布时间】:2019-12-08 18:58:32
【问题描述】:
要启动加载我的程序的 Prolog shell,我只需在终端中输入 swipl app.pl。然后,为了使用文本文件参数调用app.pl(Prolog 程序)中定义的谓词(函数)verify(InputFile),我编写了verify('path/to/file.txt')。是否可以编写一个执行上述所有任务的 bash 脚本?
通过在 bash 脚本中输入以下 swipl << writeln('Hello'),似乎可以从 bash 脚本运行内置的 Prolog 命令,例如“write line”命令。但是,如果我尝试对我定义的 verify 谓词执行相同操作,我最终会出现以下错误。
输入
Input: swipl app.pl <<< "verify('tests/unit/af-test1.txt')."
输出
true
ERROR: Type error: `character_code' expected, found `-1' (an integer)
ERROR: In:
ERROR: [11] char_code(_2720,-1)
ERROR: [10] '$in_reply'(-1,'?h') at /usr/local/Cellar/swi-prolog/8.0.3_1/libexec/lib/swipl/boot/init.pl:848
对于上下文,verify/1 谓词由以下代码定义。
verify(Input) :-
see(Input), read(Transitions), read(Labling),
read(State), read(Formula), seen,
check(Transitions, Labling, State, [], Formula).
【问题讨论】:
-
也许您的问题出在验证谓词中...您可以发布代码吗?