Skip to content
Official PYQ · 2011

GATE CS 2011 Q1 — Lexical Analysis

Explain with AI

In a compiler, keywords of a language are recognized during

Choose one option
View worked solution

Answer: C

The correct option is C.

Explanation:

  • Lexical Analysis (Scanner): This is the first phase of a compiler. Its primary task is to read the input characters of the source program, group them into lexemes, and produce a sequence of tokens. Keywords (such as if, else, while, int) are predefined lexemes recognized as specific tokens during this phase.
  • Parsing (Syntax Analysis): This phase takes the tokens produced by the lexical analyzer and groups them into a hierarchical structure (typically a parse tree) to verify grammatical correctness.
  • Code Generation: This is a late phase of the compiler that translates the intermediate representation of the source program into target machine code.
  • Dataflow Analysis: This is a technique used during code optimization to gather information about the flow of values along execution paths.

Therefore, keywords of a language are recognized during the lexical analysis of the program.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Lexical Analysis questions