Compiler Design questions

Q26

GATE CS 2024 CS-1ParsingMSQ1 mark
Which of the following is/are Bottom-Up Parser(s)?
More than one option can be correct.
Show answer without attempting

Answer: A, D

Q37

GATE CS 2024 CS-1Syntax Directed TranslationMCQ2 marks−2/3 if wrong
Consider the following syntax-directed definition (SDD).
S→DHTU{S.val=D.val+H.val+T.val+U.val;}S \to DHTU \{ S.val = D.val + H.val + T.val + U.val; \}
D→"M"D1{D.val=5+D1.val;}D \to \text{"M"}D_1 \{ D.val = 5 + D_1.val; \}
D→ϵ{D.val=−5;}D \to \epsilon \{ D.val = -5; \}
H→"L"H1{H.val=5∗10+H1.val;}H \to \text{"L"}H_1 \{ H.val = 5 * 10 + H_1.val; \}
H→ϵ{H.val=−10;}H \to \epsilon \{ H.val = -10; \}
T→"C"T1{T.val=5∗100+T1.val;}T \to \text{"C"}T_1 \{ T.val = 5 * 100 + T_1.val; \}
T→ϵ{T.val=−5;}T \to \epsilon \{ T.val = -5; \}
U→"K"{U.val=5;}U \to \text{"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.valS.val)?
Show answer without attempting

Answer: A

Q39

GATE CS 2024 CS-1Intermediate CodeMCQ2 marks−2/3 if wrong
Consider the following pseudo-code.
L1:t1=−1L1: t1 = -1
L2:t2=0L2: t2 = 0
L3:t3=0L3: t3 = 0
L4:t4=4∗t3L4: t4 = 4 * t3
L5:t5=4∗t2L5: t5 = 4 * t2
L6:t6=t5∗ML6: t6 = t5 * M
L7:t7=t4+t6L7: t7 = t4 + t6
L8:t8=a[t7]L8: t8 = a[t7]
L9:if t8<=max goto L11L9: \text{if } t8 <= max \text{ goto } L11
L10:t1=t8L10: t1 = t8
L11:t3=t3+1L11: t3 = t3 + 1
L12:if t3<M goto L4L12: \text{if } t3 < M \text{ goto } L4
L13:t2=t2+1L13: t2 = t2 + 1
L14:if t2<N goto L3L14: \text{if } t2 < N \text{ goto } L3
L15:max=t1L15: max = t1
Which one of the following options CORRECTLY specifies the number of basic blocks and the number of instructions in the largest basic block, respectively?
Show answer without attempting

Answer: D

Q21

GATE CS 2024 CS-2Lexical AnalysisMCQ1 mark−1/3 if wrong
Consider the following two sets:
Set XSet Y
P. Lexical Analyzer1. Abstract Syntax Tree
Q. Syntax Analyzer2. Token
R. Intermediate Code Generator3. Parse Tree
S. Code Optimizer4. Constant Folding
Which one of the following options is the CORRECT match from Set X to Set Y?
Show answer without attempting

Answer: B

Q29

GATE CS 2024 CS-2Syntax Directed TranslationMSQ1 mark
Which of the following statements is/are FALSE?
More than one option can be correct.
Show answer without attempting

Answer: B, D

Q40

GATE CS 2024 CS-2ParsingMCQ2 marks−2/3 if wrong
Consider the following context-free grammar where the start symbol is SS and the set of terminals is {a,b,c,d}\{a,b,c,d\}.

S→AaAb∣BbBaS \to AaAb \mid BbBa
A→cS∣ϵA \to cS \mid \epsilon
B→dS∣ϵB \to dS \mid \epsilon

The following is a partially-filled LL(1) parsing table.
aabbccdd$\$
SSS→AaAbS \to AaAbS→BbBaS \to BbBa(1)(2)
AAA→ϵA \to \epsilon(3)A→cSA \to cS
BB(4)B→ϵB \to \epsilonB→dSB \to dS
Which one of the following options represents the CORRECT combination for the numbered cells in the parsing table?

Note: In the options, "blank" denotes that the corresponding cell is empty.
Show answer without attempting

Answer: A

Q43

GATE CS 2024 CS-2Intermediate CodeMCQ2 marks−2/3 if wrong
Consider the following expression: x[i]=(p+r)∗−s[i]+u/wx[i] = (p + r) * -s[i] + u/w. The following sequence shows the list of triples representing the given expression, with entries missing for triples (1), (3), and (6).

Which one of the following options fills in the missing entries CORRECTLY?
Question figure
Show answer without attempting

Answer: A

Q65

GATE CS 2024 CS-2ParsingNAT2 marks
Consider the following augmented grammar, which is to be parsed with a SLR parser. The set of terminals is {a,b,c,d,#,@}\{a,b,c,d,\#,@\}

S′→SS' \to S
S→SS∣Aa∣bAc∣Bc∣bBaS \to SS \mid Aa \mid bAc \mid Bc \mid bBa
A→d#A \to d\#
B→@B \to @

Let I0=CLOSURE({S′→∙S})I_0 = \text{CLOSURE}(\{S' \to \bullet S\}). The number of items in the set GOTO(I0,S)\text{GOTO}(I_0, S) is ___________
Show answer without attempting

Answer: 9

0/80 correct0 marks

Related topics in GATE CS