GATE / CS ARCHIVE

GATE CSE 2017 SET 2 / QUESTION 5

GATE CSE 2017 Set 2 Q5

Compiler Design · Compiler Phases, Linking & Loading · Full GATE CSE 2017 Set 2 paper

GATE 2017 Set 2, Q5 1 mark · MCQ
Report issue

Compiler Phases, Linking & Loading

Question 5, GATE 2017: Match compiler inputs P:syntax tree, Q:character stream, R:intermediate representation, S:token stream with phases i:code generator, ii:syntax analyzer, iii:semantic analyzer, iv:lexical analyzer. Options (P,Q,R,S): A:(ii,iii,iv,i), B:(ii,i,iii,iv), C:(iii,iv,i,ii), D:(i,iv,ii,iii).
Tap to enlarge
Your answer
Answer & solution

Official answer: C

1. Follow the compiler pipeline from source text. The lexical analyzer reads characters and groups them into tokens, so Q→iv. The syntax analyzer reads those tokens and recognizes grammatical structure, so S→ii.

2. Semantic analysis then uses the syntax tree to check matters such as declarations, types, and compatible operations; hence P→iii.

3. After front-end processing and intermediate-code construction, the code generator translates the intermediate representation into target code, giving R→i. In the requested P,Q,R,S order the mapping is (iii,iv,i,ii), option C. Do not confuse a phase's output with its input.

Original paper, page 3 · Answer key