[rules-users] Translate Drools to CLIPS rules

Wolfgang Laun wolfgang.laun at gmail.com
Fri May 31 02:43:53 EDT 2013


On 31/05/2013, Mark Proctor <mproctor at codehaus.org> wrote:
>
> On 30 May 2013, at 23:36, "Stadin, Benjamin"
> <Benjamin.Stadin at heidelberg-mobil.com> wrote:
>
>> I'd be  willing to get involved, but since you mention clp to drl only,
>> will it also be possibly to convert drl to clp?
> yes. There is already a "DrlDumper" that takes a Rule and dumps it to a
> string, using a bunch of recursive mvel templates.  You can copy/paste this
> and have it dump to CLP instead.
> https://github.com/droolsjbpm/drools/blob/master/drools-compiler/src/main/java/org/drools/compiler/lang/DrlDumper.java
> https://github.com/droolsjbpm/drools/blob/master/drools-compiler/src/main/resources/org/drools/compiler/lang/drl.mvel
>
> if you change the drl.mvel to a clp.mvel and change the text it outputs, you
> have yourself a CLP<->DRL translator. The caveat ofcourse is you must keep
> to the common base level of features between the two systems.

The first if is hiding an enormous amount of work. The template
drl.mvel appears to take arbitrarily long snippets of Java (or MVEL)
code and simply copy it into the result text: function bodies, eval
expressions, accumulate init,  action and result code, and all of the
RHS. I'm not saying it can't be done, but it sure will keep you busy
for quite some time.

Translating Java expressions to CLP can't be done based on abstract
syntax. Consider, for instance,
   stdout.println( a + b );
To be able to translate this to
   printout( t (+ a b) )
you'd have to make sure that stdout is indeed the same as router t and
that a and b are numeric quantities - otherwise str-cat would be
required.

Copy/paste with a whole lot of magic ;-)

Wolfgang


More information about the rules-users mailing list