In a compiler, keywords of a language are recognized during (A) parsing of the program (B) the code generation (C) the lexical analysis of the program (D) dataflow analysis
Topic-wise GATE CS PYQs with verified steps
GATE CSE 2011 · Q1
Time
Select one answerSingle correct
Solution
Official answer: C) the lexical analysis of the program
Lexical AnalysisDuring lexical analysis (the scanning phase), the compiler reads the stream of characters composing the source program and groups them into meaningful sequences called lexemes. For each lexeme, the lexical analyzer produces a token (such as keywords, identifiers, constants, and operators).
Lexical Analysis (C): Identifies keywords, identifiers, operators, and constants.
Parsing / Syntax Analysis (A): Checks the grammatical structure against context-free grammar rules.
Code Generation (B): Translates intermediate representation into target machine code.
Dataflow Analysis (D): Collects runtime information about data values for code optimization.
Therefore, the correct option is (C).
Try the question first, then check your work.
Examiner trap
Recall the first phase of a compiler which breaks the character stream into tokens.
This Lexical Analysis previous year question is Q1 of the GATE CSE 2011 paper. Find more GATE CSE PYQs on Lexical Analysis in Compiler Design, or browse all GATE CSE PYQs.
Free diagnostic
Take the 20-minute diagnostic: the 3 topics that cost you the most marks, and a rank range. Or sit 5 related Lexical Analysis PYQs now with no account.
An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.
Lexical Analysis has 7 GATE CSE PYQs across 6 papers from 2011 to 2026. 5 of them are 1-mark MCQs like this one, and GATE CSE 2011 has 2.
How GATE tests Lexical AnalysisIndependent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.