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),并调整
换行符(主要)匹配原始的、运行的 swipl,然后
[\\'talk.P\\'],我遇到了超过两打"语法错误:运算符
预期" 错误,例如(目录位置被 [...] 替换):
Lines 15-20:
1
2
3
4
5
6 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 sentencesERROR: [...]/talk.P:16:15: Syntax error: Operator expected
---Line 38:
1 talk(_Sentence, error(’too difficult’)).ERROR: [...]/talk.P:38:25: Syntax error: Operator expected
---Lines 76-77:
1
2 % 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:
1
2
3
4
5ERROR: [...]/talk.P:91:12: Syntax error: Operator expected
---注意我也遇到十个单例变量警告,但不确定这是否会成为问题,例如:
---Lines 59-60:
1
2 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:
1
2 q(S => ‘answer(X)) -->
whpron, vp(finite, X?S, nogap).Warning: [...]/talk.P:242: Singleton variables: [S,X,X?S]
我需要做什么才能启动并运行这个模块?
有几个问题。运算符值(100、500 等)与标准运算符的旧值兼容,应该更高。此外,反引号/反引号(ASCII 96)在某些时候从符号变为引号字符。
通过更改操作符,我设法在 SWI prolog 中加载文件:
并给出命令行参数
1 2 3 4 5 6 7 8 9 10 | $ 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. |