COMPILER DESIGN

SYNTAX ANALYSIS

ROLE OF THE PARSER

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
In a bottom-up evaluation of a syntax directed definition, inherited attributes can
A
always be evaluated
B
be evaluated only if the definition is L-attributed
C
be evaluated only if the definition has synthesized attributes
D
never be evaluated
Explanation: 

Detailed explanation-1: -The correct option is C be evaluated only if the definition has synthesized attributes.

Detailed explanation-2: -BOTTOM UP EVALUATION OF S ATTRIBUTED DEFINITION Bottom Up Evaluation of S Attributed An attribute grammar is a formal way to define attributes for the productions of a formal grammar, associating these attributes to values.

Detailed explanation-3: -Bottom-up parsing starts from the leaf nodes of a tree and works in upward direction till it reaches the root node. Here, we start from a sentence and then apply production rules in reverse manner in order to reach the start symbol.

Detailed explanation-4: -Summary. In an L-attributed SDD attributes may be inherited or synthesized, this is referred to as an L-attribute definition. In an S-attributed SDD, attributes all attributes are synthesized-S-attribute definition.

Detailed explanation-5: -Bottom up evaluation of S-attributed definition ➢ Syntax-directed definitions with only synthesized attributes(S-attribute) can be evaluated. by a bottom up parser (BUP) as input is parsed. ➢ In this approach, the parser will keep the values of synthesized attributes associated with. the grammar symbol on its stack.

There is 1 question to complete.