GATEverse
← GATE CSE 2021 Set 1

Q26

MCQ2 marks, −0.67

Consider the following grammar (that admits a series of declarations, followed by expressions) and the associated syntax directed translation (SDT)\text{(SDT)} actions, given as pseudo-code P→D∗E∗D→int ID{record that ID.lexeme is of type int}D→bool ID{record that ID.lexeme is of type bool}E→E1+E2{check that E1.type=E2.type=int;set E.type :=int}E→!E1{check that E1.type=bool; set E.type:=bool}E→ID{set E.type :=int}\begin{array}{lll} P & \rightarrow & D^* E^* \\ D & \rightarrow & \textsf{int ID} \{ \text{record that } \textsf{ID.} \text{lexeme is of type} \textsf{ int\}} \\ D & \rightarrow & \textsf{bool ID} \{ \text{record that } \textsf{ID.} \text{lexeme is of type} \textsf{ bool\}} \\ E& \rightarrow & E_1 +E_2 \{ \text{check that } E_1. \text{type}=E_2. \text{type} = \textsf{int}; \text{set } E.\text{type }:= \textsf{int} \} \\ E & \rightarrow & !E_1 \{ \text{check that } E_1. \text{type} = \textsf{bool}; \text{ set } E.\text{type} := \textsf{bool} \} \\ E & \rightarrow & \textsf{ID} \{ \text{set } E. \text{type } := \textsf{int} \} \end{array} With respect to the above grammar, which one of the following choices is correct?

Sign in to save attempts.

Loading…