[rules-users] Jboss rules: or with binding issue?

Edson Tirelli tirelli at post.com
Tue Oct 23 17:07:59 EDT 2007


    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 at 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 at 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20071023/63ca7cbe/attachment.html 


More information about the rules-users mailing list