1
GATE CSE 2024 Set 2
+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

2
GATE CSE 2024 Set 1
+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

3
GATE CSE 2021 Set 1
+2
-0.67

Consider the following grammar (that admits a series of declarations, followed by expressions) and the associated syntax directed translation (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}

With respect to the above grammar; which one of the following choices is correct?

A
The actions will lead to infinite loop.
B
The actions can be used to correctly type-check any syntactically correct program.
C
The actions can be used to type-check syntactically correct boolean variable declarations and boolean expressions.
D
The actions can be used to type-check syntactically correct integer variable declarations and integer expressions.
4
GATE CSE 2016 Set 1
+2
-0.6
Consider the following Syntax Directed Translation Scheme $$(SDTS),$$ with non-terminals $$\left\{ {S,A} \right\}$$ and terminals $$\left\{ {A,B} \right\}.$$
$$S \to aA$$ $$\,\,\,\,\,$${ print $$1$$ }
$$S \to a$$ $$\,\,\,\,$$$$\,\,\,\,\,$${ print $$2$$ }
$$A \to Sb$$ $$\,\,\,\,\,$${ print $$3$$ }

Using the above $$SDTS,$$ the output printed by a bottom-up parser, for the input $$aab$$ is:

A
$$1\,\,3\,\,2$$
B
$$2\,\,2\,\,3$$
C
$$2\,\,3\,\,1$$
D
syntax error
GATE CSE Subjects
EXAM MAP
Medical
NEET