You are on page 1of 13

1

Lahore Garrison University


CSC373-Compiler Construction
Week-1 Lecture-2
Semester-#5 FALL 2019

Prepared by:

Eisha Tir Razia


2
Instructor Contact Details

 Instructor Name: Eisha Tir Razia


 Course : CSC373- Compiler Construction
 Credit Hours: 3
 Office Location: CS-Female Staff Room
 Email: eisha@lgu.edu.pk
 Visiting Hours: Tuesday 11:00 am to 12:00 pm

Lahore Garrison University


3
Cousins of the Compiler

 Preprocessor
 Assemblers
 Loader
 Link Editors

Lahore Garrison University


4
Preprocessor

 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 shorthands, called macros, into source language statements

Lahore Garrison University


5
Assembler

 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

Lahore Garrison University


6
Link Editor

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

Lahore Garrison University


7
Loader

 The loader then puts together all of the executable object files into
memory for execution

Lahore Garrison University


8
Cont..

Lahore Garrison University


9

Quiz

Lahore Garrison University


10
Properties of Compiler

 Compiler itself must be bug-free


 Machine code is generated in correct form
 Generated machine code must run fast.
 Compiler itself must run fast
 Compiler must be portable
 It must gives good diagnostics error messages
 The generated code must work well
 It must have consistent optimization

Lahore Garrison University


11
Interpreter

 Interpreter is a program that appears to execute a source


program as if it were machine language.

Lahore Garrison University


12

Q&A

Lahore Garrison University


13
References

Compilers: Principles, Techniques, and Tools By Alfred V. Aho, Ravi Sethi, Jeffrey D.
Ullman, Contributor Jeffrey D. Ullman, Addison-Wesley Pub. Co., 2nd edition, 2006

Lahore Garrison University

You might also like