2011-01-08 52 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,其中症狀被稱爲屍體。還要注意在該謂詞的最後一個句子中「假設」的拼寫錯誤。

相關問題