GATE CS — Computer Science & IT Subject test

Compiler Design — GATE Previous Year Questions

  • 10Questions
  • 14Total marks
  • 30Minutes

Every verified previous-year GATE question in the Compiler Design section of the W3Colleges bank, in chronological order. Practise them untimed with worked explanations, or take the set as a timed test.

Start timed test Practice without timer

The timed run lasts 30 minutes and is held on the server.

Questions

Compiler Design

Question 2

MCQ 2 marks · −0.66 Compiler Design

Consider the grammar

S → ( S ) | a

Let the number of states in the SLR(1), LR(1) and LALR(1) parsers for the grammar be \(n_1\), \(n_2\) and \(n_3\) respectively. Which one of the following relationships holds good?

Answers and explanations are free — they just need an account.

Question 3

MCQ 1 marks · −0.33 Compiler Design

Which one of the following is FALSE?

Answers and explanations are free — they just need an account.

Question 4

MCQ 1 marks · −0.33 Compiler Design

Match the following:

List-IList-II
(P) Lexical analysis(i) Leftmost derivation
(Q) Top down parsing(ii) Type checking
(R) Semantic analysis(iii) Regular expressions
(S) Runtime environments(iv) Activation records

Answers and explanations are free — they just need an account.

Question 5

NAT 2 marks · no negative Compiler Design

Consider the following code segment:

x = u - t;
y = x * v;
x = y + w;
y = t - z;
y = x * y;

The minimum number of total variables required to convert the above code segment to static single assignment form is ______.

Answers and explanations are free — they just need an account.

Question 6

NAT 2 marks · no negative Compiler Design

The attributes of three arithmetic operators in some programming language are given below.

OperatorPrecedenceAssociativityArity
+HighLeftBinary
MediumRightBinary
*LowLeftBinary

The value of the expression 2 − 5 + 1 − 7 * 3 in this language is ______.

Answers and explanations are free — they just need an account.

Question 7

MCQ 1 marks · −0.33 Compiler Design

Consider the following grammar:

P → x Q R S
Q → y z | z
R → w | ε
S → y

What is FOLLOW(Q)?

Answers and explanations are free — they just need an account.

Question 8

MCQ 1 marks · −0.33 Compiler Design

Consider the following intermediate program in three address code:

p = a - b
q = p * c
p = u * v
q = p + q

Which one of the following corresponds to a static single assignment form of the above code?

Answers and explanations are free — they just need an account.

Question 9

NAT 2 marks · no negative Compiler Design

Consider the grammar given below:

S → a S B | d
B → b

The number of reduction steps taken by a bottom-up parser while accepting the string aaadbbb is ______.

Answers and explanations are free — they just need an account.

Question 10

MCQ 1 marks · −0.33 Compiler Design

Consider the following statements.

S1: Every SLR(1) grammar is unambiguous but there are certain unambiguous grammars that are not SLR(1).

S2: For any context-free grammar, there is a parser that takes at most \(O(n^3)\) time to parse a string of length \(n\).

Which one of the following options is correct?

Answers and explanations are free — they just need an account.