Match the following according to input (from the left column) to the compiler phase (in the right column) that processes it:
Topic-wise GATE CS PYQs with verified steps
GATE CSE 2017 Set 2 · Q5
Time

Select one answerSingle correct
Solution
Official answer: C) P → (iii), Q → (iv), R → (i), S → (ii)
Lexical Analysis, Parsing and SDTThe inputs to the compiler phases are matched as follows:
(Q) Character stream is the input to the (iv) Lexical analyzer, which converts characters into a stream of tokens.
(S) Token stream is the input to the (ii) Syntax analyzer (parser), which constructs a parse/syntax tree.
(P) Syntax tree is the input to the (iii) Semantic analyzer, which performs semantic checks and type checking.
(R) Intermediate representation is the input to the (i) Code generator, which translates the intermediate representation into target machine code.
Therefore, the correct mapping is:
This corresponds to option (C).
Try the question first, then check your work.
Examiner trap
Trace the standard front-end and back-end pipeline of a compiler: Character stream Lexical analysis Token stream Syntax analysis Syntax tree Semantic analysis Intermediate representation Code generation.
This Lexical Analysis, Parsing and SDT previous year question is Q5 of the GATE CSE 2017 Set 2 paper. Find more GATE CSE PYQs on Lexical Analysis, Parsing and SDT 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, Parsing and SDT 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, Parsing and SDT has 14 GATE CSE PYQs across 12 papers from 2011 to 2025. 9 of them are 1-mark MCQs like this one, and GATE CSE 2017 Set 2 has 2.
How GATE tests Lexical Analysis, Parsing and SDTIndependent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.