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

Michael Anstis michael.anstis at gmail.com
Tue Oct 26 06:56:16 EDT 2010


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> 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] On Behalf Of chrbonte
> > Sent: 26 October 2010 10:52
> > To: 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-
> > tp1772702p1772702.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
>
>
>
> **************************************************************************************
> 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
>
> **************************************************************************************
>
> _______________________________________________
> 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/20101026/23648b1b/attachment.html 


More information about the rules-users mailing list