2011-01-08 92 views
2

我有问题,我的序言程序..它似乎有错误,但我不知道它是什么..有人可以给我想法如何解决它? 该错误行“症状” 开始这里是我的代码:语法错误:操作员期望

go:- 
    write('insert patient name'),nl, 
    read(Patient),nl,Patient=Patient, 
    hypothesis(Patient,Disease), 
    write(Patient),('probably has'),write(Disease),nl. 
go:- 
    write('sorry,the disease'),nl,write('cannot be diagnosed'),nl. 

symptom(Patient,abdominal pain):- 
    write('does'),write(Patient), 
    write('have abdominal pain y/n'),read(Reply), 
    Reply=y,nl. 
symptom(Patient,fever):- 
    write('does'),write(Patient),write('have a fever (y/)?'), 
    read(Reply), 
    Reply=y,nl. 
symptom(Patient,blood or mucus in stool):- 
    write('does'),write(Patient)write('have blood or mucus in stool(y/n)?'), 
    read(Reply), 
    Reply=y,nl. 
symptom(Patient,nausea and vomiting):- 
    write('does'),write(Patient)write('have nausea and vomiting (y/n)?'), 
    read(Reply), 
    Reply=y,nl. 
symptom(Patient,diarrhea):- 
    write('does'),write(Patient)write('have diarrhea (y/n)?'), 
    read(Reply), 
    Reply=y,nl. 
symptom(Patient,leg cramp):- 
    write('does'),write(Patient)write('leg cramp(y/n)?'), 
    read(Reply), 
    Reply=y,nl.  
symptom(Patient,abdominal cramp):- 
    write('does'),write(Patient)write('have abdominal cramp(y/n)?'), 
    read(Reply), 
    Reply=y,nl. 
symptom(Patient,cold skin):- 
    write('does'),write(Patient)write('have cold skin (y/n)?'), 
    read(Reply), 
    Reply=y,nl. 
symptom(Patient,weak pulse):- 
    write('does'),write(Patient)write('have weak pulse(y/n)?'), 
    read(Reply), 
    Reply=y,nl. 
symptom(Patient,voice change):- 
    write('does'),write(Patient)write('have voice change(y/n)?'), 
    read(Reply), 
    Reply=y,nl. 
symptom(Patient,sea sickness):- 
    write('does'),write(Patient)write('have sea-sickness(y/n)?'), 
    read(Reply), 
    Reply=y,nl. 
symptom(Patient,upset stomach):- 
    write('does'),write(Patient)write('have upset stomach(y/n)?'), 
    read(Reply), 
    Reply=y,nl. 
symptom(Patient,feeling green around the gill):- 
    write('does'),write(Patient)write('have feeling green around the gill(y/n)?'), 
    read(Reply), 
    Reply=y,nl. 
symptom(Patient,weakness):- 
    write('does'),write(Patient)write('have weakness(y/n)?'), 
    read(Reply), 
    Reply=y,nl. 
symptom(Patient,flu like symptom):- 
    write('does'),write(Patient)write('have flu-like symptom(y/n)?'), 
    read(Reply), 
    Reply=y,nl. 
symptom(Patient,fatigue):- 
    write('does'),write(Patient)write('have fatigue(y/n)?'), 
    read(Reply), 
    Reply=y,nl. 
symptom(Patient,intestinal pain):- 
    write('does'),write(Patient)write('have intestinal pain(y/n)?'), 
    read(Reply), 
    Reply=y,nl. 
symptom(Patient,straining at stool):- 
    write('does'),write(Patient)write('have straining at stool(y/n)?'), 
    read(Reply), 
    Reply=y,nl. 

hypothesis(Patient,chorela):- 
    symptom(Patient,diarrhea), 
    symptom(Patient,vomiting), 
    symptom(Patient,leg cramp), 
    symptom(Patient,cold skin), 
    symptom(Patient,weak pulse), 
    symptom(Patient,voice change). 
hypothesis(Patient,gastroenteritis):- 
    symptom(Patient,vomiting), 
    symptom(Patient,nausea), 
    symptom(Patient,diarrhea), 
    symptom(Patient,sea sickness), 
    symptom(Patient,upset stomach), 
    symptom(Patient,feeling green around the gill), 
    symptom(Patient,abdominal pain), 
    symptom(Patient,weakness), 
    symptom(Patient,flu like symptom), 
    symptom(Patient,fatigue), 
    symptom(Patient,blood or mucus in stool). 
hypotesis(Patient,shigellosis):- 
    symptom(Patient,diarrihea), 
    symptom(Patient,fever), 
    symptom(Patient,nausea), 
    symptom(Patient,vominting), 
    symptom(Patient,abdominal pain), 
    symptom(Patient,intestinal pain), 
    symptom(Patient,straining at stool), 
    symptom(Patient,blood or mucus in stool). 
+1

也许你可以与我们分享由编译器报告的错误的行和列?我不是很喜欢猜测。 – cdhowie 2011-01-08 16:34:56

回答

3

定义症状/ 2具有显式的第二个参数里面一片空白的第一道防线。也许你的意思是那里有一个原子的“腹痛”,但按照书面解析器将看到两个原子,腹部和疼痛,并不知道你的意思。

补充:相同的“嵌入空白”的错误出现在大部分的条款的磁头症状/ 2,并按照条款为假设/ 2,其中症状被称为尸体。还要注意在该谓词的最后一个句子中“假设”的拼写错误。

相关问题