Hello Edson,
I was not aware that
$binding : ( A(...) or A(...) ) // this is valid
works. But now I know and I like this much better than
the workaround I was using. I think this is more
intuitive.
The way I stumbled into this is I had the following
$binding : A(...) or A(...)
(note the missing brackets at the start and end)
This doesn't complain at rule compilation time.
However I was getting a NPE at rule execution time.
Rahul
--- Edson Tirelli <tirelli(a)post.com> wrote:
Rahul,
Sorry, seems there is an error in the docs. You
can only use the
up-front binding notation when you use infix OR, not
the prefixed OR:
$binding : ( A(...) or A(...) ) // this is valid
$binding : (or A(...) A(...) ) // this is not
Maybe we need to start supporting prefix
notation for this too, but I
really don't like this up-front binding notation.
This is handled as a
special case in the grammar, where you can't nest
other CEs, etc... in other
words, it is not orthogonal. It was good when we
didn't supported nesting,
but now that we do support, it makes things
dangerous. Example: this is not
valid:
$x : ( X(...) or ( X(...) and Y(...) ) ) //
obviously, not valid
But if you remove the binding or move the
binding inside, it is valid:
( X(...) or ( X(...) and Y(...) ) ) // valid
( $x : X(...) or ( $x : X(...) and Y(...) ) ) //
valid
Problem is that Mark does like that up-front
notation, and he is the
boss... ;)
Anyway, I would like to hear your opinion about
it (and possibly other
users too), if you prefer this up-front notation
even being handled as a
special case, or the multi-binding is ok for you.
Meanwhile, the workaround is either use the
multi-bind as you are using
or the infix OR as I showed above.
[]s
Edson
2007/10/23, Rahul Phadnis <rahul.phadnis(a)yahoo.com>:
>
> I am using Jboss Rules 4.0.2 version.
>
> I am trying to using or with binding. However the
> following doesn't work
> rule "RulesTest"
> # the if part
> activation-group "ActivationGroup1"
> salience 50
> when
> $eventType: EventType(id ==
> Constants.EVENT_DEVCOM_ID)
> $result : Result()
> $param : Parameter($thresh:threshold)
> # difference exceeds
threshold value and
> it is still day time
> context: (or DevContext(difference >
$thresh,
> dayTime == true)
> DevContext(difference
> $thresh, sleepy
> == false, dayTime == false) )
>
> then
> # do something here
>
> end
>
> I get rule compilation errors:
> SEVERE: CheckedDroolsException
> org.drools.CheckedDroolsException: There were
errors
> in the rule source: [320,18]: unknown:320:18
> mismatched token:
> [@1949,12142:12143='or',<34>,320:18]; expecting
type
> ID[321,15]: unknown:321:15 mismatched token:
> [@1967,12215:12227='DevContext',<7>,321:15];
expecting
> type RIGHT_PAREN[321,86]: unknown:321:86
mismatched
> token: [@1990,12286:12286=')',<12>,321:86];
expecting
> type THEN
> at
>
org.drools.compiler.RuleBaseLoader.makeRuleBase(RuleBaseLoader.java:6
>
> Is this a known bug ?
>
> I can work around by using the alternate syntax
> suggested in the documentation which is:
>
> or $context : DevContext(difference > $thresh,
dayTime
> == true)
> $context : DevComContext(difference > $thresh,
> sleepy == false, dayTime == false) )
>
> Rahul.
>
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
>
https://lists.jboss.org/mailman/listinfo/rules-users
>
--
Edson Tirelli
Software Engineer - JBoss Rules Core Developer
Office: +55 11 3529-6000
Mobile: +55 11 9287-5646
JBoss, a division of Red Hat @
www.jboss.com
> _______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users