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.