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?
- A.
Semantic analyzer
- B.
Parser
- C.
Scanner
- 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.