[CSTRCPSR1] Expected the beginning of a construct.

791 views
Skip to first unread message

atec...@gmail.com

unread,
Jan 24, 2014, 2:28:12 AM1/24/14
to clip...@googlegroups.com
hi
i'm a begineer in clips programming and i have problem with a code and clips show error :
[CSTRCPSR1] Expected the beginning of a construct.

can any one help me 

code of source

(deftemplate question
    (slot stringquestion)
    (slot answer)
    )
(deftemplate faculty
    (multislot name))

(assert (question (stringquestion nil)(answer nil)))
(assert (faculty (name nil)))

(defrule q
     (declare (salience 100))
(question (stringquestion nil)(answer nil))
=>
(printout t "Do you want some guiYnce in choosing you faculty? [Y/N]" crlf)
(bind ?r (read))
(assert (question (stringquestion "Do you want some guiYnce in choosing you faculty?")(answer ?r)))
)
(defrule r1
     (declare (salience 99))
(question (stringquestion "Do you want some guiYnce in choosing you faculty?")(answer N))
=>
(printout t "Thank you!" crlf)
)
(defrule q0
     (declare (salience 78))
	(question (stringquestion "Do you want some guiYnce in choosing you faculty?")(answer Y))
	=>
	(printout t "Ok. Your mathematic grade is?" crlf)
	(bind ?r (read))
	(assert (question (stringquestion "Your mathematic grade is?")(answer ?r)))
	)
(defrule q1
     (declare (salience 99))
(question (stringquestion "Your mathematic grade is?")(answer ?x & : (>= ?x 8)))
=>
	(printout t "Your IT grade is?" crlf)
	(bind ?r (read))
	(assert (question (stringquestion "Your IT grade is?")(answer ?r)))
)
(defrule q2
     (declare (salience 78))
	(question (stringquestion "Your mathematic grade is?")(answer ?x & : (< ?x 8)))
	=>
	(printout t "Your Literatur grade is?" crlf)
	(bind ?r (read))
	(assert (question (stringquestion "Your Literatur grade is?")(answer ?r)))
	)
(defrule q3
     (declare (salience 99))
(question (stringquestion "Your IT grade is?")(answer ?x & : (>= ?x 8)))
=>
	(printout t "Your physics grade is?" crlf)
	(bind ?r (read))
	(assert (question (stringquestion "Your physics grade is?")(answer ?r)))
)
(defrule q4
     (declare (salience 78))
	(question (stringquestion "Your IT grade is?")(answer ?x & : (< ?x 8)))
	=>
	(printout t "You should choose FEAA" crlf)
	
	)
(defrule r2
     (declare (salience 99))
(question (stringquestion "Your physics grade is?")(answer ?x & : (>= ?x 8)))
=>
	(printout t "You shoul choose UPT" crlf)
)
(defrule r3
     (declare (salience 78))
	(question (stringquestion "Your physics grade is?")(answer ?x & : (< ?x 8)))
	=>
	(printout t "You should choose the Faculty of Mathematics and Computer Science" crlf)
)

(defrule q5
     (declare (salience 99))
(question (stringquestion "Your Literatur grade is?")(answer ?x & : (>= ?x 8)))
=>
	(printout t "Your Foreign Language grade is?" crlf)
	(bind ?r (read))
	(assert (question (stringquestion "Your Foreign language grade is?")(answer ?r)))
)
(defrule q6
     (declare (salience 78))
	(question (stringquestion "Your Biology grade is?")(answer ?x & : (< ?x 8)))
	=>
	(printout t "Your physics grade is?" crlf)
	(bind ?r (read))
	(assert (question (stringquestion "Your Biology grade is?")(answer ?r)))
	)
(defrule r6
     (declare (salience 99))
(question (stringquestion "Your Foreign language grade is?")(answer ?x & : (>= ?x 8)))
=>
	(printout t "You should choose the Faculty of Literature ." crlf)
)
(defrule r7
     (declare (salience 78))
	(question (stringquestion "Your Foreign language grade is?")(answer ?x & : (< ?x 8)))
	=>
	(printout t "You should choose the Faculty of Political Science" crlf)
)
(defrule r8
     (declare (salience 99))
(question (stringquestion "Your Biology grade is?")(answer ?x & : (>= ?x 8)))
=>
	(printout t "You should choose UMF" crlf)
)
(defrule r9
     (declare (salience 78))
	(question (stringquestion "Your Biology grade is?")(answer ?x & : (< ?x 8)))
	=>
	(printout t "You should choose the Faculty of Geografy." crlf)
)

(facts)
(agenY)
(run)

CLIPS Support

unread,
Jan 24, 2014, 12:03:59 PM1/24/14
to clip...@googlegroups.com
If you have a combination of constructs (deftemplate, deffacts, defrules) and commands (assert, facts, agenda, run) in a file then you need to use the batch command to process that file. It is better, however, to place the constructs all in one file and the commands in another. You can then use the load command to load the constructs file and the batch command to process the commands. When loading constructs, if an error is detected, the load command will attempt to move on to the next construct whereas the batch command will not.

CLIPS> (watch compilations)
CLIPS> (load constructs.clp)
Defining deftemplate: question
Defining deftemplate: faculty
Defining defrule: q +j+j
Defining defrule: r1 +j+j
Defining defrule: q0 +j+j
Defining defrule: q1 +j+j
Defining defrule: q2 +j+j
Defining defrule: q3 +j+j
Defining defrule: q4 +j+j
Defining defrule: r2 +j+j
Defining defrule: r3 +j+j
Defining defrule: q5 +j+j
Defining defrule: q6 +j+j
Defining defrule: r6 +j+j
Defining defrule: r7 +j+j
Defining defrule: r8 +j+j
Defining defrule: r9 =j+j
TRUE
CLIPS> (batch commands.bat)
TRUE
CLIPS> (assert (question (stringquestion nil)(answer nil)))
<Fact-1>
CLIPS> (assert (faculty (name nil)))
<Fact-2>
CLIPS> (facts)
f-0     (initial-fact)
f-1     (question (stringquestion nil) (answer nil))
f-2     (faculty (name nil))
For a total of 3 facts.
CLIPS> (agenda)
100    q: f-1
For a total of 1 activation.
CLIPS> (run)
Do you want some guiYnce in choosing you faculty? [Y/N]

Reply all
Reply to author
Forward
0 new messages