COMPILERS

 COMPILERS:

*A compiler is a computer program which helps you transform source code written in a high-level language into low-level machine language.

*It translates the code written in one programming language to some other language without changing the meaning of the code.

*The compiler also makes the end code efficient which is optimized for execution time and memory space.

Features of compilers:

  • Correctness
  • Speed of compilation
  • Preserve the correct the meaning of the code
  • The speed of the target code
  • Recognize legal and illegal program constructs
  • Good error reporting/handling
  • Code debugging help

​Types of Compiler

*Single Pass Compilers

*Two Pass Compilers

*Multipass Compilers

SINGLE PASS COMPILERS:

  • we combine or group all the phases of compiler design in a single module known as single pass compiler.
  • A one pass/single pass compiler is that type of compiler that passes through the part of each compilation unit exactly once.
  • Single pass compiler is faster and smaller than the multi pass compiler.
  • As a disadvantage of single pass compiler is that it is less efficient in comparison with multipass compiler.
  • Single pass compiler is one that processes the input exactly once, so going directly from lexical analysis to code generator, and then going back for the next read.

Problems with single pass compiler:

  • We can not optimize very well due to the context of expressions are limited.
  • As we can’t backup and process, it again so grammar should be limited or simplified.
  • Command interpreters such as bash/sh/tcsh can be considered as Single pass compiler, but they also execute entry as soon as they are processed.

2. Two Pass compiler or Multi Pass compiler:

   A Two pass/multi-pass Compiler is a type of compiler that processes the source code or abstract syntax tree of a program multiple times. ​

First Pass: is refers as

(a). Front end

(b). Analytic part

(c). Platform independent

Second Pass

(a). Back end

(b). Synthesis Part

(c). Platform Dependent

With multi-pass Compiler we can solve these 2 basic problems:

*If we want to design a compiler for different programming language for same machine. 

*If we want to design a compiler for same programming language for different machine/system.


       

Posted on by