Exploring the Truffle interpreter/compiler pipeline
Truffle provides a Java library that can be used to write AST interpreters in Java for any language. The guest language semantics are expressed as an AST using the AST interpreters. Graal and Truffle specify the exact format of AST, and the framework enforces this specification. So, any guest language AST interpreter written using Truffle Language Implementation API will generate the semantics of the language in AST that GraalVM can then use to optimize just in time and run. The following figure provides a detailed flow of how Truffle and Graal work:
Let's understand the flow diagram better.
The guest languages are parsed using a traditional syntactical and lexical analyzer. This generates an AST. The AST is an intermediate representation built as per the Truffle/Graal specifications. The AST is a tree structure where each parent node is an...