![]() |
VOOZH | about |
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.
👁 compilerDesignDiagramThese are some operations that are done by the compiler.
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:
Processes the source code before compilation begins.
It performs the following tasks:
#include)#define)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.
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.
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.
Combines multiple object files into a single executable file.
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:
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.
Compilers are classified into different types based on how they translate source code and when the translation process takes place.
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.
A two-pass compiler processes the source code twice:
It produces more accurate results than a single-pass compiler.
An AOT compiler converts the entire source code into machine code before execution.
It improves startup time and runtime performance.
An incremental compiler compiles only the modified parts of the program instead of recompiling the entire code.
It saves time and improves development efficiency.