Skip to content

Beta · Data may be lost.Your data may be reset or lost.

GateBrew
← GATE CSE 2026 Set 1
Questions

Q43

MSQ2 marksCompiler design

Consider the following two syntax-directed definitions SDD1\text{SDD1} and SDD2\text{SDD2} for type declarations. SDD1 Grammar (G1)Semantic Rules D→T VD.type=T.typeD \rightarrow T\ V{}D.type = T.type V.type=T.typeV.type = T.type T→intT.type=intT \rightarrow \text{int}{}T.type = \text{int} T→floatT.type=floatT \rightarrow \text{float}{}T.type = \text{float} V→V1 idV1.type=V.typeV \rightarrow V_1\ \text{id}{}V_1.type = V.type put(id.entry, V.type)\text{put(id.entry, V.type)} V→idput(id.entry, V.type)V \rightarrow \text{id}{}\text{put(id.entry, V.type)} SDD2 Grammar (G2)Semantic Rules D→D1 idD.type=D1.typeD \rightarrow D_1\ \text{id}{}D.type = D_1.type put(id.entry, D_1.type)\text{put(id.entry, D\_1.type)} D→T idD.type=T.typeD \rightarrow T\ \text{id}{}D.type = T.type put(id.entry, T.type)\text{put(id.entry, T.type)} T→intT.type=intT \rightarrow \text{int}{}T.type = \text{int} T→floatT.type=floatT \rightarrow \text{float}{}T.type = \text{float} DD is the start symbol, and int, float and id are the three terminals. The non-terminal V1V_{1} is the same as VV and the non-terminal D1D_{1} is the same as DD. Here, the subscript is used to differentiate the grammar symbols on the two sides of a production. The function put updates the symbol table with the type information for an identifier. Let P\text{P} and Q\text{Q} be the languages specified by grammars G1\text{G1} and G2\text{G2}, respectively. Which of the following statements is/are true?

Sign in to save attempts.

Solutions and discussion are hidden while you attempt this question. They open once you check or show the answer.