MCQ System Software - Compiler

Download as pdf or txt
Download as pdf or txt
You are on page 1of 83

LD

Compiler Design
MULTIPLE CHOICE QUESTIONS
O
IF
July 29, 2021
N
A
M
Compiler Design Manifold Institute of Technical Education

LD
O
IF
N
A
M

www.manifoldkerala.com, Ph: 0487 2382342 ii


Contents

LD
1 Compiler Design 1
1.1 Multiple Choice Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 Solutions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75

O
IF
N
A
M

iii
Compiler Design Manifold Institute of Technical Education

LD
O
IF
N
A
M

www.manifoldkerala.com, Ph: 0487 2382342 iv


1 | Compiler Design

1.1 Multiple Choice Questions

LD
1. [ Parsers | GATE 2019 ] Consider the grammar given below:
S ! Aa
A ! BD
B !b|2
D !d| 2
Let a, b, d and $ be indexed as follows:

O
IF
Compute the FOLLOW set of the non-terminal B and write the index values for
the symbols in the FOLLOW set in the descending order. (For example, if the
FOLLOW set is { a, b, d, $ } , then the answer should be 3210)
(a) 30
N

(b) 31
(c) 10
(d) 21
2. [ Parsers | GATE 2019 ] Which one of the following kinds of derivation is used
A

by LR parsers?
(a) Leftmost in reverse
(b) Rightmost in reverse
M

(c) Leftmost
(d) Rightmost
3. [ Parsers | GATE 2019 ] Consider the augmented grammar given below:
S’ ! S
S ! ( L ) | id
L ! L,S | S

Let I0 = CLOSURE ({ [ S’ ! ·S] } ). The number of items in the set GOTO (I0 ,
( ) is: _____.
(a) 4

1
Compiler Design Manifold Institute of Technical Education

(b) 5
(c) 6
(d) 7
4. [ Synthesized-and-L-Attribute | GATE 2019 ] Consider the following grammar
and the semantic actions to support the inheritance type declaration attributes. Let
X1 , X2 , X3 , X4 , X5 and X6 be the placeholders for the non-terminals D, T, L or L1
in the following table:

LD
Which one of the following are the appropriate choices for X1 , X2 , X3 and X4 ?
(a) X1 = L, X2 = L, X3 = L1 , X4 = T

O
(b) X1 = L, X2 = T, X3 = L1 , X4 = L
(c) X1 = T, X2 = L, X3 = L1 , X4 = T
(d) X1 = T, X2 = L, X3 = T, X4 = L1
IF
5. [ Compilers | GATE 2018 ] Which one of the following statements is FALSE?
(a) Context-free grammar can be used to specify both lexical and syntax rules.
(b) Type checking is done before parsing.
N

(c) High-level language programs can be translated to different Intermediate Rep-


resentations.
(d) Arguments to a function can be passed using the program stack.
6. [ Associativity-and-Precedence | GATE 2018 ] Consider the following parse tree
A

for the expression a# b$ c$ d# e# f, involving two binary operators $ and # .


M

Which one of the following is correct for the given parse tree?
(a) $ has higher precedence and is left associative; # is right associative

www.manifoldkerala.com, Ph: 0487 2382342 2


Compiler Design Manifold Institute of Technical Education

(b) # has higher precedence and is left associative; $ is right associative


(c) $ has higher precedence and is left associative; # is left associative
(d) # has higher precedence and is right associative; $ is left associative
7. [ Compilers | GATE 2018 ] A lexical analyzer uses the following patterns to
recognize three tokens T1 , T2 , and T3 over the alphabet { a,b,c} .
T1 : a?(b| c)*a
T2 : b?(a| c)*b
T3 : c?(b| a)*c
Note that ’x?’ means 0 or 1 occurrence of the symbol x . Note also that the analyzer

LD
outputs the token that matches the longest possible prefix.
If the string bbaacabc is processes by the analyzer, which one of the following is
the sequence of tokens it outputs?
(a) T1 T2 T3
(b) T1 T1 T3
(c) T2 T1 T3
(d) T3 T3

O
8. [ Static-single-assignment | GATE 2017 [ Set-1] ]
mediate program in three address code
p = a − b
Consider the following inter-
IF
q = p * c
p = u * v
q = p + q

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

(a)
M

(b)

www.manifoldkerala.com, Ph: 0487 2382342 3


Compiler Design Manifold Institute of Technical Education

(c)

(d)
9. [ First-and-Follow | GATE 2017 [ Set-1] ] Consider the following grammar:

LD
What is FOLLOW(Q) ?
(a) { R}
(b) { w}
(c) { w, y}
(d) { w, $ }
O
IF
10. [ Parsers | GATE 2017 [ Set-1] ] Consider the following grammar:
stmt ! if expr then expr else expr ; stmt | l
expr ! term relop term | term
term ! id | number
id ! a | b | c
N

number ! [ 0-9 ]

where relop is a relational operator (e.g., < , > , ...), l refers to the empty state-
ment, and if , then , else are terminals.
A

Consider a program P following the above grammar containing ten if terminals.


The number of control flow paths in P is ________. For example, the program
if e 1 then e 2 else e 3

has 2 control flow paths, e1 ! e2 and e1 ! e3 .


M

(a) 1024
(b) 1025
(c) 1026
(d) 1027
11. [ Register-Allocation | GATE 2017 [ Set-1] ] Consider the expression (a-1)*(((b+c)/3)+d)).
Let X be the minimum number of registers required by an optimal code genera-
tion (without any register spill) algorithm for a load/store architecture, in which
(i) only load and store instructions can have memory operands and (ii) arithmetic instructions can have only
The value of X is ___________.

www.manifoldkerala.com, Ph: 0487 2382342 4


Compiler Design Manifold Institute of Technical Education

(a) 2
(b) 3
(c) 4
(d) 5
12. [ Compilers | GATE 2017 [ Set-2] ] Match the following according to input (from
the left column) to the compiler phase (in the right column) that processes it:

LD
(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)
13. [ Parsers | GATE 2017 [ Set-2] ]
is/are CORRECT? O
Which of the following statements about parser

I. Canonical LR is more powerful than SLR.


II. SLR is more powerful than LALR.
IF
III. SLR is more powerful than Canonical LR.
(a) I only
(b) II only
(c) III only
N

(d) II and III only


14. [ Left-Recursive-Grammar | GATE 2017 [ Set-2] ] Consider the following expres-
sion grammar G:
A

E!E-T|T
T!T+F|F
F ! (E) | id
Which of the following grammars is not left recursive, but is equivalent to G?
M

(a)

www.manifoldkerala.com, Ph: 0487 2382342 5


Compiler Design Manifold Institute of Technical Education

(b)

(c)

LD
(d)
15. [ Static-single-assignment | GATE 2016 [ Set-1] ] Consider the following code
segment.
x = u - t;
y = x * v;
x = y + w;
y = t - z;
y = x * y;
O
IF
The minimum number of variables required to convert the above code segment
to static single assignment form is ________.
(a) 10
(b) 11
N

(c) 12
(d) 13
16. [ Syntax-Directed-Translation | GATE 2016 [ Set-1] ] Consider the following Syn-
A

tax Directed Translation Scheme (SDTS), with non-terminals { S, A} and terminals


{ a,b}.
S ! a A { print 1 }
S ! a { print 2 }
M

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
17. [ Compilers | GATE 2016 [ Set-2] ] Match the following:

www.manifoldkerala.com, Ph: 0487 2382342 6


Compiler Design Manifold Institute of Technical Education

(P) Lexical analysis ( i ) Leftmost d e r i v a t i o n


(Q) Top down p a r s i n g ( i i ) Type checking
(R ) Semantic a n a l y s i s ( i i i ) Regular e x p r e s s i o n s
(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
18. [ Left-Recursive-Grammar | GATE 2016 [ Set-2] ] Which one of the following

LD
grammars is free from left recursion?

(a)

O
IF
(b)
N

(c)
A

(d)
19. [ Parsers | GATE 2015 [ Set-1] ] Which one of the following is True at any valid
M

state in shift-reduce parsing?


(a) Viable prefixes appear only at the bottom of the stack and not inside
(b) Viable prefixes appear only at the top of the stack and not inside
(c) The stack contains only a set of viable prefixes
(d) The stack never contains viable prefixes
20. [ Static-single-assignment | GATE 2015 [ Set-1] ] The least number of temporary
variables required to create a three-address code in static single assignment form
for the expression q + r/3 + s - t * 5 + u * v/w is _________.
(a) 8

www.manifoldkerala.com, Ph: 0487 2382342 7


Compiler Design Manifold Institute of Technical Education

(b) 9
(c) 10
(d) 11
21. [ Live-Variable | GATE 2015 [ Set-1] ] Let an represent the number of bit strings
of length n containing two consecutive 1s. What is the recurrence relation for an ?
(a) an + an + 2n 2
2 1

(b) an + 2an + 2n 2
2 1

(c) 2an + an + 2n 2
2 1

LD
(d) 2an + 2an + 2n 2
2 1

22. [ Live-Variable | GATE 2015 [ Set-1] ] A variable x is said to be live at a statement


Si in a program if the following three conditions hold simultaneously:
i. There exists a statement S j that uses x
ii. There is a path from Si to S j in the flow graph corresponding to the program
iii. The path has no intervening assignment to x including at Si and S j

O
IF
N

The variables which are live both at the statement in basic block 2 and at the
statement in basic block 3 of the above control flow graph are
A

(a) p, s, u
(b) r, s, u
(c) r, u
M

(d) q, v
23. [ Syntax-tree-and-context-flow-graph | GATE 2015 [ Set-2] ] In the context of
abstract-syntax-tree (AST) and control-flow-graph (CFG), which one of the follow-
ing 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
in 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

www.manifoldkerala.com, Ph: 0487 2382342 8


Compiler Design Manifold Institute of Technical Education

(d) Each node is AST and CFG corresponds to at most one statement in the input
program
24. [ Compilers | GATE 2015 [ Set-2] ] Match the following:
(P) Lexical analysis (1) Graph c o l o r i n g
(Q) Parsing (2) DFA minimization
(R ) Register allocation (3) Post −order t r a v e r s a l
(S) Expression evaluation (4) Production t r e e

(a) P-2, Q-3, R-1, S-4


(b) P-2, Q-1, R-4, S-3

LD
(c) P-2, Q-4, R-1, S-3
(d) P-2, Q-3, R-4, S-1
25. [ Control-Flow-Graph | GATE 2015 [ Set-2] ] Consider the intermediate code
given below.
1. i = 1
2. j = 1
3. t1 = 5 * i
4. t2 = t1 + j
5. t3 = 4 * t2
6. t4 = t3
7. a[ t4] = -1
8. j = j + 1
O
IF
9. if j < = 5 goto(3)
10. i = i + 1
11. if i < 5 goto(2) The number of nodes and edges in the control-flow-graph
constructed for the above code, respectively, are
(a) 5 and 7
N

(b) 6 and 7
(c) 5 and 5
(d) 7 and 8
A

26. [ Parsers | 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
M

(b) Canonical LR, LALR


(c) SLR, canonical LR
(d) LALR, canonical LR
27. [ Parsers | 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?

www.manifoldkerala.com, Ph: 0487 2382342 9


Compiler Design Manifold Institute of Technical Education

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
(a) Only S1
(b) Only S2
(c) Both S1 and S2
(d) Neither S1 nor S2
28. [ Code-Optimization | GATE 2014 [ Set-1] ] Which one of the following is
FALSE?
(a) A basic block is a sequence of instructions where control enters the sequence

LD
at the beginning and exits at the end.
(b) Available expression analysis can be used for common subexpression elimina-
tion.
(c) Live variable analysis can be used for dead code elimination.
(d) x=4*5 ) x=20 is an example of common subexpression elimination.
29. [ Parsers | GATE 2014 [ Set-1] ] A canonical set of items is given below
S −−> L . > R
Q −−> R .

On input symbol < the set has


O
IF
(a) a shift-reduce conflict and a reduce-reduce conflict.
(b) a shift-reduce conflict but not a reduce-reduce conflict.
(c) a reduce-reduce conflict but not a shift-reduce conflict.
(d) neither a shift-reduce nor a reduce-reduce conflict.
N

30. [ Closure-Property | GATE 2014 [ Set-1] ] Let L be a language and L’ be its


complement. Which one of the following is NOT a viable possibility?
(a) Neither L nor
A

is recursively enumerable (r.e.).


(b) One of L and
M

is r.e. but not recursive; the other is not r.e.


(c) Both L and

are r.e. but not recursive.

www.manifoldkerala.com, Ph: 0487 2382342 10


Compiler Design Manifold Institute of Technical Education

(d) Both L and

are recursive.
31. [ Regular-Expressions | GATE 2014 [ Set-1] ] Which of the regular expressions
given below represent the following DFA?

LD
I) 0*1(1+00*1)*
II) 0*1*1+11*0*1
III) (0+1)*1
(a) I and II only
(b) I and III only
O
IF
(c) II and III only
(d) I, II, and III
32. [ Associativity-and-Precedence | GATE 2014 [ Set-2] ] Consider the grammar
defined by the following production rules, with two operators * and +
N

S −−> T * P
T −−> U | T * U
P −−> Q + P | Q
Q −−> Id
U −−> Id
A

Which one of the following is TRUE?


(a) + is left associative, while * is right associative
(b) + is right associative, while * is left associative
M

(c) Both + and * are right associative


(d) Both + and * are left associative
33. [ Run-Time-Environments | GATE 2014 [ Set-2] ] Which one of the following is
NOT performed during compilation?
(a) Dynamic memory allocation
(b) Type checking
(c) Symbol table management
(d) Inline expansion

www.manifoldkerala.com, Ph: 0487 2382342 11


Compiler Design Manifold Institute of Technical Education

34. [ Intermediate-Code | GATE 2014 [ Set-2] ] For a C program accessing X[ i] [ j] [


k] , the following intermediate code is generated by a compiler. Assume that the
size of an integer is 32 bits and the size of a character is 8 bits.
t0 = i * 1024
t1 = j * 32
t2 = k * 4
t3 = t1 + t0
t4 = t3 + t2
t5 = X[ t 4 ]

Which one of the following statements about the source code for the C program is

LD
CORRECT?
(a) X is declared as "int X[ 32] [ 32] [ 8] ".
(b) X is declared as "int X[ 4] [ 1024] [ 32] ".
(c) X is declared as "char X[ 4] [ 32] [ 8] ".
(d) X is declared as "char X[ 32] [ 16] [ 2] ".
35. [ General | GATE 2014 [ Set-2] ] Consider the expression tree shown. Each

O
leaf represents a numerical value, which can either be 0 or 1. Over all possible
choices of the values at the leaves, the maximum possible value of the expression
represented by the tree is _______.
IF
N

(a) 6
(b) 7
A

(c) 8
(d) 9
36. [ Code-Generation-and-Code-Optimization | GATE 2014 [ Set-3] ] One of the
purposes of using intermediate code in compilers is to
M

(a) make parsing and semantic analysis simpler.


(b) improve error recovery and error reporting.
(c) increase the chances of reusing the machine-independent code optimizer in
other compilers.
(d) improve the register allocation.
37. [ General | GATE 2014 [ Set-3] ] Which of the following statements are COR-
RECT?
1) Static allocation of all data areas by a compiler makes it impossible to implement
recursion.

www.manifoldkerala.com, Ph: 0487 2382342 12


Compiler Design Manifold Institute of Technical Education

2) Automatic garbage collection is essential to implement recursion.


3) Dynamic allocation of activation records is essential to implement recursion.
4) Both heap and stack are essential to implement recursion.

(a) 1 and 2 only

(b) 2 and 3 only

(c) 3 and 4 only

(d) 1 and 3 only

38. [ Page-Replacement-Algorithm | GATE 2014 [ Set-3] ] A system uses 3 page


frames for storing process pages in main memory. It uses the Least Recently Used

LD
( LRU ) page replacement policy. Assume that all the page frames are initially
empty. What is the total number of page faults that will occur while processing
the page reference string given below?
4, 7, 6, 1, 7, 6, 1, 2, 7, 2

(a) 6

(b) 7

(c) 8

(d) 9
O
IF
39. [ Run-Time-Environments | GATE 2012 ] Consider the program given below,
in a block-structured pseudo-language with lexical scoping and nesting of proce-
dures permitted.
Program main ;
Var . . .
N

Procedure A1 ;
Var . . .
C a l l A2 ;
End A1
A

Procedure A2 ;
Var . . .

Procedure A21 ;
M

Var . . .
C a l l A1 ;
End A21

C a l l A21 ;
End A21

C a l l A1 ;
End main .

Consider the calling chain : Main-> A1-> A2-> A21-> A1 The correct set of
activation records along with their access links is given by:

www.manifoldkerala.com, Ph: 0487 2382342 13


Compiler Design Manifold Institute of Technical Education

(a)

LD
(b) O
IF
N

(c)
A
M

(d)
40. [ Parsers | GATE 2012 ] For the grammar below, a partial LL(1) parsing table is
also presented along with the grammar. Entries that need to be filled are indicated
as E1, E2, and E3. 2 is the empty string, $ indicates end of input, and, | separates
alternate right hand sides of productions.
S ! aAbB | bAaB | 2
A ! S
B ! S

www.manifoldkerala.com, Ph: 0487 2382342 14


Compiler Design Manifold Institute of Technical Education

The FIRST and FOLLOW sets for the non-terminals A and B are
(a) FIRST(A) = { a,b,2 } = FIRST(B)
FOLLOW(A) = { a,b}
FOLLOW(B) = { a,b,$ }
(b) FIRST(A) = { a,b,$ }
FIRST(B) = { a,b,2 }

LD
FOLLOW(A) = { a,b}
FOLLOW(B) = { $ }
(c) FIRST(A) = { a,b,2 } = FIRST(B)
FOLLOW(A) = { a,b}
FOLLOW(B) = f
(d) FIRST(A) = { a,b} = FIRST(B)
FOLLOW(A) = { a,b}
FOLLOW(B) = { a,b}

O
41. [ Parsers | GATE 2012 ] For the grammar below, a partial LL(1) parsing table is
also presented along with the grammar. Entries that need to be filled are indicated
as E1, E2, and E3. 2 is the empty string, $ indicates end of input, and, | separates
alternate right hand sides of productions.
IF
S ! aAbB | bAaB | 2
A ! S
B ! S
N

The appropriate entries for E1, E2, and E3 are


A

(a) E1: S ! aAbB,A ! S


E2: S ! bAaB,B! S
E3: B ! S
(b) E1: S ! aAbB,S! 2
E2: S ! bAaB,S ! 2
M

E3: S ! 2
(c) E1: S ! aAbB,S ! 2
E2: S ! bAaB,S! 2
E3: B ! S
(d) E1: A ! S,S ! 2
E2: B ! S,S ! 2
E3: B ! S
42. [ Compilers | GATE 2011 ] The lexical analysis for a modern computer language
such as Java needs the power of which one of the following machine models in a
necessary and sufficient sense?

www.manifoldkerala.com, Ph: 0487 2382342 15


Compiler Design Manifold Institute of Technical Education

(a) Finite state automata

(b) Deterministic pushdown automata

(c) Non-Deterministic pushdown automata

(d) Turing machine

43. [ Compilers | GATE 2011 ] In a compiler, keywords of a language are recognized


during

LD
(a) parsing of the program

(b) the code generation

(c) the lexical analysis of the program

(d) dataflow analysis

O
44. [ Parsers | GATE 2011 ] Consider two binary operators ’↑’ and ’↓’ with the
precedence of operator ↓ being lower than that of the operator ↑. Operator ↑ is
right associative while operator ↓, is left associative. Which one of the following
represents the parse tree for expression (7↓3↑4↑3↓2)?
IF
N
A

(a)
M

(b)

www.manifoldkerala.com, Ph: 0487 2382342 16


Compiler Design Manifold Institute of Technical Education

(c)

LD
(d)
O
IF
45. [ Register-Allocation | GATE 2011 ] Consider evaluating the following expres-
sion tree on a machine with load-store architecture in which memory can be ac-
cessed only through load and store instructions. The variables a, b, c, d and e
initially stored in memory. The binary operators used in this expression tree can
be evaluate by the machine only when the operands are in registers. The instruc-
N

tions produce results only in a register. If no intermediate results can be stored


in memory, what is the minimum number of registers needed to evaluate this
expression?
A
M

(a) 2

www.manifoldkerala.com, Ph: 0487 2382342 17


Compiler Design Manifold Institute of Technical Education

(b) 9
(c) 5
(d) 3
46. [ Compilers | GATE 2010 ] Which data structure in a compiler is used for man-
aging information about variables and their attributes?
(a) Abstract syntax tree
(b) Symbol table
(c) Semantic stack

LD
(d) Parse Table
47. [ Run-Time-Environments | GATE 2010 ] Which languages necessarily need
heap allocation in the runtime environment?
(a) Those that support recursion
(b) Those that use dynamic scoping
(c) Those that allow dynamic data structures
(d) Those that use global variables
O
48. [ Register-Allocation | GATE 2010 ]
variables a, b, c, d, e, f.
The program below uses six temporary
IF
a = 1
b = 10
c = 20
d = a+b
e = c+d
N

f = c+e
b = c+e
e = b+ f
d = 5+e
r e t u r n d+ f
A

Assuming that all operations take their operands from registers, what is the mini-
mum number of registers needed to execute this program without spilling?
(a) 2
M

(b) 3
(c) 4
(d) 6
49. [ Parsers | GATE 2010 ] The grammar S ! aSa| bS| c is
(a) LL(1) but not LR(1)
(b) LR(1) but not LR(1)
(c) Both LL(1) and LR(1)
(d) Neither LL(1) nor LR(1)

www.manifoldkerala.com, Ph: 0487 2382342 18


Compiler Design Manifold Institute of Technical Education

50. [ Compilers | GATE 2009 ] Match all items in Group 1 with correct options from
those given in Group 2
Group 1 Group 2
P. Regular e x p r e s s i o n 1. Syntax a n a l y s i s
Q. Pushdown automata 2. Code g e n e r a t i o n
R. Dataflow a n a l y s i s 3. Lexical analysis
S. Register allocation 4. Code o p t i m i z a t i o n

(a) P-4, Q-1, R-2, S-3


(b) P-3, Q-1, R-4, S-2
(c) P-3, Q-4, R-1, S-2

LD
(d) P-2, Q-1, R-4, S-3
51. [ Parsers | GATE 2009 ] Which of the following statements are TRUE?
I.There exist parsing algorithms for some programming languages whose com-
plexities are less than (n3 ).
II.A programming language which allows recursion can be implemented with
static storage.
III.No L-attributed definition can be evaluated in the framework of bottom-up
parsing.
O
IV.Code improving transformations can be performed at both source language and
intermediate code level.
(a) I and II
IF
(b) I and IV
(c) III and IV
(d) I, III and IV
52. [ Parsers | GATE 2008 ] Which of the following describes a handle (as applicable
N

to LR-parsing) appropriately?
(a) It is the position in a sentential form where the next shift or reduce operation
will occur.
(b) It is non-terminal whose production will be used for reduction in the next step.
A

(c) It is a production that may be used for reduction in a future step along with
a position in the sentential form where the next shift or reduce operation will
occur.
(d) It is the production p that will be used for reduction in the next step along with
M

a position in the sentential form where the right hand side of the production
may be found.
53. [ Compilers | GATE 2008 ] Some code optimizations are carried out on the
intermediate code because
(a) They enhance the portability of the compiler to other target processors
(b) Program analysis is more accurate on intermediate code than on machine code
(c) The information from dataflow analysis cannot otherwise be used for opti-
mization
(d) The information from the front end cannot otherwise be used for optimization

www.manifoldkerala.com, Ph: 0487 2382342 19


Compiler Design Manifold Institute of Technical Education

54. [ Run-Time-Environments | GATE 2008 ] Which of the following are true?


I. A programming language which does not permit global variables of any kind
and has no nesting of procedures/functions, but permits recursion can be imple-
mented with static storage allocation
II. Multi-level access link (or display) arrangement is needed to arrange activation
records only if the programming language being implemented has nesting of pro-
cedures/functions
III. Recursion in programming languages cannot be implemented with dynamic
storage allocation
IV. Nesting procedures/functions and recursion require a dynamic heap allocation
scheme and cannot be implemented with a stack-based allocation scheme for acti-

LD
vation records
V.Programming languages which permit a function to return a function as its result
cannot be implemented with a stack-based storage allocation scheme for activation
records
(a) II and V only
(b) I, III and IV only
(c) I, II and V only
(d) II, III and V only
O
55. [ Parsres | GATE 2008 ] An LALR(1) parser for a grammar G can have shift-
reduce (S-R) conflicts if and only if
(a) the SLR(1) parser for G has S-R conflicts
IF
(b) the LR(1) parser for G has S-R conflicts
(c) the LR(0) parser for G has S-R conflicts
(d) the LALR(1) parser for G has reduce-reduce conflicts
N

56. [ Parsers | GATE 2007 ] Which one of the following is a top-down parser?
(a) Recursive descent parser.
(b) Operator precedence parser.
(c) An LR(k) parser.
A

(d) An LALR(k) parser.


57. [ Parsers | GATE 2007 ] Consider the grammar with non-terminals N = { S,C,S1
} ,terminals T = { a,b,i,t,e} , with S as the start symbol, and the following set of
rules:
M

S −−> i C t S S 1 | a
S 1 −−> eS | 2
C −−> b

The grammar is NOT LL(1) because:


(a) it is left recursive
(b) it is right recursive
(c) it is ambiguous
(d) it is not context-free

www.manifoldkerala.com, Ph: 0487 2382342 20


Compiler Design Manifold Institute of Technical Education

58. [ Parsers | GATE 2007 ] Consider the following two statements:


P : Every r e g u l a r grammar i s LL ( 1 )
Q: Every r e g u l a r s e t has a LR ( 1 ) grammar

Which of the following is TRUE?


(a) Both P and Q are true
(b) P is true and Q is false
(c) P is false and Q is true
(d) Both P and Q are false

LD
59. [ Grammar | GATE 2007 ] Consider the CFG with { S,A,B} as the non-terminal
alphabet, { a,b} as the terminal alphabet, S as the start symbol and the following
set of production rules:
S ! aB S ! bA
B ! b A ! a
B ! bS A ! aS
B ! aBB A ! bAA

(a) aaaabb
(b) aabbbb
O
Which of the following strings is generated by the grammar?
IF
(c) aabbab
(d) abbbba
60. [ Grammar | GATE 2007 ] Consider the CFG with { S,A,B} as the non-terminal
alphabet, { a,b} as the terminal alphabet, S as the start symbol and the following
set of production rules:
N

S ! aB S ! bA
B ! b A ! a
B ! bS A ! aS
B ! aBB A ! bAA
A

For the correct answer strings to Q.78, how many derivation trees are there?
(a) 1
(b) 2
M

(c) 3
(d) 4
61. [ Parsers | GATE 2006 ] Consider the following grammar.
S ! S * E
S ! E
E ! F + E
E ! F
F ! id

Consider the following LR(0) items corresponding to the grammar above.

www.manifoldkerala.com, Ph: 0487 2382342 21


Compiler Design Manifold Institute of Technical Education

( i ) S ! S * .E
( ii ) E ! F. + E
( i i i ) E ! F + .E

Given the items above, which two of them will appear in the same set in the
canonical sets-of-items for the grammar?

(a) (i) and (ii)

(b) (ii) and (iii)

(c) (i) and (iii)

LD
(d) None of the above

62. [ Code-Optimization | GATE 2006 ] Consider these two functions and two state-
ments S1 and S2 about them
i n t work1 ( i n t * a , i n t i , i n t j ) i n t work2 ( i n t * a , i n t i , i n t j )
{ {
i n t x = a [ i +2 ] ; i n t t1 = i +2;
a[ j ] = x + 1 ; i n t t 2 = a[ t 1 ] ;
r e t u r n a [ i +2 ] − 3 ; a[ j ] = t 2 + 1 ;
}
O }
return t2 − 3;

S1: The transformation form work1 to work2 is valid, i.e., for any program state
IF
and input arguments, work2 will compute the same output and have the same
effect on program state as work1
S2: All the transformations applied to work1 to get work2 will always improve the
performance (i.e reduce CPU time) of work2 compared to work1

(a) S1 is false and S2 is false


N

(b) S1 is false and S2 is true

(c) S1 is true and S2 is false

(d) S1 is true and S2 is true


A

63. [ Parsers | GATE 2006 ] Consider the following grammar:


S ! FR
R ! S | 2
F ! id
M

In the predictive parser table, M, of the grammar the entries M[ S,id] and M[ R,$ ]
respectively.

(a) { S ! FR} and { R ! 2 }

(b) { S ! FR} and { }

(c) { S ! FR} and { R ! *S}

(d) { F ! id} and { R ! 2 }

64. [ Syntax-Directed-Translation | GATE 2006 ] Consider the following translation


scheme.

www.manifoldkerala.com, Ph: 0487 2382342 22


Compiler Design Manifold Institute of Technical Education

S ! ER
R ! * E{ p r i n t ( " * " ) ; } R| 2
E ! F + E { print ( " + " ) ; } | F
F ! ( S ) | id { p r i n t ( id . value ) ; }

Here id is a token that represents an integer and id.value represents the corre-
sponding integer value. For an input ’2 * 3 + 4’, this translation scheme prints
(a) 2 * 3 + 4
(b) 2 * +3 4
(c) 2 3 * 4 +

LD
(d) 2 3 4+*
65. [ Code-Optimization | GATE 2006 ] Consider the following C code segment.
f o r ( i = 0 , i < n ; i ++)
{
f o r ( j = 0 ; j < n ; j ++)
{
i f ( i% 2)

}
{

}
O
x += ( 4 * j + 5 * i ) ;
y += ( 7 + 4 * j ) ;
IF
}

Which one of the following is false?


(a) The code contains loop invariant computation
(b) There is scope of common sub-expression elimination in this code
N

(c) There is scope of strength reduction in this code


(d) There is scope of dead code elimination in this code
66. [ Parsers | GATE 2005 ] The grammar A ! AA | (A) | 2 is not suitable for
predictive-parsing because the grammar is:
A

(a) ambiguous
(b) left-recursive
(c) right-recursive
M

(d) an operator-grammar
67. [ Grammar | GATE 2005 ] Consider the grammar:
E ! E + n | E * n | n

For a sentence n + n * n, the handles in the right-sentential form of the reduction


are:
(a) n, E + n and E + n * n
(b) n, E + n and E + E * n
(c) n, n + n and n + n * n

www.manifoldkerala.com, Ph: 0487 2382342 23


Compiler Design Manifold Institute of Technical Education

(d) n, E + n and E * n
68. [ Parsers | GATE 2005 ] Consider the grammar:
S ! (S) | a

Let the number of states in SLR(1), LR(1) and LALR(1) parsers for the grammar be
n1 , n2 and n3 respectively. The following relationship holds good:
(a) n1 < n2 < n3
(b) n1 = n3 < n2
(c) n1 = n2 = n3

LD
(d) n1 n3 n2
69. [ Compilers | GATE 2005 ] Consider line number 3 of the following C-program.
i n t main ( ) { / * Line 1 * /
i n t I , N; / * Line 2 * /
f r o ( I = 0 , I < N, I + + ) ; / * Line 3 * /
}

(a) No compilation error


(b) Only a lexical error
O
Identify the compiler’s response about this line while creating the object-module:
IF
(c) Only syntactic errors
(d) Both lexical and syntactic errors
70. [ Parsres | GATE 2005 ] Consider the following expression grammar. The seman-
tic rules for expression calculation are stated next to each grammar production.
N

E ! number E . v a l = number . v a l
| E ’+ ’ E E(1) . v a l = E(2) . v a l + E> sup > ( 3 ) . v a l
| E ’* ’ E E( 1 ) . v a l = E( 2 ) . v a l * E( 3 ) . v a l

The above grammar and the semantic rules are fed to a yacc tool (which is an
A

LALR(1) parser generator) for parsing and evaluating arithmetic expressions. Which
one of the following is true about the action of yacc for the given grammar?
(a) It detects recursion and eliminates recursion
(b) It detects reduce-reduce conflict, and resolves
M

(c) It detects shift-reduce conflict, and resolves the conflict in favor of a shift over
a reduce action
(d) It detects shift-reduce conflict, and resolves the conflict in favor of a reduce
over a shift action
71. [ Parsers | GATE 2005 ] Consider the following expression grammar. The seman-
tic rules for expression calculation are stated next to each grammar production.
E ! number E . v a l = number . v a l
| E ’+ ’ E E(1) . v a l = E(2) . v a l + E> sup > ( 3 ) . v a l
| E ’* ’ E E( 1 ) . v a l = E( 2 ) . v a l * E( 3 ) . v a l

www.manifoldkerala.com, Ph: 0487 2382342 24


Compiler Design Manifold Institute of Technical Education

Assume the conflicts in Part (a) of this question are resolved and an LALR(1)
parser is generated for parsing arithmetic expressions as per the given grammar.
Consider an expression 3 * 2 + 1. What precedence and associativity properties
does the generated parser realize?
(a) Equal precedence and left associativity; expression is evaluated to 7
(b) Equal precedence and right associativity; expression is evaluated to 9
(c) Precedence of ’*’ is higher than that of ’+’, and both operators are left associa-
tive; expression is evaluated to 7
(d) Precedence of ’+’ is higher than that of ’*’, and both operators are left associa-
tive; expression is evaluated to 9

LD
72. [ Parsers | GATE 2004 ] Which of the following grammar rules violate the re-
quirements of an operator grammar? P,Q,R are nonterminals, and r,s,t are termi-
nals.
(i) P ! Q R
(ii) P ! Q s R
(iii) P ! 2
(iv) P ! Q t R r
(a) (i) only
(b) (i) and (iii) only
(c) (ii) and (iii) only
O
IF
(d) (iii) and (iv) only
73. [ Compilers | GATE 2004 ] Consider a program P that consists of two source
modules M1 and M2 contained in two different files. If M1 contains a reference to
a function defined in M2 , the reference will be resolved at
N

(a) Edit time


(b) Compile time
(c) Link time
(d) Load time
A

74. [ Target-Code-Generation | GATE 2004 ] Consider the grammar rule E ! E1 -


E2 for arithmetic expressions. The code generated is targeted to a CPU having a
single user register. The subtraction operation requires the first operand to be in
the register. If E1 and E2 do not have any common sub expression, in order to get
M

the shortest possible code


(a) E1 should be evaluated first
(b) E2 should be evaluated first
(c) Evaluation of E1 and E2 should necessarily be interleaved
(d) Order to evaluation of E1 and E2 is of no consequence
75. [ Grammar | GATE 2004 ] Consider the grammar with the following translation
rules and E as the start symbol.
E ! E1 # T { E . value = E1 . value * T . value }
| T { E . value = T . value }

www.manifoldkerala.com, Ph: 0487 2382342 25


Compiler Design Manifold Institute of Technical Education

T ! T1 & F { T . value = T1 . value + F . value }


| F { T . value = F . value }
F ! num { F . value = num . value }

Compute E.value for the root of the parse tree for the expression: 2 # 3 & 5 # 6 &
4.
(a) 200
(b) 180
(c) 160
(d) 40

LD
76. [ Grammar | GATE 2004 ] Consider the following grammar G:
S ! bS | aA| b
A ! bA| aB
B ! bB| aS | a

Let Na (w) and Nb (w) denote the number of a’s and b’s in a string w respectively.
The language L(G) ✓ { a, b} + generated by G is
(a) { w| Na (w) > 3Nb (w)}
(b) { w| Nb (w) > 3Na (w)} O
(c) { w| Na (w) = 3k, k 2 { 0, 1, 2, ...} }
IF
(d) { w| Nb (w) = 3k, k 2 { 0, 1, 2, ...} }
77. [ Grammar | GATE 2003 ] Which of the following suffices to convert an arbitrary
CFG to an LL(1) grammar?
(a) Removing left recursion alone
N

(b) Factoring the grammar alone


(c) Removing left recursion and factoring the grammar
(d) None of the above
78. [ Parsers | GATE 2003 ] Assume that the SLR parser for a grammar G has n1
A

states and the LALR parser for G has n2 states. The relationship between n1 and
n2 is:
(a) n1 is necessarily less than n2
(b) n1 is necessarily equal to n2
M

(c) n1 is necessarily greater than n2


(d) None of the above
79. [ Syntax-Directed-Translation | GATE 2003 ] In a bottom-up evaluation of a
syntax directed definition, inherited attributes can
(a) always be evaluated
(b) be evaluated only if the definition is L-attributed
(c) be evaluated only if the definition has synthesized attributes
(d) never be evaluated

www.manifoldkerala.com, Ph: 0487 2382342 26


Compiler Design Manifold Institute of Technical Education

80. [ Run-Time-Environments | GATE 2003 ] Which of the following statements is


FALSE?
(a) In statically typed languages, each variable in a program has a fixed type
(b) In un-typed languages, values do not have any types
(c) In dynamically typed languages, variables have no types
(d) In all statically typed languages, each variable in a program is associated with
values of only a single type during the execution of the program
81. [ Parsers | GATE 2003 ] Consider the grammar shown below
S ! i E t S S’ | a

LD
S’ ! e S | 2
E ! b

In the predictive parse table. M, of this grammar, the entries M[ S’, e] and M[ S’, $
] respectively are
(a) { S’! e S} and { S’! 2 }
(b) { S’! e S} and { }
(c) { S’! 2 } and { S’! 2 }

82. [ Parsers | GATE 2003 ]


S ! C C
O
(d) { S’! e S, S’! 2 } and { S’! 2 }
Consider the grammar shown below.
IF
C ! c C | d

The grammar is
(a) LL(1)
N

(b) SLR(1) but not LL(1)


(c) LALR(1) but not SLR(1)
(d) LR(1) but not LALR(1)
83. [ Syntax-Directed-Translation | GATE 2003 ] Consider the translation scheme
A

shown below.
S ! T R
R ! + T { p r i n t ( ’ + ’ ) ; } R| 2
T ! num { p r i n t ( num . v a l ) ; }
M

Here num is a token that represents an integer and num .val represents the corre-
sponding integer value. For an input string ’9 + 5 + 2’, this translation scheme will
print
(a) 9 + 5 + 2
(b) 9 5 + 2 +
(c) 9 5 2 + +
(d) + + 9 5 2
84. [ Syntax-Directed-Translation | GATE 2003 ] Consider the syntax directed defi-
nition shown below.

www.manifoldkerala.com, Ph: 0487 2382342 27


Compiler Design Manifold Institute of Technical Education

S ! id : = E { gen ( id . p l a c e = E . p l a c e ; ) ; }
E ! E1 + E2 { t = newtemp ( ) ;
gen ( t = E1 . p l a c e + E2 . p l a c e ; ) ;
E . place = t }
E ! id { E . p l a c e = id . p l a c e ; }

Here, gen is a function that generates the output code, and newtemp is a function
that returns the name of a new temporary variable on every call. Assume that ti’s
are the temporary variable names generated by newtemp. For the statement ’X: =
Y + Z’, the 3-address code sequence generated by this definition is
(a) X = Y + Z

LD
(b) t1 = Y + Z; X = t1
(c) t1 = Y; t2 = t1 + Z; X = t2
(d) t1 = Y; t2 = Z; t3 = t1 + t2 ; X = t3
85. [ Run-Time-Environments | GATE 2003 ] Which of the following is NOT an
advantage of using shared, dynamically linked libraries as opposed to using stati-
cally linked libraries?

O
(a) Smaller sizes of executable files
(b) Lesser overall page fault rate in the system
(c) Faster program startup
IF
(d) Existing programs need not be re-linked to take advantage of newer versions
of libraries
86. [ Descriptive | GATE 2002 ] (a) Construct all the parse trees corresponding to i
+ j * k for the grammar
E ! E+E
N

E ! E*E
E ! id

(b) In this grammar, what is the precedence of the two operators * and +?
(c) If only one parse tree is desired for any string in the same language, what
A

changes are to be made so that the resulting LALR(1) grammar is non-ambiguous?


(a) Theory Explanation is given below.
87. [ Run-Time-Environments | GATE 2001 ] The process of assigning load ad-
dresses to the various parts of the program and adjusting the code and date in the
M

program to reflect the assigned addresses is called


(a) Assembly
(b) Parsing
(c) Relocation
(d) Symbol resolution
88. [ Parsers | GATE 2001 ] Which of the following statements is false?
(a) An unambiguous grammar has same leftmost and rightmost derivation
(b) An LL(1) parser is a top-down parser

www.manifoldkerala.com, Ph: 0487 2382342 28


Compiler Design Manifold Institute of Technical Education

(c) LALR is more powerful than SLR


(d) An ambiguous grammar can never be LR(k) for any k
89. [ Parsers | GATE 2001 ] Consider the following grammar with terminal alphabet
S { a,(,),+,*} and start symbol E. The production rules of the grammar are:
E ! aA
E ! (E)
A ! +E
A ! *E
A ! 2

LD
(a) Compute the FIRST and FOLLOW sets for E and A.
(b) Complete the LL(1) parse table for the grammar.
(a) Theory Explanation is given below.
90. [ Syntax-Directed-Translation | GATE 2001 ] The syntax of the repeat-until state-
ment is given by the gollowing grammar
S ! r e p e a t S1 u n t i l E

O
Where E stands for expressions, S and S1 stand for statement. The non-terminals
S and S1 have an attribute code that represents generated code. The nonterminal
E has two attributes. The attribute code represents generated code to evaluate
the expression and store its truth value in a distinct variable, and the attribute
varName contains the name of the variable in which the truth value is stored? The
IF
truth-value stored in the variable is 1 if E is true, 0 if E is false.
Give a syntax-directed definition to generate three-address code for the repeatuntil
statement. Assume that you can call a function newlabel( ) that returns a distinct
label for a statement. Use the operator ’
’ to concatenate two strings and the function gen(s) to generate a line containing
N

the string s.
(a) Theory Explanation is given below.
91. [ Grammar | GATE 2001 ] (a) Remove left-recursion from the following grammar:
S ! Sa | Sb | a | b
A

(b) Consider the following grammar:


S ! aSbS | bSaS | 2
M

Construct all possible parse trees for the string abab. Is the grammar ambiguous?
(a) Theory Explanation is given below.
92. [ Compilers | GATE 2000 ] The number of tokens in the following C statement.
printf (" i = % d, &i = % x" , i , &i ) ;

is
(a) 3
(b) 26
(c) 10

www.manifoldkerala.com, Ph: 0487 2382342 29


Compiler Design Manifold Institute of Technical Education

(d) 21
93. [ Parsers | GATE 2000 ] Which of the following derivations does a top-down
parser use while parsing an input string? The input is assumed to be scanned in
left to right order.
(a) Leftmost derivation
(b) Leftmost derivation traced out in reverse
(c) Rightmost derivation
(d) Rightmost derivation traced out in reverse
94. [ Grammar | GATE 2000 ] Given the following expression grammar:

LD
E ! E * F | F + E | F
F ! F − F | id

which of the following is true?


(a) * has higher precedence than +
(b) - has higher precedence than *
(c) + and - have same precedence
(d) + has higher precedence than * O
95. [ Descriptive | GATE 2000 ] Consider the syntax directed translation scheme
(SDTS) given in the following.
IF
Assume attribute evaluation with bottom-up parsing, i.e., attributes are evaluated
immediately after a reduction.
E ! E1 * T { E . v a l = E1 . v a l * T . v a l }
E ! T { E . val = T . val}
T ! F − T1 { T . v a l = F . v a l − T1 . v a l }
N

T ! F { T . val = F . val}
F ! 2 { F . v a l = 2}
F ! 4 { F . v a l = 4}

(a) Using this SDTS, construct a parse tree for the expression
A

4-2-4*2
and also compute its E.val.
(b) It is required to compute the total number of reductions performed to parse a
given input. Using synthesized attributes only, modify the SDTS given, without
M

changing the grammar, to find E.red, the number of reductions performed while
reducing an input to E.
(a) Theory Explanation is given below.
96. [ Parsers | GATE 1999 ] Which of the following is the most powerful parsing
method?
(a) LL (1)
(b) Canonical LR
(c) SLR
(d) LALR

www.manifoldkerala.com, Ph: 0487 2382342 30


Compiler Design Manifold Institute of Technical Education

97. [ Compile | GATE 1999 ] The number of tokens in the Fortran statement DO 10
I = 1.25 is
(a) 3
(b) 4
(c) 5
(d) None of the above
98. [ Run-Time-Environments | GATE 1998 ] In a resident - OS computer, which of
the following systems must reside in the main memory under all situations?
(a) Assembler

LD
(b) Linker
(c) Loader
(d) Compiler
99. [ Parsers | GATE 1998 ] Which of the following statements is true?
(a) SLR parser is more powerful than LALR

O
(b) LALR parser is more powerful than Canonical LR parser
(c) Canonical LR parser is more powerful than LALR parser
(d) The parsers SLR, Canonical CR, and LALR have the same power
100. [ Compilers | GATE 1998 ] Type checking is normally done during
IF
(a) lexical analysis
(b) syntax analysis
(c) syntax directed translation
N

(d) code optimization


101. [ Grammar | GATE 1997 ] In the following grammar
X ::= X Y/Y
Y : : = Z * Y/Z
A

Z : : = id

Which of the following is true?


(a) ’ ’ is left associative while ’*’ is right associative
M

(b) Both ’ ’ and ’*’ is left associative


(c) ’ ’ is right associative while ’*’ is left associative
(d) None of the above
102. [ Run-Time-Environments | GATE 1997 ] A language L allows declaration of
arrays whose sizes are not known during compilation. It is required to make
efficient use of memory. Which of the following is true?
(a) A compiler using static memory allocation can be written for L
(b) A compiler cannot be written for L; an interpreter must be used
(c) A compiler using dynamic memory allocation can be written for L

www.manifoldkerala.com, Ph: 0487 2382342 31


Compiler Design Manifold Institute of Technical Education

(d) None of the above


103. [ Macros | GATE 1997 ] The conditional expansion facility of macro processor is
provided to
(a) test a condition during the execution of the expanded program
(b) to expand certain model statements depending upon the value of a condition
during the execution of the expanded program
(c) to implement recursion
(d) to expand certain model statements depending upon the value of a condition
during the process of macro expansion

LD
104. [ Run-Time-Environments | GATE 1997 ] Heap allocation is required for lan-
guages
(a) that support recursion
(b) that support dynamic data structures
(c) that use dynamic scope rules
(d) None of the above
105. [ Assembler | GATE 1996 ]
1. Object code generation
2. Literals added to literal table
3. Listing printed
O
The pass number for each of the following activities
IF
4. Address resolution of local symbols That occur in a two pass assembler respec-
tively are
(a) 1, 2, 1, 2
(b) 2, 1, 2, 1
N

(c) 2, 1, 1, 2
(d) 1, 2, 2, 2
106. [ Macros | GATE 1996 ] Which of the following macros can put a micro assembler
into an infinite loop?
A

(i) .MACRO M1 X
. I F EQ, X ; i f X=0 then
M1 X + 1
.ENDC
. I F NE X ; I F X 6= 0 then
M

.WORD X ; address ( X ) i s s t o r e d here


.ENDC
.ENDM
( i i ) .MACRO M2 X
. I F EQ X
M2 X
.ENDC
. I F NE, X
.WORD X+1
.ENDC
.ENDM

www.manifoldkerala.com, Ph: 0487 2382342 32


Compiler Design Manifold Institute of Technical Education

(a) (ii) only


(b) (i) only
(c) both (i) and (ii)
(d) None of the above
107. [ Run-Time-Environments | GATE 1995 ] A linker is given object modules for
a set of programs that were compiled separately. What information need to be
included in an object module?
(a) Object code
(b) Relocation bits

LD
(c) Names and locations of all external symbols defined in the object module
(d) Absolute addresses of internal symbols
108. [ Parsers | GATE 1995 ] A shift reduce parser carries out the actions specified
within braces immediately after reducing with the corresponding rule of grammar
S ! xxW { p r i n t " 1 " }
S ! y { print "2"}
W ! Sz { p r i n t " 3 " }
O
What is the translation of xxxxyzz using the syntax directed translation scheme
described by the above rules?
IF
(a) 23131
(b) 11233
(c) 11231
(d) 33211
N

109. [ Compilers | GATE 1994 ] Generation of intermediate code based on an abstract


machine model is useful in compilers because
(a) it makes implementation of lexical analysis and syntax analysis easier
(b) syntax-directed translations can be written for intermediate code generation
A

(c) it enhances the portability of the front end of the compiler


(d) it is not possible to generate code for real machines directly from high level
language programs
M

110. [ General | GATE 1994 ] Match the following items

(a) (i) - (d), (ii) - (a), (iii) - (b), (iv) - (c)


111. [ Parsers | GATE 2020 ] Consider the following grammar.

www.manifoldkerala.com, Ph: 0487 2382342 33


Compiler Design Manifold Institute of Technical Education

S ! aSB | d
B ! b

The number of reduction steps taken by a bottom-up parser while accepting the
string aaadbbb is _______.
(a) 7
112. [ Run-Time-Environment | GATE 2020 ] Consider the following statements.
I. Symbol table is accessed only during lexical analysis and syntax analysis.
II. Compilers for programming languages that support recursion necessarily need
heap storage for memory allocation in the run-time environment.

LD
III. Errors violating the condition ’any variable must be declared before its use’ are de-
tected during syntax analysis. Which of the above statements is/are TRUE?
(a) II only
(b) I only
(c) I and III only
(d) None of I, II and III

O
113. [ Synthesized-Attribute | GATE 2020 ] Consider the productions A! PQ and
A! XY. Each of the five non-terminals A, P, Q, X, and Y has two attributes: s is a
synthesized attribute, and i is an inherited attribute. Consider the following rules.
Rule 1 : P . i = A. i + 2 , Q. i = P . i + A. i , and A. s = P . s + Q. s
Rule 2 : X . i = A. i + Y . s and Y . i = X . s + A. i
IF
Which one of the following is TRUE?
(a) Only Rule 2 is L-attributed.
(b) Neither Rule 1 nor Rule 2 is L-attributed.
N

(c) Both Rule 1 and Rule 2 are L-attributed.


(d) Only Rule 1 is L-attributed.
114. [ Compilers | GATE 1993 ] For the program segment given below, which of the
following are true?
A

program main ( output ) ;


type l i n k = ^ data ;
data = r e c o r d
d : real ;
n : link
M

end ;
var p t r : l i n k ;
begin
new ( p t r ) ;
ptr := n i l ;
. ptr^ . d : = 5 . 2 ;
write ln ( ptr )
end .

(a) The program leads to compile time error


(b) The program leads to run time error

www.manifoldkerala.com, Ph: 0487 2382342 34


Compiler Design Manifold Institute of Technical Education

(c) The program outputs 5.2


(d) The program produces error relating to nil pointer dereferencing
(e) None of the above
115. [ General | GATE 1993 ] A part of the system software, which under all circum-
stances must reside in the main memory, is:
(a) text editor
(b) assembler
(c) linker

LD
(d) loader
(e) none of the above
116. [ Parsers | GATE 1992 ] Consider the SLR(1) and LALR (1) parsing tables for a
context free grammar. Which of the following statements is/are true?
(a) The go to part of both tables may be different.
(b) The shift entries are identical in both the tables.

O
(c) The reduce entries in the tables may be different.
(d) The error entries in the tables may be different.
(e) B, C and D.
IF
117. [ Operands | GATE 1991 ] The arithmetic expression : (a + b) * c - d / e * * f is
to be evaluated on a two-address machine, where each operands, the number of
registers required to evaluate this expression is ______. The number of memory
access of operand is __________.
(a) 3, 4
N

118. [ Precedence-Graph | GATE 1991 ] A given set of processes can be implemented


by using only parbegin/parend statement, if the precedence graph of these pro-
cesses is ________
(a) properly nested.
A

119. [ Linker-Loader | GATE 1991 ] Choose the correct alternatives (more than one
may be correct) and write the corresponding letters only: A "link editor" is a
program that:
(a) matches the parameters of the macro-definition with locations of the parame-
M

ters of the macro call


(b) matches external names of one program with their location in other programs
(c) matches the parameters of subroutine definition with the location of parame-
ters of subroutine call
(d) acts as link between text editor and the user
(e) acts as a link between compiler and user program
120. [ Parsers | GATE 1991 ] Choose the correct alternatives (more than one may be
correct) and write the corresponding letters only: Indicate all the true statements
from the following:

www.manifoldkerala.com, Ph: 0487 2382342 35


Compiler Design Manifold Institute of Technical Education

(a) Recursive descent parsing cannot be used for grammar with left recursion.
(b) The intermediate form the representing expressions which is best suited for
code optimization is the post fix form.
(c) A programming language not supporting either recursion or pointer type does
not need the support of dynamic memory allocation.
(d) Although C does not support call by name parameter passing, the effect can
be correctly simulated in C.
(e) No feature of Pascal violates strong typing in Pascal.
(f) A and D

LD
121. [ Match-the-Following | GATE 1990 ] Match the pairs in the following questions:
(a) P o i n t e r data type (p) Type c o n v e r s i o n
(b) Activation record (q) Dynamic data s t r u c t u r e
(c) Repeat − u n t i l (r) Recursion
(d) Coercion (s) Non− d e t e r m i n i s t i c loop

(a) (a) - (q), (b) - (r), (c) - (s), (d) - (p)


122. [ Match-the-Following | GATE 1990 ] Match the pairs in the following questions:
(a)
(b)
(c)
(d)
Lexical analysis
Code o p t i m i z a t i o n
Code g e n e r a t i o n
Abelian groups
O (p)
(q)
(r)
(s)
DAG’ s
Syntax t r e e s
Push down automaton
F i n i t e automaton
IF
(a) (a) - (s), (b) - (p), (c) - (q), (d) - (r)
123. [ Parsers | GATE 1989 ] Merging states with a common core may produce
__________ conflicts and does not produce ___________ conflicts in an LALR purser.
(a) Reduce-Reduce, Shift-Reduce
N

124. [ Compilers | GATE 1987 ] In a compiler the module the checks every character
of the source text is called:
(a) The code generator.
A

(b) The code optimizer.


(c) The lexical analyser.
(d) The syntax analyser.
125. [ Parsers | GATE 1987 ] An operator precedence parser is a
M

(a) Bottom-up parser.


(b) Top-down parser.
(c) Back tracking parser.
(d) None of the above.
126. [ Compilers | GATE 1987 ] Using longer identifiers in a program will necessarily
lead to:
(a) Somewhat slower compilation
(b) A program that is easier to understand

www.manifoldkerala.com, Ph: 0487 2382342 36


Compiler Design Manifold Institute of Technical Education

(c) An incorrect program


(d) None of the above
127. [ Grammar | GATE 2007-IT ] Consider an ambiguous grammar G and its disam-
biguated version D. Let the language recognized by the two grammars be denoted
by L(G) and L(D) respectively. Which one of the following is true ?
(a) L (D) ⇢ L (G)
(b) L (D) L (G)
(c) L (D) = L (G)
(d) L (D) is empty

LD
128. [ Compilers | ISRO-2018 ] Which of the following comparisons between static
and dynamic type checking is incorrect?
(a) Dynamic type checking slows down the execution
(b) Dynamic type checking offers more flexibility to the programmers
(c) In contrast to Static type checking, dynamic type checking may cause failure
in runtime due to type errors

129. [ Compilers | ISRO-2018 ] O


(d) Unlike static type checking, dynamic type checking is done during compilation
Incremental Compiler is a compiler
(a) which is written in a language that is different from the source language
IF
(b) compiles the whole source code to generate object code afresh
(c) compiles only those portion of source code that has been modified.
(d) that runs on one machine but produces object code for another machine
130. [ Compilers | ISRO-2018 ] DU-chains(Definition-Use) in compiler design
N

(a) Consist of a definition of a variable and all its uses, reachable from that defini-
tion
(b) Are created using a form of static code analysis
(c) Are prerequisite for many compiler optimization including constant propaga-
A

tion and common sub-expression elimination


(d) All of the above
131. [ Code-Optimization | ISRO-2018 ] Which of the following comment about
peephole optimization is true?
M

(a) It is applied to a small part of the code and applied repeatedly


(b) It can be used to optimize intermediate code
(c) It can be applied to a portion of the code that is not contiguous
(d) It is applied in the symbol table to optimize the memory requirements.
132. [ Compilers | ISRO CS 2008 ] Relative to the program translated by a compiler,
the same program when interpreted runs
(a) Faster
(b) Slower

www.manifoldkerala.com, Ph: 0487 2382342 37


Compiler Design Manifold Institute of Technical Education

(c) At the same speed


(d) May be faster or slower
133. [ Compilers | ISRO-2017 May ] The output of a lexical analyzer is
(a) A parse tree
(b) Intermediate code
(c) Machine code
(d) A stream of tokens
134. [ Code-Optimization | ISRO CS 2008 ] Which of the following class of statement

LD
usually produces no executable code when compiled?
(a) declaration
(b) assignment statements
(c) input and output statements
(d) structural statements
135. [ Symbol-Table | ISRO-2016 ] The access time of the symbol table will be loga-
rithmic if it is implemented by
(a) Linear list
(b) Search tree
O
IF
(c) Hash table
(d) Self organization list
136. [ Parsers | ISRO-2016 ] Recursive descent parsing is an example of
(a) Top-down parsers
N

(b) Bottom-up parsers


(c) Predictive parsers
(d) None of the above
A

137. [ Parsers | ISRO-2016 ] A top-down parser generates


(a) Rightmost Derivation
(b) Rightmost derivation in reverse
(c) Leftmost derivation
M

(d) Leftmost derivation in reverse


138. [ Code-Optimization | ISRO-2016 ] Peephole optimization is a form of
(a) Loop optimization
(b) Local optimization
(c) Constant folding
(d) Data flow analysis
139. [ Code-Optimization | ISRO CS 2009 ] Substitution of values for names (whose
values are constants) is done in

www.manifoldkerala.com, Ph: 0487 2382342 38


Compiler Design Manifold Institute of Technical Education

(a) Local optimization


(b) Loop optimization
(c) Constant folding
(d) Strength reduction
140. [ Compilers | ISRO-2016 ] Which one of the following is correct about the state-
ments are given below?
I. All function calls are resolved at compile time in C language
II. All function calls are resolved at compile time in C++ language

LD
(a) Only II is correct
(b) Both I and II are correct
(c) Only I is correct
(d) Both I and II are incorrect
141. [ Assembler | ISRO-2016 ] A simple two-pass assembler does which of the
following in the first pass:

O
(a) Checks to see if the instructions are legal in the current assembly mode
(b) It allocates space for the literals.
(c) It builds the symbol table for the symbols and their values.
IF
(d) All of these
142. [ Code-Optimization | ISRO CS 2011 ] In compiler terminology reduction in
strength means
(a) Replacing run time computation by compile time computation
N

(b) Removing loop invariant computation


(c) Removing common subexpressions
(d) replacing a costly operation by a relatively cheaper one
143. [ Code-Optimization | ISRO CS 2011 ] Which of the following statements about
A

peephole optimization is False?


(a) It is applied to a small part of the code
(b) It can be used to optimize intermediate code
M

(c) To get the best out of this, it has to be applied repeatedly


(d) It can be applied to the portion of the code that is not contiguous
144. [ Context-free-grammar | ISRO CS 2011 ] Which variable does not drive a ter-
minal string in grammar?
S ! AB
A!a
B!b
B!C

(a) A

www.manifoldkerala.com, Ph: 0487 2382342 39


Compiler Design Manifold Institute of Technical Education

(b) B
(c) C
(d) S
145. [ Parsers | ISRO CS 2013 ] Shift reduce parsing belongs to a class of
(a) bottom up parsing
(b) top down parsing
(c) recursive parsing
(d) predictive parsing

LD
146. [ Parsers | ISRO CS 2013 ] Which of the following productions eliminate left
recursion in the productions given below:
S ! Aa | b
A ! Ac | Sd | 2

(a) S ! Aa | b
A ! bdA’
A’ ! A’c
| A’ba | A | 2
(b) S ! Aa | b
A ! A’ |
bdA’,
O
IF
A’ ! cA’
| adA’ | 2
(c) S ! Aa | b
A ! A’c |
A’d
N

A’ ! bdA’
| cA | 2
(d) S ! Aa | b
A ! cA’ |
adA’ | bdA’
A

A’ ! A | 2

147. [ Syntax-tree-and-context-flow-graph | UGC-NET CS 2018 JUNE Paper-2 ] A


bottom-up parser generates :
M

(a) Leftmost derivation in reverse


(b) Right-most derivation in reverse
(c) Left-most derivation
(d) Right-most derivation
148. [ Nielit Scentist-B [ 02-12-2018] ] Identify the correct nodes and edges in the
given intermediate code:
(1) i=1
(2) t1=5*I
(3) t2=4*t1

www.manifoldkerala.com, Ph: 0487 2382342 40


Compiler Design Manifold Institute of Technical Education

(4) t3=t2
(5) a[ t3] =0
(6) i=i+1;
(7) if i< 15 goto(2)

(a) 33
(b) 44
(c) 43
(d) 34

LD
149. [ Nielit Scentist-B [ 02-12-2018] ] __number of queues are needed to implement
symbol and is acting as permanent database
(a) Variable Table
(b) Terminal Table
(c) Keyword Table
(d) Identifier Table

statements printf("A% B=", &i);


(a) 7
(b) 8
O
150. [ Nielit Scentist-B [ 02-12-2018] ] Identify the total number of tokens in the given
IF
(c) 9
(d) 13
151. [ Nielit Scentist-B [ 02-12-2018] ] Which of the following code replacements is
an example of operator strength reduction?
N

(a) Replace P^ 2 by P*P


(b) Replace P*16 by P< < 4
(c) Replace pow(P,3) by P*P*P
A

(d) Replace (P < < 5) -P by P*3


152. [ Nielit Scentist-B [ 02-12-2018] ] ____ merges the bodies of two loops.
(a) Loop rolling
M

(b) Loop folding


(c) Loop merge
(d) Loop jamming
153. [ Nielit Scentist-B [ 02-12-2018] ] ____ merges the bodies of two loops.
(a) Loop rolling
(b) Loop folding
(c) Loop merge
(d) Loop jamming

www.manifoldkerala.com, Ph: 0487 2382342 41


Compiler Design Manifold Institute of Technical Education

154. [ External-subroutines | Nielit Scientist-C 2016 march ] Which of the following


can be accessed by transfer vector approach of linking?
(a) External data segments
(b) External subroutines
(c) data located in other procedure
(d) All of these
155. [ Parsers | Nielit Scientist-C 2016 march ] YACC builds up
(a) SLR parsing table

LD
(b) Canonical LR parsing table
(c) LALR parsing table
(d) None of these
156. [ Micro-Program | Nielit Scientist-C 2016 march ] Micro program is
(a) the name of source program in micro computers
(b) the set of instructions indicating the primitive operations in a system

(d) program of very small size


O
(c) primitive form of macros used in assembly language programming

157. [ Parsers | Nielit Scientist-B CS 22-07-2017 ] What is the maximum number of


IF
reduce moves that can be taken by a bottom up parser for a grammar with no
epsilon and unit production(i.e., of type A ! 2 and A ! a) to parse a string
with n tokens?
(a) n/2
(b) n-1
N

(c) 2n-1
(d) 2n
158. [ Compilers | Nielit Scientist-B CS 22-07-2017 ] In a compiler, keywords of a
A

language are recognized during


(a) Parsing of the program
(b) the code generation
(c) the lexical analysis of the program
M

(d) dataflow analysis


159. [ Linker-Loader | Nielit Scientist-B CS 22-07-2017 ] A system program that
combines the separately compiled modules of a program into a form suitable for
execution
(a) Assembler
(b) linking loader
(c) cross compiler
(d) load and go

www.manifoldkerala.com, Ph: 0487 2382342 42


Compiler Design Manifold Institute of Technical Education

160. [ Nielit STA [ 02-12-2018] ] Which of the following statements is false?


(a) There exist parsing algorithms for some programming languages whose com-
plexities are less than O(n3 )
(b) A programming language which allows recursion can be implemented with
static storage allocation
(c) L-attributed definition can be evaluated in the framework of bottom-up pars-
ing
(d) Code improving transformation can be performed at both source language
and intermediate code level.

LD
161. [ Assembler | Nielit Scientist-B CS 2016 march ] In a single pass assembler,
most of the forward references can be avoided by putting the restriction
(a) on the number of strings/lifereacs
(b) that the data segment must be defined after the code segment
(c) on unconditional rump
(d) that the data segment be defined before the code segment

O
162. [ Parsers | UGC-NET CS 2018 DEC Paper-2 ] The grammar S ! (S) | SS | 2 is
not suitable for predictive parsing because the grammar is
(a) An Operator Grammar
(b) Right Recursive
IF
(c) Left Recursive
(d) Ambiguous
163. [ Assembler | NieLit STA 2016 March 2016 ] Pseudo-instructions are
(a) assembler directives
N

(b) instructions in any program that have no corresponding machine code instruc-
tion
(c) instruction in any program whose presence or absence will not change the
output for any input
A

(d) none of these


164. [ Parsers | UGC-NET CS 2018 DEC Paper-2 ] Consider the following Grammar
G:
M

S! A | B
A! a | c
B! b | c

Where { S,A,B} is the set of non-terminals, { a,b,c} is the set of terminals.


Which of the following statement(s) is/are correct ?
S1 : LR(1) can parse all strings that are generated using grammar G.
S2 : LL(1) can parse all strings that are generated using grammar G.
Choose the correct answer from the code given below :
Code :

www.manifoldkerala.com, Ph: 0487 2382342 43


Compiler Design Manifold Institute of Technical Education

(a) Both S1 and S2


(b) Only S2
(c) Neither S1 nor S2
(d) Only S1
165. [ Code Optimization | Nielit Scientist-B CS 4-12-2016 ] The identification of
common sub-expression and replacement of run time computations by compile-
time computations is:
(a) Local optimization
(b) Constant folding

LD
(c) Loop Optimization
(d) Data flow analysis
166. [ Basics | Nielit Scientist-B CS 4-12-2016 ] The structure or format of data is
called:
(a) Syntax
(b) Struct
(c) Semantic
(d) none of the above
O
167. [ Code-Optimization | Nielit Scientist-B CS 4-12-2016 ] The graph that shows
IF
basic blocks and their successor relationship is called:
(a) DAG
(b) Control graph
(c) Flow graph
N

(d) Hamiltonian graph


168. [ Compilers | Nielit Scientist-B CS 4-12-2016 ] A top down parser generates:
(a) Leftmost derivation
A

(b) rightmost derivation


(c) Leftmost derivation in reverse
(d) Rightmost derivation in reverse
169. [ Syntax-Directed-Translation | Nielit Scientist-B CS 4-12-2016 ] Syntax directed
M

translation scheme is desirable because:


(a) It is based on the syntax
(b) It is easy to modify
(c) Its description is independent of any implementation
(d) All of these
170. [ Compilers | Nielit Scientist-B CS 4-12-2016 ] The output of lexical analyzer is:
(a) A set of regular expressions
(b) Strings of character

www.manifoldkerala.com, Ph: 0487 2382342 44


Compiler Design Manifold Institute of Technical Education

(c) Syntax tree


(d) Set of tokens
171. [ Associativity-and-Precedence | ISRO CS 2015 ] Given the following expression
grammar:
E! E*F | F+E | F
F! F-F | id
Which of the following is true?

(a) * has higher precedence than +


(b) - has higher precedence than *

LD
(c) + and - have same precedence
(d) + has higher precedence than *
172. [ Compilers | ISRO CS 2015 ] The number of tokens in the following C statement
is
printf("i=% d, &i=% x", i&i);

(a) 13
(b) 6
(c) 10
O
IF
(d) 0
173. [ Parsers | ISRO CS 2015 ] Which grammar rules violate the requirement of the
operator grammar? A, B, C are variables and a, b, c are terminals 1) A ! BC 2) A
! CcBb 3) A ! BaC 4) A ! 2
(a) 1 only
N

(b) 1 and 2 only


(c) 1 and 3 only
(d) 1 and 4 only
A

174. [ Parsers | ISRO CS 2015 ] Which one of the following is a top-down parser?
(a) Recursive descent parser
(b) Shift left associative parser
M

(c) SLR(k) parser


(d) LR(k) parser
175. [ Parsers | ISRO CS 2015 ] YACC stands for
(a) yet accept compiler constructs
(b) yet accept compiler compiler
(c) yet another compiler construct
(d) yet another compiler compiler
176. [ Parsers | ISRO CS 2015 ] Which statement is true?

www.manifoldkerala.com, Ph: 0487 2382342 45


Compiler Design Manifold Institute of Technical Education

(a) LALR parser is more powerful and costly as compare to other parsers
(b) All CFG’s are LP and not all grammars are uniquely defined
(c) Every SLR grammar is unambiguous but not every unambiguous grammar is
SLR
(d) LR(K) is the most general backtracking shift reduce parsing method
177. [ Parsers | JT(IT) 2018 PART-B Computer Science ] With respect to compiler
design, "recursive descent" is a ____ parsing technique that reads the inputs from
____.
(a) top-down, right to left

LD
(b) top-down, left to right
(c) bottom up, right to left
(d) bottom up, left to right
178. [ Parsers | JT(IT) 2018 PART-B Computer Science ] Which of the following is
NOT a bottom up, shift reduce parser?
(a) LR parser
(b) LL parser
(c) SLR parser
(d) LALR parser
O
IF
179. [ Nielit Scientist-B 17-12-2017 ] Which of the following is machine independent
optimization?
(a) Loop optimization
(b) Redundancy Elimination
N

(c) Folding
(d) All of the options
180. [ Nielit Scientist-B 17-12-2017 ] Which of the following statements is/ are false?
A

S1: LR(0) grammar and SLR(1) grammar are equivalent


S2: LR(1) grammar are subset of LALR(1) grammars

(a) S1 only
M

(b) S1 and S2 both


(c) S2 only
(d) None of the options
181. [ Nielit Scientist-B 17-12-2017 ] The optimization phase in a compiler gererally:
(a) Reduces the space of the code
(b) Optimization the code to reduce execution time
(c) Both (A) and (B)
(d) Neither (A) nor (B)

www.manifoldkerala.com, Ph: 0487 2382342 46


Compiler Design Manifold Institute of Technical Education

182. [ Parsers | JT(IT) 2018 PART-B Computer Science ] Which of the following
phases of the compilation process is also known as parsing?
(a) Lexical analysis
(b) Code optimization
(c) Syntax analysis
(d) Semantic analysis
183. [ Linker | KVS 22-12-2018 Part-B ] Resolution of externally defined symbols is
performed by____

LD
(a) Linker
(b) Loader
(c) Compiler
(d) Editor
184. [ Compilers-and-Parsers | KVS 22-12-2018 Part-B ] Which of the following are
language processor?
(a) Assembler and editor
(b) Compiler and word processor
(c) Only Assembler and compiler
O
IF
(d) Assembler,Compiler and Interpreter
185. [ Syntax-Directed-Translation | Nielit Scientific Assistance CS 15-10-2017 ] Syn-
thesized attribute can easily be simulated by an
(a) LL grammar
N

(b) ambiguous grammar


(c) LR grammar
(d) none of the above
186. [ Parsers | Nielit Scientific Assistance CS 15-10-2017 ] Consider an 2 -tree CFG.
A

If for every pair of productions A ! u and A ! v


(a) if FIRST(u) \ FIRST(v) is empty then the CFG has to be LL(1)
(b) If the CFG is LL(1) then FIRST(u) \ FIRST(v) has to be empty
M

(c) Both (A) and (B)


(d) None of the above
187. [ Compilers | JT(IT) 2016 PART-B Computer Science ] Which of the following
checks are not included in semantic analysis done by the compiler:
(a) Type checks
(b) Spelling checks
(c) Uniquencess checks
(d) Flow of control checks

www.manifoldkerala.com, Ph: 0487 2382342 47


Compiler Design Manifold Institute of Technical Education

188. [ Compilers-and-Parsers | KVS 30-12-2018 Part B ] In a computer, keywords of


a language are recognized during
(a) Parsing of the program
(b) Code generation
(c) Lexical analysis of the program
(d) Data flow diagrams
189. [ Compilers | UGC NET CS 2017 Nov- paper-2 ] Match the description of several
parts of a classic optimizing compiler in List - I, with the names of those parts in
List - II:

LD
O
IF
(a) (a)-(iii), (b)-(iv), (c)-(ii), (d)-(i)
(b) (a)-(iv), (b)-(iii), (c)-(ii), (d)-(i)
(c) (a)-(ii), (b)-(iv), (c)-(i), (d)-(iii)
N

(d) (a)-(ii), (b)-(iv), (c)-(iii), (d)-(i)


190. [ Linker-Loader | UGC NET CS 2017 Nov- paper-2 ] In Distributed system, the
capacity of a system to adapt the increased service load is called __________ .
(a) Tolerance
A

(b) Scalability
(c) Capability
(d) Loading
M

191. [ Compilers | UGC NET CS 2017 Jan -paper-2 ] Consider the following state-
ments related to compiler construction :
I. Lexical Analysis is specified by context-free grammars and implemented by
pushdown automata.
II. Syntax Analysis is specified by regular expressions and implemented by finite-
state machine.
Which of the above statement(s) is/are correct ?
(a) Only I
(b) Only II
(c) Both I and II

www.manifoldkerala.com, Ph: 0487 2382342 48


Compiler Design Manifold Institute of Technical Education

(d) Neither I nor II


192. [ Code-Optimization | UGC NET CS 2016 Aug- paper-2 ] In compiler opti-
mization, operator strength reduction uses mathematical identities to replace slow
math operations with faster operations. Which of the following code replacements
is an illustration of operator strength reduction ?
(a) Replace P + P by 2 * P or Replace 3 + 4 by 7.
(b) Replace P * 32 by P < < 5
(c) Replace P * 0 by 0
(d) Replace (P < < 4) - P by P * 15

LD
193. [ Linker-Loader | UGC NET CS 2016 Aug- paper-2 ] Which of the following are
the principles tasks of the linker?
I. Resolve external references among separately compiled program units.
II. Translate assembly language to machine code.
III. Relocate code and data relative to the beginning of the program.
IV. Enforce access-control restrictions on system libraries

(a) I and II
(b) I and III
(c) II and III
(d) I and IV
O
IF
194. [ Code-Optimization | UGC NET CS 2016 July- paper-2 ] In _______, the bodies
of the two loops are merged together to form a single loop provided that they do
not make any references to each other.
(a) Loop unrolling
N

(b) Strength reduction


(c) Loop concatenation
(d) Loop jamming
A

195. [ Linker-Loader | UGC NET CS 2016 July- paper-2 ] Which of the following is
not typically a benefit of dynamic linking?
I. Reduction in overall program execution time.
II. Reduction in overall space consumption in memory.
III. Reduction in overall space consumption on disk.
M

IV. Reduction in the cost of software updates.

(a) I and IV
(b) I only
(c) II and III
(d) IV only
196. [ Parsers | UGC NET CS 2016 July- paper-2 ] Which of the following is FALSE?
(a) The grammar S ! a Sb | bSa| SS| 2 , where S is the only non-terminal symbol
and 2 is the null string, is ambiguous.

www.manifoldkerala.com, Ph: 0487 2382342 49


Compiler Design Manifold Institute of Technical Education

(b) SLR is powerful than LALR.


(c) An LL(1) parser is a top-down parser.
(d) YACC tool is an LALR(1) parser generator.
197. [ Code-Optimization | UGC NET CS 2015 Dec- paper-2 ] Loop unrolling is a
code optimization technique:
(a) that avoids tests at every iteration of the loop.
(b) that improves performance by decreasing the number of instructions in a basic
block.
(c) that exchanges inner loops with outer loops

LD
(d) that reorders operations to allow multiple computations to happen in parallel
198. [ Pre-Processor | UGC NET CS 2015 Jun- paper-2 ] The translator which per-
forms macro calls expansion is called:
(a) Macro processor
(b) Micro preprocessor
(c) Macro preprocessor
(d) Dynamic Linker
O
199. [ Parsers | UGC NET CS 2015 Jun- paper-2 ]
false?
Which one from the following is
IF
(a) LALR parser is Bottom up parser
(b) A parsing algorithm which performs a left to right scanning and a right most
deviation is RL (1)
(c) LR parser is Bottom up parser.
N

(d) In LL(1), the 1 indicates that there is a one - symbol look - ahead.
200. [ Phases-of-Compilers | UGC NET CS 2015 Jun- paper-2 ] Which phase of
compiler generates stream of atoms?
(a) Syntax Analysis
A

(b) Lexical Analysis


(c) Code Generation
(d) Code Optimization
M

201. [ Assembler | UGC NET CS 2004 Dec-Paper-2 ] Which activity is not included
in the first pass of two pass assemblers ?
(a) Build the symbol table
(b) Construct the intermediate code
(c) Separate mnemonic opcode and operand fields
(d) None of the above
202. [ Code-Optimization | UGC NET CS 2004 Dec-Paper-2 ] Code optimization is
responsibility of :
(a) Application programmer

www.manifoldkerala.com, Ph: 0487 2382342 50


Compiler Design Manifold Institute of Technical Education

(b) System programmer


(c) Operating system
(d) All of the above
203. [ Assembler | UGC NET CS 2004 Dec-Paper-2 ] Which activity is included in
the first pass of two pass assemblers ?
(a) Build the symbol table
(b) Construct the intermediate code
(c) Separate mnemonic opcode and operand fields

LD
(d) None of these
(e) A,B and C
204. [ Assembler | UGC NET CS 2004 Dec-Paper-2 ] In two pass assembler the
symbol table is used to store :
(a) Label and value
(b) Only value
(c) Mnemonic
(d) Memory Location O
205. [ Parsers | UGC NET CS 2005 Dec-Paper-2 ]
(a) Leftmost derivation
A Top-down Parser generates :
IF
(b) Rightmost derivation
(c) Rightmost derivation in reverse
(d) Leftmost derivation in reverse
N

206. [ Assembler | UGC NET CS 2005 Dec-Paper-2 ] A general macroprocessor is an


in built function of :
(a) Loader
(b) Linker
A

(c) Editor
(d) Assembler
207. [ Assembler | UGC NET CS 2005 Dec-Paper-2 ] Which activities is not included
in the first pass of two pass assembler ?
M

(a) build the symbol table


(b) construct the Intermediate code
(c) separate mnemonic opcode and operand field.
(d) none of these
208. [ Compilers | UGC NET CS 2005 june-paper-2 ] Which of the statements related
to Compilers is wrong ?
(a) Lexical analysis is breaking the input into tokens
(b) Syntax analysis is for parsing the phrase

www.manifoldkerala.com, Ph: 0487 2382342 51


Compiler Design Manifold Institute of Technical Education

(c) Syntax analysis is for analyzing the semantic


(d) None of these
209. [ Run-Time-Environment | UGC NET CS 2005 june-paper-2 ] The dynamic
binding occurs during the :
(a) Compile time
(b) Run time
(c) Linking time
(d) Pre-processing time.

LD
210. [ Symbol-Table | UGC NET CS 2005 june-paper-2 ] Symbol Table can be used
for :
(a) Checking type compatibility
(b) Suppressing duplication of error message
(c) Storage allocation
(d) All of these

O
211. [ Compilers | UGC NET CS 2006 Dec-paper-2 ] A compiler for a high level
language that runs on one machine and produces code for a different machine is
called :
(a) Optimizing
IF
(b) One pass compiler
(c) Cross compiler
(d) Multipass compiler
212. [ Parsers | UGC NET CS 2006 Dec-paper-2 ] The ’K’ in LR(R) cannot be :
N

(a) 0
(b) 1
(c) 2
A

(d) None of these


213. [ Code-Optimization | UGC NET CS 2006 Dec-paper-2 ] Peer-hole optimization
is a form of :
(a) loop optimization
M

(b) local optimization


(c) constant folding
(d) data flow analysis
214. [ Compilers | UGC NET CS 2006 Dec-paper-2 ] A permanent database of a
general model of compiler is ____________ .
(a) Identifier table
(b) Page map table
(c) Literal table

www.manifoldkerala.com, Ph: 0487 2382342 52


Compiler Design Manifold Institute of Technical Education

(d) Terminal table


215. [ Parsers | UGC NET CS 2006 June-Paper-2 ] Tasks done in parsing are :
(a) Check the validity of a source string
(b) Determine the syntactic structure of a source string
(c) Both (A) and (B)
(d) None of these
216. [ Parsers | UGC NET CS 2006 June-Paper-2 ] YACC builds up __________ pars-
ing table.

LD
(a) LALR
(b) LR
(c) SLR
(d) LLR
217. [ Parsers | UGC NET CS 2006 June-Paper-2 ] The action of passing the source
program into the proper syntactic class is known as :
(a) Syntax analysis
(b) Lexical analysis
(c) Interpretation analysis
O
IF
(d) Uniform symbol generation
218. [ Run-Time-Environment | UGC NET CS 2006 June-Paper-2 ] The dynamic
binding occurs during the :
(a) Compile time
N

(b) Run time


(c) Linking time
(d) Pre - processing time
219. [ Parsers | UGC NET CS 2014 Dec-Paper-2 ] Shift-Reduce parsers perform the
A

following :
(a) Shift step that advances in the input stream by K(K > 1) symbols and Reduce
step that applies a completed grammar rule to some recent parse trees, joining
them together as one tree with a new root symbol.
M

(b) Shift step that advances in the input stream by one symbol and Reduce step
that applies a completed grammar rule to some recent parse trees, joining them
together as one tree with a new root symbol.
(c) Shift step that advances in the input stream by K(K = 2) symbols and Reduce
step that applies a completed grammar rule to form a single tree.
(d) Shift step that does not advance in the input stream and Reduce step that
applies a completed grammar rule to form a single tree.
220. [ Parsers | UGC NET CS 2014 Dec-Paper-2 ] Which of the following is true ?
(a) Canonical LR parser is LR (1) parser with single look ahead terminal

www.manifoldkerala.com, Ph: 0487 2382342 53


Compiler Design Manifold Institute of Technical Education

(b) All LR(K) parsers with K > 1 can be transformed into LR(1) parsers.
(c) Both (A) and (B)
(d) None of the above
221. [ Symbol-table | UGC NET CS 2014 Dec-Paper-2 ] In a two-pass assembler,
symbol table is
(a) Generated in first pass
(b) Generated in second pass
(c) Not generated at all

LD
(d) Generated and used only in second pass
222. [ Debugger | UGC NET CS 2014 Dec-Paper-2 ] Debugger is a program that
(a) allows to examine and modify the contents of registers
(b) does not allow execution of a segment of program
(c) allows to set breakpoints, execute a segment of program and display contents
of register
(d) All of the above
O
223. [ Parsers | UGC NET CS 2014 June-paper-2 ] A grammar G is LL(1) if and only
if the following conditions hold for two distinct productions
A!a|b
IF
1. First ( a ) \ First ( b ) 6= { a} where a is some terminal symbol of the grammar.
2. First ( a ) \ First ( b ) 6= l
III. First ( a ) \ Follow (A) = F if l 2 First ( b )
N

(a) I and II
(b) I and III
(c) II and III
(d) I, II and III
A

224. [ Parsers | UGC NET CS 2014 June-paper-2 ] Which of the following suffices to
convert an arbitrary CFG to an LL(1) grammar ?
(a) Removing left recursion alone
M

(b) Removing the grammar alone


(c) Removing left recursion and factoring the grammar
(d) None of the above
225. [ Parsers | UGC NET CS 2014 June-paper-2 ] A shift reduce parser suffers from
(a) shift reduce conflict only
(b) reduce reduce conflict only
(c) both shift reduce conflict and reduce reduce conflict
(d) shift handle and reduce handle conflicts

www.manifoldkerala.com, Ph: 0487 2382342 54


Compiler Design Manifold Institute of Technical Education

226. [ Parsers | UGC NET CS 2018-DEC Paper-2 ] The grammar S ! (S) | SS | 2 is


not suitable for predictive parsing because the grammar is
(a) An Operator Grammar
(b) Right Recursive
(c) Left Recursive
(d) Ambiguous
227. [ Parsers | UGC NET CS 2018-DEC Paper-2 ] Consider the following Grammar
G:
S!A|B

LD
A! a | c
B! b | c
Where { S,A,B} is the set of non-terminals, { a,b,c} is the set of terminals.
Which of the following statement(s) is/are correct ?
S 1 : LR(1) can parse all strings that are generated using grammar G.
S 2 : LL(1) can parse all strings that are generated using grammar G.

(a) Both S 1 and S 2


(b) Only S 2
(c) Neither S 1 nor S 2
(d) Only S 1
O
IF
228. [ Ambiguous-and-Unambiguous-Grammar | UGC NET CS 2018 JUNE Paper-2 ]
Consider the following two Grammars :
G1 : S ! SbS| a
G2 : S ! aB| ab, A! GAB| a, B! ABb| b
Which of the following option is correct ?
N

(a) Only G1 is ambiguous


(b) Only G2 is ambiguous
(c) Both G1 and G2 are ambiguous
(d) Both G1 and G2 are not ambiguous
A

229. [ Parsers | UGC NET CS 2018 JUNE Paper-2 ] A bottom-up parser generates :
(a) Leftmost derivation in reverse
(b) Right-most derivation in reverse
M

(c) Left-most derivation


(d) Right-most derivation
230. [ Compilers | UGC NET CS 2012 Dec-Paper-2 ] In compiler design ’reducing
the strength’ refers to
(a) reducing the range of values of input variables.
(b) code optimization using cheaper machine instructions.
(c) reducing efficiency of program.
(d) None of the above

www.manifoldkerala.com, Ph: 0487 2382342 55


Compiler Design Manifold Institute of Technical Education

231. [ Grammars | UGC NET CS 2012 Dec-Paper-2 ] Given the following expressions
of a grammar
E!E*F/F+E/F
F ! F - F / id
Which of the following is true ?

(a) * has higher precedence than +


(b) - has higher precedence than *
(c) + and - have same precedence
(d) + has higher precedence than *

LD
232. [ Parsers | UGC NET CS 2012 Dec-Paper-2 ] Which of the following is true while
converting CFG to LL(I) grammar ?
(a) Remove left recursion alone
(b) Factoring grammar alone
(c) Both of the above
(d) None of the above

powerful parsing method ?


(a) LL(I)
O
233. [ Parsers | UGC NET CS 2012 Dec-Paper-2 ] Which of the following is the most
IF
(b) Canonical LR
(c) SLR
(d) LALR
234. [ Parsers | UGC NET CS 2013 Dec-paper-2 ] Given the following statements :
N

S1: SLR uses follow information to guide reductions. In case of LR and LALR
parsers, the lookaheads are associated with the items and they make use of the left
context available to the parser.
S2: LR grammar is a larger subclass of context free grammar as compared to that
SLR and LALR grammars.
A

Which of the following is true ?

(a) S1 is not correct and S2 is not correct.


M

(b) S1 is not correct and S2 is correct.


(c) S1 is correct and S2 is not correct.
(d) S1 is correct and S2 is correct.
235. [ Parsers | UGC NET CS 2013 Dec-paper-2 ] Which of the following derivations
does a top-down parser use while parsing an input string? The input is scanned
from left to right.
(a) Leftmost derivation
(b) Leftmost derivation traced out in reverse
(c) Rightmost derivation traced out in reverse

www.manifoldkerala.com, Ph: 0487 2382342 56


Compiler Design Manifold Institute of Technical Education

(d) Rightmost derivation


236. [ Interpreter | UGC NET CS 2011 June-Paper-2 ] The scheme of which inter-
preter translates the source program is known as
(a) Paragraph by paragraph
(b) Instruction by instruction
(c) Line by line
(d) None of the above
237. [ Compilers | UGC NET CS 2011 June-Paper-2 ] Portable program means

LD
(a) Program with wheels
(b) Independent from its authors
(c) Independent of platform
(d) None of the above
238. [ Symbol-Table | UGC NET CS 2011 June-Paper-2 ] Which of the following
permanent database that has an entry for each terminal symbol ?
(a) Literal table
(b) Identifier table
(c) Terminal table
O
IF
(d) Source table
239. [ Assembler | UGC NET CS 2011 June-Paper-2 ] In which way(s) a macro pro-
cessor for assembly language can be implemented ?
(a) Independent two-pass processor
N

(b) Independent one-pass processor


(c) Expand macro calls and substitute arguments
(d) All of the above
240. [ Ambiguous-and-Unambiguous-Grammar | UGC NET CS 2013 June-paper-2 ]
A

Given the production rules of a grammar G1 as


S1 ! AB | aaB
A ! a | Aa
B!b
and the production rules of a grammar G2 as
M

S2 ! aS2 bS2 | bS2 aS2 | l


Which of the following is correct statement ?

(a) G1 is ambiguous and G2 is not ambiguous.


(b) G1 is ambiguous and G2 is ambiguous.
(c) G1 is not ambiguous and G2 is ambiguous.
(d) G1 is not ambiguous and G2 is not ambiguous.
241. [ Handles | UGC NET CS 2013 June-paper-2 ] Given a grammar : S1 ! Sc, S !
SA | A, A ! aSb | ab, there is a rightmost derivation

www.manifoldkerala.com, Ph: 0487 2382342 57


Compiler Design Manifold Institute of Technical Education

S1 ) Sc ) SAC ) SaSbc
Thus, SaSbc is a right sentential form, and its handle is

(a) SaS
(b) bc
(c) Sbc
(d) aSb
242. [ Grammars | UGC NET CS 2013 June-paper-2 ] The equivalent production rules
corresponding to the production rules

LD
S!Sa 1 | S a 2 | b 1 | b 2 is
(a) S ! b 1 |b2,A!a1A|a2A|l
(b) S ! b 1 | b 2 | b 1 A | b 2 A, A ! a 1 A | a 2 A
(c) S ! b 1 |b2,A!a1A|a2A
(d) S ! b 1 | b 2 | b 1 A | b 2 A, A ! a 1 A | a 2 A | l
243. [ Parsers | UGC NET CS 2013 June-paper-2 ] Which is the correct statement(s)
for Non Recursive predictive parser ?
O
S1 : First( a ) = { t | a ) *t b for some string b } ) *t b
S2 : Follow(X) = { a | S) * a Xa b for some strings a and b }
IF
(a) Both statements S1 and S2 are incorrect.
(b) S1 is incorrect and S2 is correct.
(c) S1 is correct and S2 is incorrect.
(d) Both statements S1 and S2 are correct.
N

244. [ Macros | UGC NET CS 2010 Dec-Paper-2 ] ’Macro’ in an assembly level pro-
gram is _______.
(a) sub program
(b) a complete program
A

(c) a hardware portion


(d) relative coding
245. [ Phases-of-Compilers | UGC NET CS 2010 Dec-Paper-2 ] Grammar of the pro-
M

gramming is checked at ________ phase of compiler


(a) semantic analysis
(b) code generation
(c) syntax analysis
(d) code optimization
246. [ Macros | UGC NET CS 2010 Dec-Paper-2 ] Macro-processors are ______.
(a) Hardware
(b) Compiler

www.manifoldkerala.com, Ph: 0487 2382342 58


Compiler Design Manifold Institute of Technical Education

(c) Registers
(d) None of the above
247. [ Parsers | UGC NET CS 2010 June-Paper-2 ] Which of the following expression
is represented by the parse tree ?

LD
(a) (A + B) * C
(b) A + * BC
(c) A + B * C
(d) A * C + B
O
248. [ Compiler-Design | UGC NET CS 2010 June-Paper-2 ] Consider the following
IF
left associative operators in decreasing order of precedence :
- subtraction (highest precedence)
* multiplication
$ exponentiation (lowest precedence)
What is the result of the following expression ?
N

3 - 2 * 4 $ | * 2**3

(a) - 61
(b) 64
A

(c) 512
(d) 4096
249. [ Phases-of-Compilers | UGC NET CS 2010 June-Paper-2 ] Which of the follow-
ing is used for grouping of characters into tokens(in a computer)?
M

(a) A parser
(b) Code optimizer
(c) Code generator
(d) Scanner
250. [ Compilers | UGC NET CS 2009-June-Paper-2 ] A compiler that runs on one
machine and produces code for a different machine is called:
(a) Cross compilation
(b) One pass compilation

www.manifoldkerala.com, Ph: 0487 2382342 59


Compiler Design Manifold Institute of Technical Education

(c) Two pass compilation


(d) None of the above
251. [ Compilers | UGC NET CS 2009 Dec-Paper-2 ] In an absolute loading scheme
which loader function is accomplished by assembler ?
(a) re-allocation
(b) allocation
(c) linking
(d) loading

LD
252. [ Parsers | UGC NET CS 2009 Dec-Paper-2 ] Which of the following grammar is
LR (1) ?
(a) A ! a A b, A ! b A b, A ! a , A ! b
(b) A ! a A a, A ! a A b, A ! c
(c) A ! A + A, A ! a
(d) Both (A) and (B)

O
253. [ Syntax-Directed-Translation | UGC NET CS 2009 Dec-Paper-2 ] A shift-reduce
parser carries out the actions specified within braces immediately after reducing
with the corresponding rule of the grammar.
S ! x x W [ print "1"]
S ! y [ print "2"]
IF
W ! S2 [ print "3"]
what is the translation of "x x x x y z z" ?

(a) 1 1 2 3 1
N

(b) 1 1 2 3 3
(c) 2 3 1 3 1
(d) 2 3 3 2 1
A

254. [ Synthesized-Attribute | UGC NET CS 2009 Dec-Paper-2 ] Synthesized at-


tribute can be easily simulated by a
(a) LL grammar
(b) Ambiguous grammar
M

(c) LR grammar
(d) None of the above
255. [ Assembler | UGC NET CS 2008 Dec-Paper-2 ] An assembly program contains
:
(a) imperative and declarative statements
(b) imperative statements and assembler directives
(c) imperative and declarative statements as well as assembler directives
(d) declarative statements and assembler directives

www.manifoldkerala.com, Ph: 0487 2382342 60


Compiler Design Manifold Institute of Technical Education

256. [ Assembler | UGC NET CS 2008 Dec-Paper-2 ] Which of the following are As-
sembler Directives ?
(i) EQU
(ii) ORIGIN
(iii) START
(iv) END

(a) (ii), (iii) and (iv)


(b) (i), (iii) and (iv)
(c) (iii) and (iv)

LD
(d) (i), (ii), (iii) and (iv)
257. [ Assembler | UGC NET CS 2008-june-Paper-2 ] Assembler program is :
(a) dependent on the operating system
(b) dependent on the compiler
(c) dependent on the hardware
(d) independent of the hardware

(a) tokens are identified.


O
258. [ Parsers | UGC NET CS 2008-june-Paper-2 ]

(b) set of instructions are identified.


At the end of parsing,
IF
(c) the syntactic groups are identified.
(d) machine instructions are identified
259. [ Code-Optimization | UGC NET CS 2008-june-Paper-2 ] Dead-code elimination
in machine code optimization refers to :
N

(a) removal of all labels.


(b) removal of values that never get used.
(c) removal of function which are not involved.
A

(d) removal of a module after its use.


260. [ Parsers | UGC NET CS 2008-june-Paper-2 ] A parse tree is an annotated parse
tree if :
(a) it shows attribute values at each node.
M

(b) there are no inherited attributes.


(c) it has synthesized nodes as terminal nodes.
(d) every non-terminal nodes is an inherited attribute.
261. [ Compilers | UGC NET CS 2007-Dec-Paper-2 ] In a two pass compiler, during
the first pass :
(a) user defined address symbols are correlated with their binary equivalent
(b) the syntax of the statement is checked and mistakes, if any, are listed
(c) object program is generated

www.manifoldkerala.com, Ph: 0487 2382342 61


Compiler Design Manifold Institute of Technical Education

(d) semantic of the source program is elucidated.


262. [ Compilers | UGC NET CS 2007-Dec-Paper-2 ] A single instruction in an as-
sembly language program contains :
(a) one micro operation
(b) one macro operation
(c) one instruction to be completed in a single pulse
(d) one machine code instruction
263. [ Linker-Loader | UGC NET CS 2007-Dec-Paper-2 ] Absolute loader demands
that the programmer needs to know the :

LD
(a) start address of the available main memory
(b) total size of the program
(c) actual address of the data location
(d) absolute values of the operands used
264. [ Parsers | UGC NET CS 2007-Dec-Paper-2 ] Top-down parsers are predictive
parsers, because :
(a) next tokens are predicted. O
(b) length of the parse tree is predicted beforehand
(c) lowest node in the parse tree is predicted.
IF
(d) next lower level of the parse tree is predicted.
265. [ Code-Optimization | UGC NET CS 2007-Dec-Paper-2 ] In the context of com-
piler design, "reduction in strength" refers to :
N

(a) code optimization obtained by the use of cheaper machine instructions


(b) reduction in accuracy of the output
(c) reduction in the range of values of input variables
(d) reduction in efficiency of the program
A

266. [ Parsers | UGC NET CS 2007 June-Paper-2 ] The parsing technique that avoids
backtracking is :
(a) Top - down parsing
M

(b) Recursive - descent parsing


(c) Predicative
(d) Syntax tree
267. [ Parsers | UGC NET CS 2007 June-Paper-2 ] A Top down Parser generates :
(a) Rightmost derivation.
(b) Rightmost derivation, in reverse.
(c) Leftmost derivation.
(d) Leftmost derivation in reverse.

www.manifoldkerala.com, Ph: 0487 2382342 62


Compiler Design Manifold Institute of Technical Education

268. [ Symbol-Table | UGC NET CS 2007 June-Paper-2 ] Symbol table can be used
for :
(a) Checking type compatibility
(b) Suppressing duplication of error message
(c) Storage allocation
(d) All of these above
269. [ Run-Time-Environment | UGC NET CS 2017 Nov- paper-3 ] Heap allocation
is required for languages that
(a) use dynamic scope rules

LD
(b) support dynamic data structures
(c) support recursion
(d) support recursion and dynamic data structures
270. [ Code-Optimization | UGC NET June-2019 CS Paper-2 ] Replacing the expres-
sion 4*2.14 by 8.56 is known as
(a) Constant folding
(b) Induction variable
(c) Strength reduction
(d) Code reduction
O
IF
271. [ Symbol-Table | UGC NET June-2019 CS Paper-2 ] Which data structure is
used by the compiler for managing variables and their attributes?
(a) Binary tree
(b) link list
N

(c) Symbol table


(d) Parse table
272. [ Parsers | UGC NET June-2019 CS Paper-2 ] Shift-reduce parser consists of
A

(a) input buffer


(b) stack
(c) parse table
choose the correct option from those given below:
M

(a) (a) and (b) only


(b) (a) and (c) only
(c) (c) only
(d) (a), (b) and (c)
273. [ Intermediate-code-generator | UGC NET June-2019 CS Paper-2 ] On translat-
ing the expression given below into quadruple representation, how many opera-
tions are required?
(i*j)+(e+f)*(a*b+c)
(a) 5

www.manifoldkerala.com, Ph: 0487 2382342 63


Compiler Design Manifold Institute of Technical Education

(b) 6

(c) 3

(d) 7

274. [ Parsers | CIL Part - B ]


Which of the following is/are FALSE?

I) Operator precedence parser works on ambiguous grammar

II) Top-down parser works on left recursive, unambiguous and deterministic gram-
mar

LD
III) LL(I) is a non-recursive descent parser

IV) CLR(I) is the most powerful parser

(a) Only II

(b) I, II, III and IV

(c) ll and IV

(d) I, III and IV

275. [ Parsers | CIL Part - B ]


O
What will be the "First" and "Follow" of E and F for the
IF
following grammar?
E-> TE’
E’-> +TE’/2
T-> FT’
T’-> *FT’/2
F-> id/(E)
N

(a) First(E)={ id, (,2 } ,follow(E)={ 2 ,) } , First(F)={ id,),$ } , Follow(F)={ *,$ ,(}

(b) First(E)={ id, ( } ,follow(E)={ $ ,) } , First(F)={ id,(} , Follow(F)={ *,$ ,),+}


A

(c) First(E)={ id, (,2 } ,follow(E)={ 2 ,) } , First(F)={ id,)} , Follow(F)={ *,$ ,(,+ }

(d) First(E)={ id, )} ,follow(E)={ $ ,) } , First(F)={ id,(,$ } , Follow(F)={ *,$ ,),+}

276. [ Parsers | CIL Part - B ]


Which of the following statements is TRUE for the grammar given below?
M

S-> (L)/a

L-> L.S/S

(a) The grammar can be parsed by LR(0) parser only

(b) The grammar can be parsed by LR(0) and SLR(1) parsers

(c) The grammar can be parsed by LL(1) parser only

(d) The grammar can be parsed by LL(1) and LR(0) parsers

www.manifoldkerala.com, Ph: 0487 2382342 64


Compiler Design Manifold Institute of Technical Education

277. [ Parsers | CIL Part - B ]


The number of tokens in the following

"C" language statement is:

printf("The number of tokens are % d", &tcount);

(a) 8
(b) 9
(c) 10

LD
(d) 11
278. [ Lexical-Analyzer | ISRO CS 2020 ] The number of tokens in the following C
code segment is
switch(inputvalue)
{
case 1;b=c*d; break;
Default : b = b++ ; break;
}
(a) 27
(b) 29
(c) 26
O
IF
(d) 24
279. [ Assembler | ISRO CS 2020 ] In a two-pass assembler, resolution of subroutine
calls and inclusion of labels in the symbol table is done during
(a) Second pass
N

(b) First pass and second pass respectively


(c) Second pass and first pass respectively
(d) First pass
A

280. [ Code-Optimization | ISRO CS 2020 ] Which of the following is a type of


out-of-order execution, with the reordering done by a compiler
(a) Loop unrolling
(b) Dead code elimination
M

(c) Strength reduction


(d) Software pipelining
281. [ Ambiguous-and-Unambiguous-Grammar | ISRO CS 2020 ] A given grammar
is called ambiguous if
(a) two or more production have the same non-terminal on the left hand side
(b) A derivation tree has more than one associated sentence
(c) there is a sentence with more than one derivation tree corresponding to it
(d) Brackets are not present in the grammar

www.manifoldkerala.com, Ph: 0487 2382342 65


Compiler Design Manifold Institute of Technical Education

282. [ Compilers | ISRO CS 2020 ] Which one indicate a technique of building cross
compilers?
(a) Beta cross
(b) Canadian cross
(c) Mexican cross
(d) X-cross
283. [ Parsers | ISRO CS 2020 ] Given the grammar
s! T*S | T
T!U+T|U

LD
U!a|b
Which of the following statements is wrong?

(a) Grammar is not ambiguous


(b) Priority of + over * is ensured
(c) Right to left evaluation of * and + happens
(d) None of these

O
284. [ Parsers | APPSC-2016-DL-CS ] Consider the grammar with non-terminals N =
{ S,C,S1} , terminals T = { a,b,i,t,e} , with S as the start symbol, and the following
set of rules:
IF
S – > iCtSS1| a
S1 – > eS | *
C–>b
The grammar is NOT LL(1) because:
N

(a) It is left recursive


(b) It is right recursive
(c) It is ambiguous
A

(d) It is not context-free


285. [ Run-Time-Environment | APPSC-2016-DL-CS ] Which of the following com-
binations of statements is TRUE?
I. There exist parsing algorithms for some programming languages whose com-
M

plexities are less than O(n3).


II. A programming language which allows recursion can be implemented with
static storage allocation.
III. No L-attributed definition can be evaluated in the framework of bottom-up
parsing
IV. Code improving transformations can be performed at both source language
and intermediate code level.
(a) I and II
(b) I and IV

www.manifoldkerala.com, Ph: 0487 2382342 66


Compiler Design Manifold Institute of Technical Education

(c) III and IV


(d) I, III and IV
286. [ Parsers | APPSC-2016-DL-CS ] Which one of the following is a top-down
parser?
(a) Recursive descent parser.
(b) Operator precedence parser.
(c) An LR(k) parser.
(d) An LALR(k) parser

LD
287. [ Synthesized-and-L-Attribute | APPSC-2016-DL-CS ] In a bottom-up evalua-
tion of a syntax directed definition, inherited attributes can
(a) Always be evaluated
(b) Be evaluated only if the definition is L- -attributed
(c) Be evaluated only if the definition has synthesized attributes
(d) Never be evaluated
288. [ Parsers | APPSC-2016-DL-CS ]
state in shift-reduce parsing?
O Which one of the following is True at any valid

(a) Viable preflxes appear only at the bottom of the stack and not inside
(b) Viable prefixes appear only at the top of the stack and not inside
IF
(c) The stack contains only a set of viable prefixes
(d) The stack never contains viable prefixes
289. [ Parsers | CIL 2020 ] Consider the following grammar
N

S ! m | mn | mno

Choose correct statement from the following:


(a) The grammar is LL(4)
A

(b) The grammar is LL(3)


(c) The grammar is LL(2)
(d) The grammar is LL(1)
M

290. [ Compilers | CIL 2020 ] Generation of intermediate code based on an abstract


machine model is useful in compilers because:
(a) It makes implementation of lexical and syntax analysis easier
(b) It is difficult to generate executable code from high level language program
(c) Syntax translations are easier for intermediate code generation
(d) It enhances the portability of the compiler system program
291. [ Parsers | CIL 2020 ] Which of the following derivations does a top-down parser
use while parsing a input string?
The input is assumed to be scanned in left to right order.

www.manifoldkerala.com, Ph: 0487 2382342 67


Compiler Design Manifold Institute of Technical Education

(a) Topmost derivation


(b) Leftmost derivation traced out in reverse
(c) Leftmost derivation
(d) Rightmost derivation
292. [ Parsers | CIL 2020 ] Which of the following statement is true?
(a) The parsers canonical LR and LALR have the same power
(b) LALR parser is more important than canonical LR parser
(c) SLR parser is more powerful than LALR parser

LD
(d) Canonical LR parser is more powerful than LALR parser
293. [ Parsers | CIL 2020 ] Which grammar rules violate the requirement of the oper-
ator grammar? A,B,C are variables and a,b,c are terminals.
I . A ! BC
I I . A ! CcBb
I I I . A ! BaC
IV . A ! 2

(a) I only
(b) I and II
(c) I and III
O
IF
(d) I and IV
294. [ Parsers | CIL 2020 ] Write true (T) / false (F) for each of the following state-
ments:
A. Symbol table is used only in the first phase of a compiler.
N

B. A pretty printer analyses a program and prints it in such a way that the struc-
ture of the program becomes early visible.
C. YACC build up LALR parsing table
D. If a grammar is LALR(1), it is not necessarily SLR(1)
(a) T T F T
A

(b) F T T T
(c) T T T F
(d) F T T F
M

295. [ Parsers | CIL 2020 ] The following grammar is:


S ! Aa | bAc | Bc | bBa
A ! d
B ! d

(a) Not LR(1) but LALR(1)


(b) Neither LR(1) nor LALR(1)
(c) LR(1) and LALR(1)
(d) LR(1) but not LALR(1)

www.manifoldkerala.com, Ph: 0487 2382342 68


Compiler Design Manifold Institute of Technical Education

296. [ Parsers | CIL 2020 ] Consider the grammar

S −−> AbBaCc | 2
A −−> aAb | ba
B −−> bBC | cb
C −−> cCa | ac

Find the first() of S


(a) { a, b, 2 }
(b) { 2 }

LD
(c) { a,2 }
(d) { a,b,c,2 }
297. [ Parsers | CIL 2020 ] The following grammar is:
S ! Aa | b Ac | dc | bda
A ! a

(a) Neither LALR(1) nor SLR(1)


(b) LALR(1) but not SLR(1)
(c) Not LALR(1) but SLR(1)
(d) LALR(1) and SLR(1)
O
IF
298. [ Parsers | APPSC-2012-DL-CS ] Which of the following statements is false?
(a) An unambiguous grammar has the same leftmost and rightmost derivation
(b) An LL(1) parser is a top-down parser
(c) LALR is more powerful than SLR
N

(d) An unambiguous grammar can never be LR(k) for any k


299. [ Compilers | APPSC-2012-DL-CS ] Type checking is normally done during
(a) Lexical Analysis
A

(b) Syntax-directed Translation


(c) Syntax Analysis
(d) Code Optimization
M

300. [ Intermediate-code-generator | TNPSC-2012-Polytechnic-CS ] Which of the


following is not used as an intermediate representation?
(a) Postfix notation
(b) DAG
(c) 3 address code
(d) Context free grammar
301. [ Three-address-code | TNPSC-2012-Polytechnic-CS ] Which of the following
implementations of three address codes occupy less space?
(a) Triple

www.manifoldkerala.com, Ph: 0487 2382342 69


Compiler Design Manifold Institute of Technical Education

(b) Quadruples
(c) Indirect triples
(d) All will occupy same space
302. [ Compilers | TNPSC-2012-Polytechnic-CS ] Macro-expansion type parameter
passing is called as
(a) Call-by value
(b) Call-by reference
(c) Copy-restore

LD
(d) Call-by name
303. [ Ambiguous-and-Unambiguous-Grammar | TNPSC-2012-Polytechnic-CS ] A
given grammar is said to be ambiguous if
(a) Two or more productions have the same non-terminal on the left hand side
(b) A derivation tree has more than one associated sentence
(c) There is a sentence with more than one derivation tree corresponding to it

the compiler are


(a) Syntax errors
O
(d) Brackets are not present in the grammar
304. [ Compilers | TNPSC-2012-Polytechnic-CS ] Errors that can be pointed out by
IF
(b) Semantic errors
(c) Logical errors
(d) Internal errors
305. [ Symbol-Table | TNPSC-2012-Polytechnic-CS ] Search tables used by compilers
N

for efficient searching generally use


(a) Hash tables
(b) Linear lists of records
A

(c) Binary search tables


(d) Binary search trees
306. [ Symbol-Table | TNPSC-2012-Polytechnic-CS ] Uniform symbol table
(a) Contains all constants in the program
M

(b) Is a permanent table of division rules in the form of patterns for matching with
the uniform symbol table to discover syntactic structure
(c) Consists of full or partial list of the tokens as they appear in the program,
created by Lexical Analysis and used for syntax analysis and interpretation
(d) A permanent table which lists all key words and special symbols of the lan-
guage in symbolic form
307. [ Run-Time-Environment | APPSC-2012-DL-CS ] Heap allocation is required
for language
(a) That support recursion

www.manifoldkerala.com, Ph: 0487 2382342 70


Compiler Design Manifold Institute of Technical Education

(b) That support dynamic data structures


(c) That use dynamic scope rules
(d) None
308. [ Parsers | APPSC-2012-DL-CS ] Which of the following derivations does a
top-down parser use while parsing an input string? The input is assumed to
be scanned in left to right order.
(a) Leftmost Derivation
(b) Leftmost Derivation traced out in reverse
(c) Rightmost Derivation

LD
(d) Rightmost Derivation traced out in reverse
309. [ Phases-of-Compilers | APPSC-2012-DL-CS ] The output of a lexical analyzer
is
(a) Machine Code
(b) Intermediate Code
(c) A Stream of Tokens
(d) A Parse Tree O
310. [ Parsers | TNPSC-2017-Polytechnic-CS ] The grammar A! AA| (A)| 2 is not
suitable for predictive parsing because the grammar is:
IF
(a) Ambiguous
(b) Left - Recursive
(c) Right Recursive
N

(d) An operator grammar


311. [ Phases-of-Compilers | TNPSC-2017-Polytechnic-CS ] An example for a pattern
- scanning language is :
(a) lex
A

(b) awk
(c) bison
(d) yacc
M

312. [ Grammars | TNPSC-2017-Polytechnic-CS ] Consider the following grammar :

S ! L| a L ! LS | S

After the elimination of left - recursion, we get the following:


(a) S! L| a L! SA A! SA| 2
(b) S! L| A A! SAL L! aSL| 2
(c) S! L| 2 L! SA A! SA| 2
(d) S! L| a A! aSA| 2 L! aSA

www.manifoldkerala.com, Ph: 0487 2382342 71


Compiler Design Manifold Institute of Technical Education

313. [ Parsers | TNPSC-2017-Polytechnic-CS ] Consider the grammar


S! AS/b A! SA / a then Closure (S’! .S,$ ) is:

(a) S1 ! .S,$
S! .AS,$ / a/b
S! .b,$ /a/b
A! .SA, a/b
A! .a,a /b

(b) S1 ! .S,$
S! .AS,$ s/ b
S! .b,$ / b

LD
(c) S1 ! .S,$
S! .AS,$ / a/b
S! .AS,$ / a/b
S! .b,$ / a/b

(d) S1 ! .S,$
S! .AS,$
S! .b,$

O
314. [ Ambiguous-and-Unambiguous-Grammar | UGC NET CS 2014 June-paper-3 ]
Given the following two grammars :

G1 : S ! AB | aaB A ! a | Aa B ! b
IF
G2 : S ! a S b S | b S a S | l

Which statement is correct ?


N

(a) G1 is unambiguous and G2 is unambiguous.

(b) G1 is unambiguous and G2 is ambiguous.

(c) G1 is ambiguous and G2 is unambiguous.


A

(d) G1 is ambiguous and G2 is ambiguous.

315. [ Lexical-Analyzer | UGC NET CS 2014 Dec - paper-3 ]


How many tokens will be generated by the scanner for the following statement ?
M

x = x * (a + b) - 5;

(a) 12

(b) 11

(c) 10

(d) 07

316. [ Grammars | TIFR PHD CS & SS 2015 ]

www.manifoldkerala.com, Ph: 0487 2382342 72


Compiler Design Manifold Institute of Technical Education

LD
O
IF
N
A
M

(a) a

(b) b

(c) c

(d) d

(e) e

317. [ Parsers | TIFR PHD CS & SS 2012 ] Consider the parse tree

www.manifoldkerala.com, Ph: 0487 2382342 73


Compiler Design Manifold Institute of Technical Education

LD
Assume that * has higher precedence than +, - and operators associate right to left
(i.e. a + b + c =(a + (b + c))). Consider
(i) 2 + a - b
(ii) 2 + a - b * a + b
(iii) (2 + ((a - b) * (a + b)))
(iv) 2 + (a - b) * (a + b)
The parse tree corresponds to
(a) Expression (i)
(b) Expression (ii)
(c) Expression (iv) only
(d) Expression (ii), (iii) and (iv)
O
IF
(e) Expressions (iii) and (iv) only
318. [ Parsers | TIFR PHD CS & SS 2012 ] Which of the following correctly describes
LR(k) parsing?
(a) The input string is alternately scanned left to right and right to left with k
N

reversals.
(b) Input string is scanned once Left to Right with rightmost derivation and k
symbol look-ahead
(c) LR(k) grammers are expressively as powerful as context-free grammers.
A

(d) Parser makes k left-to-right passes over input string


(e) Input string is scanned from left to right once with k symbol to the right as
look-ahead to give left-most derivation.
M

319. [ Grammars | TIFR PHD CS & SS 2020 ] A particular Panini-Backus-Naur Form


definition for a < word > is given by the following rules:

Which of the following lexical entities can be derived from < word > ?

www.manifoldkerala.com, Ph: 0487 2382342 74


Compiler Design Manifold Institute of Technical Education

I. word
II. words
III. c22
(a) None of I, II or III
(b) I and II only
(c) I and III only
(d) II and III only
(e) I, II and III

LD
1.2 Solutions

1. B 27. D 53. A 79. B 105. B 131. A 157. B 183. A


2. B 28. D 54. A 80. C 106. A 132. B 158. C 184. D
3. B 29. D 55. B 81. D 107. C 133. D 159. B 185. C
4. B 30. C 56. A 82. A 108. A 134. A 160. B 186. C
5. B
6. A
7. D
8. B
31. B
32. B
33. A
34. A
57. C
58. C
59. C
60. B
O
83. B
84. B
85. B
86. A
109. C
110. A
111. A
112. D
135. B
136. A
137. C
138. B
161. B
162. D
163. A
164. C
187. B
188. C
189. A
190. B
IF
9. C 35. A 61. D 87. C 113. D 139. C 165. B 191. D
10. A 36. C 62. A 88. A 114. D 140. D 166. A 192. B
11. A 37. D 63. A 89. A 115. D 141. D 167. C 193. B
N

12. C 38. A 64. D 90. A 116. E 142. D 168. A 194. D


13. A 39. D 65. D 91. A 117. A 143. D 169. B 195. B
14. C 40. A 66. A 92. C 118. A 144. C 170. D 196. B
15. A 41. C 67. D 93. A 119. B 145. A 171. B 197. A
A

16. C 42. A 68. B 94. B 120. F 146. B 172. D 198. C


17. B 43. C 69. A 95. A 121. A 147. B 173. D 199. B
18. B 44. B 70. C 96. B 122. A 148. D 174. A 200. A
M

19. C 45. D 71. B 97. C 123. A 149. A 175. D 201. D


20. A 46. B 72. B 98. C 124. C 150. B 176. C 202. B
21. A 47. C 73. C 99. C 125. A 151. B 177. B 203. E
22. C 48. B 74. B 100. C 126. A 152. D 178. B 204. D
23. C 49. C 75. C 101. A 127. C 153. D 179. D 205. A
24. C 50. B 76. C 102. C 128. D 154. B 180. B 206. D
25. B 51. B 77. D 103. D 129. C 155. C 181. C 207. D
26. C 52. D 78. B 104. B 130. D 156. B 182. C 208. C

www.manifoldkerala.com, Ph: 0487 2382342 75


Compiler Design Manifold Institute of Technical Education

209. B 223. D 237. C 251. A 265. A 279. C 293. D 307. B


210. D 224. D 238. C 252. D 266. C 280. A 294. B 308. A
211. C 225. C 239. D 253. B 267. C 281. C 295. D 309. C
212. D 226. D 240. B 254. C 268. D 282. B 296. A 310. A
213. B 227. C 241. D 255. C 269. B 283. D 297. D
311. A
214. D 228. C 242. D 256. D 270. A 284. C 298. A
312. A
215. C 229. B 243. D 257. C 271. C 285. B 299. B
313. A
216. A 230. B 244. A 258. A 272. D 286. A 300. D

LD
314. D
217. B 231. B 245. C 259. B 273. B 287. D 301. C
315. A
218. B 232. D 246. B 260. A 274. A 288. C 302. C
219. B 233. B 247. A 261. A 275. B 289. B 303. C 316. B

220. C 234. D 248. D 262. B 276. B 290. D 304. A 317. E

221. A 235. A 249. D 263. A 277. A 291. C 305. A 318. B

222. C 236. C 250. A 264. A 278. C 292. D 306. C 319. D

O
IF
N
A
M

www.manifoldkerala.com, Ph: 0487 2382342 76

You might also like