Danno Ferrin | 24 Jun 06:58
Favicon
Gravatar

Re: [groovy-dev] AST Transformations status

AST Transformation are in Groovy 1.6-beta-1, and the first examples of them are the <at> groovy.beans.Bindable, <at> groovy.beans.Vetoable, and <at> groovy.lang.Mixin annotations. and in the current dev releases there is also <at> groovy.lang.Category.  The best way to get a feel for them is to look at those examples.

As compared to Jocen's posts the transformations are not quite the same.  The transformation class follows the spirit of what Jocen wanted, but that is about the extent.  The first change is that you do not use a different import statement to declare a transformation.  You use an annotation that is a transformation annotation (an annotation on the annotation declares this).  Not useing an import statement restricts us to using grammer symbols with a strictly static meaning at compile time to insure we are transforming what we should be.  So transforming method calls basically won't work then in this case, since the MOP can redirect any method call done from groovy code.  The import mechanic used to designate a symbol name was a solution that would allow us to transform on such ordinarily dynamic symbols, but the response on the dev list.

As far as using a transform to remove import statements, the current implementation basically preculdes it since the transform is not run until after hte imports are resolved, and the DSL class would start failing because the classes wouldn't be guaranteed to be resolved early enough.  There is some affordance for that by adding transforms via the Java services API (basically adding a file in a particular palce in META-INF in the jar), but that doesn't have any concerte example in groovy core.  A half-baked example exists in the grape-ivy modeule in the SVN tree of having <at> Grab add jars to the classpath so the imports work.  But you may be able to add the imports by directly manipulating some of the AST structures and insureing that the annotation you are marking the DSL with is evaluated first.

--Danno

On Mon, Jun 23, 2008 at 3:29 PM, melix <cedric.champeau-kwIsuXZtyu5BDgjK7y7TUQ@public.gmane.org> wrote:

Hi guys,

I'm really interested in AST Transformations to simplify my DSL grammar (a
simple example is removing import statements). However, I can't find
documentation about the project status : I found some (old) blog posts by
Jochen about AST macros, but I know there's been some work lately. Is there
any place where I could find some examples about how it works ?

Cedric
--
View this message in context: http://www.nabble.com/AST-Transformations-status-tp18078932p18078932.html
Sent from the groovy - dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email





--
------------------------------------------------------
I'm Danno Ferrin, and I approved this message.

Gmane