[jboss-jira] [JBoss JIRA] Created: (JBRULES-1953) Documentation error or Bug related to parsing braces({, }) in rhs of DSL sentence definitions
Shahad Ahmed (JIRA)
jira-events at lists.jboss.org
Tue Feb 3 11:59:44 EST 2009
Documentation error or Bug related to parsing braces({, }) in rhs of DSL sentence definitions
---------------------------------------------------------------------------------------------
Key: JBRULES-1953
URL: https://jira.jboss.org/jira/browse/JBRULES-1953
Project: JBoss Drools
Issue Type: Bug
Security Level: Public (Everyone can see)
Components: drools-compiler, drools-docs
Affects Versions: 5.0.0.M5
Reporter: Shahad Ahmed
Assignee: Mark Proctor
There appears to be an error in the Drools documentation concerning the use of braces { and } on the right-hand side (RHS) of a DSL definition, or the documentation is correct and there is a bug in parsing of the RHS of DSL sentences
In section 6.7.2 Editing and managing a DSL, the documentation states that you can use { and } on the RHS of a DSL on its own, not just to mark tokens, and immediately gives an example of a valid RHS:
if (foo) {doSomething(); }
I know this worked in Drools 4, but it doesn't seem to work in Drools 5.0M5. To get this to work in Drools 5 you need to escape the use of { and }on the RHS of a DSL as follows, otherwise you get a parse error.
if (foo) \{doSomething(); \}
For example, consider the following DSL and rule where the consequence in the DSL does not use an escape of the RHS to escape the { and } surrounding the println method.
[condition][]Always valid=eval(1==1)
[consequence][]Test value {value}=if ({value} == 1) {System.out.println("value was " + "{value}") ;}
package com.dsl.test
expander test.dsl
rule "DSL Rule Test"
when
Always valid
then
Test value 1
end
The example above thrown the following error in eclipse:
[7] Unable to expand: Test value 1
However if I escape the braces i.e.\{ on the RHS of the consequence in the DSL as follows then it all works.
[consequence][]Test value {value}=if ({value} == 1) \{System.out.println("value was " + "{value}") ;\}
One funny thing I noticed is that even though the eclipse plugin reports an error, if you select the DRL viewer tab to see the translation in eclipse, then the translation appears to be okay! In summary, I'm not sure if the parsing of DSL's has changed deliberately and only the documentation is incorrect, or whether this is a bug in the DSL parsing introduced in Drools 5.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jboss-jira
mailing list