expected the beginning of a construct error

匆匆过客 提交于 2019-12-25 16:57:49

问题


When I run system, it shows error "expected the beginning of a construct" .. how can I correct this mistake

my rules look like this

(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))
     )))

second issue:

want to exit system when press "q" key, with each rule, which every rule has y and n keys ..... what is the proper defunction ..


回答1:


If you watch compilations, you can see the point at which the error occurs:

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> 

The issue occurs after the UFP rule. There is an extra right parenthesis after the rule. When editing CLIPS rules, it's helpful to use an editor that has some type of parentheses balancing. It makes it easier to find these types of mistakes.

If you want to halt CLIPS execution without exiting CLIPS, use the (halt) command. If you want to exit CLIPS, use the (exit) command.



来源:https://stackoverflow.com/questions/30853388/expected-the-beginning-of-a-construct-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!