Compiler Construction MCQs with Answers
Practice important Compiler Construction MCQs with answers and explanations.
Chapter: 35
Q981:
Which IR form is more concise than a parse tree but retains the structure of source code?
A. Abstract Syntax Tree (AST)
B. Directed Acyclic Graph (DAG)
C. Three-address code
D. Stack-machine code
Correct Answer:
A
Chapter: 35
Q982:
The IR form that represents the program in a graph form is called ______.
A. Graphical IR
B. Linear IR
C. Hybrid IR
D. Parse Tree
Correct Answer:
A
Chapter: 35
Q983:
Which IR form is closest to assembly language code?
A. Linear IR
B. Graphical IR
C. Hybrid IR
D. Source code
Correct Answer:
A
Chapter: 36
Q984:
Three-address code is attractive because it allows the compiler to reuse ______.
A. names and values
B. operators
C. memory blocks
D. registers
Correct Answer:
A
Chapter: 36
Q985:
The typical size of operations in three-address code is about ______ bytes.
A. 1 to 2
B. 2 to 3
C. 3 to 4
D. 4 to 5
Correct Answer:
A
Chapter: 36
Q986:
The typical size of addresses in three-address code is ______ bytes.
A. 2
B. 3
C. 4
D. 5
Correct Answer:
C
Chapter: 36
Q987:
In the production S → id = E, the translation scheme uses ______ to find the identifier.
A. emit
B. lookup
C. newtemp
D. install
Correct Answer:
B
Chapter: 36
Q988:
In the rule E → E1 + E2, a new temporary is created using ______.
A. emit
B. lookup
C. newtemp
D. install
Correct Answer:
C
Chapter: 36
Q989:
The translation scheme function that generates a three-address statement is called ______.
A. lookup
B. emit
C. newtemp
D. install
Correct Answer:
B
Chapter: 36
Q990:
The routine that checks if a name is in the symbol table is called ______.
A. newtemp
B. install
C. lookup
D. emit
Correct Answer:
C
Chapter: 36
Q991:
The routine that returns a new temporary variable is called ______.
A. lookup
B. emit
C. newtemp
D. install
Correct Answer:
C
Chapter: 36
Q992:
The symbol table can be implemented as a ______ for efficient lookup.
A. binary tree
B. hash table
C. linked list
D. stack
Correct Answer:
B
Chapter: 36
Q993:
The attribute that records the symbol table location in translation is called ______.
A. E.name
B. E.place
C. E.value
D. E.temp
Correct Answer:
B
Chapter: 36
Q994:
The production E → – E1 generates code using ______ to negate the operand.
A. newtemp
B. emit
C. lookup
D. install
Correct Answer:
B
Chapter: 36
Q995:
The translation scheme for E → E1 * E2 generates a three-address code using the operator ______.
A. +
B. *
C. -
D. /
Correct Answer:
B
Chapter: 36
Q996:
The translation scheme for E → id uses ______ to get the address of id.
A. newtemp
B. lookup
C. emit
D. install
Correct Answer:
B
Chapter: 36
Q997:
Three-address code is reasonably ______ compared to other IR forms.
A. verbose
B. compact
C. complex
D. slow
Correct Answer:
B
Chapter: 36
Q998:
In three-address code, the statement format is generally:
A. x ← y op z
B. op x y z
C. y ← op x z
D. x ← op y z
Correct Answer:
A
Chapter: 36
Q999:
The purpose of newtemp() is to generate ______.
A. new operators
B. new symbol table entries
C. new temporary variables
D. new identifiers
Correct Answer:
C
Chapter: 36
Q1000:
In the translation scheme, E → ( E1 ) sets E.place to ______.
A. E1.place
B. newtemp()
C. id.name
D. emit statement
Correct Answer:
A