Arrange the following stages of parsing in the correct order as they typically occur in the compilation process. (A) Lexical Analysis (B) Sematic Analysis (C) Syntax Analysis (D) Intermediate Code Generation (E) Code Optimization Choose the correct answer from the options given below :
(A), (C), (B), (D), (E)
A compiler (Aho, Sethi, Ullman) is a pipeline of phases; each phase consumes the representation produced by the previous one.
Step 1 — Lexical Analysis (A): the character stream is grouped into tokens.
Step 2 — Syntax Analysis (C): the parser checks the tokens against the grammar and builds a parse tree.
Step 3 — Semantic Analysis (B): type checking and scope checks are done on the tree.
Step 4 — Intermediate Code Generation (D): an intermediate form such as three-address code is produced.
Step 5 — Code Optimization (E): the intermediate code is improved before target code generation.
Semantic analysis needs a parse tree, so it cannot come before syntax analysis; intermediate code needs a semantically checked tree, so it cannot come before semantic analysis. The other three sequences break one of these dependencies.
(A), (C), (B), (D), (E) option is correct.
Shift-Reduce parsers perform the following :
Which phase of compiler generates stream of atoms ?
Match List I with List II
| List I | List II |
|---|---|
| A. Initial Configuration of stack and input in LL Parsing process. | I. \(\$\) w\(\$\) |
| B. Final Configuration of stack and input in LL Parsing process | II. \(\$\) \(\$\) |
| C. Initial Configuration of stack and input in LR Parsing process | III. \(\$\)S w\(\$\) |
| D. Final Configuration of stack and input in LR Parsing process | IV. \(\$\)S \(\$\) |
Choose the correct answer from the options given below:
While processing a string by an LR parser, the reading of the given string by the parser is--------------.
Which of the following not correct according to input to output, the compiler phase that is processes by it?
| Phases of Compiler | Input | Output | |
| A | Lexical Analyzer | Character stream | Token stream |
| B | Syntax Analyzer | Token stream | Syntax tree |
| C | Semantic Analyzer | Syntax tree | Syntax tree |
| D | Intermediate Code Generator | Syntax tree | Target-machine code |
Match the description of several parts of a classic optimizing compiler in List - I, with the names of those parts in List - II:
List - I | List - II |
A. A part of a compiler that is responsible for recognizing | 1. Optimizer syntax |
B. A part of a compiler that takes as input a stream of characters and produces as output a stream of words along with their associated syntactic categories. | 2. Semantic Analysis |
C. A part of a compiler that understands the meanings of variable names and other symbols and checks that they are used in ways consistent with their definitions. | 3. Parser |
D. An IR-to-IR transformer that tries to improve the IR program in some way (Intermediate Representation). | 4. Scanner |
Shift-Reduce parsers perform the following :
Which phase of compiler generates stream of atoms ?
Match List I with List II
| List I | List II |
|---|---|
| A. Initial Configuration of stack and input in LL Parsing process. | I. \(\$\) w\(\$\) |
| B. Final Configuration of stack and input in LL Parsing process | II. \(\$\) \(\$\) |
| C. Initial Configuration of stack and input in LR Parsing process | III. \(\$\)S w\(\$\) |
| D. Final Configuration of stack and input in LR Parsing process | IV. \(\$\)S \(\$\) |
Choose the correct answer from the options given below: