Match the description of several parts of a classic optimizing compiler in…

2017

Match the description of several parts of a classic optimizing compiler in List - I, with the names of those parts in List - II :

\(\begin{array}{clcl} & \textbf{List-I} && \textbf{List-II} \\ \text{(a)}& \text{A part of a compiler that is responsible} & \text{(i)}& \text{Optimizer} \\ & \text{for recognizing syntax.} \\ \\ \text{(b)} & \text{A part of a compiler that takes as input a stream of} & \text{(ii)} & \text{Semantic Analysis} \\ & \text{characters and produces as output a stream of words} \\ & \text{along with their associated syntactic categories.} \\ \\ \text{(c)} & \text{A part of a compiler that understand the meanings of} & \text{(iii)} & \text{Parser} \\ & \text{variable names and other symbols and checks that they} \\ & \text{are used in ways consistent with their definitions.} \\ \\ \text{(d)} & \text{An IR-to-IR transformer that tries to improve the IR} & \text{(iv)} & \text{Scanner} \\ & \text{program in some way (Intermediate Representation).} \end{array}\)

Code :

  1. A.

    (a)-(iii); (b)-(iv);  (c)-(ii); (d)-(i)

  2. B.

    (a)-(iv); (b)-(iii);  (c)-(ii);  (d)-(i)

  3. C.

    (a)-(ii); (b)-(iv);  (c)-(i);  (d)-(iii)

  4. D.

    (a)-(ii); (b)-(iv);  (c)-(iii); (d)-(i)

Attempted by 194 students.

Show answer & explanation

Correct answer: A

Correct matching: (a) -> Parser; (b) -> Scanner; (c) -> Semantic Analysis; (d) -> Optimizer

  • (a) Recognizing syntax -> Parser. The parser performs syntactic analysis using tokens produced by the scanner to build a parse tree or syntax structure.

  • (b) Taking a stream of characters and producing words/tokens with categories -> Scanner (lexical analyzer). It groups characters into tokens and assigns token types.

  • (c) Understanding meanings of names and checking their usage -> Semantic Analysis. This phase builds symbol information and enforces type and usage rules.

  • (d) IR-to-IR transformer that improves the intermediate representation -> Optimizer. Optimization passes transform IR to make the generated code more efficient.

Quick tip: remember the pipeline order—scanner (tokenizes characters), parser (recognizes syntax from tokens), semantic analysis (checks meanings/types), then optimization (improves IR).

Explore the full course: Mppsc Assistant Professor