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 theGroovyShell
class, this is where that object is opened and interrogated. You will notice in the AST viewer that the AST...