Consider the following two sets:
Which one of the following options is the CORRECT match from Set to Set ?
View worked solution
Answer: B
We can determine the correct match by analyzing the primary functions and outputs of each compiler phase:
- P. Lexical Analyzer 2. Token:
The lexical analyzer reads the source program as a stream of characters and groups them into meaningful sequences called lexemes, which are mapped to tokens. - Q. Syntax Analyzer 3. Parse Tree:
The syntax analyzer (parser) takes the tokens as input and verifies their grammatical structure against the source language's context-free grammar, producing a parse tree. - R. Intermediate Code Generator 1. Abstract Syntax Tree:
The intermediate code generator often uses an abstract syntax tree (AST) as a high-level intermediate representation of the program structure before translating it into lower-level intermediate code (like three-address code). - S. Code Optimizer 4. Constant Folding:
Constant folding is a standard compile-time optimization technique where expressions with constant operands (e.g.,3 + 5) are evaluated at compile-time to simplify the code.
Combining these matches, we get:
P - 2; Q - 3; R - 1; S - 4
Therefore, the correct option is B.
Free practice · Your answers on this page are not saved.
