




























































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
Introduction to compiling Definition of compiler, translator, interpreter Analysis of the source program The phases of a compiler Compiler construction tools Programming language basics Lexical analysis Role of lexical analyzer Input buffering Specification of tokens Recognition of tokens using finite automata Regular expressions and finite automata From NFA to DFA Regular expression to an NFA
Typology: Slides
1 / 191
This page cannot be seen from the preview
Don't miss anything!
Introduction to compiling 1.^
Definition of compiler, translator, interpreter
2.^
Analysis of the source program
3.^
The phases of a compiler
4.^
Compiler construction tools
2.
Programming language basics 3.
Lexical
analysis
Lexical
analysis
1.^
Role of lexical analyzer
2.^
Input buffering
3.^
Specification of tokens
4.^
Recognition of tokens using finite automata
5.^
Regular expressions and finite automata
6.^
From NFA to DFA
7.^
Regular expression to an NFA
a)
Definition Of Compiler: ^
Compiler
is^
a^
software(translator/program)
which
converts a program written in high level language(sourcelanguage) to low level language (object/target/machine language)
language)
It converts the whole program in one session and reportserrors detected after the conversion.
compiler
is^
processor
dependent
and
platform
dependent.
Example: GCC(GNU compiler collection)
Types of compiler(Based on compiler passes):^
A compiler pass refers to the traversal of a compilerthrough the entire program. Compiler pass are two types:
Single
pass
compiler
Single
pass
compiler
Two pass compiler or Multi pass Compiler
Single pass compiler: ^
If we combine or group all the phases of compilerdesign
in
a
single
module
known
as
single
pass
compiler.
Example : Pascal ,C
There are two parts to compilation:^ 1.
Analysis:
The analysis part breaks up the source program intoconstituent
pieces
and
creates
an
intermediate
representation of the source program. 2.
Synthesis:
The
synthesis
part
constructs
the
desired
target
program from the intermediate representation.
The context of a compiler: A language processing system:^
A language processor is a software program designed orused to perform tasks such as processing program code tomachine code.
There
are
two
main
types
of
language
processors:
Interpreter
and
translator(Compiler
and
assembler)
Interpreter
and
translator(Compiler
and
assembler)
The difference between an interpreter and a translator isthat an interpreter is telling the computer what to do. Atranslator
takes
the
program’s
code
and converts
it
to
machine code, allowing the computer to read it.
We have learnt that any computer system is made ofhardware
and
software.
The
hardware
understands
a
language, which humans cannot understand. So we writeprograms in high level language, which is easier for us to understand and remember. These programs are then fedinto a series of tools and OS component to get the desiredcode that can be used by the machine. This is known as language processing system.
Preprocessor:
A preprocessor, generally considered as a
part of compiler, is a tool that produces input for compilers.It deals with macro processing,augmentation,file inclusion,language extension etc.
Compiler:
Compile the preprocessed code and translates it
to assembly
code
to assembly
code
Assembler:
An assembler translates assembly language
into machine code. The output of an assembler is called anobject
file,
which
contains
a
combination
of
machine
instructions as well as the data required to place theseinstructions in memory.
Linker:
Linker
is
a
computer
program
that
links
and
merges various object files together in order to make anexecutable file.
Loader:
It is a part of OS and is responsible for loading
executable
files
into
memory
and
execute
them.
It
calculates the size of a program(instructions and data) andcreates memory space for it. It initializes various register toinitiate execution.
b)
Translator: ^
It is a programming language processor that converts a computerprogram from one language to another. It takes a program writtenin source code and converts it into machine code. It discovers andidentifies the error during translation. ^
Purpose:
It translates high level language program into a machinelanguage program that the CPU can understand. It also detectserrors in the program.
^
Types 1.^
Compiler
2.^
Interpreter
3.^
Assembler
c)^
Interpreter: ^
It is a translator used to convert high level programminglanguage to low level programming language. ^
It^
converts
the program one at
a time and
reports
errors
detected at once, while doing the conversion. ^
An interpreter is faster than a compiler as it immediately executes
the
code
upon
reading
the
code
.
executes
the
code
upon
reading
the
code
.
^
It used as a debugging tool for software development as it canexecute a single line of code at a time. ^
An interpreter is also more portable than a compiler as it is notprocessor dependent. ^
Example : Python