Compiler Design - Phases of Compiler

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

Compiler Design - Phases of Compiler

The compilation process is a sequence of various phases. Each phase


takes input from its previous stage, its own representation of source
program, and feeds its output to the next phase of the compiler.
Lexical Analysis
The first phase of scanner works as a text scanner. This phase scans the
source code as a stream of characters
Syntax Analysis
The next phase is called the syntax analysis or parsing. It takes the token
produced by lexical analysis as input and generates a parse tree

Semantic Analysis
Semantic analysis checks whether the parse tree constructed follows the
rules of language

Intermediate Code Generation


After semantic analysis the compiler generates an intermediate code of the
source code for the target machine. 

Code Optimization
The next phase does code optimization of the intermediate code.
Optimization can be assumed as something that removes unnecessary code
lines, 

Code Generation
The code generator translates the intermediate code into a sequence of
(generally) re-locatable machine code. 

Symbol Table
The symbol table makes it easier for the compiler to quickly search the
identifier record and retrieve it. The symbol table is also used for scope
management.

Applications of Compiler Technology


 Compiler technology has other important uses as well. Additionally,
compiler design impacts several other areas of computer science.

1 Implementation of High-Level Programming


A high-level programming language defines a programming abstraction:
the programmer expresses an algorithm using the language, and the
compiler must translate that program to the target language.

2. Optimizations for Computer Architectures


The rapid evolution of computer architectures has also led to an insatiable
demand for new compiler technology. 

3. Design of New Computer Architectures


Thus, in modern computer architecture development, compilers are
developed in the processor-design stage, and compiled code, running on
simulators, is used to evaluate the proposed architectural features.

4. Program Translations
 
While we normally think of compiling as a translation from a high-level language
to the machine level, the same technology can be applied to translate between
different kinds of languages. 

5. Software Productivity Tools


 
Programs are arguably the most complicated engineering artifacts ever pro-duced;
they consist of many many details, every one of which must be correct before the
program will work completely. 

You might also like