[rules-users] Simple DSL example

morge maxime.morge at lifl.fr
Wed Oct 20 15:20:20 EDT 2010


Hi everybody,

I try to run a simple DSL example.

My DRL is as follows:
package org.mydrools.examples
#must be in the following order.
import org.mydrools.examples.Person
import org.mydrools.examples.Cheese
#refer to test_expander.dsl
expander test_expander.dsl
rule "my rule"
	when
		#Person(name=="Dani", likes=="maroilles")
		#Cheese(type=="maroilles")
		There is a person with the name of Dani who likes maroilles
		There is some maroilles cheese available
		
	then
		Add the message "We have a winner"
		#System.out.println("We have a winner");
end

My DSL is as follow:
#some description
[when]There is a person with the name of {name} who likes
{cheese}=Person(name=="{name}", likes=="{cheese}")
[when]There is some {cheese} cheese available=Cheese(type=="{cheese}")
[then]Add the message {message}=System.out.println({message});
[when]person with eval=p : Person() eval(p.getName().equals("fire"))

And I load them as below:
kbuilder.add(ResourceFactory.newClassPathResource("test_expander.dsl"),ResourceType.DSL);
kbuilder.add(ResourceFactory.newClassPathResource("Sample.drl"),
ResourceType.DRL);

The following error messages appear:
[8,9]: [ERR 101] Line 8:9 no viable alternative at input 'test_expander' in
rule expander
[11,0]: [ERR 101] Line 11:0 no viable alternative at input 'rule' in rule
expander in rule dsl
[15,2]: [ERR 101] Line 15:2 no viable alternative at input 'There' in rule
expander in rule dsl in rule "my rule"

Any idea ?

Thanks in advance,

Maxime.


-- 
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Simple-DSL-example-tp1741029p1741029.html
Sent from the Drools - User mailing list archive at Nabble.com.



More information about the rules-users mailing list