GATE CS 2024 Set 2 — Question 21
MCQ+1 / -0.33EasyLexical AnalysisCompiler DesignSyntax AnalysisIntermediate Code GenerationCode Optimization
Compiler Design → Code Optimization
Last updated
Question
Consider the following two sets:
Which one of the following options is the CORRECT match from Set X to Set Y?
| Set X | Set Y |
|---|---|
| P. Lexical Analyzer | 1. Abstract Syntax Tree |
| Q. Syntax Analyzer | 2. Token |
| R. Intermediate Code Generator | 3. Parse Tree |
| S. Code Optimizer | 4. Constant Folding |
A.
P – 4; Q – 1; R – 3; S – 2
B.
P – 2; Q – 3; R – 1; S – 4
C.
P – 2; Q – 1; R – 3; S – 4
D.
P – 4; Q – 3; R – 2; S – 1
Correct answer
(B) P – 2; Q – 3; R – 1; S – 4
Solution
The correct mapping between the compiler phases and their associated concepts is:
- P. Lexical Analyzer: Reads the source program character by character and groups them into meaningful sequences called lexemes, producing Tokens (2).
- Q. Syntax Analyzer: Takes tokens as input and generates a Parse Tree (3) (or Concrete Syntax Tree) checking for syntax errors.
- S. Code Optimizer: Improves the intermediate code. Constant Folding (4) is a standard optimization technique where constant expressions are evaluated at compile time.
- R. Intermediate Code Generator: Generates an intermediate representation. While Syntax Analysis produces the Parse Tree, the Abstract Syntax Tree (AST) (1) is often considered a high-level intermediate representation or the output of a syntax analyzer used for intermediate code generation. Given the options, R maps to 1.
- P 2
- Q 3
- R 1
- S 4
More questions on Code Optimization
2024 Set 1 Q26Which of the following is/are Bottom-Up Parser(s)?2024 Set 2 Q29Which of the following statements is/are FALSE?2024 Set 1 Q37Consider the following syntax-directed definition (SDD). | Production | Semantic Rules | | ------ |…2024 Set 1 Q38Consider the following grammar , with as the start symbol. The grammar has three…2024 Set 1 Q39Consider the following pseudo-code. [code] Which one of the following options CORRECTLY specifies…
Practice GATE CS PYQs with adaptive difficulty
Timed practice, skill tracking, and AI explanations — free to start.
Start practicing free