1
GATE CSE 2026 Set 1
MCQ (More than One Correct Answer)
+2
-0

$$ \text { Consider the following two syntax-directed definitions SDD1 and SDD2 for type declarations. } $$

SDD1
Grammar(G1) $$
\text { Semantic Rules }
$$
$$
\mathrm{D} \rightarrow \mathrm{TV}
$$
$$
\begin{aligned}
& \text { D.type = T.type } \\
& \text { V.type = T.type }
\end{aligned}
$$
$$
\mathrm{T} \rightarrow \mathrm{int}
$$
$$
\text { T.type = int }
$$
$$
\mathrm{T} \rightarrow \text { float }
$$
$$
\text { T.type = float }
$$
$$
\mathrm{V} \rightarrow \mathrm{~V}_1 \mathrm{id}
$$
$$
\begin{aligned}
& V_1 \cdot \text { type }=\text { V.type } \\
& \text { put(id.entry, V.type) }
\end{aligned}
$$
$$
\mathrm{V} \rightarrow \mathrm{id}
$$
$$
\text { put(id.entry, V.type) }
$$
SDD2
Grammar(G2) $$
\text { Semantic Rules }
$$
$$
\mathrm{D} \rightarrow D_1 \mathrm{id}
$$
$$
\begin{aligned}
& \text { D.type }=D_1 \cdot \text { type } \\
& \text { put(id.entry, } D_1 \cdot \text { type) }
\end{aligned}
$$
$$
\mathrm{D} \rightarrow \mathrm{~T} \text { id }
$$
$$
\begin{aligned}
& \text { D.type = T.type } \\
& \text { put(id.entry, T.type) }
\end{aligned}
$$
$$
\mathrm{T} \rightarrow \text { int }
$$
$$
\text { T.type = int }
$$
$$
\mathrm{T} \rightarrow \text { float }
$$
$$
\text { T.type = float }
$$
$D$ is the start symbol, and int, float and id are the three terminals. The non-terminal $V_1$ is the same as $V$ and the non-terminal $D_1$ is the same as $D$. 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$ and $Q$ be the languages specified by grammars G1 and G2, respectively. Which of the following statements is/are true?
A

The languages P and Q are the same

B

SDD2 is S-attributed and contains only synthesized attributes

C

SDD1 is L-attributed and contains only inherited attributes

D

The specifications of SDD1 and SDD2 are such that the same entries get added to the symbol table

2
GATE CSE 2024 Set 2
MCQ (Single Correct Answer)
+2
-0.66

Consider the following expression: $x[i] = (p + r) * -s[i] + \frac{u}{w}$. The following sequence shows the list of triples representing the given expression, with entries missing for triples (1), (3), and (6).

(0) + p r
(1)
(2) uminus (1)
(3)
(4) / u w
(5) + (3)(4)
(6)
(7) = (6)(5)

Which one of the following options fills in the missing entries CORRECTLY?

A

(1) = [] s i     (3) * (0) (2)     (6) []= x i

B

(1) []= s i     (3) - (0) (2)     (6) =[] x (5)

C

(1) =[] s i     (3) * (0) (2)     (6) []= x (5)

D

(1) []= s i     (3) - (0) (2)     (6) =[] x i

3
GATE CSE 2024 Set 1
MCQ (Single Correct Answer)
+2
-0.66

Consider the following syntax-directed definition (SDD).

S → DHTU { S.val = D.val + H.val + T.val + U.val; }
D → “M” D1 { D.val = 5 + D1.val; }
D → ε { D.val = –5; }
H → “L” H1 { H.val = 5 * 10 + H1.val; }
H → ε { H.val = –10; }
T → “C” T1 { T.val = 5 * 100 + T1.val; }
T → ε { T.val = –5; }
U → “K” { U.val = 5; }
Given “MMLK” as the input, which one of the following options is the CORRECT value computed by the SDD (in the attribute S.val)?
A

45

B

50

C

55

D

65

4
GATE CSE 2023
Numerical
+2
-0

Consider the syntax directed translation given by the following grammar and semantic rules. Here N, I, F and B are non-terminals. N is the starting non-terminal, and #, 0 and 1 are lexical tokens corresponding to input letters "#", "0" and "1", respectively. X.val denotes the synthesized attribute (a numeric value) associated with a non-terminal X. I$$_1$$ and F$$_1$$ denote occurrences of I and F on the right hand side of a production, respectively. For the tokens 0 and 1, 0.val = 0 and 1.val = 1.

$\begin{array}{llll}N & \rightarrow & I \# F & \text { N.val }=I . v a l+F . v a l \\ I & \rightarrow & I_1 B & I . v a l=\left(2 I_1 \cdot v a l\right)+\text { B.val } \\ I & \rightarrow & B & I . v a l=B . v a l \\ F & \rightarrow & B F_1 & F . v a l=\frac{1}{2}\left(B . v a l+F_1 \cdot v a l\right) \\ F & \rightarrow & B & F . v a l=\frac{1}{2} B . v a l \\ B & \rightarrow & 0 & \text { B.val }=\mathbf{0} . \mathrm{val} \\ B & \rightarrow & 1 & \text { B.val }=\mathbf{1} . \mathrm{val}\end{array}$

The value computed by the translation scheme for the input string

$$10 \# 011$$

is ____________. (Rounded off to three decimal places)

Your input ____

GATE CSE Subjects

Browse all chapters by subject

Software Engineering
Web Technologies