Question 1 | MCQ
THIS IS QUESTION PAPER FOR THE SUBJECT "DEGREE LEVEL : COMPILER DESIGN (COMPUTER
BASED EXAM)"
ARE YOU SURE YOU HAVE TO WRITE EXAM FOR THIS SUBJECT?
CROSS CHECK YOUR HALL TICKET TO CONFIRM THE SUBJECTS TO BE WRITTEN.
(IF IT IS NOT THE CORRECT SUBJECT, PLS CHECK THE SECTION AT THE TOP FOR THE SUBJECTS REGISTERED BY YOU)
BASED EXAM)"
ARE YOU SURE YOU HAVE TO WRITE EXAM FOR THIS SUBJECT?
CROSS CHECK YOUR HALL TICKET TO CONFIRM THE SUBJECTS TO BE WRITTEN.
(IF IT IS NOT THE CORRECT SUBJECT, PLS CHECK THE SECTION AT THE TOP FOR THE SUBJECTS REGISTERED BY YOU)
Solution
A programmer writes an expression with mismatched grouping:
.
Which compiler phase detects the missing closing parenthesis?
Which compiler phase detects the missing closing parenthesis?
Solution
Why does the Static Single Assignment (SSA) form simplify compiler optimization and dataflow analysis?
Solution
Why do bottom-up LR parser generators (like Bison) handle left-recursive grammar rules efficiently, whereas predictive top-down LL(1) parsers cannot parse them directly?
Solution
Consider the semantic rules associated with production
:
-
-
-
-
Which classification accurately describes this Syntax-Directed Definition (SDD)?
-
-
-
-
Which classification accurately describes this Syntax-Directed Definition (SDD)?
Solution
A compiler permits implicit widening (
) but reports semantic errors for implicit narrowing conversions (
or
).
Given functions
and variables
, which function call compiles without semantic errors?
Given functions
Solution
If a compiler designer removes the marker production
from
and parses
while attempting to create the symbol table upon reduction of
, what semantic- action/symbol-table problem occurs during parsing?
Solution
In a
loop containing a
statement, what is the precise control-flow target address to which the
jump must be backpatched?
Solution
During compilation of a function body, the compiler encounters a local variable declaration
inside an inner block, while a parameter named
exists at the function level. Which statement correctly describes how the symbol table handles this declaration?
Solution
What is the defining structural invariant of Static Single Assignment (SSA) form?
Solution
In Local Value Numbering (LVN), what value number is assigned to a copy statement
?
Solution
Inscript
A lexical analyzer uses standard Lex rules to tokenize an input stream. Code snippet

Input:

How many total tokens are produced by the lexical analyzer for this input?
A lexical analyzer uses standard Lex rules to tokenize an input stream. Code snippet
Input:
How many total tokens are produced by the lexical analyzer for this input?
Solution
Inscript
Consider the following expression grammar:



How many derivation steps are required in the rightmost derivation of the string

from the start symbol E?
Consider the following expression grammar:
How many derivation steps are required in the rightmost derivation of the string
from the start symbol E?
Solution
Inscript
Consider the augmented grammar:




How many total
items are present in state
?
Consider the augmented grammar:
How many total
Solution
Inscript
Consider the Boolean expression:

Using the standard syntax-directed translation with backpatching for Boolean expressions, assume that:
- Each relational expression
generates two consecutive TAC instructions:
1. A conditional jump:
2. An unconditional jump:
- The
counter gives the address of the next generated instruction.
- Initially,
.
- The logical NOT operator
only swaps the
and
and does not generate additional instructions.
At which instruction number is the conditional jump for the comparison
generated?
Consider the Boolean expression:
Using the standard syntax-directed translation with backpatching for Boolean expressions, assume that:
- Each relational expression
1. A conditional jump:
2. An unconditional jump:
- The
- Initially,
- The logical NOT operator
At which instruction number is the conditional jump for the comparison
Solution
Consider the Deterministic Finite Automaton (DFA)
where:
-
-
-
-
The transition function δ is defined as:

Which of the following strings will be accepted by this DFA? (Select all that apply)
-
-
-
-
The transition function δ is defined as:
Which of the following strings will be accepted by this DFA? (Select all that apply)
Solution
Consider the following standard expression grammar:





What is
?
What is
Solution
Given pointer
of type
and integer
, where
. When translating the pointer arithmetic expression
, which TAC sequence correctly computes the resulting address?
Solution
Consider the Three-Address Code block:

Which of the following is the correct set of instruction leaders for basic block partitioning?
Which of the following is the correct set of instruction leaders for basic block partitioning?
Solution
Inscript
A compiler translates the expression
without optimization or common subexpression elimination. Each binary operation generates exactly one binary arithmetic TAC instruction. How many binary arithmetic TAC instructions are emitted?
A compiler translates the expression
Solution
Consider the following program with nested declarations:

Which statements are TRUE regarding the variable bindings?
Which statements are TRUE regarding the variable bindings?
Solution
Consider the TAC basic blocks:

Which of the following statements are correct at the entry of basic block B2?
Which of the following statements are correct at the entry of basic block B2?
Solution
Shape
Thickness [ / ]
3
All colors