Question Detail

COS 102 test topic Objective Question

Question

What is the purpose of a compiler's lexical analysis (scanning) phase?
Options
A To verify semantic type correctness
B To convert the input character stream into a sequence of tokens
Correct Answer
C To generate intermediate machine code
D To optimize CPU register allocation
Correct Answer

Option B is the correct answer.

Detailed Explanation

The lexical analyzer reads raw source characters and aggregates them into meaningful lexical units termed tokens.

Hint

No hint available

Question Info