Compiler Design GATE previous year questions with answer

Ques 14 Gate 2019


Consider the augmented grammar given below:

S′ → S
S → ⏐id
L → L, S⏐S
Let I0= CLOSURE ({[S′ → S]}).

The number of items in the set GOTO (I0, <) is __________.


(5) is the correct answer.

Ques 15 Gate 2017 Set-2


Which of the following statements about the parser is/are correct?

I. Canonical LR is more powerful than SLR.
II. SLR is more powerful than LALR.
III. SLR is more powerful than canonical LR.

A

I only

B

II only

C

III only

D

II and III only


(Parsing) is the correct answer.

Ques 16 Gate 2017 Set-2


Match the following according to input(from the left column) to the compiler phase(in the right column) that process it:

(P)Syntax Tree (i)Code generator
(Q)Character Stream (ii)Syntax analyser
(R)Intermediate representation (iii)Semantic analyser
(S)Token stream (iv)Lexical analyser

A

P -> (ii), Q -> (iii), R -> (iv), S -> (i)

B

P -> (ii), Q -> (i), R -> (iii), S -> (iv)

C

P -> (iii), Q -> (iv), R -> (i), S -> (ii)

D

P -> (i), Q -> (iv), R -> (ii), S -> (iii)


(Compiler Design) is the correct answer.

Ques 17 Gate 2016 Set-2


Match the following

(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

A

P ↔ i, Q ↔ ii, R ↔ iv, S ↔ iii

B

P ↔ iii, Q ↔ i, R ↔ ii, S ↔ iv

C

P ↔ ii, Q ↔ iii, R ↔ i, S ↔ iv

D

P ↔ iv, Q ↔ i, R ↔ ii, S ↔ iii


(Phase of Compiler) is the correct answer.

Ques 18 Gate 2016 Set-1


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 ____


(a) is the correct answer.

Ques 19 Gate 2016 Set-1


Consider the following Syntax Directed Translation Scheme (SDTS), with non-terminals {S, A} and terminals {a, b}.

S −→ aA { print 1 }
S −→ a { print 2 }
A −→ Sb { print 3 }


Using the above SDTS, the output printed by a bottom-up parser, for the input aab is:

A

1 3 2

B

2 2 3

C

2 3 1

D

Syntax Error


(SDT) is the correct answer.

Ques 20 Gate 2015 Set-3


Consider the following grammar G.

S → F ⎪ H
F → p ⎪ c
H → d ⎪ c

Where S, F and H are non-terminal symbols, p, d and c are terminal symbols. Which of the following statement(s) is/are correct?

S1: LL(1) can parse all strings that are generated using grammar G.
S2: LR(1) can parse all strings that are generated using grammar G.

A

Only S1

B

Only S2

C

Both S1 and S2

D

Neither S1 and S2


(Parser) is the correct answer.

Ques 21 Gate 2015 Set-3


Among simple LR (SLR), canonical LR, and look-ahead LR (LALR), which of the following pairs identify the method that is very easy to implement and the method that is the most powerful, in that order?

A

SLR, LALR

B

Canonical LR, LALR

C

SLR, canonical LR

D

LALR, canonical LR


(Parser) is the correct answer.

Ques 22 Gate 2015 Set-2


In the context of abstract-syntax-tree (AST) and control-flow-graph (CFG), which one of the following is True?

A

In both AST and CFG, let node N2 be the successor of node N1. In the input program, the code corresponding to N2 is present after the code corresponding to N1.

B

For any input program, neither AST nor CFG will contain a cycle.

C

The maximum number of successors of a node in an AST and a CFG depends on the input program.

D

Each node in AST and CFG corresponds to at most one statement in the input program.


(CFG) is the correct answer.

Ques 23 GATE 2015 SET-2


Match the following:

A

P-2, Q-3, R-1, S-4

B

P-2, Q-1, R-4, S-3

C

P-2, Q-4, R-1, S-3

D

P-2, Q-3, R-4, S-1


(a) is the correct answer.

Unique Visitor Count

Total Unique Visitors

Loading......