Skip to content

GATE CS Compiler Design questions

Practise Compiler Design questions for GATE CS. Explore official PYQs and original subject-wise quizzes, check answers and view available solutions. Free, no sign-in.

Subject, topic, year and type filter the full library. Match any choice within a filter, and all selected filter categories. Search, source and sort apply to this page.

20 on this page
Official PYQ2026Compiler DesignLexical AnalysisMCQ · 1 mark
Consider the following C statements: char *str1 = "Hello; /* Statement S1 */ char *str2 = "Hello;"; /* Statement S2 */ int *str3 = "Hello"; /* Statement S3 */ Which of the following options is/are correct?
Official PYQ2026Compiler DesignParsing (LL, LR)MCQ · 1 mark
Which of the following statements is/are true?
Official PYQ2026Compiler DesignParsing (LL, LR)MCQ · 2 marks
Consider the control flow graph shown in the figure. Which one of the following options correctly lists the set of redundant expressions (common subexpressions) in the basic blocks B44 and B55? Note: All the variables are integers.
Official PYQ2026Compiler DesignSyntax-directed TranslationMSQ · 2 marks
Consider the following two syntax-directed definitions SDD1\text{SDD1} and SDD2\text{SDD2} for type declarations. …
Official PYQ2026Compiler DesignParsing (LL, LR)MSQ · 1 mark
Which of the following grammars is/are ambiguous?
Official PYQ2026Compiler DesignLexical AnalysisNAT · 1 mark
A lexical analyzer uses the following token definitions letter→[A−Za−z]{letter → [A-Za-z]} digit→[0−9]{digit → [0-9]} id→letter(letter∣digit)∗{id → letter (letter | digit)^*} number→digit{number → digit} +{ }^{+} ws→(blank∣tab∣newline){ws → (blank | tab| newline)} +{ }^{+} For the string given below, …
Official PYQ2026Compiler DesignParsing (LL, LR)MCQ · 2 marks
Consider the canonical LR(0)L R(0) parsing of the grammar below using terminals {a,b,c}\{a, b, c\} and non-terminals {A,B,C,S}\{A, B, C, S\} with SS as the start symbol. S→ACBA→aA∣ϵC→cC∣ϵB→bB∣b\begin{array}{l} S \rightarrow A C B \\ A \rightarrow a A \mid \epsilon \\ C \rightarrow c C \mid \epsilon \\ B \rightarrow b B \mid b \end{array} Which one of the following options gives the …
Official PYQ2026Compiler DesignLocal OptimizationMCQ · 2 marks
Consider the control flow graph given below. Which one of the following options is the set of live variables at the exit point of each basic block?
Official PYQ2025Compiler DesignLexical AnalysisMCQ · 1 mark
Which ONE of the following statements is FALSE regarding the symbol table?
Official PYQ2025Compiler DesignLocal OptimizationMCQ · 1 mark
Which ONE of the following techniques used in compiler code optimization uses live variable analysis?
Official PYQ2025Compiler DesignParsing (LL, LR)MSQ · 2 marks
Which of the following statement(s) is/are TRUE while computing First⁡\operatorname{First} and Follow⁡\operatorname{Follow} during top down parsing by a compiler?
Official PYQ2025Compiler DesignIntermediate Code GenerationNAT · 2 marks
Refer to the given 33-address code sequence. This code sequence is split into basic blocks. The number of basic blocks is ________. (Answer in integer) 1001: i = 1 1002: j = 1 1003: t1 = 10*i 1004: t2 = t1+j 1005: t3 = 8*t2 1006: t4 = t3-88 1007: a[t4] = 0.0 1008: j = j+1 1009: if j <= 10 goto 1003 1010: i = i+1 1011: if i <= 10 goto 1002 1012: i = …
Official PYQ2025Compiler DesignParsing (LL, LR)MSQ · 2 marks
Consider two grammars G1G_{1} and G2G_{2} with the production rules given below: G1:S→G_{1} : S \rightarrow ifif EE thenthen SS ∣| ifif EE thenthen SS elseelse SS ∣| aa E→bE \rightarrow b G2:S→G_{2} :S \rightarrow ifif EE thenthen SS ∣| MM M→M \rightarrow ifif EE thenthen MM elseelse SS ∣| cc …
Official PYQ2025Compiler DesignIntermediate Code GenerationMCQ · 1 mark
​​​​Consider the following statements about the use of backpatching in a compiler for intermediate code generation: Backpatching can be used to generate code for Boolean expression in one pass. Back[atching can be used to generate code for flow-of-control statements in one pass. Which ONE of the folloeing options is CORRECT?
Official PYQ2025Compiler DesignSyntax-directed TranslationMCQ · 1 mark
​​Given the following syntax directed translation rules: Rule 1: R→AB{B.i=R.i−1;A.i=B.i;R.i=A.i+1;}R \rightarrow A B\{B . i=R . i-1 ; A . i=B . i ; R . i=A . i+1 ;\} Rule 2: P→CD{P.i=C.i+D.i;D.i=C.i+2;}P \rightarrow C D\{P . i=C . i+D . i ; D . i=C . i+2 ;\} Rule 3: Q→EF{Q.i=E.i+F.i;}Q \rightarrow E F\{Q . i=E . i+F . i ;\} Which ONE is the CORRECT option among the following?
Official PYQ2025Compiler DesignParsing (LL, LR)MCQ · 2 marks
​​Given a Context-Free Grammar G\text{G} as follows: S→Aa∣bAc∣dc∣bdaA→d\begin{array}{l} S \rightarrow A a|b A c| d c \mid b d a \\ A \rightarrow d \end{array} Which ONE of the following statements is TRUE?
Official PYQ2024Compiler DesignParsing (LL, LR)MSQ · 1 mark
Which of the following is/are Bottom-Up Parser(s)?
Official PYQ2024Compiler DesignParsing (LL, LR)NAT · 1 mark
Consider the operator precedence and associativity rules for the integer arithmetic operators given in the table below. …
Official PYQ2024Compiler DesignSyntax-directed TranslationMCQ · 2 marks
​Consider the following syntax-directed definition (SDD)\text{(SDD)}. …
Official PYQ2024Compiler DesignIntermediate Code GenerationMCQ · 2 marks
Consider the following pseudo-code. L 1: t1 = -1 L 2: t2 = 0 L 3: t3 = 0 L 4: t4 = 4 * t3 L 5: t5 = 4 * t2 L 6: t6 = t5 * M L 7: t7 = t4 + t6 L 8: t8 = a[t7] L 9: if t8 <= max goto L11 L 10: t1 = t8 L 11: t3 = t3 + 1 L 12: if t3 < M goto L4 L 13: t2 = t2 + 1 L 14: if t2 < N goto L3 L 15: max = t1 Which one of the following options CORRECTLY …