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 PYQ2007Compiler DesignParsing (LL, LR)MCQ · 1 mark
Consider the CFG with {S,A,B}\left\{S, A, B\right\} as the non-terminal alphabet, {a,b}\{a, b\} as the terminal alphabet, SS as the start symbol and the following set of production rules: S→aBS \rightarrow aB S→bAS \rightarrow bA B→bB \rightarrow b A→aA \rightarrow a B→bSB \rightarrow bS A→aSA \rightarrow aS B→aBBB \rightarrow aBB A→bAAA \rightarrow bAA For …
Official PYQ2007Compiler DesignParsing (LL, LR)MCQ · 1 mark
Consider the CFG with {S,A,B}\left\{S, A, B\right\} as the non-terminal alphabet, {a,b}\{a, b\} as the terminal alphabet, SS as the start symbol and the following set of production rules: S→aBS \rightarrow aB S→bAS \rightarrow bA B→bB \rightarrow b A→aA \rightarrow a B→bSB \rightarrow bS A→aSA \rightarrow aS B→aBBB \rightarrow aBB A→bAAA \rightarrow bAA Which …
Official PYQ2007Compiler DesignParsing (LL, LR)MCQ · 1 mark
Consider the following two statements: P: Every regular grammar is LL(1) Q: Every regular set has a LR(1) grammar Which of the following is TRUE?
Official PYQ2007Compiler DesignParsing (LL, LR)MCQ · 1 mark
Consider the grammar with non-terminals N={S,C,S1}N=\left\{S,C,S_1\right\}, terminals T={a,b,i,t,e}T=\left\{a, b, i, t, e\right\}, with SS as the start symbol, and the following set of rules: S→iCtSS1∣aS \rightarrow iCtSS_1 \mid a S1→eS∣ϵS_1 \rightarrow eS \mid \epsilon C→bC \rightarrow b The grammar is NOT LL(1) because:
Official PYQ2007Compiler DesignParsing (LL, LR)MCQ · 1 mark
Which one of the following is a top-down parser?
Official PYQ2006Compiler DesignParsing (LL, LR)MCQ · 1 mark
The grammar S→AC∣CBS\rightarrow AC\mid CB C→aCb∣ϵC\rightarrow aCb\mid \epsilon A→aA∣aA\rightarrow aA\mid a B→Bb∣bB\rightarrow Bb\mid b generates the language L={aibj∣i≠j}L=\left \{ a^{i}b^{j}\mid i\neq j \right \}. In this grammar what is the length of the derivation (number of steps starting from SS) to generate the string albma^{l}b^{m} with l≠ml\neq m
Official PYQ2006Compiler DesignParsing (LL, LR)MCQ · 1 mark
Which one of the following grammars generates the language L={aibj∣i≠j}L=\left \{ a^{i}b^{j}\mid i\neq j \right \}?
Official PYQ2006Compiler DesignLocal OptimizationMCQ · 1 mark
Consider the following C code segment. for (i = 0, i < n; i++) { for (j = 0; j < n; j++) { if (i%2) { x += (4*j + 5*i); y += (7 + 4*j); } } } Which one of the following is false?
Official PYQ2006Compiler DesignParsing (LL, LR)MCQ · 1 mark
Consider the following translation scheme. S→ERS\rightarrow ER R→∗E{print(‘∗’);}R∣εR\rightarrow *E\left \{ \text{print}(\text{‘}*\text{’}); \right \} R\mid \varepsilon E→F+E{print(‘+’);}∣FE\rightarrow F+E\left \{ \text{print}(\text{‘}+\text{’}); \right \}\mid F F→(S)∣id{print(id.value);}F\rightarrow (S)\mid id \left \{ \text{print}(id.value); \right \} Here idid is a token that represents an integer and …
Official PYQ2006Compiler DesignLocal OptimizationMCQ · 1 mark
Consider these two functions and two statements S1 and S2 about them. int work1(int *a, int i, int j) { int x = a[i+2]; a[j] = x+1; return a[i+2] - 3; } int work2(int *a, int i, int j) { int t1 = i+2; int t2 = a[t1]; a[j] = t2+1; return t2 - 3; } S1: The transformation form work1 to work2 is valid, i.e., for any program state and input arguments, work2 will …
Official PYQ2006Compiler DesignParsing (LL, LR)MCQ · 1 mark
Consider the following statements about the context free grammar G={S→SS,S→ab,S→ba,S→ϵ}G = \left \{ S \rightarrow SS, S \rightarrow ab, S \rightarrow ba, S \rightarrow \epsilon \right \} GG is ambiguous GG produces all strings with equal number of aa’s and bb’s GG can be accepted by a deterministic PDA. Which combination below expresses all the true statements …
Official PYQ2006Compiler DesignParsing (LL, LR)MCQ · 1 mark
Consider the following grammar S→S∗ES \rightarrow S * E S→ES \rightarrow E E→F+EE \rightarrow F + E E→FE \rightarrow F F→idF \rightarrow id Consider the following LR(0) items corresponding to the grammar above S→S∗.ES \rightarrow S *.E E→F.+EE \rightarrow F. + E E→F+.EE \rightarrow F + .E Given the items above, which two of them will appear in the same set in the …
Official PYQ2005Compiler DesignParsing (LL, LR)MCQ · 1 mark
Consider the following expression grammar. The semantic rules for expression evaluation are stated next to each grammar production. …
Official PYQ2005Compiler DesignParsing (LL, LR)MCQ · 1 mark
Consider line number 33 of the following C-program. int main() { /*Line 1 */ int I, N; /*Line 2 */ fro (I=0, I<N, I++); /*Line 3 */ } Identify the compiler’s response about this line while creating the object-module:
Official PYQ2005Compiler DesignParsing (LL, LR)MCQ · 1 mark
Statement for Linked Answer Questions 83a & 83b: Consider the following expression grammar. The semantic rules for expression evaluation are stated next to each grammar production. …
Official PYQ2005Compiler DesignParsing (LL, LR)MCQ · 1 mark
Consider the grammar: S→(S)∣aS \rightarrow (S) \mid a Let the number of states in SLR (1), LR(1) and LALR(1) parsers for the grammar be n1,n2n_1, n_2 and n3n_3 respectively. The following relationship holds good:
Official PYQ2005Compiler DesignParsing (LL, LR)MCQ · 1 mark
Consider the grammar: E→E+n∣E×n∣nE \rightarrow E + n \mid E \times n \mid n For a sentence n+n×nn + n \times n, the handles in the right-sentential form of the reduction are:
Official PYQ2005Compiler DesignParsing (LL, LR)MCQ · 1 mark
The grammar A→AA∣(A)∣ϵA \rightarrow AA \mid (A) \mid \epsilon is not suitable for predictive-parsing because the grammar is:
Official PYQ2004Compiler DesignLocal OptimizationMCQ · 1 mark
Consider the grammar rule E→E1–E2E \rightarrow E1 – E2 for arith­metic expressions. The code generated is targeted to a CPU having a single user register. The sub­traction operation requires the first operand to be in the register. If E1E1 and E2E2 do not have any com­mon sub expression, in order to get the shortest possible code
Official PYQ2004Compiler DesignParsing (LL, LR)MCQ · 1 mark
Consider the following grammar G: S→bS∣aA∣bS \rightarrow bS \mid aA \mid b A→bA∣aBA \rightarrow bA \mid aB B→bB∣aS∣aB \rightarrow bB \mid aS \mid a Let Na(w)N_a(w) and Nb(w)N_b(w) denote the number of a’s and b’s in a string ω\omega respectively. The language L(G)L(G) over {a,b}+\left\{a, b\right\}^+ generated by GG is