Compiler Design questions

Q11

GATE CS 2023 CSLexical AnalysisMCQ1 mark−1/3 if wrong
Consider the following statements regarding the front-end and back-end of a compiler.
S1: The front-end includes phases that are independent of the target hardware.
S2: The back-end includes phases that are specific to the target hardware.
S3: The back-end includes phases that are specific to the programming language used in the source code.

Identify the CORRECT option.
Show answer without attempting

Answer: B

Q19

GATE CS 2023 CSLexical AnalysisMCQ1 mark−1/3 if wrong
Consider the following definition of a lexical token id for an identifier in a programming language, using extended regular expressions:
<br>letter→[A-Za-z]<br>digit→[0-9]<br>id→letter (letter ∣ digit)∗<br>\begin{align*}<br>\text{letter} & \to \text{[A-Za-z]} \\<br>\text{digit} & \to \text{[0-9]} \\<br>\text{id} & \to \text{letter (letter } | \text{ digit)}^*<br>\end{align*}

Which one of the following Non-deterministic Finite-state Automata with ϵ\epsilon-transitions accepts the set of valid identifiers? (A double-circle denotes a final state)
Show answer without attempting

Answer: C

Q37

GATE CS 2023 CSOptimization and Data FlowMCQ2 marks−2/3 if wrong
Consider the control flow graph shown.

Which one of the following choices correctly lists the set of live variables at the exit point of each basic block?
Question figure
Show answer without attempting

Answer: D

Q60

GATE CS 2023 CSSyntax Directed TranslationNAT2 marks
Consider the syntax directed translation given by the following grammar and semantic rules. Here N,I,FN, I, F and BB are non-terminals. NN is the starting non-terminal, and #, 0 and 1 are lexical tokens corresponding to input letters "#", "0" and "1", respectively. X.valX.val denotes the synthesized attribute (a numeric value) associated with a non-terminal XX. I1I_1 and F1F_1 denote occurrences of II and FF on the right hand side of a production, respectively. For the tokens 0 and 1, 0.val=00.val = 0 and 1.val=11.val = 1.

<br>N→I#FN.val=I.val+F.val<br>I→I1BI.val=(2×I1.val)+B.val<br>I→BI.val=B.val<br>F→BF1F.val=12(B.val+F1.val)<br>F→BF.val=12B.val<br>B→0B.val=0.val<br>B→1B.val=1.val<br>\begin{align*}<br>N & \to I \# F && N.val = I.val + F.val \\<br>I & \to I_1 B && I.val = (2 \times I_1.val) + B.val \\<br>I & \to B && I.val = B.val \\<br>F & \to B F_1 && F.val = \frac{1}{2}(B.val + F_1.val) \\<br>F & \to B && F.val = \frac{1}{2} B.val \\<br>B & \to 0 && B.val = 0.val \\<br>B & \to 1 && B.val = 1.val<br>\end{align*}

The value computed by the translation scheme for the input string
10#01110\#011
is ____________. (Rounded off to three decimal places)
Show answer without attempting

Answer: 2.374 to 2.376

0/40 correct0 marks

Related topics in GATE CS