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

Consider the following grammar and the semantic actions to support the inherited type declaration attributes. Let X1,X2,X3,X4,X5 and X6 be the place holders for the non-terminals D, T, L or L1 in the following table:

Production rule Semantic action
DTL X1.type=X2.type
Tint T.type = int
TFloat T.type = float
LL1.id X3.type=X4.type add Type (id.entry, X5. type)
Lid add Type (id. entry, X6. type)

Which one of the following are the appropriate choices for X1,X2,X3 and X4?

A
X1=T, X2=L, X3=L1, X4=T
No worries! We‘ve got your back. Try BYJU‘S free classes today!
B
X1=L, X2=T, X3=L1, X4=L
Right on! Give the BNAT exam to get a 100% scholarship for BYJUS courses
C
X1=L, X2=L, X3=L1, X4=T
No worries! We‘ve got your back. Try BYJU‘S free classes today!
D
X1=T, X2=L, X3=T, X4=L1
No worries! We‘ve got your back. Try BYJU‘S free classes today!
Open in App
Solution

The correct option is B X1=L, X2=T, X3=L1, X4=L
SDT for inserting type information in the symbol table
DTL {L. idtype = T.stype}
Tint {T. stype = int}
T float {T. stype = float}
LL1, id {L1. itype = L.itype}
addtype(id.entry, L.itype)
Lid addtype (id.entry, L.itype)

Replace these attribute information in the given SDT.

So option (a) is the correct answer.

flag
Suggest Corrections
thumbs-up
0
Join BYJU'S Learning Program
similar_icon
Related Videos
thumbnail
lock
Covalent Bonds
MATHEMATICS
Watch in App
Join BYJU'S Learning Program
CrossIcon