[
http://jira.jboss.com/jira/browse/JBRULES-1083?page=comments#action_12372969 ]
Edson Tirelli commented on JBRULES-1083:
----------------------------------------
I think for this case we should fix documentation only and keep parser behavior as it is
right now, i.e., for "not" and "exists", the brackets are option only
if they are followed by a single pattern.
The current grammar rules are:
LHS_NOT::= 'not' ( '(' <conditional_element> ')' ) |
<pattern>
LHS_EXISTS::= 'exists' ( '(' <conditional_element> ')' ) |
<pattern>
So, the following is valid:
not Bus()
not ( Bus() ) // brackets are optional for single pattern.
Any other following conditional element will require the brackets. Following are all
valid:
not( Bus() and Driver() )
not( Bus() from $buses )
not( Bus() and not Driver() )
not( Bus() and not( Driver() ) )
Please note that the following is valid and require the ():
not( exists( Bus() ) )
But the above is Semantically EQUIVALENT as:
not( Bus() )
Brackets are not always optional for non-existential quantifier
"not"
----------------------------------------------------------------------
Key: JBRULES-1083
URL:
http://jira.jboss.com/jira/browse/JBRULES-1083
Project: JBoss Rules
Issue Type: Bug
Security Level: Public(Everyone can see)
Components: Drl Parser/Builder
Affects Versions: 4.0.0.GA
Reporter: Markus Reitz
Assigned To: Mark Proctor
Priority: Minor
Fix For: 4.0.1
According to the documentation, brackets are optional as illustrated by
Example 6.37. No Busses
not Bus()
In case of the rule (class SpecialString in
http://jira.jboss.com/jira/browse/JBRULES-1079)
package test
rule "Brackets"
when
not exists(x : SpecialString() and
forall(y : SpecialString(this!=x)
SpecialString(this==y, text=="Universe")))
then
System.out.println("Condition satisfied");
end
this is not true. Trying to load this rule leads to
org.drools.rule.InvalidRulePackage: [8,8]: unknown:8:8 Unexpected token 'exists'
at org.drools.rule.Package.checkValidity(Package.java:408)
at org.drools.common.AbstractRuleBase.addPackage(AbstractRuleBase.java:288)
at DroolsTest.<init>(Unknown Source)
at DroolsTest.main(Unknown Source)
When brackets are added:
package test
rule "Brackets"
when
not(exists(x : SpecialString() and
forall(y : SpecialString(this!=x)
SpecialString(this==y, text=="Universe"))))
then
System.out.println("Condition satisfied");
end
rule loading works without any exceptions.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira