[rules-users] no viable alternative at input 'or'

Swindells, Thomas TSwindells at nds.com
Tue Oct 26 08:11:37 EDT 2010


Why not just have the following?

 rule "cboFemale"
 when
    Patient(sex == "F")
then
...
end.

rule "cboNotBaby"
 when
    Patient(age > 2)
then
...
end.

rule "cboNoSex"
 when
    Patient(sex == "F")
then
...
end.

This has the advantage that rule auditing will identify which condition matches and means that you can use the binding in the rule.
Alternatively you should be able to do

rule "cbo"
 when
    Patient(sex == "F" or sex == "" or age > 2)
then
...
end.




From: rules-users-bounces at lists.jboss.org [mailto:rules-users-bounces at lists.jboss.org] On Behalf Of Michael Anstis
Sent: 26 October 2010 11:56
To: Rules Users List
Subject: Re: [rules-users] no viable alternative at input 'or'

I tried a few permutations with 5.1.x

Nested infix appears to have a few problems, as you describe (although your last example is incomplete); e.g.:-

rule "Unknown error while parsing. This is a bug. Please contact the Development team."
when
(or
    (
    or Fact( ) Fact( )
    )
    Fact()
)
then
    //Something
end
Non-nested infix looked OK:-

rule "compiles OK - 1"
when
(or Fact( ) Fact( ) Fact())
then
    //Something
end

Post-fix appears OK:-

rule "compiles OK - 2"
when
(
    Fact() or
    Fact()
) or
Fact()
then
    //Something
end

Based on my limited test it appears to be a bug and my advice would be to raise a JIRA.

As a work around you can change your rules in post-fix notation.

With kind regards,

Mike


On 26 October 2010 11:09, Swindells, Thomas <TSwindells at nds.com<mailto:TSwindells at nds.com>> wrote:
What are you actually trying to achieve?
It would probably be a lot cleaner and better just to write these as separate rules - one for each case you want to consider.

Thomas

> -----Original Message-----
> From: rules-users-bounces at lists.jboss.org<mailto:rules-users-bounces at lists.jboss.org> [mailto:rules-users-<mailto:rules-users->
> bounces at lists.jboss.org<mailto:bounces at lists.jboss.org>] On Behalf Of chrbonte
> Sent: 26 October 2010 10:52
> To: rules-users at lists.jboss.org<mailto:rules-users at lists.jboss.org>
> Subject: [rules-users] no viable alternative at input 'or'
>
>
> Hi
>
> I'm struggling with the rule syntax. I took over this drools project of a
> collegue who left the company and am struggling with a bug in our
> application.
>
> The following works:
>
> rule "cbo2"
> when
> (or
> Patient(sex == "F")
> Patient(sex == "")
> )
> then
> ...
> end
>
> What doesn't work is the following:
>
> rule "cbo"
> when
> (or
>       (or
>               Patient(sex == "F")
>               Patient(age > 2)
>       )
>       Patient(sex == "")
> )
> then
> ...
> end
>
> AND
>
> rule "cbo"
> when
> (or
>       (or
>               Patient(sex == "F")
>               Patient(age > 2)
>       )
> )
> then
> ...
> end
>
> -------------------
>
> Can someone please point me in the right direction or explain to me why I
> get "no viable alternative at input 'or' with the last 2 examples?
>
> Regards
> Christophe
> --
> View this message in context: http://drools-java-rules-
> engine.46999.n3.nabble.com/no-viable-alternative-at-input-or-<http://engine.46999.n3.nabble.com/no-viable-alternative-at-input-or->
> tp1772702p1772702.html
> Sent from the Drools - User mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org<mailto:rules-users at lists.jboss.org>
> https://lists.jboss.org/mailman/listinfo/rules-users

**************************************************************************************
This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmaster at nds.com<mailto:postmaster at nds.com> and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary.

NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00
**************************************************************************************

_______________________________________________
rules-users mailing list
rules-users at lists.jboss.org<mailto:rules-users at lists.jboss.org>
https://lists.jboss.org/mailman/listinfo/rules-users


________________________________

**************************************************************************************
This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmaster at nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary.

NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00
**************************************************************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20101026/ffd17e08/attachment.html 


More information about the rules-users mailing list