What is difference between Parse Tree, Annotated Parse Tree and Activation Tree ?(compiler)

18,353

Solution 1

AN ANNOTATED PARSE TREE is a parse tree showing the values of the attributes at each node. The process of computing the attribute values at the nodes is called annotating or decorating the parse tree.

For example: Refer link below, it is annotated parse tree for 3*5+4n

https://i.stack.imgur.com/WAwdZ.png

Solution 2

A parse tree is a representation of how a source text (of a program) has been decomposed to demonstate it matches a grammar for a language. Interior nodes in the tree are language grammar nonterminals (BNF rule left hand side tokens), while leaves of the tree are grammar terminals (all the other tokens) in the order required by grammar rules.

An annotated parse tree is one in which various facts about the program have been attached to parse tree nodes. For example, one might compute the set of identifiers that each subtree mentions, and attach that set to the subtree. Compilers have to store information they have collected about the program somewhere; this is a convenient place to store information which is derivable form the tree.

An activation tree is conceptual snapshot of the result of a set of procedures calling one another at runtime. Node in such a tree represent procedures which have run; childen represent procedures called by their parent.

So a key difference between (annotated) parse trees and activation trees is what they are used to represent: compile time properties vs. runtime properties.

Share:
18,353
Polish
Author by

Polish

Lazy

Updated on June 20, 2022

Comments

  • Polish
    Polish almost 2 years

    I know what is a Parse Tree and what is an Abstract Tree but I after reading some about Annotated Parse Tree(as we draw detailed tree which is same as Parse Tree), I feel that they are same as Parse Tree.

    Can anyone please explain differences among these three in detail ?

    Thanks.