Chapter 24. Tree Construction

The parser creates and returns a syntax tree representation of the source text that is manipulated later by tree-walking code.


24.1 How It Works

Any parser using Syntax-Directed Translation builds up a syntax tree while it’s doing the parsing. It builds the tree up on the stack, pruning the branches when it’s done with them. With Tree Construction, we create parser actions that build up a syntax tree in memory during the parse. Once the parse is complete, we have a syntax tree for the DSL script. We can then carry out further manipulations based on that syntax tree. If we are using a Semantic Model, we run code ...

Get Domain Specific Languages now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.