You are on page 1of 16

Department of Computer Science and Engineering

School of Technology

T. Y. B. Tech
Course - Compiler Design (CST305R1)
Unit No – 1 – Introduction To Compiler
[ U1 – L5]
Course Coordinator – Ms. Sujata A. Pardeshi,
Assistant Professor, CSE, SOT.
Points to be cover

■ Review on Previous Lecture


■ Compiler Construction Tools
■ Application of Compiler Technologies Part - I

7/6/2020 CSE, SOT, SGU 2


Review on Previous Lecture
■ Quiz

7/6/2020 CSE, SOT, SGU 3


Compiler Construction Tools
■ Scanner Generator
■ Parser Generator
■ Syntax directed translation engines
■ Automatic code generators
■ Data-flow analysis engines
■ Compiler construction toolkits

7/6/2020 CSE, SOT, SGU 4


Compiler Construction Tool – Scanner Generator

int a1, a2;


To write down name of the identifiers in C
programming language there is rule
•It should start with either “_” or alphabetical
letter
•Then it will follow by any letter or digit.
•Based on these two rules a pattern is defined
in terms of the regular expression which
• RE – _ |(A-Z | a-z )* (A-Z | a-z )* | (0-9)*

7/6/2020 CSE, SOT, SGU 5


Compiler Construction Tool – Parser Generator
■ It produces syntax analyzers (parsers) from the input (series of the
tokens received from lexical analyzer).
■ Use of grammatical description of programming language or on a
context-free grammar.
■ The syntax analysis phase is highly complex and consumes more
manual and compilation time of the compiler and generates the output
as the Abstract syntax tree.
■ Example: Yacc Tool

7/6/2020 CSE, SOT, SGU 6


7/6/2020 CSE, SOT, SGU 7
Compiler Construction Tool - Syntax directed translation engines

■ It generates intermediate code with three address


format from a parse tree provided from the parser.
■ These engines have routines / small programs to
traverse the parse tree and then produce the
intermediate code.
■ During traversing, each node of the parse tree is
associated with one or more translations which
generate Syntax Directed Definition [SDD] and
Syntax Directed Translation [SDT].

7/6/2020 CSE, SOT, SGU 8


Compiler Construction Tool - Syntax directed translation engines

7/6/2020 CSE, SOT, SGU 9


Compiler Construction Tool – Automatic Code Generator

■ It generates the machine language for a target machine.


■ Each operation of the intermediate language is translated using
a collection of rules.
■ These rules are taken as an input by the code generator to
generate the code by using template matching process.
■ An intermediate language statement is replaced by its
equivalent machine language statement using templates

7/6/2020 CSE, SOT, SGU 10


Compiler Construction Tool - Data-flow analysis engines

■ It is used in code optimization.


■ Data flow analysis is a key part of the code optimization that
gathers the information about the flow of values that flow from
one part of a program to next part.

7/6/2020 CSE, SOT, SGU 11


Compiler Construction Tool - Compiler
construction toolkits

■ It provides an integrated set of routines that aids in building


compiler components or in the construction of various phases
of compiler.

7/6/2020 CSE, SOT, SGU 12


Applications of Computer Technology – Part - I

■ Implementation of High – Level Programming Languages


■ Optimization for Computer Architectures

7/6/2020 CSE, SOT, SGU 13


Applications of Computer Technology –Implementation
of High – Level Programming Languages

■ A HLL programming languages defines programme abstraction


while writing the programs which are less efficient as it takes
more time to convert the code into low level language.
■ Writing the programme in low level language is highly
efficient but its very difficult to write down code.
■ So once code is written in HLL, it is required for optimizing by
the compilers to include the techniques to improve the
performance of the generated target code

7/6/2020 CSE, SOT, SGU 14


Implementation of High – Level Programming Languages
■ Use of User defined aggregate data types such as arrays and structure in C, C++ and
COBOL programming languages.
■ High level control flow such as loops and invocations of procedures.
■ Use of Data flow optimization compiler optimization techniques to analyze the flow of
data through the program and remove the redundancies across these constructs.
■ Use of Data Abstraction techniques, Inheritance of properties in different languages
such as C++, C#, and Java to make program more modular and easier to maintain.
■ Use of Type - Safe, Checking of bounds of arrays in Java.
■ Java uses the Built in Garbage collection which automatically frees memory of
variables which are not in use. So efficient algorithms have been written to minimize
the overhead of the garbage collection.
■ OOP program contain many more but small procedures called as methods for which
compiler optimization must perform procedure inlining.

7/6/2020 CSE, SOT, SGU 15


Thank You

7/6/2020 CSE, SOT, SGU 16

You might also like