0% found this document useful (0 votes)
71 views4 pages

Types of Compiler

The document outlines the types of compilers, which convert high-level programming languages into machine language. It describes three types: single-pass compilers that process all phases in one module, two-pass compilers that separate the process into front-end and back-end modules, and multi-pass compilers that divide programs into smaller parts for processing. Each type has its own advantages and disadvantages regarding speed, memory usage, and performance.

Uploaded by

nikhilmishra1710
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
71 views4 pages

Types of Compiler

The document outlines the types of compilers, which convert high-level programming languages into machine language. It describes three types: single-pass compilers that process all phases in one module, two-pass compilers that separate the process into front-end and back-end modules, and multi-pass compilers that divide programs into smaller parts for processing. Each type has its own advantages and disadvantages regarding speed, memory usage, and performance.

Uploaded by

nikhilmishra1710
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Types of Compilers

➢ It converts high level language into machine language. High level language
means English, Hindi etc. and machine level language means binary,
assembly language.
➢ Compiler is a special program that processes statements (instructions)
written in a particular programming language (c, cpp, java, python, etc.)
and turns them into machine language.

Source Code Target Code


COMPILER

Types of Compiler
Following are the different types of Compiler:
• Single Pass Compilers
• Two Pass Compilers
• Multipass Compilers

Single Pass Compilers


Source Code COMPILER Target Code

➢ In a single-pass compiler, the source code is directly transformed into


machine code (target code).
➢ Pascal language is an example of a single-pass compiler.
➢ All the six phases of the compiler (i.e. lexical analysis phase, syntax
analysis, semantic analysis, intermediate code generation phase, code
optimization, and code generation phase) are implemented in one single
module.

Advantages:
➢ Compilation process is very fast because all phases are implemented in a
single module.

Disadvantages:
➢ It takes more space in the main memory because all its phases are
implemented in a single module.
Two-Pass Compilers

Source Code Front IR Target Code


Back End
End

➢ In a two-pass compiler, the six phases of the compiler are implemented in


two modules.
➢ The first pass is referred to as a front end and the second pass is referred to
as a back end
➢ IR represents the intermediate representation.
➢ Front end consists of lexical analysis, syntax analysis, semantic analysis,
and the intermediate code generation phases.
➢ Back end consists of code optimization and code generation phases.
➢ The output of the front end phase becomes an input of the back end phase.

Advantages:
➢ At a time only one module is placed into the main memory
➢ The performance of the compiler is increased due to two modules.

Disadvantages:
➢ It is slow as compared to a single-pass compiler.
Multi-Pass Compilers

Source Target
Front Middle Back
Code IR IR Code
End End End

➢ Multi-pass compiler is divide a large program into multiple small programs


and processes them
➢ In a multi-pass compiler, the phases of the compiler are implemented with
multiple modules.
➢ It develops multiple intermediate codes.

Advantages:
➢ At a time only one module is placed into the main memory
➢ The performance of the compiler is increased due to multiple modules.
➢ It consumes less space in the main memory as only one module of it is
placed in the main memory at a time.

Disadvantages:
➢ It is slow as compared to a single-pass compiler.

You might also like