wiz-icon
MyQuestionIcon
MyQuestionIcon
1
You visited us 1 times! Enjoying our articles? Unlock Full Access!
Question

In a bottom-up evaluation of a syntax directed definition, inherited attributes can

A
always be evaluated
No worries! We‘ve got your back. Try BYJU‘S free classes today!
B
never be evaluated
No worries! We‘ve got your back. Try BYJU‘S free classes today!
C
be evaluated only if the definition has synthesized attributes
Right on! Give the BNAT exam to get a 100% scholarship for BYJUS courses
D
be evaluated only if the definition is L-attributed
No worries! We‘ve got your back. Try BYJU‘S free classes today!
Open in App
Solution

The correct option is C be evaluated only if the definition has synthesized attributes
Every S(Synthesized). attributed definition is L-attributed. For implementing inherited attributed during bottom-up parsing, extends to some, but not LR grammars. Consider the following example
Production Semantic Rule
SL L. count : = 0
LL1 1 L. count : = L. count : + 1
LE print (L.count)

In the example above the nonterminal L in LE inherits the count of the number of 1's generated by S. Since the production LE is the first that a bottom. up parser would reduce by, the translator at the time can't know the number of 1's in the input. So in a bottom-up evaluation of a syntax directed definition, inherits attributes can't be evaluated if the definition is L-attributed in the given example. So we can say that L-attributed definition is based on simple LR(1) grammar, but it can't be implemented always but inherit attributes can be evaluated only if the definition has synthesized attributes.

flag
Suggest Corrections
thumbs-up
1
Join BYJU'S Learning Program
similar_icon
Related Videos
thumbnail
lock
Language is a Pattern
MATHEMATICS
Watch in App
Join BYJU'S Learning Program
CrossIcon