8. In a syntax directed translation scheme, if value of an attribute of a node is a function
of the values of the attributes of its children, then it is called
A. synthesized attribute
B. inherited attribute
C. canonical attribute
D. none of the above
[01]



Answer :

In a syntax-directed translation scheme, when the value of an attribute of a node depends on the values of the attributes of its children, it is categorized as either a synthesized attribute or an inherited attribute. Let's break down the definitions and differences between these two types: 1. **Synthesized Attribute**: - **Definition**: A synthesized attribute is one whose value at a node is determined by the values of attributes at its children and possibly its siblings as well. - **Example**: In a syntax tree representing arithmetic expressions, the value of an attribute "type" at a non-terminal node representing an expression could be synthesized by combining the types of its children (operands). 2. **Inherited Attribute**: - **Definition**: An inherited attribute is one whose value at a node is determined by the values of attributes at its parent and possibly its siblings as well. - **Example**: In a syntax tree for a programming language, the attribute "scope" at a node representing a block of code could be inherited from its parent node representing the surrounding scope. So, to answer the question, when the value of an attribute of a node is a function of the values of the attributes of its children, it is called a **synthesized attribute** (Option A). By understanding the distinction between synthesized and inherited attributes, you can better grasp how information is propagated and computed within a syntax-directed translation scheme.