What is Compiler Design?

Compiler DesignProgramming LanguagesComputer Programming

A compiler is a program that translates a high-level language (for example, C, C++, and Java) into a low-level language (object program or machine program).

The compiler also finds out the various errors encountered during the compilation of a program.

The compiler converts high-level language into low-level language using various phases. A character stream inputted by the customer goes through multiple stages of compilation which at last will provide target language.

The task of the compiler is to change the program written in one language without changing the meaning of the program. When you implement a program that is written in the HLL programming language then it implements into two parts. In the first element, the source code is compiled and translated into the object code (low-level language). In the second element, the object program is translated into the target code through the assembler.

Features of Compiler

There are various features of compilers which are as follows −

  • It compiles a large amount of code in less time.

  • It needed less amount of memory area to compile the source language.

  • It can compile only the modified code segment if frequent alterations are needed in the source code.

  • While managing the hardware interrupts best compilers connect closely with the operating system.

Advantages of Compiler

There are various advantages of the compiler which are as follows −

  • A compiler translates a code in a single run.

  • It consumes less time.

  • CPU utilization is more.

  • Both syntactic and semantic errors can be checked concurrently.

  • It is easily supported by many high-level languages like C, C++, JAVA, etc.

Disadvantages of Compiler

There are various disadvantages of the compiler which are as follows −

  • It is not flexible.

  • It consumes more space.

  • Error localization is difficult.

  • The source program has to be compiled for every modification.

  • It must generate the correct machine code which should run fast.

  • It should be portable.

  • It should give diagnostic and error messages.

  • It must have consistent optimization.

Types of Compiler

There are two types of compilers are as follows −

One-Pass Compiler

One pass compiler reads the code only once and then translates it. The one-pass compiler passes only once through the parts of each compilation unit. It translates each part into its final machine program. In the one-pass compiler, when the line source is processed, it is scanned and the token is extracted.

Multi-Pass Compiler

Compiler scans the input source once and creates the first modified form, thus scans the first-produced form and create a second modified form, etc., until the object form is produced. Such a compiler is known as a multi-pass compiler.

raja
Published on 22-Oct-2021 11:32:27
Advertisements