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

Compiler Construction 1

Uploaded by

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

Compiler Construction 1

Uploaded by

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

Compiler Construction

Lecture # 01

Instructor: Muhammad Shahid Khan


Course
Evaluation
 Assignments
 Quizzes
 Term Project /
Report
 Midterm
 Final Exam

2
Key to
Success
 Attendance

Listen to lectures and keep extra notes

Ask questions

 Effort

Do homework on your own. It’s ok to discuss with
others
but make your own effort.

 Consistency

Keep up with reading and homework.
3
Plagiarism
Policy
 According to this policy, a student's submitted
work must be the student's own. In this course,
this policy will be applied to all work submitted
for grade including exams, quizzes, homework,
and projects.

9
Compiler
• Programming languages are notations for describing
computation to people and to machines.
• All the software running on the computers was written in some
programming language.
• Types of Languages:
• High level languages
• Low level languages
• Machine level languages
5
Compilers
• A program 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.

6
Course Description
• The purpose of the course is to become familiar with the
functionality of the different phases in the construction of a
compiler front end and to gain insight of how these phases
are related to each other.

7
Course Description
• Covers the fundamentals & details of following:
• Process of construction of a Compiler
• Lexical Analysis
• Syntax Analysis
• Semantic Analysis
• Syntax Directed Translation
• Intermediate Code Representation

8
Flow of Course
• We start with an Introduction followed by some motivational
material and will also discuss some background issues in
computer architecture and programming-language principles.
• Then we move on to a section which develops a miniature
compiler and introduces many of the important concepts.
• So, then we study lexical analysis, regular expressions, finite-
state machines, and scanner-generator tools. This material is
fundamental to text-processing of all sorts.

9
Flow of Course
• In the later section we will see the major parsing methods,
top- down(recursive-descent, LL) and bottom-up (LR and its
variants).
• Start of last quarter introduces the principal ideas in syntax-
directed definitions and syntax-directed translations.
• Last part of the course takes the theory of previous section
and shows how to use it to generate intermediate code for a
typical programming language.

10
Course Objective
• The course is intended to teach the students the basic
techniques that underlie the practice of Compiler
Construction.
• The course will introduce the theory that can be standardly
employed in order to perform syntax-directed translation of a
high-level programming language into an executable code.

11
Course Objective
• Additionally, These techniques can be employed in wider
areas of application whenever we need a syntax-directed
analysis of symbolic expressions and languages and their
translation into a lower-level description.
• They have multiple applications for man-machine interaction,
including verification and program analysis

12
Recommended Book

13
Course Prerequisites
• It is expected that students are somehow familiar with the
• Data structures
• Programming languages (High level & Low level)
• Automata Theory &
• Operating systems concepts

14
Language Processors
• Simply stated, a compiler is a program that can read a program in one
• language
• -
• the source language
• -
• and translate it into an equivalent program in
• another language
• -
• the target language
• .
• An important role of the
• compiler is to
• report any errors in the
• source program that it detects during
• the translation
• process.

15
Language Processors
• If the target program is an executable machine-language program, it can then be
called by the user to process inputs and produce outputs.

16
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 t he source
program on inputs supplied by the user

17
Compiler vs Interpreter
• Compiler
• Compiler
• Pros
• Pros
• Less space
• Easy debugging
• Fast execution
• Fast development
• Cons
• cons
• Slow processing
• Not for large projects
• Partly Solved
• Require more space
(Separate compilation)
• Slower execution
• Debugging
• Improved thru IDES
18
Language Processor
Java language processors combine compilation
and interpretation, as shown in following figure

19
Language Processor…
• A Java source program may first be
compiled into an intermediate form called
bytecodes.
• The bytecodes are then interpreted by a
virtual machine.
• A benefit of this arrangement is that
bytecodes compiled on one machine can
be interpreted on another machine,
perhaps across a network.
20
Language Processor…
• In order to achieve faster processing of
inputs to outputs, some Java compilers,
called just-in-time compilers, translate the
bytecodes into machine language
immediately before they run the
intermediate program to process the input.

21
Language Processor…
• A source program may be divided into modules stored in
separate files.
• The task of collecting the source program is
sometimes entrusted to a separate program, called
a preprocessor.
• The preprocessor may also expand shorthand's, called
macros, into source language statements. The modified
source program is then fed to a compiler.

22
Language processor…
• The modified source program is then fed to a
compiler.
• The compiler may produce an assembly -language
program as its output, because assembly language is
easier to produce as output and is easier to debug.
• The assembly language is then processed by a
program called an assembler that produces
relocatable machine code as its output.

23
Language processor…
• Large programs are often compiled in pieces, so the
relocatable machine code may have to be linked
together with other relocatable object files and
library files into the code that actually runs on
the machine.
• The linker resolves external memory addresses,
where the code in one file may refer to a location in
another file.
• The loader then puts together the entire executable
object files into memory for execution.
. 24
Language Processing System

25

You might also like