Which of the following best describes the role of a lexical analyzer in a…
2025
Which of the following best describes the role of a lexical analyzer in a compiler design?
Answer: D. It partitions the source code into tokens and removes comments and white spaces. — A lexical analyzer tokenizes source code into tokens and removes whitespace/comments.
- A.
It converts high-level source code into assembly code.
- B.
It checks semantic consistency in the program.
- C.
It builds the symbol table during code generation.
- D.
It partitions the source code into tokens and removes comments and white spaces.
Attempted by 146 students.
Show answer & explanation
Correct answer: D
A lexical analyzer tokenizes source code into tokens and removes whitespace/comments.
Loading lesson…