Compiler Design MCQs - Unit 3
A
only tokens
B
only a symbol table
C
only machine code
D
attributes and semantic rules
Correct Answer
attributes and semantic rules
A
inherited
B
global
C
synthesized
D
constant
Correct Answer
synthesized
A
synthesized
B
inherited
C
terminal
D
static
Correct Answer
inherited
A
inherited attributes
B
no attributes
C
global variables
D
synthesized attributes
Correct Answer
synthesized attributes
A
siblings to its right only
B
children only
C
grandchildren only
D
siblings to its left
Correct Answer
siblings to its left
A
top-down only
B
random order
C
reverse input order
D
bottom-up (post-order) fashion
Correct Answer
bottom-up (post-order) fashion
A
the number of tokens
B
the size of the symbol table
C
the machine registers
D
a valid order of evaluating attributes
Correct Answer
a valid order of evaluating attributes
A
annotated parse tree
B
abstract tree
C
binary tree only
D
empty tree
Correct Answer
annotated parse tree
A
no productions
B
only attributes
C
semantic actions embedded in the production bodies
D
only tokens
Correct Answer
semantic actions embedded in the production bodies
A
at the right end of the production
B
at the left end of the production
C
in the middle only
D
outside the grammar
Correct Answer
at the right end of the production
A
increase the number of nodes
B
remove all operators
C
store tokens
D
identify common subexpressions
Correct Answer
identify common subexpressions
A
two operators on the right side
B
three operators on the right side
C
no operands
D
one operator on the right side
Correct Answer
one operator on the right side
A
quadruples, triples and indirect triples
B
tokens, lexemes and patterns
C
stacks, queues and trees
D
bytes, words and pages
Correct Answer
quadruples, triples and indirect triples
A
two
B
three
C
four
D
five
Correct Answer
four
A
two
B
four
C
three
D
five
Correct Answer
three
A
a list of pointers to triples
B
four fields per entry
C
no pointers
D
only registers
Correct Answer
a list of pointers to triples
A
every variable has a short name
B
operands are of compatible types for the operator
C
the source file is small
D
comments are removed
Correct Answer
operands are of compatible types for the operator
A
implicit conversion (coercion)
B
explicit cast
C
overloading
D
linking
Correct Answer
implicit conversion (coercion)
A
remove dead code
B
allocate registers
C
fill in jump targets that are not known when the jump is generated
D
scan the input
Correct Answer
fill in jump targets that are not known when the jump is generated
A
no code at all
B
jumping code
C
only registers
D
only the symbol table
Correct Answer
jumping code
A
a jump table or a sequence of conditional jumps
B
only a for loop
C
only a stack
D
no jumps
Correct Answer
a jump table or a sequence of conditional jumps
A
declare a variable
B
pass an actual parameter
C
return a value
D
end the program
Correct Answer
pass an actual parameter
A
it makes the program run slower
B
it removes the need for a parser
C
it avoids type checking
D
it makes the compiler easier to retarget to other machines
Correct Answer
it makes the compiler easier to retarget to other machines
Correct Answer
2
A
they have the same structure
B
they have the same name only
C
they are declared in the same line
D
they use the same colour
Correct Answer
they have the same structure
Fill in the Blanks
26
A syntax-directed definition is a context-free grammar with attributes and ______ rules.
Correct Answer
semantic
27
An attribute computed from the attributes of its children is called ______.
Correct Answer
synthesized
28
An attribute computed from its parent and siblings is called ______.
Correct Answer
inherited
29
An S-attributed definition uses only ______ attributes.
Correct Answer
synthesized
30
A ______ graph is used to decide the order of evaluating attributes.
Correct Answer
dependency
31
A parse tree that shows the attribute values at each node is called an ______ parse tree.
Correct Answer
annotated
32
A ______ for an expression identifies its common subexpressions.
Correct Answer
DAG (directed acyclic graph)
33
In three-address code, there is at most ______ operator on the right side of an instruction.
Correct Answer
one
34
Three-address code can be stored as quadruples, triples and ______.
Correct Answer
indirect triples
35
A quadruple has ______ fields.
Correct Answer
four
36
______ is the technique of filling in jump targets after they become known.
Correct Answer
Backpatching
37
A type conversion inserted automatically by the compiler is called ______ conversion.
Correct Answer
implicit
38
In an L-attributed definition, an inherited attribute may depend on the parent and the ______ siblings.
Correct Answer
left
39
Intermediate code is independent of the ______ machine.
Correct Answer
target
40
Boolean expressions in control flow are translated using ______ code.
Correct Answer
jumping