Annotated Parse Tree in Compiler

In this class, We discuss Annotated Parse Tree in Compiler.

For Complete YouTube Video: Click Here

The reader should have a prior understanding of syntax-directed translation. Click Here.

The concept of the annotated parse tree is very simple to understand.

Before going to the annotated parse tree, we have a deeper understanding of synthesized and inherited attribute concepts.

The below diagram shows a syntax-directed definition for the expression grammar.

The first condition T’.inh = F.val is an inherited attribute.

T.val = T’.syn is a synthesized attribute.

Important: T’ has two attributes. T’.inh and t’.syn.

We can assign any number of attributes according to the requirement.

An important point to understand: Attribute can take values from a child or itself.

The example T’ – epsilon has the semantic condition T’.syn = T’.inh

Annotated parse Tree:

The below diagram shows the annotated parse tree for the expression 3*5.

In annotated parse tree, We show the attribute values.

The dependency graph shows how the parse tree attribute values

evaluated.

We discuss dependency graphs in our next class.

T – *FT’ production has two attributes for the non-terminal T’, and we show both in the annotated parse tree.