-
Book Overview & Buying
-
Table Of Contents
Building Programming Language Interpreters
By :
An AST is a representation of the code that has a lot of higher-level semantics about how the code will actually be interpreted, while a parse tree is very focused on what’s required by the grammar engine.
There are many things that will be present in the parse tree but can be eliminated from the AST; at the same time, there are entirely new data structures. This is important because it gets us closer to what will be needed to actually generate code.
Designing the types for the AST of your language will require a lot of thought, while keeping in mind the relationship with the interpreter itself, as you want to start representing the semantics of how the code will run.
In the case of the language being designed in this book, that involved transforming the messages described by the parse tree into the state machines of the different agents, as well as identifying what all the actions those agents will need to take are.
Once you define the types for your...