On 5 May 2011 05:03, boy18nj <boy18nj(a)gmail.com> wrote:
I'm trying to create DSL and DSLR out of DRL but so far
unsuccessfull with
this small example-
DSL-
[condition][]There is fire in "{room}"=Fire( "{room}" : room )
Imagine that the characters corresponding to each {x} are taken and
replace the same construct after the equal sign. Here you end up with
something like
Fire( "kitchen" : room )
which can't be right. Omit the quotes from the expansion.
[condition][]"{sprinkler}" is in same "{room}"
and sprinkler is
"{off}"="{sprinkler}" : Sprinkler( room == "{room}", on ==
"{off}" )
Again, omit quotes in the expansion, or you'll get incorrect DRL code.
[consequence][]Turn on the
"{sprinkler}"=modify("{sprinkler}"){setOn(true)};
Omit quotes from the text after '='.
However in order to make this work you would have to write, in DSLR:
There is a fire in "$room"
"$sprinkler" is in same "$room" and sprinkler is "false"
then
Turn on the "$sprinkler"
Which isn't very convincing. If your DSL expresses some specific
situation, you wouldn't need variable parts. The bindings for
associating one pattern with another and some fact with an object on
the RHS can be implied. Also, it doesn't make much sense to let the
author write the "false" when the consequence is to turn the sprinkler
on.
[condition][]There is fire in a room=Fire( $room : room )
[condition][]the sprinkler in the same room is off=$sprinkler:
Sprinkler( room == $room, on == false )
[consequence][]Turn the sprinkler on=modify($sprinkler){setOn(true)};
The example you have chosen isn't well suited for demonstrating
variable parts and their insertion into the expanded code.
-W
DSLR- (Error message when compiling mismatched input)
#created on: Apr 30, 2011
package com.fire
expander fireAlarm.dsl
#list any import classes here.
import com.fire.*;
rule "When there is a fire turn on the sprinkler"
when
#conditions
There is fire in "{room}"
"{sprinkler}" is in same "{room}" and sprinkler is
"{off}"
then
#actions
Turn on the "{sprinkler}"
log;
end
Can somebody point out what I am doing wrong?
--
View this message in context:
http://drools.46999.n3.nabble.com/Unable-to-create-DSL-properly-tp2901873...
Sent from the Drools: User forum mailing list archive at
Nabble.com.
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users