The syntax tree of a program is a data structure which shows precisely how the various segments of a program text are to be viewed in terms of grammar.
The syntax tree can be obtained through a process called parsing.
Parsing is the process of structuring a text according to a given grammar.
Syntax trees can also be called parse tree or syntax analysis. For larger and more complicated grammar, parse generator is used to generate the parser.
Now, the exact form of the parse tree as required by the grammar is called abstract syntax tree (AST).
Detailed information about the semantics can be attached to the nodes in this tree through annotations which are stored in additional data field in the nodes hence the term "annotated abstract syntax tree".
Examples of annotations are:
1. Type Information - This assignment mode concerns a boolean array assignment.
2. Optimization Information - This expression does not contain a function call.
Type information is related to the semantics and it is used for context error checking while optimization information is important for code generation.
Annotations in a node is called the attribution of the node and represent the grammar symbol.
No comments:
Post a Comment