Compiler Design MCQs (Set-3)

Given S → AB, A → a | ε, B → b, what is FIRST(S)?

A {ε, b}
B {b}
C {a}
D {a, b}

Because B can derive ε in A → BC, what else can begin A?

A FOLLOW(C)
B FOLLOW(A)
C LAST(B)
D FIRST(C)

In S → ( A ), which symbol enters FOLLOW(A)?

A $
B )
C A
D (

With S → AB, A → a, B → b | ε, what is FOLLOW(A)?

A {$}
B {b}
C {b, $}
D {a, $}

Rewrite E → E + T | T without immediate left recursion: which form is correct?

A E→TE’; E’→+TE’|ε
B E→T+E’; E’→E
C E→+TE’; E’→E|ε
D E→E’T; E’→T+E’

When A → a | ε and a ∈ FOLLOW(A), what can an LL(1) table show?

A Lexical ambiguity
B Shift/reduce conflict
C No conflict
D FIRST/FOLLOW conflict

State-based shift/reduce decisions belong to which parser family?

A LL
B LR
C Recursive descent
D Lexical scanner

Beyond an LR(0) core, an LR(1) item carries what?

A One lookahead token
B Two grammar starts
C A register class
D A parse tree

For production A→β, SLR permits reduction on which terminals?

A FOLLOW(β)
B FIRST(β)
C All terminals
D FOLLOW(A)

Compared with canonical LR(1), what quantity does LALR seek to reduce?

A AST nodes
B Token length
C Number of parser states
D Grammar terminals

One LR table conflict offers what choice between actions?

A Scan or link
B Type or coerce
C Shift or reduce
D Emit or spill

On a valid lookahead, which action does a completed non-start LR item suggest?

A Enter a new scope
B Emit a machine opcode
C Reduce by its rule
D Shift the next token

Without braces, the usual convention attaches else to which if?

A Reject every else
B Attach else to outermost if
C Use lexical priority
D Bind else to nearest if

Possible transfers between basic blocks are recorded in which graph?

A Control-flow graph
B Interference graph
C Symbol table
D Syntax tree

Which condition keeps a pure arithmetic expression loop-invariant?

A Its inputs stay unchanged
B Its output is printed
C Its block has one edge
D Its token is a keyword

Reaching-definitions analysis reports what at a program point?

A Tokens already consumed
B Statements never executed
C Definitions that may arrive
D Registers already allocated

At point p, when is variable x live?

A Present in symbol table
B Used before next redefinition
C Defined only once
D Stored in object file

At a control-flow join, what does φ choose?

A Value from incoming path
B Nearest symbol name
C Target machine opcode
D Value from next token

Unreachable-code elimination can remove which blocks?

A Blocks with many variables
B Blocks containing operators
C Blocks before the lexer
D Blocks unreachable from entry

Filling unresolved branch targets later is called what?

A Unresolved branch targets
B Symbol attributes
C Register colors
D Token patterns

Loop-invariant code motion moves what before a loop?

A Dead-store elimination
B Constant propagation
C Loop-invariant code motion
D Register spilling

In register allocation, what does spilling do?

A Rewriting grammar rules
B Storing a value in memory
C Splitting source tokens
D Moving loops to entry

Temporaries connected by an interference-graph edge are what?

A Shared token class
B Same source variable
C Syntactically adjacent
D Live at the same time

Mapping IR operations to machine instructions is called what?

A Lexical analysis
B Instruction selection
C Error recovery
D Type inference

Instruction scheduling can reorder independent operations for what reason?

A To resolve identifiers
B To reduce execution stalls
C To remove every branch
D To change program results