1
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

2
GATE CSE 2023
Numerical
+2
-0.67

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 ____
3
GATE CSE 2021 Set 1
MCQ (Single Correct Answer)
+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
MCQ (Single Correct Answer)
+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
Software Engineering
Web Technologies
EXAM MAP
Medical
NEET
Graduate Aptitude Test in Engineering
GATE CSEGATE ECEGATE EEGATE MEGATE CEGATE PIGATE IN
Civil Services
UPSC Civil Service
Defence
NDA
CBSE
Class 12