Pereira 中的 Prolog 运算符错误

Prolog operator errors in Pereira

在 Ubuntu Linux 中使用 SWI Prolog 7.7.2,我正在尝试 运行 "talk" Pereira 和 Schieber 的模块(附录 A, http://www.mtome.com/Publications/PNLA/prolog-digital.pdf).

复制粘贴到文本编辑器(Sublime)并调整后 换行符(大部分)匹配原始 运行ning swipl,然后 ['talk.P'],我遇到了两打以上的“语法错误:运算符 预期的”错误,例如(目录位置替换为 [...]):

Lines 15-20:

main_loop :-
    write(’>> ’),       % prompt the user
    read_sent(Words),   % read a sentence
    talk(Words, Reply), % process it with TALK
    print_reply(Reply), % generate a printed reply
    main_loop.          % process more sentences

ERROR: [...]/talk.P:16:15: Syntax error: Operator expected

---Line 38:

talk(_Sentence, error(’too difficult’)).

ERROR: [...]/talk.P:38:25: Syntax error: Operator expected

---Lines 76-77:

% Replying to some other type of sentence.
reply(_Type, _FreeVars, _Clause, error(’unknown type’)).

ERROR: [...]/talk.P:77:42: Syntax error: Operator expected

---Lines 87-91:

print_reply(error(ErrorType)) :-
    write(’Error: "’), write(ErrorType), write(’."’), nl.

print_reply(asserted(Assertion)) :-
    write(’Asserted "’), write(Assertion), write(’."’), nl.

ERROR: [...]/talk.P:91:12: Syntax error: Operator expected

---注意我也遇到了十个单例变量警告,但我不确定这是否会被证明是一个问题,例如:

---Lines 59-60:

reply(query, FreeVars,
    (answer(Answer):-Condition), Reply) :- Warning: [...]/talk.P:59:  Singleton variables:

[FreeVars,Condition,FreeVarsˆCondition] Warning: [...]/talk.P:59: Singleton variable in branch: FreeVarsˆCondition

---Lines 242-243:

q(S => ‘answer(X)) -->
    whpron, vp(finite, XˆS, nogap).

Warning: [...]/talk.P:242: Singleton variables: [S,X,XˆS]

我需要做什么才能启动和 运行ning 这个模块?

有几个问题。运算符值(100、500 等)与标准运算符的旧值兼容,应该更高。此外,back-quote/back-tick (ASCII 96) 在某些时候从符号变为引号字符。

我设法让 the files 加载到 SWI prolog 中,方法是更改​​运算符:

:- op(1000,xfy,&). 
:- op(1010,xfy,=>). 
:- op(200,fx,`).

并给命令行参数 --traditional(使反引号成为符号而不是引号字符)。

$ swipl --traditional
Welcome to SWI-Prolog (threaded, 64 bits, version 7.4.2)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
Please run ?- license. for legal details.

For online help and background, visit http://www.swi-prolog.org
For built-in help, use ?- help(Topic). or ?- apropos(Word).

?- [talk].
true.