Where I can learn how to construct the AST’s that Scala’s macros generate?
The Scaladoc isn’t as helpful as I’d like. For example:
abstract def Apply(sym: Universe.Symbol, args: Universe.Tree*): Universe.Tree
A factory method for Apply nodes.
But how do I figure out what an Apply node is? Where can I find a list of the node types in AST’s, and how they fit together?
There isn’t a lot of documentation for the internals of the compiler available, but the things that are available should be enough to get started.
Mirko Stocker, has written his Master Thesis about Scala Refactoring. In Appendix D (p. 95) he describes the architecture of the AST. It includes also a graphical overview:
Another way to find information about the AST is to look directly into the sources of reflect.internal.Trees, which contains the AST.
If one needs to find out how a specific source code snippet is represented internally there is
reify: