cs4032_2026T2_ET_FN.pdf
Compiler Design · End Term · May 2026 FN
← Course papers · Start practice / exam
Questions and published explanations below are available without starting a test. Some questions may not have a published solution yet.
Question 2 MCQ · 2.0 marks
A programmer writes an expression with mismatched grouping:
[[IMAGE:359b4f7928435d09_2_2]] .
Which compiler phase detects the missing closing parenthesis?

Lexical Analyzer
Syntax Analyzer (Parser)
Semantic Analyzer
Code Optimizer
A published solution is not available for this question yet.
Question 3 MCQ · 2.0 marks
Why does the Static Single Assignment (SSA) form simplify compiler optimization and dataflow
analysis?
It gives each definition a unique SSA name so that every SSA name has exactly
one static definition, simplifying def-use chains.
It converts non-deterministic context-free grammars into deterministic
parsing tables.
It directly maps high-level syntax into binary machine code without an
assembler.
It automatically executes hot code blocks dynamically at runtime.
A published solution is not available for this question yet.
Question 4 MCQ · 2.0 marks
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?
LR parsers shift input symbols and reduce recognized handles rather than
recursively expanding the leftmost nonterminal, so left recursion does not cause infinite recursive
expansion.
LR parsers convert left recursion to right recursion at compile time.
Top-down parsers use state-splitting algorithms that eliminate shift actions.
LR parsers construct leftmost derivations.
A published solution is not available for this question yet.
Question 5 MCQ · 2.0 marks
Consider the semantic rules associated with production [[IMAGE:359b4f7928435d09_3_3]] :
• [[IMAGE:359b4f7928435d09_3_4]]
• [[IMAGE:359b4f7928435d09_3_5]]
• [[IMAGE:359b4f7928435d09_3_6]]
• [[IMAGE:359b4f7928435d09_3_7]]
Which classification accurately describes this Syntax-Directed Definition (SDD)?





It is an S-attributed definition because [[IMAGE:359b4f7928435d09_3_8]] is synthesized.

It is an L-attributed definition because inherited attributes depend only on
parent attributes and left-sibling attributes.
It is not L-attributed because [[IMAGE:359b4f7928435d09_3_9]] depends on multiple preceding siblings.

It contains a cyclic dependency preventing evaluation.
A published solution is not available for this question yet.
Question 6 MCQ · 2.0 marks
A compiler permits implicit widening ( [[IMAGE:359b4f7928435d09_4_10]] ) but reports semantic errors for
implicit narrowing conversions ( [[IMAGE:359b4f7928435d09_4_11]] or [[IMAGE:359b4f7928435d09_4_12]] ).
Given functions [[IMAGE:359b4f7928435d09_4_13]] and variables [[IMAGE:359b4f7928435d09_4_14]] ,
which function call compiles without semantic errors?





[[IMAGE:359b4f7928435d09_4_15]]

[[IMAGE:359b4f7928435d09_4_16]]

[[IMAGE:359b4f7928435d09_4_17]]

[[IMAGE:359b4f7928435d09_4_18]]

A published solution is not available for this question yet.
Question 7 MCQ · 2.0 marks
If a compiler designer removes the marker production [[IMAGE:359b4f7928435d09_4_19]] from [[IMAGE:359b4f7928435d09_4_20]] and parses
[[IMAGE:359b4f7928435d09_4_21]] while attempting to create the symbol table upon reduction of [[IMAGE:359b4f7928435d09_4_22]] , what semantic-
action/symbol-table problem occurs during parsing?




The parser cannot perform any shift actions.
The lexer stops emitting token codes.
Identifiers encountered inside [[IMAGE:359b4f7928435d09_4_23]] attempt to enter their scope records into a
symbol table that has not yet been initialized.

All variable data sizes default to 0 bytes.
A published solution is not available for this question yet.
Question 8 MCQ · 2.0 marks
In a [[IMAGE:359b4f7928435d09_4_24]] loop containing a [[IMAGE:359b4f7928435d09_4_25]] statement, what is the precise control-flow
target address to which the [[IMAGE:359b4f7928435d09_4_26]] jump must be backpatched?



The first instruction of the loop body [[IMAGE:359b4f7928435d09_4_27]] .

The instruction marking the beginning of the condition evaluation [[IMAGE:359b4f7928435d09_5_28]] .

The instruction immediately following the [[IMAGE:359b4f7928435d09_5_29]] condition (the loop exit).

The start of the surrounding function activation block.
A published solution is not available for this question yet.
Question 9 MCQ · 2.0 marks
During compilation of a function body, the compiler encounters a local variable declaration
[[IMAGE:359b4f7928435d09_5_30]] inside an inner block, while a parameter named [[IMAGE:359b4f7928435d09_5_31]] exists at the function level.
Which statement correctly describes how the symbol table handles this declaration?


It emits a fatal redeclaration error because identifier [[IMAGE:359b4f7928435d09_5_32]] already exists in
an enclosing table.

It accepts the declaration into the current inner block table because
redeclaration checks examine only the current local scope ( [[IMAGE:359b4f7928435d09_5_33]] ).

It overwrites the parameter [[IMAGE:359b4f7928435d09_5_34]] in the function-level table.

It automatically renames the variable to avoid shadowing.
A published solution is not available for this question yet.
Question 10 MCQ · 2.0 marks
What is the defining structural invariant of Static Single Assignment (SSA) form?
Every source variable can only be modified at runtime once during execution.
Every SSA variable name has exactly one static definition in the intermediate
representation.
No conditional jumps or loop structures are permitted in the control flow
graph.
All variables are allocated exclusively to hardware registers.
A published solution is not available for this question yet.
Question 11 MCQ · 2.0 marks
In Local Value Numbering (LVN), what value number is assigned to a copy statement [[IMAGE:359b4f7928435d09_6_35]] ?

[[IMAGE:359b4f7928435d09_6_36]] is assigned the existing value number of [[IMAGE:359b4f7928435d09_6_37]] ( [[IMAGE:359b4f7928435d09_6_38]] ).



A brand new, unique value number is generated for [[IMAGE:359b4f7928435d09_6_39]] .

[[IMAGE:359b4f7928435d09_6_40]] receives a value number only after an arithmetic operation is performed.

The value number of [[IMAGE:359b4f7928435d09_6_41]] is reset to null.

A published solution is not available for this question yet.
Question 12 NAT · 3.0 marks
A lexical analyzer uses standard Lex rules to tokenize an input stream.
Code snippet
[[IMAGE:359b4f7928435d09_6_42]]
Input:
[[IMAGE:359b4f7928435d09_6_43]]
How many total tokens are produced by the lexical analyzer for this input?


A published solution is not available for this question yet.
Question 13 NAT · 3.0 marks
Consider the following expression grammar:
[[IMAGE:359b4f7928435d09_7_44]]
[[IMAGE:359b4f7928435d09_7_45]]
[[IMAGE:359b4f7928435d09_7_46]]
How many derivation steps are required in the **rightmost derivation** of the string
[[IMAGE:359b4f7928435d09_7_47]]
from the start symbol E?




A published solution is not available for this question yet.
Question 14 NAT · 3.0 marks
Consider the augmented grammar:
[[IMAGE:359b4f7928435d09_7_48]]
[[IMAGE:359b4f7928435d09_7_49]]
[[IMAGE:359b4f7928435d09_8_50]]
[[IMAGE:359b4f7928435d09_8_51]]
How many total [[IMAGE:359b4f7928435d09_8_52]] items are present in state [[IMAGE:359b4f7928435d09_8_53]] ?






A published solution is not available for this question yet.
Question 15 NAT · 3.0 marks
Consider the Boolean expression:
[[IMAGE:359b4f7928435d09_8_54]]
Using the standard syntax-directed translation with backpatching for Boolean expressions,
assume that:
• Each relational expression [[IMAGE:359b4f7928435d09_8_55]] generates two consecutive TAC instructions:
1. A conditional jump: [[IMAGE:359b4f7928435d09_8_56]]
2. An unconditional jump: [[IMAGE:359b4f7928435d09_8_57]]
• The [[IMAGE:359b4f7928435d09_8_58]] counter gives the address of the next generated instruction.
• Initially, [[IMAGE:359b4f7928435d09_8_59]] .
• The logical NOT operator [[IMAGE:359b4f7928435d09_8_60]] only swaps the [[IMAGE:359b4f7928435d09_8_61]] and [[IMAGE:359b4f7928435d09_8_62]] and does not generate
additional instructions.
At which instruction number is the conditional jump for the comparison [[IMAGE:359b4f7928435d09_9_63]] generated?










A published solution is not available for this question yet.
Question 16 MSQ · 3.0 marks
Consider the Deterministic Finite Automaton (DFA) [[IMAGE:359b4f7928435d09_9_64]] where:
• [[IMAGE:359b4f7928435d09_9_65]]
• [[IMAGE:359b4f7928435d09_9_66]]
• [[IMAGE:359b4f7928435d09_9_67]]
• [[IMAGE:359b4f7928435d09_9_68]]
The transition function δ is defined as:
[[IMAGE:359b4f7928435d09_10_69]]
Which of the following strings will be **accepted** by this DFA? (Select all that apply)






[[IMAGE:359b4f7928435d09_10_70]]

[[IMAGE:359b4f7928435d09_10_71]]

[[IMAGE:359b4f7928435d09_10_72]]

[[IMAGE:359b4f7928435d09_10_73]]

[[IMAGE:359b4f7928435d09_10_74]]

A published solution is not available for this question yet.
Question 17 MCQ · 3.0 marks
Consider the following standard expression grammar:
[[IMAGE:359b4f7928435d09_10_75]]
[[IMAGE:359b4f7928435d09_10_76]]
[[IMAGE:359b4f7928435d09_10_77]]
[[IMAGE:359b4f7928435d09_10_78]]
[[IMAGE:359b4f7928435d09_10_79]]
What is [[IMAGE:359b4f7928435d09_10_80]] ?






{ +, ), $ }
{ *, +, $ }
{ +, * }
{ ), $ }
A published solution is not available for this question yet.
Question 18 MCQ · 3.0 marks
Given pointer [[IMAGE:359b4f7928435d09_11_81]] of type [[IMAGE:359b4f7928435d09_11_82]] and integer [[IMAGE:359b4f7928435d09_11_83]] , where [[IMAGE:359b4f7928435d09_11_84]] . When
translating the pointer arithmetic expression [[IMAGE:359b4f7928435d09_11_85]] , which TAC sequence correctly computes the
resulting address?





t1 = ptr * 8
t2 = t1 + k
t1 = k * 8
t2 = ptr + t1
t1 = ptr + k
t1 = k + 8
t2 = ptr + t1
A published solution is not available for this question yet.
Question 19 MCQ · 3.0 marks
Consider the Three-Address Code block:
[[IMAGE:359b4f7928435d09_11_86]]
Which of the following is the correct set of instruction leaders for basic block partitioning?

[[IMAGE:359b4f7928435d09_12_87]]

[[IMAGE:359b4f7928435d09_12_88]]

[[IMAGE:359b4f7928435d09_12_89]]

[[IMAGE:359b4f7928435d09_12_90]]

A published solution is not available for this question yet.
Question 20 NAT · 2.0 marks
A compiler translates the expression [[IMAGE:359b4f7928435d09_12_91]] 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 published solution is not available for this question yet.
Question 21 MSQ · 2.0 marks
Consider the following program with nested declarations:
[[IMAGE:359b4f7928435d09_13_92]]
Which statements are TRUE regarding the variable bindings?

Inside the first nested block, [[IMAGE:359b4f7928435d09_13_93]] shadows the parameter [[IMAGE:359b4f7928435d09_13_94]] .


In the second nested block, [[IMAGE:359b4f7928435d09_13_95]] is assigned the value of the parameter [[IMAGE:359b4f7928435d09_13_96]] .


In the second nested block, [[IMAGE:359b4f7928435d09_13_97]] is assigned the value of the global [[IMAGE:359b4f7928435d09_13_98]] .


The two nested blocks share identical symbol table instances.
A published solution is not available for this question yet.
Question 22 MSQ · 2.0 marks
Consider the TAC basic blocks:
[[IMAGE:359b4f7928435d09_13_99]]
Which of the following statements are correct at the **entry of basic block B2**?

[[IMAGE:359b4f7928435d09_13_100]] is live at the entry of [[IMAGE:359b4f7928435d09_13_101]] .


[[IMAGE:359b4f7928435d09_13_102]] is live at the entry of [[IMAGE:359b4f7928435d09_13_103]] .


[[IMAGE:359b4f7928435d09_14_104]] is live at the entry of [[IMAGE:359b4f7928435d09_14_105]] .


A variable is defined as live at a program point if its current value may be used
along at least one future execution path before being redefined.
A published solution is not available for this question yet.