SYNTAX ANALYSIS
ROLE OF THE PARSER
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
|
S-attributed
|
|
L-attributed
|
|
Both A and B
|
|
Attribute grammar
|
Detailed explanation-1: -S-attributed SDD. A syntax-directed definition (SDD) that involves only synthesized attributes is called S-attributed SDD. In an S-attributed SDD, each rule computes. an attribute for the nonterminal at the head of a production from attributes taken from the body of the production.
Detailed explanation-2: -An SDD is S-attributed if every attribute is synthesized. S-attributed SDDs are useful for bottom-up parsing. Inherited attributes are values that are computed at a node N in a parse tree from attribute values of the parent of N, the siblings of N, and N itself.
Detailed explanation-3: -Synthesized attribute is an attribute whose parse tree node value is determined by the attribute value at child nodes.To illustrate, assume the following production S → ABC if S is taking values from its child nodes (A, B, C), then it is said to be a synthesized attribute, as the values of ABC are synthesized to S.
Detailed explanation-4: -In L-attributed grammars attribute evaluation can be performed in left-to-right traversal. Since in S-attributed grammars attributes are not inherited, it does not prevent you from doing just that. As such, you can say an S-attributed grammar conforms to that characteristic of an L-grammar.