Compiler Design MCQs (Set-1)

Converting source characters into tokens is the job of which phase?

A Syntax analysis
B Code generation
C Lexical analysis
D Type checking

Once tokenization ends, which phase checks grammar rules?

A Code generation
B Syntax analysis
C Linking
D Optimization

Identifier attributes are stored in what compiler structure?

A Target register
B Control-flow edge
C Parse stack
D Symbol table

Unlike a concrete parse tree, which details does an AST usually omit?

A Operator structure
B Expression hierarchy
C Program meaning
D Unneeded grammar details

The actual source text matched as one token is called what?

A Semantic value
B Grammar rule
C Token class
D Lexeme

Valid strings for a token kind are described by which feature?

A Token pattern
B Parse rule
C Lexeme table
D Code target

Token patterns are commonly specified using which notation?

A SSA instruction
B Context-free grammar
C Control-flow graph
D Regular expression

Using pattern [A-Za-z][A-Za-z0-9]*, which lexeme matches?

A temp!
B temp42
C temp-name
D 42temp

Grammar symbols that appear directly and are not expanded are called what?

A Nonterminals
B Attributes
C Productions
D Terminals

Expanding through productions is the role of which grammar symbol?

A Lexeme
B Token value
C Nonterminal
D Terminal

If a character matches no token rule, what error follows?

A Lexical error
B Link error
C Syntax error
D Type error

From a token stream, what does a parser recover?

A Syntactic structure
B File layout
C Register map
D Machine address

When one string has two valid parse trees, what does this reveal?

A Grammar ambiguity
B Tokenization
C Code motion
D Type inference

In usual arithmetic expressions, which operator has higher precedence?

A Assignment
B Multiplication
C Comma
D Addition

Under left associativity, which grouping represents x-y-z?

A x-(y-z)
B (x-y)-z
C x-(y+z)
D (x+y)-z

Operand types are verified by which semantic check?

A Token buffering
B Lexical scanning
C Type checking
D Register allocation

Target-machine instructions are emitted during which phase?

A Name resolution
B Code generation
C Lexical analysis
D Parsing

Intermediate representation sits where in a compiler?

A Inside source comments
B After program output
C Only inside linker
D Between frontend and backend

Replacing 3 Γ— 4 with 12 is known as what?

A Constant folding
B Code scheduling
C Register spilling
D Loop unrolling

For correctness, what must optimization preserve?

A Token order
B Source formatting
C Program behavior
D Variable names

Executing operations while processing source describes which model?

A Ahead-of-time compilation
B Interpretation
C Code assembly
D Static linking

Object files are combined and external names resolved by what?

A Parser
B Assembler
C Linker
D Optimizer

Assembly text becomes object code through which tool?

A Loader
B Linker
C Lexer
D Assembler

How is a basic block best characterized?

A Single-entry, single-exit sequence
B Token group
C Many-entry arbitrary code
D Expression tree only

Up to three explicit addresses per instruction identify what IR format?

A Object module
B Syntax tree
C Three-address code
D Polish notation