Converting source characters into tokens is the job of which phase?
A Syntax analysis
B Code generation
C Lexical analysis
D Type checking
Answer: C. Lexical analysis. The lexer groups character sequences into token classes such as identifiers, keywords, and operators.
Once tokenization ends, which phase checks grammar rules?
A Code generation
B Syntax analysis
C Linking
D Optimization
Answer: B. Syntax analysis. The parser checks token order against the language grammar.
Identifier attributes are stored in what compiler structure?
A Target register
B Control-flow edge
C Parse stack
D Symbol table
Answer: D. Symbol table. A symbol table records names and information such as type, scope, and storage location.
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
Answer: D. Unneeded grammar details. An abstract syntax tree keeps essential structure while omitting redundant grammar details and punctuation.
The actual source text matched as one token is called what?
A Semantic value
B Grammar rule
C Token class
D Lexeme
Answer: D. Lexeme. A lexeme is the actual character sequence recognized by a lexer.
Valid strings for a token kind are described by which feature?
A Token pattern
B Parse rule
C Lexeme table
D Code target
Answer: A. Token pattern. A token pattern specifies which character strings belong to a token class.
Token patterns are commonly specified using which notation?
A SSA instruction
B Context-free grammar
C Control-flow graph
D Regular expression
Answer: D. Regular expression. Regular expressions compactly describe character patterns used by lexical analyzers.
Using pattern [A-Za-z][A-Za-z0-9]*, which lexeme matches?
A temp!
B temp42
C temp-name
D 42temp
Answer: B. temp42. The pattern requires a letter first, followed only by letters or digits.
Grammar symbols that appear directly and are not expanded are called what?
A Nonterminals
B Attributes
C Productions
D Terminals
Answer: D. Terminals. Terminals are the grammar symbols that cannot be expanded by another production.
Expanding through productions is the role of which grammar symbol?
A Lexeme
B Token value
C Nonterminal
D Terminal
Answer: C. Nonterminal. A nonterminal represents a syntactic category that can be replaced using a production.
If a character matches no token rule, what error follows?
A Lexical error
B Link error
C Syntax error
D Type error
Answer: A. Lexical error. A lexer reports a lexical error when input characters cannot form a valid token.
From a token stream, what does a parser recover?
A Syntactic structure
B File layout
C Register map
D Machine address
Answer: A. Syntactic structure. Parsing organizes the token stream according to the grammar.
When one string has two valid parse trees, what does this reveal?
A Grammar ambiguity
B Tokenization
C Code motion
D Type inference
Answer: A. Grammar ambiguity. An ambiguous grammar permits more than one parse tree for the same string.
In usual arithmetic expressions, which operator has higher precedence?
A Assignment
B Multiplication
C Comma
D Addition
Answer: B. Multiplication. Multiplication is conventionally evaluated before addition in arithmetic expressions.
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
Answer: B. (x-y)-z. Left associativity groups repeated subtraction from left to right.
Operand types are verified by which semantic check?
A Token buffering
B Lexical scanning
C Type checking
D Register allocation
Answer: C. Type checking. Type checking rejects operations whose operand types are not permitted.
Target-machine instructions are emitted during which phase?
A Name resolution
B Code generation
C Lexical analysis
D Parsing
Answer: B. Code generation. The backend’s code-generation phase maps the program representation to target instructions.
Intermediate representation sits where in a compiler?
A Inside source comments
B After program output
C Only inside linker
D Between frontend and backend
Answer: D. Between frontend and backend. An intermediate representation connects language-specific analysis to later compiler stages.
Replacing 3 Γ 4 with 12 is known as what?
A Constant folding
B Code scheduling
C Register spilling
D Loop unrolling
Answer: A. Constant folding. Constant folding evaluates an expression whose operands are known constants.
For correctness, what must optimization preserve?
A Token order
B Source formatting
C Program behavior
D Variable names
Answer: C. Program behavior. A correct optimization preserves the observable behavior required by the language.
Executing operations while processing source describes which model?
A Ahead-of-time compilation
B Interpretation
C Code assembly
D Static linking
Answer: B. Interpretation. An interpreter executes program operations as it processes the program.
Object files are combined and external names resolved by what?
A Parser
B Assembler
C Linker
D Optimizer
Answer: C. Linker. The linker combines object files and resolves references between separately compiled units.
Assembly text becomes object code through which tool?
A Loader
B Linker
C Lexer
D Assembler
Answer: D. Assembler. An assembler translates assembly-language instructions into machine-code object form.
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
Answer: A. Single-entry, single-exit sequence. A basic block is a straight-line instruction sequence with one entry and one exit.
Up to three explicit addresses per instruction identify what IR format?
A Object module
B Syntax tree
C Three-address code
D Polish notation
Answer: C. Three-address code. Three-address code limits each instruction to a small number of explicit operands.