XSL and DSL code refactoring

I've had lately a lot of fun and success with refactoring our DSL using XSL.

While I could have coded the refactoring in our main language (Delphi), I've tried to use a language dedicated to XML transformations and with pattern matching capabilities.

In order to do so, I've had to stream out the AST of our DSL files into XML files.
Then I've written a small IDE to select the DSL file and the XSL transformation to apply on it.
I've several tabs to display the different steps of the transformations, disable some steps, select the command line XSL engine, ...

When the transformation has been applied, the resulting AST is reloaded and the corresponding DSL code is generated.
I can then compare the source and the result to see if the transformation has changed the source file.

It's an incremental process, you can watch the corresponding XML for the DSL file being processed, compare it to the refactored one.
You then make some changes to the XSL files and restart the transformation until the resulting AST fits your needs.

Have you also had some success in this domain using XSL ?

Some references :
XSL : http://www.w3.org/TR/xslt
Java ML : java modelisation using XML

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

there have been comments in t

there have been comments in the past here about using xsl to process the ast during compilation. i was looking at that not so long ago and ended up thinking i would probably follow a different route, also described in the same thread.

of course, i can no longer find the thread or my notes.

[google google. time passes.] yay. here it is. wander round this thread: http://lambda-the-ultimate.org/node/view/634

Thanks for the link

michaelw seems to have used it in his compiler course with good success.

I've spoken about AST but it is more of a semantic tree than a simple AST.
This tree directly contains representations for template, object instanciation, property affectation, ...

I don't think writing the transformations with a general language would have been so rewarding.
I was feeling like when I hack a small python script for code generation, no compile time and fast iteration !

One last thing I do appreciate is the very small difference between the XML representation of the AST and the XSL template matching rule.
In fact, I always first copy and paste the AST representation and then transform it manually to the right matching rule.

I'll look forward if I can find more references.