Sie sind auf Seite 1von 3

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING

KAKATIYA INSTITUTE OF TECHNOLOGY & SCIENCE,


WARANGAL
(An Autonomous Institute under Kakatiya University, Warangal)

Special Assignment -1 as Course Research Paper (SA-CRP1 )

NAME: Sri Shiva Narasimha Dev Para

ROLL_NO: B18CS143

CLASS: B.Tech. V-Semester

SECTION: CSE-III

Code-Subject: U18CS503 –compiler design

TITLE OF RESEARCH PAPER:

ABSTRACT
We are in need of a interface or a software program that changes given source code
to our required code, that interface or software program is simply called as compiler.
Compiler simply cannot convert our code, compiler consists of many layers or stages,
In which each layer performs particular task. Let’s see all these.

Introduction
Computer cannot understand our language (high level language),it can understands
only binary code(low level language).Compiler is the software that converts into
binary code. Before going into compiler, lets see what are pre-processors,
translators, linkers and loaders as well as Language Processing System
LANGUAGE PROCESSING SYSTEM: It consists of 1) Pre-processor, 2) Compiler, 3)
Assembler, 4) Linker, 5) Loader. All these shows how the language is processing.
PRE-PROCESSOR: It is a program which works on input data to give output. The
output is a high-level language. Its main task is to load files that all are useful for
compiler.
COMPILER: It compiles the code and generate intermediate code to give target code.
Displays error messages if any errors are present in our source code.
ASSEMBLER: It is also like a compiler used for assembly language which translates
into machine understandable code. It is useful for developers to access hardware.
LINKERS: Its main task is to link files such as source file, library file, object file into
single file in order make this single file into executable file.
LODAERS: We can see loader in operating system whose task is to load executable
files into memory and execute them. It also checks for memory space to load data.

COMPILER DESIGN AND ITS PROCEDURE


Before designing anything, planning is important to get desired results. And same
goes with compiler know as algorithm of compiler. It consists of 6 phases they are as
follows
1. Lexical Analyzer:
lexical is the tool used in lexical analyser that gives output as a stream of
tokens. It takes source code as input which contains variables, white-spaces,
numbers, symbols etc. The generated stream of tokens are sent to parser one
by one. Parser after receiving one token sends ‘get next token’ command to
lexical analyser it continues till all tokens are completed.
2. Syntax Analyzer:
Syntax analyser is also known as parser, takes tokens as input and combines it
into syntax tree where tokens are stored in tree leaves. Syntax tree is the final
output of syntax analyser. Parser is divided into two types depending upon
how the tree is build. 1) top down parser and 2) Bottom up parser.

3. Semantic Analyzer:
Semantic analyser is to check the syntax such that they are meaningful. Its
input is syntax tree and checks whether the tree is semantically meaningful or
not. And by performing some tasks like type checking, level checking, Flow
control checking in order to generate output as syntax tree which is
semantically meaningful.

4. Intermediate Code Generation:


Analysis process is same for any kind of machine. So intermediate code
generator consists of information about analysis. Such that when we compile
our source code in a new machine it helps new compiler to start compilation
from this phase. Syntax tree as input and generates intermediate code as
output.

5. Code Optimization:
Code optimiser belongs to synthesis phase which optimizes intermediate code
in order to decrease compilation time by using limited resources of system
such as CPU, memory etc. Optimization is done by removing unnecessary
symbols which makes code size smaller. Divided into 2 types 1) Machine
Independent and 2) Machine Dependent

6. Code Generation:
Input is taken from code optimizer performs particular task based on special
instructions and generates machine understandable code.

CONCLUSION
This is how the compiler translates source code into target code. It consists of two
phases known as analysis phase and synthesis phase also known as front end and
back end of compiler respectively.

Das könnte Ihnen auch gefallen