BY
S.SUDHAA
ASSISTANT PROFESSOR,
SELVAMM ARTS AND SCIENCE COLLEGE ,
NAMAKKAL
 Computers are a balanced mix of software and hardware.
Hardware is just a piece of mechanical device and its
functions are being controlled by a compatible software.
Hardware understands instructions in the form of electronic
charge, which is the counterpart of binary language in
software programming. Binary language has only two
alphabets, 0 and 1.
 To instruct, the hardware codes must be written in binary
format, which is simply a series of 1s and 0s. It would be a
difficult and cumbersome task for computer programmers
to write such codes, which is why we have compilers to
write such codes.
 We have learnt that any computer system is made of
hardware and software. The hardware understands a
language, which humans cannot understand. So we
write programs in high-level language, which is easier
for us to understand and remember.
 These programs are then fed into a series of tools and
OS components to get the desired code that can be used
by the machine. This is known as Language Processing
System.
 The high-level language is converted into binary language in
various phases. A compiler is a program that converts high-
level language to assembly language. Similarly,
an assembler is a program that converts the assembly language
to machine-level language.
 Let us first understand how a program, using C compiler, is
executed on a host machine.
 User writes a program in C language (high-level language).
 The C compiler, compiles the program and translates it to
assembly program (low-level language).
 An assembler then translates the assembly program into
machine code (object).
 A linker tool is used to link all the parts of the program
together for execution (executable machine code).
 A loader loads all of them into memory and then the program is
executed.
 Before diving straight into the concepts of compilers, we
should understand a few other tools that work closely with
compilers.
Compiler:
It is a translator which takes input i.e., High-Level
Language, and produces an output of low-level
language i.e. machine or assembly language.
 A compiler is more intelligent than an assembler it
checks all kinds of limits, ranges, errors, etc.
 But its program run time is more and occupies a
larger part of memory. It has slow speed because a
compiler goes through the entire program and then
translates the entire program into machine codes.
 An interpreter is a program that translates a
programming language into a
comprehensible language. –
 It translates only one statement of the
program at a time.
 Interpreters, more often than not are smaller
than compilers.
COMPILER INTERPRETER
Compiler scans the whole program in one
go.
Translates program one statement at a
time.
As it scans the code in one go, the errors
(if any) are shown at the end together.
Considering it scans code one line at a
time, errors are shown line by line.
Main advantage of compilers is it’s
execution time.
Due to interpreters being slow in
executing the object code, it is preferred
less.
It converts the source code into object
code.
It does not convert source code into object
code instead it scans it line by line
It does not require source code for later
execution.
It requires source code for later execution.
Eg. C, C++, C# etc Python, Ruby, Perl, SNOBOL, MATLAB, etc.
 Any program written in a high level
language is known as source code .
Before it can be run, source code must
first be translated into a form which a
computer understands - this form is
called object code. A translator is a
program that converts source code into
object code..

Compiler design slide share

  • 1.
    BY S.SUDHAA ASSISTANT PROFESSOR, SELVAMM ARTSAND SCIENCE COLLEGE , NAMAKKAL
  • 2.
     Computers area balanced mix of software and hardware. Hardware is just a piece of mechanical device and its functions are being controlled by a compatible software. Hardware understands instructions in the form of electronic charge, which is the counterpart of binary language in software programming. Binary language has only two alphabets, 0 and 1.  To instruct, the hardware codes must be written in binary format, which is simply a series of 1s and 0s. It would be a difficult and cumbersome task for computer programmers to write such codes, which is why we have compilers to write such codes.
  • 3.
     We havelearnt that any computer system is made of hardware and software. The hardware understands a language, which humans cannot understand. So we write programs in high-level language, which is easier for us to understand and remember.  These programs are then fed into a series of tools and OS components to get the desired code that can be used by the machine. This is known as Language Processing System.
  • 5.
     The high-levellanguage is converted into binary language in various phases. A compiler is a program that converts high- level language to assembly language. Similarly, an assembler is a program that converts the assembly language to machine-level language.  Let us first understand how a program, using C compiler, is executed on a host machine.  User writes a program in C language (high-level language).  The C compiler, compiles the program and translates it to assembly program (low-level language).  An assembler then translates the assembly program into machine code (object).  A linker tool is used to link all the parts of the program together for execution (executable machine code).  A loader loads all of them into memory and then the program is executed.  Before diving straight into the concepts of compilers, we should understand a few other tools that work closely with compilers.
  • 6.
    Compiler: It is atranslator which takes input i.e., High-Level Language, and produces an output of low-level language i.e. machine or assembly language.  A compiler is more intelligent than an assembler it checks all kinds of limits, ranges, errors, etc.  But its program run time is more and occupies a larger part of memory. It has slow speed because a compiler goes through the entire program and then translates the entire program into machine codes.
  • 8.
     An interpreteris a program that translates a programming language into a comprehensible language. –  It translates only one statement of the program at a time.  Interpreters, more often than not are smaller than compilers.
  • 9.
    COMPILER INTERPRETER Compiler scansthe whole program in one go. Translates program one statement at a time. As it scans the code in one go, the errors (if any) are shown at the end together. Considering it scans code one line at a time, errors are shown line by line. Main advantage of compilers is it’s execution time. Due to interpreters being slow in executing the object code, it is preferred less. It converts the source code into object code. It does not convert source code into object code instead it scans it line by line It does not require source code for later execution. It requires source code for later execution. Eg. C, C++, C# etc Python, Ruby, Perl, SNOBOL, MATLAB, etc.
  • 10.
     Any programwritten in a high level language is known as source code . Before it can be run, source code must first be translated into a form which a computer understands - this form is called object code. A translator is a program that converts source code into object code..