Keywords are recognized during which phase of compilation?
-
Line reconstruction
-
Lexical analysis
-
Preprocessing
-
Syntax analysis
-
Semantic analysis
B
Correct answer
Explanation
Lexical analysis breaks the source code text into small pieces called tokens. Each token is a single atomic unit of the language, for instance a keyword, identifier or symbol name. The token syntax is typically a regular language, so a finite state automaton constructed from a regular expression can be used to recognize it. This phase is also called lexing or scanning, and the software doing lexical analysis is called a lexical analyzer or scanner.