Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 18

Compiler

Construction
INTRODUCTION

1
Outline
1. Introduction to the Course
1. Course Introduction
2. Course Objectives
3. Organization of the Course
4. Topics to be Covered
5. Pre-requisites & Evaluation
2. Introduction to Compiler
3. Summary

2
Course Introduction
At the end of the course, students should understand the overall
structure of a compiler, and will have the knowledge of the significant
details of a number of important techniques commonly used. The
language features that raise challenges for compiler builders are also
introduced in this course.

3
Course Objectives
Understand the basic concept of compiler design,
and its different phases which will be helpful to
construct new tools like LEX, YACC, etc.

4
LEARNING OUTCOMES
• Acquire knowledge in different phases and passes of
Compiler, and specifying different types of tokens by lexical
analyzer, and also able to use the Compiler tools like LEX,
YACC, etc.
• Parser and its types i.e. Top-down and Bottom-up parsers.
•Construction of LL, SLR, CLR and LALR parse table.
• Syntax directed translation, synthesized and inherited
attributes.
• Techniques for code optimization.

5
Topics to be Covered
Introduction to Compilers
Lexical Analysis
Syntax analysis
Run-time Storage Organization
Intermediate Code Generation
Optimization
Code Generation

6
TEXT BOOK
Compiler Design K.Muneeswaran, OXFORD

Reference BOOKS
1. Compilers, Principles Techniques and Tools.Alfred V Aho, Monical S.
Lam, Ravi Sethi Jeffery D. Ullman,2nd edition,pearson,2007
2.Principles of compiler design,2nd edition,Nandhini Prasad,Elsebier.
REFERENCE BOOKS:
3. Compiler Construction, Principles and practice, Kenneth C Louden,
CENGAGE
4. Implementations of Compiler, A New approach to Compilers including
the algebraic methods, Yunlinsu ,SPRINGER

7
Pre-requisites & Evaluation
Pre-requisites
◦ Automata Theory
◦ Computer Programming

Evaluation
◦ Mid-term Exam 25%
◦ Final Exam 35%
◦ Class Assignments 10%
◦ Lab Assignments 10%
◦ Quiz 10%
◦ Project 10%

8
9
What is a Compiler?
Compiler is a tool:
which translate notations from one system to another, usually from
source code (high level code) to machine code (object code, target
code, low level code).

10
What is a Compiler? (Continue…)
A computer program translates one language to
another
Source Compiler Target
Program Program

A compiler is a complex program


◦ From 10,000 to 1,000,000 lines of codes

Compilers are used in many forms of computing


◦ Command interpreters, interface programs

11
Why Compiler?
Writing machine language-numeric codes is time
consuming and tedious
C7 06 0000 0002
Mov x, 2
X=2

The assembly language has a number of defects


◦ Not easy to write
◦ Difficult to read and understand

12
13
Brief History of Compiler
The first compiler was developed between 1954 and 1957
◦ The FORTRAN language and its compiler by a team at IBM led
by John Backus
◦ The structure of natural language was studied at about the
same time by Noam Chomsky
◦ Chomsky classified languages according to the complexity of their
grammar
◦ Chomsky’s Hierarchy, as it is now called have four levels of grammar type
0, 1, 2, and 3
◦ The type 2 or context free grammar is considered the most useful for
programming languages

14
Files Involved in Compiler
Operations
A source code text file (.c, .cpp, .java, etc. file
extensions)
Intermediate code files: transformations of source
code during compilation, usually kept in temporary
files rarely seen by the user
An assembly code text file containing symbolic
machine code, often produced as the output of a
compiler (.asm, .s file extensions)

15
Files Involved in Compiler
Operations
(Continue…)
One or more binary object code files: machine instructions, not yet
linked or executable (.obj, .o file extensions)
A binary executable file: linked, independently executable (well, not
always…) code (.exe, .out extensions, or no extension)

16
Difference between a
Compiler and an Interpreter

17
18

You might also like