[jboss-jira] [JBoss JIRA] Created: (JBRULES-790) DSL mechanism not working if some keywords are part of the DSL

Gilles Dubuc (JIRA) jira-events at lists.jboss.org
Wed Apr 11 22:34:58 EDT 2007


DSL mechanism not working if some keywords are part of the DSL
--------------------------------------------------------------

                 Key: JBRULES-790
                 URL: http://jira.jboss.com/jira/browse/JBRULES-790
             Project: JBoss Rules
          Issue Type: Bug
      Security Level: Public (Everyone can see)
          Components: Drl Parser/Builder
    Affects Versions: 3.1-m1, 3.0.6
         Environment: Issue happened with both 3.1-m1 and
            Reporter: Gilles Dubuc
         Assigned To: Mark Proctor


Please ignore what this rule actually does when executed, as this is a syntax issue in the DSL/DRL parsing.

If you have a DSL like this:

[when]Invoke rule executor=ruleExec: RuleExecutor()
[then]Execute rule "{id}"=ruleExec.ExecuteSubRule( new Long({id}));

and a DRL like that:

package something;

rule "1"
when
      Invoke rule executor
then
      Execute rule "5"
end

When calling addPackageFromnDrl( drl, dsl ) you get an exception about "Invoke" not being a keyword (I can reproduce the error and provide the exception if needed). What I'm guessing is happening is the following:

Before going through the DSL to translate the DRL file, the DRL is broken down into rules and their when/then parts. Since there is the word "rule" in "Execute rule executor" the parser thinks it's the start of a new rule. Even more so with "Execute rule "5"" because of the quotes. Strangely enough it probably goes beyond that stage and the parser assumes that "Invoke" is the only text present in the when part of rule "1". And obviously there is no translation for "Invoke" in the DSL.

Maybe I missed it, but I didn't see any mention of the fact that DRL keywords have to be avoided in the left parts or DSL statements. If it's missing from the documentation maybe it would be worth being added to it. It took me a huge amount of time before understanding that the issue came from there, banging my head for hours on the DSL translation suddenly not working even made me reimplement the DSL translation mechanism using StringTemplate...

I haven't checked if "when" and "then" induce similar issues, but if they do it might be limiting for some uses of the DSL to have to avoid these words. In that case, maybe revising the part of the parser interpreting a DSL-ed DRL would be required. It all comes down to the parser knowing accurately which parts of the DSL file are the rules, their LHS and RHS. As far as I know it shouldn't be possible to define a rule in the middle of the when statement of another one, so there is no reason why the "rule" in "Invoke rule executor" should be treated as the start of a new rule. Same goes for the "Execute rule" that sits in the RHS of another rule.

-- 
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

        



More information about the jboss-jira mailing list