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?
- 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 45 students.
Show answer & explanation
Correct answer: D
A lexical analyzer tokenizes source code into tokens and removes whitespace/comments.