Introduction
Structure of a Compiler – Compiler Phases
Analysis Phase
Synthesis Phase
Structure of a Compiler – Compiler Phases
Working of Compiler - Phases
Working of Compiler - Phases
Single Pass and Multi Pass Compiler
• Single Pass : A source code goes through
different stages during compilation. A single-
pass compiler passes the code into these
steps in a single-pass; in other words, it
translates each part of the source code into
the final required machine code.
• As not all programming languages are well-
suited for single-pass compilation, here are
some examples of programming languages
related to single-pass compilers: Pascal, C,
FORTRAN, etc.
Single Pass and Multi Pass Compiler
Advantages of Single Pass Compiler
• It is faster for small programs and embedded systems in case of small code size and critical time
compilation.
• It requires less memory.
• It can generate the machine code faster than another type.
Limitations/ Disadvantages of Single Pass Compiler
• It cannot perform complex optimization techniques as we need to perform multiple passes for optimization.
• There is no intermediate code generation.
• It imposes some restrictions upon the program constants, variables, types, and procedures that must be
defined before use.
Single Pass and Multi Pass Compiler
• Multi Pass : A multi-pass compiler makes the source
code go through several passes during the compilation
process; it also generates intermediate optimized code
after each step. It converts the source program into one
or more intermediate codes in steps between the source
code and machine code. It reprocesses the entire
program in each succeeding pass.
• Some examples of programming languages related to
multi-pass compilers are Java, C++, Lisp, etc. These
languages' codes are highly abstract and require
multiple passes to optimize.
Single Pass and Multi Pass Compiler
Advantages of Multi Pass Compiler
• It is machine independent as multiple passes include a modular structure, and code generation is separate from
other steps; the passes can be reused for different machines.
• It works well with complex programming languages.
• It generates better code than single-pass compilers, as they perform more optimization through multiple passes.
Limitations/ Disadvantages of Multi Pass Compiler
• It requires more memory and processing power as it goes through multiple passes over the source code and
stores intermediate optimized codes.
• It also increases the compilation time.