预期构造错误的开始

expected the beginning of a construct error

当我运行系统时,显示错误"expected the beginning of a construct" ..我该如何纠正这个错误

我的规则是这样的

(defrule UFP
 (not (repair ?))
   ?f <- (rule1)

   =>
(retract ?f)
(printout t "Finish UFP (y/n)
yes> go to rule 10 - Advise : Select your major
No> go to rule 2 - Advise : please finish all the levels of UFP to enter your major
q>Exit system" crlf)

(bind ?response (check-YNoptions-input))
(if (eq ?response y)
then
(assert (rule10))
)
(if (or(eq ?response q) (eq ?response Q))
    then 
    (output-exitmessage)
)
(if (eq ?response n)
    then



            (assert (rule2))
        )
)
)



; --------------------------------------------------
; Define coleege-system rule2
; --------------------------------------------------
(defrule rule2
?f <- (rule2)
   =>
   (retract ?f)

(bind ?response (ask-question "which level from OET result: (A0 or A1 =level1 ,A2= level2, B1=level3)
 (level1/level2/level3)
level1 > go to rule 3
level2 > go to rule 5
level3 > go to rule 7"


                   level1 level2 level3))
   (if (eq ?response level1)
       then 
      (assert (rule3))
       else (if (eq ?response level2)
                then (assert (rule5))

     else  (assert (rule7))
     )))

第二期:

想要在按 "q" 键时退出系统,对于每个规则,每个规则都有 y 和 n 键.....什么是正确的 defunction ..

如果你看编译,你可以看到错误发生的点:

CLIPS> (clear)
CLIPS> (watch compilations)
CLIPS> (load problem.clp)
Defining deffunction: check-YNoptions-input
Defining deffunction: output-exitmessage
Defining deffunction: ask-question
Defining defrule: UFP +j+j+j

[CSTRCPSR1] Expected the beginning of a construct.
Defining defrule: rule2 +j+j
FALSE
CLIPS> 

问题发生在 UFP 规则之后。规则后有一个额外的右括号。编辑 CLIPS 规则时,使用具有某种括号平衡的编辑器会很有帮助。这样更容易发现这些类型的错误。

如果您想在不退出 CLIPS 的情况下停止 CLIPS 执行,请使用 (halt) 命令。如果你想退出CLIPS,使用(exit)命令。