Dirk,
This is similar to Groovy AST. Also refer to Scala Trees (http://docs.scala-lang.org/overviews/reflection/symbols-trees-types.html). A concrete use of these trees to generate diagrammed assertions can be found in the excellent expecty (https://github.com/pniederw/expecty) that is used by ScalaTest. A wholly similar mechanism exists in Groovy/Spock.
Jon