可能的错误或遗漏
Possible bug or omission
可能的错误或者我遗漏了一些明显的东西:
test(struct(X,Y)) --> X,[isa],Y.
当我尝试使用此规则时出现错误.. 前几天它还有效!!
该列表在规则中使用了 phrase(),如果没记错的话应该是差异列表!!!
您的列表() 显示什么?
我错过了什么?看起来很愚蠢!
唯一似乎合理的是我最近升级了 SWI !!嗯..
Welcome to SWI-Prolog (threaded, 64 bits, version 8.2.3)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
Please run ?- license. for legal details.
For online help and background, visit https://www.swi-prolog.org
For built-in help, use ?- help(Topic). or ?- apropos(Word).
?- consult(test_grammar).
true.
?- listing(test).
test(struct(X, Y), A, B) :-
phrase(X, A, C),
C=[isa|D],
phrase(Y, D, B).
true.
?- phrase(test(T), [this,isa,test]).
ERROR: Arguments are not sufficiently instantiated
ERROR: In:
ERROR: [15] '$dcg':call_dcg(user:_9038,[this,isa|...],_9032)
ERROR: [13] test(struct(_9082,_9084),[this,isa|...],[]) at /my/dev/python3/chatbot/lib/semantics/test_grammar.pl:2
ERROR: [12] '$dcg':call_dcg(user:test(...),[this,isa|...],[]) at /usr/lib/swi-prolog/boot/dcg.pl:368
ERROR: [9] <user>
ERROR:
ERROR: Note: some frames are missing due to last-call optimization.
ERROR: Re-run your program in debug mode (:- debug.) to get more detail.
?-
你的语法规则应该是:
test(struct(X,Y)) --> [X,isa,Y].
这会给你:
?- [user].
|: test(struct(X,Y)) --> [X,isa,Y].
|: ^D% user://1 compiled 0.01 sec, 1 clauses
true.
?- phrase(test(T), [this,isa,test]).
T = struct(this, test).
可能的错误或者我遗漏了一些明显的东西:
test(struct(X,Y)) --> X,[isa],Y.
当我尝试使用此规则时出现错误.. 前几天它还有效!! 该列表在规则中使用了 phrase(),如果没记错的话应该是差异列表!!!
您的列表() 显示什么?
我错过了什么?看起来很愚蠢! 唯一似乎合理的是我最近升级了 SWI !!嗯..
Welcome to SWI-Prolog (threaded, 64 bits, version 8.2.3)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
Please run ?- license. for legal details.
For online help and background, visit https://www.swi-prolog.org
For built-in help, use ?- help(Topic). or ?- apropos(Word).
?- consult(test_grammar).
true.
?- listing(test).
test(struct(X, Y), A, B) :-
phrase(X, A, C),
C=[isa|D],
phrase(Y, D, B).
true.
?- phrase(test(T), [this,isa,test]).
ERROR: Arguments are not sufficiently instantiated
ERROR: In:
ERROR: [15] '$dcg':call_dcg(user:_9038,[this,isa|...],_9032)
ERROR: [13] test(struct(_9082,_9084),[this,isa|...],[]) at /my/dev/python3/chatbot/lib/semantics/test_grammar.pl:2
ERROR: [12] '$dcg':call_dcg(user:test(...),[this,isa|...],[]) at /usr/lib/swi-prolog/boot/dcg.pl:368
ERROR: [9] <user>
ERROR:
ERROR: Note: some frames are missing due to last-call optimization.
ERROR: Re-run your program in debug mode (:- debug.) to get more detail.
?-
你的语法规则应该是:
test(struct(X,Y)) --> [X,isa,Y].
这会给你:
?- [user].
|: test(struct(X,Y)) --> [X,isa,Y].
|: ^D% user://1 compiled 0.01 sec, 1 clauses
true.
?- phrase(test(T), [this,isa,test]).
T = struct(this, test).