[rules-users] Simple DSL example

esteban.aliverti at gmail.com esteban.aliverti at gmail.com
Wed Oct 20 17:52:41 EDT 2010


Which version of drools are you using? I think the "expander" is no longer
needed.

When adding Sample.drl to kbuilder, use ResourceType.DSLR instead
of ResourceType.DRL.

Best,

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Esteban Aliverti
- Developer @ http://www.plugtree.com
- Blog @ http://ilesteban.wordpress.com


On Wed, Oct 20, 2010 at 4:20 PM, morge <maxime.morge at lifl.fr> wrote:

>
> 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.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20101020/11b4297a/attachment.html 


More information about the rules-users mailing list