Introduction of Compiler Design (original) (raw)

Last Updated : 11 Apr, 2026

A compiler is software that translates or converts a program written in a high-level language (Source Language) into a low-level language (Machine Language or Assembly Language). Compiler design is the process of developing a compiler.

compilerDesignDiagram

Operations of Compilers

These are some operations that are done by the compiler.

**Compiler and Other Language Processing Systems

Computers understand only machine language, which is difficult for humans to write and understand. Therefore, we write programs in high-level languages.

To convert these programs into machine language, different language processing tools are used:

high_level_language

High-Level Language to Machine Code

Preprocessor

Processes the source code before compilation begins.

It performs the following tasks:

Example:
If the program contains #include <stdio.h>, the preprocessor replaces this directive with the actual contents of the stdio.h file in the output.

Assembler

Assembly language is neither pure binary nor a high-level language. It is a low-level language that uses symbolic instructions to represent machine code.

The assembler converts assembly language into machine code.

Compiler

A compiler is a system program that translates an entire high-level language program into machine code.

It performs:

A compiler processes the entire program at once and then generates the output file. Compilation may take more time and memory, but the resulting program runs faster.

Linker

Combines multiple object files into a single executable file.

Loader

The loader loads the executable file into main memory for execution.

Since the code generated by the compiler and linker is usually **relocatable (its starting address is not fixed), the loader:

Interpreter

An interpreter also converts high-level language into machine language, but it works differently from a compiler.

Because translation happens during execution, interpreted programs are generally slower than compiled programs.

Types of Compilers

Compilers are classified into different types based on how they translate source code and when the translation process takes place.

Self Compiler

A self compiler or a resident compiler is a compiler that runs on a machine and generates machine code for the same machine on which it is running.

Cross Compiler

Source-to-Source Compiler (Transpiler)

Single-Pass Compiler

Two-Pass Compiler

A two-pass compiler processes the source code twice:

It produces more accurate results than a single-pass compiler.

Multi-Pass Compiler

Just-in-Time (JIT) Compiler

Ahead-of-Time (AOT) Compiler

An AOT compiler converts the entire source code into machine code before execution.
It improves startup time and runtime performance.

Incremental Compiler

An incremental compiler compiles only the modified parts of the program instead of recompiling the entire code.
It saves time and improves development efficiency.