MCQ SOLVED

#Q Discuss the Phases of Compilation

⇒ Click to View Answer

#Q2022 Explain with example, any four code optimization techniques

⇒ Click to view the Answer

Single Pass Compiler

If we combine or group all the phases of compiler design in a single module known as single pass compiler

Untitled

Two-Pass / Multi-Pass Compiler

Two-pass/multi-pass Compiler is a type of compiler that processes the source code or abstract syntax tree of a program multiple times. In a multi-pass Compiler, we divide phases into two passes:

The first Phase is also referred to as Frontend, Analytical part, and platform independent.

The second phase is also referred to as the Backend, Synthesis part, and Platform dependent.

Untitled

Problems that can be solved with a Multi-pass compiler

First: If we want to design a compiler for a different programming language for the same machine. In this case for each programming language, there is a requirement to make the Front end/first pass for each of them and only one Back end/second pass as:

Untitled

Second: If we want to design a compiler for the same programming language for different machines/systems. In this case, we make different Back end for different Machine/system and make only one Front end for the same programming language as:

Untitled

Difference Between One Pass & Two Pass Compiler

One pass Two-pass
It performs Translation in one pass It performs Translation in two pass
It scans the entire file only once. It requires two passes to scan the source file.
It generates Intermediate code It does not generate Intermediate code
It is faster than two pass assembler It is slower than two pass assembler
A loader is not required A loader is required.
No object program is written. A loader is required as the object code is generated.
Perform some professing of assembler directives. Perform processing of assembler directives not done in pass-1
The data structure used are:
The symbol table, literal table, pool table, and table of incomplete. The data structure used are:
The symbol table, literal table, and pool table.
These assemblers perform the whole conversion of assembly code to machine code in one go. These assemblers first process the assembly code and store values in the opcode table and symbol table and then in the second step they generate the machine code using these tables.
Example: C and Pascal uses One Pass Compiler. Example: Modula-2 uses Multi Pass Compiler.

2022 Q8. RE to DFA a(aa + bb)b* + b( a+b)*aa

2.jpg

3.jpg

Note: here B and C are not final state. it is normal state.

IMG_20240129_142322.jpg

IMG_20240129_142340.jpg

IMG_20240129_142410.jpg

IMG_20240129_142450.jpg

Note: here B and C are not final state. it is normal state.

IMG_20240129_142307.jpg

Untitled

IMG_20240129_184849.jpg

IMG_20240129_184907.jpg