Compiler Design MCQs - Unit 2
A
tokens
B
lexemes
C
registers
D
productions
Correct Answer
productions
A
it has no start symbol
B
some string has more than one parse tree
C
it has no terminals
D
every string has exactly one parse tree
Correct Answer
some string has more than one parse tree
A
run faster
B
go into an infinite loop
C
stop immediately with success
D
skip tokens
Correct Answer
go into an infinite loop
A
A → αA and A → β
B
A → βA′ and A′ → αA′ | ε
C
A → Aβ | α
D
A → ε
Correct Answer
A → βA′ and A′ → αA′ | ε
A
make a grammar ambiguous
B
remove all terminals
C
make a grammar suitable for predictive parsing
D
increase the number of states
Correct Answer
make a grammar suitable for predictive parsing
A
from the leaves up to the root
B
from the middle outwards
C
without any tree
D
from the root down to the leaves
Correct Answer
from the root down to the leaves
A
leftmost derivation
B
rightmost derivation in reverse
C
random derivation
D
no derivation
Correct Answer
rightmost derivation in reverse
A
from left to right
B
from right to left
C
in the middle only
D
at random
Correct Answer
from left to right
A
only a queue
B
only a hash table
C
no data structure
D
a parsing table and a stack
Correct Answer
a parsing table and a stack
A
terminals that can begin strings derived from A
B
terminals that can end strings derived from A
C
all non-terminals
D
all productions of A
Correct Answer
terminals that can begin strings derived from A
A
terminals that begin A
B
terminals that can appear immediately to the right of A
C
non-terminals only
D
productions of A
Correct Answer
terminals that can appear immediately to the right of A
A
ε
B
$ (the end marker)
C
the first terminal
D
the empty set
Correct Answer
$ (the end marker)
A
error
B
jump
C
load
D
store
Correct Answer
error
A
matches the left side of every production
B
is always a terminal
C
is always the empty string
D
matches the right side of a production and whose reduction is a step in a reverse rightmost derivation
Correct Answer
matches the right side of a production and whose reduction is a step in a reverse rightmost derivation
A
constructing a rightmost derivation in reverse
B
reading the input from right to left
C
recursion
D
repetition
Correct Answer
constructing a rightmost derivation in reverse
A
SLR
B
Canonical LR (CLR)
C
LALR
D
LL(1)
Correct Answer
Canonical LR (CLR)
A
lookahead only
B
core
C
name
D
number of items
Correct Answer
core
A
FIRST sets only
B
random choice
C
FOLLOW sets
D
the input length
Correct Answer
FOLLOW sets
A
lexical analyzer generator
B
code optimizer
C
linker
D
parser generator
Correct Answer
parser generator
A
the input is empty
B
the stack is empty
C
the parser cannot decide whether to shift or to reduce
D
the grammar has no productions
Correct Answer
the parser cannot decide whether to shift or to reduce
A
precedence and associativity of operators
B
more terminals
C
a longer input
D
extra comments
Correct Answer
precedence and associativity of operators
A
Recursive-descent parser
B
LL(1) parser
C
Predictive parser
D
SLR parser
Correct Answer
SLR parser
A
a single table only
B
only one variable
C
a set of procedures, one for each non-terminal
D
a symbol table only
Correct Answer
a set of procedures, one for each non-terminal
A
discards input symbols until a synchronizing token is found
B
stops the compilation immediately
C
inserts random code
D
restarts from the first line
Correct Answer
discards input symbols until a synchronizing token is found
A
left-recursive or ambiguous
B
context-free
C
written with terminals
D
written with productions
Correct Answer
left-recursive or ambiguous
Fill in the Blanks
26
A context-free grammar consists of terminals, non-terminals, a start symbol and ______.
Correct Answer
productions
27
A grammar that produces more than one parse tree for some string is called ______.
Correct Answer
ambiguous
28
Eliminating left recursion from A → Aα | β gives A′ → αA′ | ______.
Correct Answer
ε
29
In LL(1), the second L stands for a ______ derivation.
Correct Answer
leftmost
30
The ______ of the start symbol always contains the end marker $.
Correct Answer
FOLLOW
31
Bottom-up parsing produces a rightmost derivation in ______.
Correct Answer
reverse
32
A substring that matches the right side of a production and can be reduced is called a ______.
Correct Answer
handle
33
The actions of a shift-reduce parser are shift, reduce, accept and ______.
Correct Answer
error
34
SLR parsers use ______ sets to decide where to place reduce actions.
Correct Answer
FOLLOW
35
Of SLR, LALR and CLR, the most powerful parser is ______.
Correct Answer
CLR (canonical LR)
36
LALR parsers merge LR(1) states that have the same ______.
Correct Answer
core
37
______ is a widely used LALR parser generator.
Correct Answer
Yacc
38
A ______ conflict occurs when the parser cannot decide whether to shift or reduce.
Correct Answer
shift-reduce
39
A recursive-descent parser has one ______ for each non-terminal.
Correct Answer
procedure
40
In panic-mode recovery, the parser discards input ______ until a synchronizing token is found.
Correct Answer
symbols (tokens)