Вы находитесь на странице: 1из 19

Compiler Construction

(CS-636)
Muhammad Bilal Bashir
UIIT, Rawalpindi

Outline
Introduction to the Course

1.
1.
2.
3.
4.
5.

2.
3.

Course Introduction
Course Objectives
Organization of the Course
Topics to be Covered
Pre-requisites & Evaluation

Introduction to Compiler
Summary

Introduction to the
Course
Compiler Construction
CS-636

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.

Course Objectives

To teach students the basic concepts of


compilers, their components and how they work
together
To get lexical analyzer and syntax analyzer
implemented of any programming language,
most likely C++

Organization of the Course

Theoretical

Presentation

This part will be covered through lectures delivered


with the help of slides during class meetings
Students will be given a topic to prepare a brief
presentation. The presentation will be scheduled in the
later part of the semester

Project

Implementation of Lexical Analyzer and Parser of C++


OR Java will be required from the students
6

Topics to be Covered

Compiler introduction
Organization of compilers
Background / Revision of Automata Concepts
Lexical analysis
Syntax analysis
Parsing techniques
Object code generation and optimization
Detection and recovery from errors
Advanced Topics
7

Pre-requisites & Evaluation

Pre-requisites

Automata Theory
Computer Programming

Evaluation

Mid-term Exam
12%
Quizzes, Assignments, & Project 8%
Final Theory
20%
Final Practical
20%
8

Miscellaneous

Online Course Folder


http://jbillu.net/cc/

How to Reach Me
bilalbezar@gmail.com
Subject: CC - XYZ

Introduction to
Compiler
Lecture: 1

10

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).

11

What is a Compiler?

A computer program translates one language to


another
Source
Program

Compiler

Target
Program

A compiler is a complex program

(Continue)

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

Compilers are used in many forms of computing

Command interpreters, interface programs

12

What is Involved in
Compilers?

Programming Languages
Formal Languages
Regular Expressions & Automata Theory
Applications

Programming Languages ?

We use natural languages to communicate


We use programming languages to speak with
computers
13

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
14

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
Chomskys 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
15

Brief History of Compiler


(Continue)

Recent advances in compiler design

More sophisticated algorithms for inferring and/or


simplifying the information contained in program,

Window-based Interactive Development


Environment

such as the unification algorithm of Hindley-Milner


type checking

IDE that includes editors, linkers, debuggers, and


project managers

However, the basic of compiler design have not


changed much in the last 50+ years
16

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)

17

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)

18

Summary

Any Questions?

19

Вам также может понравиться