Gate2019 cs Q46

0. 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 placeholders for the non-terminals D, T, L or L1 in the following table:
 Productions rule Semantic action
 D   TL X1 .type =  X2 .type
 T   int T.type = int
 T    float T.type = float
 L   L1 , id X3 .type = X4  .type add Type(id.entry, X5 .type)
 L   id addType(id.entry, X6 .type)

Which one of the following are the appropriate choices for 𝑋1, 𝑋2, 𝑋3 and 𝑋4?

  • Option : A
  • Explanation :
    SDT for inserting type information in the symbol table
    D → TL {L.idtype = T.stype}
    T → int {T.stype = int}
    T → float {T.stype = float}
    L → L1, id {L1.itype = L.itype}
    addtype(id.entry, L.itype)
    L → id addtype(id.entry, L.itype)
Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *