Question:

In a compiler, which phase is responsible for identifying the token types from the source program's stream of characters?

Show Hint

A Lexer often uses Regular Expressions to define what constitutes a token and Finite Automata (DFA) to implement the actual scanning logic.
Updated On: Jul 4, 2026
  • Syntax Analysis
  • Semantic Analysis
  • Lexical Analysis
  • Intermediate Code Generation
Show Solution
collegedunia
Verified By Collegedunia

The Correct Option is C

Solution and Explanation

Concept: The compilation process consists of several sequential phases. The first phase interacts directly with the source code string.
Lexical Analysis (Scanning): Converts characters into tokens.
Syntax Analysis (Parsing): Checks the grammatical structure.
Semantic Analysis: Checks for logical meaning (e.g., type checking).

Step 1:
Defining the input of the Lexer.
The Lexer takes a stream of characters (raw text) as input. It scans these characters from left to right.

Step 2:
The process of Tokenization.
It groups these characters into meaningful sequences called "lexemes." For each lexeme, it identifies a "token" type (Keyword, Identifier, Operator, etc.).

Step 3:
Output of the phase.
The output is a sequence of tokens that is then passed to the Parser. Lexical Analysis is the specific phase described in the question.
Was this answer helpful?
0
0