Groovy for Domain-specific Languages - Second Edition

(nextflipdebug2) #1

AST Transformations


[ 222 ]

We mentioned earlier that the Groovy compiler supports custom file extensions. If
we add a META-INF/services/org.codehaus.groovy.source.Extensions file to
our JAR with a list of file extensions we want to support, then the compiler will also
compile any files it finds with these extensions.


Summary


This chapter has been quite a deep dive into the relatively complex subject of AST
transformations. We've covered both local and global AST transformations and even
used AST transformation to build a mini DSL.


In the next chapter, we will look at some of the publicly available Groovy DSLs. We
will describe how to use them, but we will also be taking a critical view of how they
might be implemented given the knowledge we now have about the Groovy MOP
and Groovy AST transformations.


http://www.ebook3000.com
Free download pdf