Compiler Design MCQs - Unit 1
A
lexical analysis
B
syntax analysis
C
semantic analysis
D
code generation
Correct Answer
lexical analysis
A
parse trees
B
tokens
C
machine instructions
D
symbol tables
Correct Answer
tokens
A
parse tree (syntax tree)
B
stream of characters
C
object file
D
list of tokens
Correct Answer
parse tree (syntax tree)
A
lexical analysis
B
code generation
C
linking
D
semantic analysis
Correct Answer
semantic analysis
A
target machine code
B
intermediate representation
C
source code
D
a token
Correct Answer
intermediate representation
A
store the machine code
B
store the source file
C
store the compiler's own code
D
store information about identifiers such as name, type and scope
Correct Answer
store information about identifiers such as name, type and scope
A
executes the source statement by statement
B
never produces output
C
translates the whole source program into a target program
D
works only on assembly code
Correct Answer
translates the whole source program into a target program
A
Lexical analysis
B
Syntax analysis
C
Semantic analysis
D
Code generation
Correct Answer
Code generation
A
pattern
B
lexeme
C
grammar
D
production
Correct Answer
lexeme
A
pattern
B
lexeme
C
symbol
D
handle
Correct Answer
pattern
A
white space and comments
B
all identifiers
C
all operators
D
all keywords
Correct Answer
white space and comments
A
encrypt the input
B
store tokens
C
generate code
D
reduce the number of tests needed to detect the end of the buffer
Correct Answer
reduce the number of tests needed to detect the end of the buffer
A
parsers
B
lexical analyzers
C
code generators
D
linkers
Correct Answer
lexical analyzers
A
one
B
three (declarations, translation rules, auxiliary functions)
C
two
D
five
Correct Answer
three (declarations, translation rules, auxiliary functions)
A
all strings of a's and b's, including the empty string
B
only the string ab
C
only strings of a's
D
only non-empty strings
Correct Answer
all strings of a's and b's, including the empty string
A
exactly one transition for each input symbol from each state
B
ε-transitions
C
more than one start state
D
no final states
Correct Answer
exactly one transition for each input symbol from each state
A
exactly one transition per symbol
B
no transitions
C
only one state
D
ε-transitions and multiple transitions on the same symbol
Correct Answer
ε-transitions and multiple transitions on the same symbol
A
Thompson's construction
B
subset construction
C
Kleene's closure
D
Huffman coding
Correct Answer
subset construction
A
Thompson's construction
B
subset construction
C
LR construction
D
Prim's algorithm
Correct Answer
Thompson's construction
A
increase the number of states
B
add ε-transitions
C
reduce the number of states
D
remove the start state
Correct Answer
reduce the number of states
A
FOLLOW of a grammar symbol
B
gotopos
C
shiftpos
D
followpos
Correct Answer
followpos
A
reachable from it using ε-transitions only
B
reachable using any one symbol
C
that are final only
D
that have no outgoing edges
Correct Answer
reachable from it using ε-transitions only
A
A type mismatch
B
A missing return value
C
An undefined function call
D
An illegal character in the source program
Correct Answer
An illegal character in the source program
Correct Answer
7
A
dynamic scope
B
global scope only
C
static (lexical) scope
D
run-time scope
Correct Answer
static (lexical) scope
Fill in the Blanks
26
The first phase of a compiler is ______ analysis.
Correct Answer
lexical
27
A sequence of characters in the source program that matches the pattern of a token is called a ______.
Correct Answer
lexeme
28
______ is a tool that generates lexical analyzers.
Correct Answer
Lex
29
An NFA is converted into a DFA using the ______ construction.
Correct Answer
subset
30
A regular expression is converted into an NFA using ______ construction.
Correct Answer
Thompson's
31
The ______ of a state is the set of states reachable from it using only ε-transitions.
Correct Answer
ε-closure
32
The ______ table stores information about the identifiers in the source program.
Correct Answer
symbol
33
In input buffering, a ______ character marks the end of a buffer.
Correct Answer
sentinel
34
The lexical analyzer reads the ______ program and produces a stream of tokens.
Correct Answer
source
35
DFA minimization reduces the number of ______.
Correct Answer
states
36
The output of the lexical analyzer is a stream of ______.
Correct Answer
tokens
37
A compiler that runs on one machine and produces code for a different machine is called a ______ compiler.
Correct Answer
cross
38
The analysis part (front end) of a compiler is independent of the ______ machine.
Correct Answer
target
39
An ______ translates and executes the source program statement by statement.
Correct Answer
interpreter
40
Scope that is determined from the program text at compile time is called ______ scope.
Correct Answer
static (lexical)