Book Image

Groovy for Domain-Specific Languages, Second Edition

By : Fergal Dearle
Book Image

Groovy for Domain-Specific Languages, Second Edition

By: Fergal Dearle

Overview of this book

Table of Contents (20 chapters)
Groovy for Domain-specific Languages Second Edition
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Free Chapter
1
Introduction to DSLs and Groovy
Index

Compiler phases


As the compiler works through the different phases, it adds detail to the AST. In all the examples we will work on in this chapter, we will have sufficient detail for our transformations to work on in the semantic analysis phase of compilation. It is worth understanding the compiler phases and what additional information is added to the AST at each phase.

The AST viewer is a useful tool for exploring this. The preceding screenshot is the panel where the AST tree is displayed; the AST viewer also maintains a source view. This view is also augmented to reflect what nodes have been added to the AST. Try switching phases in the view, and you will see this happen. Now, let's look at the individual compiler phases:

  • Initialization: In this phase, the compiler opens up all source files and configures its environment. If we are using CompilerConfiguration with the GroovyShell class, this is where that object is opened and interrogated. You will notice in the AST viewer that the AST...