Docsity

DIFFRENCE BETWEEN TWO PASSES AND THREE PASSES COMPILER, Summaries of Compiler Construction

Toggle sidebar
bg1
Two-Pass vs Three-Pass Compilers
Definitions
Two-Pass Compiler:
A two-pass compiler processes the source code in two main steps:
1. First Pass: Reads and analyzes the code (collects information like types and variables).
2. Second Pass: Generates the final machine code using the collected info.
Roman Urdu:
Two-pass compiler source code ko do steps mein process karta hai:
1. Pehla pass: Code ko read karta hai aur information collect karta hai.
2. Doosra pass: Us info ko use karke machine code banata hai.
Three-Pass Compiler:
A three-pass compiler processes code in three stages:
1. Front End: Checks syntax and structure.
2. Middle End: Optimizes the code.
3. Back End: Generates machine code.
Roman Urdu:
Three-pass compiler teen stages mein kaam karta hai:
1. Pehla pass: Syntax check karta hai.
2. Doosra pass: Code ko optimize karta hai.
3. Teesra pass: Final machine code banata hai.
Examples
Examples of Two-Pass Compilers:
pf3

Partial preview of the text

Download DIFFRENCE BETWEEN TWO PASSES AND THREE PASSES COMPILER and more Summaries Compiler Construction in PDF only on Docsity!

Two-Pass vs Three-Pass Compilers

Definitions

Two-Pass Compiler: A two-pass compiler processes the source code in two main steps:

  1. First Pass: Reads and analyzes the code (collects information like types and variables).
  2. Second Pass: Generates the final machine code using the collected info.

Roman Urdu: Two-pass compiler source code ko do steps mein process karta hai:

  1. Pehla pass: Code ko read karta hai aur information collect karta hai.
  2. Doosra pass: Us info ko use karke machine code banata hai.

Three-Pass Compiler: A three-pass compiler processes code in three stages:

  1. Front End: Checks syntax and structure.
  2. Middle End: Optimizes the code.
  3. Back End: Generates machine code.

Roman Urdu: Three-pass compiler teen stages mein kaam karta hai:

  1. Pehla pass: Syntax check karta hai.
  2. Doosra pass: Code ko optimize karta hai.
  3. Teesra pass: Final machine code banata hai.

Examples

Examples of Two-Pass Compilers:

  • Old Pascal Compilers
  • Early C Compilers (e.g., UNIX C Compiler)

Examples of Three-Pass Compilers:

  • LLVM (Clang)
  • Java HotSpot Compiler

Key Differences

  1. Number of Passes:
  • Two-Pass: 2
  • Three-Pass: 3
  1. Optimization:
  • Two-Pass: Basic or no optimization
  • Three-Pass: Advanced optimization
  1. Compilation Speed:
  • Two-Pass: Faster
  • Three-Pass: Slower but more efficient output
  1. Complexity:
  • Two-Pass: Simpler
  • Three-Pass: More complex
  1. Use Case:
  • Two-Pass: Suitable for small/medium programs
  • Three-Pass: Suitable for large and performance-critical applications