Match the following according to input (from the left column) to the compiler…
2017
Match the following according to input (from the left column) to the compiler phase (in the right column) that processes it:
\(\begin{array}{|l|l|}\hline \text{P. Syntax tree} & \text{i. Code generator} \\\hline \text{Q. Character stream} & \text{ii. Syntax analyser} \\\hline \text{R. Intermediate representation} & \text{iii. Semantic analyser} \\\hline \text{S. Token stream} & \text{iv. Lexical analyser} \\\hline \end{array}\)
- A.
\(\text{P-ii; Q-iii; R-iv; S-i}\) - B.
\(\text{P-ii; Q-i; R-iii; S-iv}\) - C.
\(\text{P-iii; Q-iv; R-i; S-ii}\) - D.
\(\text{P-i; Q-iv; R-ii; S-iii}\)
Attempted by 371 students.
Show answer & explanation
Correct answer: C
Correct matching: P → Semantic analyser; Q → Lexical analyser; R → Code generator; S → Syntax analyser.
Why each pairing is correct:
Syntax tree — processed by the semantic analyser: performs type checking, scope resolution, and other semantic checks on the parse/syntax tree.
Character stream — processed by the lexical analyser: reads raw characters and groups them into tokens.
Intermediate representation — processed by the code generator: is translated into target machine code or lower-level code by the code generator.
Token stream — processed by the syntax analyser: the parser consumes tokens to build the parse/syntax tree.
Therefore the correct mapping is: P-iii; Q-iv; R-i; S-ii.
A video solution is available for this question — log in and enroll to watch it.