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?

  1. A.

    It converts high-level source code into assembly code.

  2. B.

    It checks semantic consistency in the program.

  3. C.

    It builds the symbol table during code generation.

  4. 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.

Explore the full course: Niacl Ao It Specialist