0% found this document useful (0 votes)
3 views

CC lec 1

Uploaded by

Wahaj ch
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

CC lec 1

Uploaded by

Wahaj ch
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 20

COMPILER

CONSTRUCTIO
N
Lecture # 1
PRE-REQUISITE
 Theory of automata
RECOMMENDED BOOKS
 Compilers: Principles, Techniques and Tools, Alfred v.Aho, Ravi Sethi ,
Jeffrey D.Ullman.
 Modern Compiler Design, D. Grune, H. E. Bal, C. J. H. Jacobs, K. G.
Langendoen,
 John Wiley, 2003.
 Modern Compiler Implementation in C, A. W. Appel, M. Ginsburg,
Cambridge University Press, 2004.
COURSE OBJECTIVES
 At the end of the course:
 you will know the basic theories and methodologies behind the
construction of a compiler
 you should be able to understand the basic issues related to compilers
construction.
TODAY'S LECTURE
 Introduction to Compiler

 Language Processing System

 Exercise
INTRODUCTION TO
COMPILERS
 Programming languages are notations for describing computations to
people and to machines.
 The world as we know it depends on programming languages, because all
the software running on all the computers was written in some
programming language.
 But, before a program can be run, it first must be translated into a form in
which it can be executed by a computer.
 The software systems that do this translation are called compilers.
WHY STUDY COMPILER?
 Build a large ambitious software system.
 See theory come to life.
 Learn how to build programming language.
 Learn how programming language works.
 Learn tradeoffs in language design
HISTORY
 1940s: computers programmed in assembly
 1951-2: Grace Hopper developed A-0 for the UNIVAC I
 1957: FORTRAN compiler developed by team led by John Backus
 1960s: development of the first bootstrapping compiler for LISP
A MORE FORMAL
DEFINITION OF COMPILER
 It is a software program that
converts a program written in HLL
(Source Code) into low level
language (target or object code).
 Also reports errors in programs
(Debugging).
LANGUAGE TRANSLATORS
 A program that translates between high level languages is usually called a
language translator ,source to source translator ,language converter,or
language rewriter
 This last term is usually applied to translations that do not involve a change
of language

 Compiler is also type of Language translator, but it converts low HLL to


m/c.
INTERPRETER
 An interpreter is another common kind of language processor.
 Instead of producing a target program as a translation, an interpreter
appears to directly execute the operations specified in the source program
on inputs supplied by the user.
LANGUAGE PROCESSING
SYSTEM
 In addition to a compiler, several
other programs may be required
to create an executable target
program.
CONT...
 Preprocessor
 A preprocessor produce input to compilers.
 In preprocessing, HLL is
converted to modified
HLL/ pure HLL.
CONT...
They may perform following functions:
 File Inclusion: It may remove preprocessor directives and include
respective header files.
 e.g., #include<stdio.h>
 Macro Expansion: Allow a user define macros that are Short
hands for a longer construction.
 e.g., a++ to a=a+1
 Language Extension: These processors attempt add capabilities
to the language.
 e.g., the language EQUEL is a database query language
embedded in C.
CONT...
 Compiler
 Modified HLL is fed to the compiler
as input
 it will generate an intermediate
code/ assembly code (the target
program)
CONT.
 Assembler
 Some compiler produce assembly
code that is passed to an
Assembler for further processing.
 Producing relocatable machine
code
CONT.
 Linker
 Large programs are often
compiled in pieces, so they may
have to be linked together with
other relocatable object files and
library files into executable files.
 Loader
 Loads that executable file and
execute it.
We will study further about it.
ANSWER THE FOLLOWING:
 Exercise 1.1.1 : What is the difference between a compiler and an interpreter?
 Exercise 1.1.2 : What are the advantages of (a) a compiler over an interpreter
 (b) an interpreter over a compiler?
 Exercise 1.1.3 : What advantages are there to a language-processing system in
 which the compiler produces assembly language rather than machine language?
 Exercise 1.1.4 : A compiler that translates a high-level language into another
high-level language is called a source-to-source translator. What advantages are
there to using C as a target language for a compiler?
 Exercise 1.1.5 : Describe some of the tasks that an assembler needs to perform.
SUGGESTED READING
 Aho2, Ch#1, sec 1.1.

You might also like