In lexical analysis, which component is primarily responsible for recognising…

2025

In lexical analysis, which component is primarily responsible for recognising tokens from the input source program?

  1. A.

    Semantic analyzer

  2. B.

    Parser

  3. C.

    Scanner

  4. D.

    Syntax tree builder

Attempted by 55 students.

Show answer & explanation

Correct answer: C

Lexical analysis is the first phase of a compiler. In this phase, the scanner (lexical analyzer) reads the input source code and converts sequences of characters into tokens. Tokens are the basic building blocks of programming languages, including keywords, identifiers, literals, and operators.

Explore the full course: Niacl Ao It Specialist