Definition

The lexical analyzer (scanner) reads raw source characters and groups them into tokens — the smallest meaningful units (keywords, identifiers, operators, literals).

Key Points

Example

For total = rate + 12:

Lexeme Token
total ID
= ASSIGN_OP
rate ID
+ ADD_OP
12 NUM

📌 CSS Frequency: High (explicitly listed as 2016 repeated topic) — often paired with "define token, lexeme, pattern" and buffering diagrams.

Model Answer (short)

"Lexical analysis converts a character stream into tokens using patterns specified as regular expressions and recognized via finite automata. Input buffering (commonly double-buffering with sentinels) minimizes the overhead of re-reading characters. A token is the category (e.g. ID), a lexeme is the actual matched text (e.g. 'total'), and a pattern is the rule (regex) that defines the token."