Multiple choice

Keywords are recognized during which phase of compilation?

  1. Line reconstruction

  2. Lexical analysis

  3. Preprocessing

  4. Syntax analysis

  5. Semantic analysis

Reveal answer Fill a bubble to check yourself
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.