[rules-users] Parse bug in predicate constraints?
Edson Tirelli
tirelli at post.com
Thu Feb 8 16:54:19 EST 2007
Justine,
It shouldn't be space sensitive. Where are you inserting the space
that is giving you the error? I see your line bellow is missing a ')' in
the end, but maybe it was a mistake when you wrote the e-mail... so,
could you please clarify?
In trunk the syntax was simplified to almost what you asked for. In
trunk you can write:
rule "test"
when
valObj : MyValuesObject(a:aVal, b:bVal, c:cVal,
(a < (1/780)*(b+c)),
((b + c) > 500000) )
then
System.out.println("Alert condition met on obj:" + valObj);
end
You can break lines as you wish, but the predicates must be inside
the fact scope.
Hope it helps,
Edson.
Justine Hlista wrote:
> Should predicate constraints be sensitive to whitespace?? I have the
> following rule with a predicate constraint:
> rule "test"
> when
> valObj : MyValuesObject(a:aVal, b:bVal, c:cVal ->
> ((a.intValue() < (1/780) * (b.intValue() + c.intValue()) &&
> (b.intValue() + c.intValue()) > 500000)
> then
> System.out.println("Alert condition met on obj:" + valObj);
> end
>
> Inserting whitespace into the predicate results in the following
> exception:
>
> org.drools.rule.InvalidRulePackage: unknown:155:85 mismatched token:
> [@1723,5226:5227='\r\n',<4>,155:85]; expecting type ')'
> unknown:156:28 mismatched token: [@1752,5256:5256='(',<23>,156:28];
> expecting type ')'
>
> If instead I use an eval on the LHS, I can insert whitespace without
> an exception.
>
> In addition, I would like to know if there are any plans to simplify
> the syntax for similar types of rules, as the above is extremely
> unwieldy for the non-expert.
> For instance, I would vastly prefer to write the following:
>
> rule "test"
> when
> valObj : MyValuesObject(a:aVal, b:bVal, c:cVal)
> (a < (1/780)*(b+c))
> ((b + c) > 500000)
> then
> System.out.println("Alert condition met on obj:" + valObj);
> end
>
>
> Also, since everything in rules needs to be an Object, is there any
> plan to make the operators deal with said Objects? That is, so I do
> not always have to de-reference with my eval or predicate objects with
> intValue() or floatValue() or whatever?
>
> In our application, the user (i.e. not a drools or java expert) will
> be writing the rules. The current syntax requirements for encoding the
> above simple rule makes me very nervous about our users ever being
> able to use the rules effectively.
>
> Thanks,
> Justine
>
>
>
>
>
>------------------------------------------------------------------------
>
>_______________________________________________
>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 3124-6000
Mobile: +55 11 9218-4151
JBoss, a division of Red Hat @ www.jboss.com
More information about the rules-users
mailing list