0% found this document useful (0 votes)
36 views11 pages

CD Module1 18 1 23 PDF

This document provides an overview of the Compiler Design course including: - A list of 8 recommended textbooks on compiler design - A definition of what a compiler is and its role in translating a program from one language to another - A brief history of compiler development from the 1950s to today - An overview of the phases of a compiler including analysis, synthesis, lexical analysis, syntax analysis, and semantic analysis

Uploaded by

Tapasi Mondal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views11 pages

CD Module1 18 1 23 PDF

This document provides an overview of the Compiler Design course including: - A list of 8 recommended textbooks on compiler design - A definition of what a compiler is and its role in translating a program from one language to another - A brief history of compiler development from the 1950s to today - An overview of the phases of a compiler including analysis, synthesis, lexical analysis, syntax analysis, and semantic analysis

Uploaded by

Tapasi Mondal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Compiler Design (YCS6003)

Introduction
Soumya Majumdar
Text/Reference Books

● A. Aho, V. R. Sethi and D. J. Ullman, “Compilers Principles, Techniques and Tools”,


Pearson Education.
● M. L. Scott, “Programming Language Pragmatics”, Morgan Kaufmann Publishers.
● C. N. Fischer, R. K. Cytron, and R. J. LeBlanc, ”Crafting a Compiler”, Addison-Wesley.
● S. Chattopadhyay, “Compiler Design”, Prentice-Hall of India.
● A. W. Appel, ”Modern Compiler Implementation in C”, Cambridge University Press.
● R. Mark, “Writing Compilers and Interpreters: A Modern Software Engineering Approach
Using Java”, Wiley Publishing.
● K. D. Cooper and L. Torczon, “Engineering a Compiler”, Morgan Kaufmann Publishers.
● A. I. Holub, “Compiler Design in C”, Prentice-Hall of India.
What is compiler?
● If we want to run a program by computer, it should be translated into a form in which it can be
executed by a computer.
● Software systems that do this translation are called Compilers.
● Compiler is a program that can read a program in one language- source language - and
translate it into an equivalent program in another language - target language
● An important role of the compiler is to report any errors in the source program that it
detects during the translation process.
History of Compiler Design
● Software for early computers was primarily written in assembly language, and before that
directly in machine code.
● First practical compiler was written by Corrado Böhm in 1951 for his PhD thesis.
● First implemented compiler was written by Grace Hopper, who also coined the term "compiler".
She refers her A-0 system which functioned as a loader or linker, not the modern notion of a
compiler.
● First Autocode and compiler in the modern sense were developed by Alick Glennie in 1952 at
the University of Manchester for the Mark 1 computer.
● FORTRAN team led by John W. Backus at IBM introduced the first commercially available
compiler in 1957.
● First ALGOL 58 compiler was completed by the end of 1958 by Friedrich L. Bauer, Hermann
Bottenbruch, Heinz Rutishauser, and Klaus Samelson for the Z22 computer.
Language Processing System
Phases of Compiler
Phases of Compiler
● There are two phases of compilers: Analysis phase and Synthesis phase.
● Analysis phase creates an intermediate representation from the given source code
● Synthesis phase creates an equivalent target program from the intermediate representation
● analysis part is often called the front end of the compiler
● synthesis part is the back end of the compiler
Analysis phase
● Analysis part breaks up the source program into constituent pieces and imposes a grammatical
structure on them
● It then uses this structure to create an intermediate representation of the source program
● If the analysis part detects that the source program is either syntactically ill formed or
semantically unsound, then it must provide informative messages, so the user can take
corrective action
● Analysis part also collects information about the source program and stores it in a data structure
called a symbol table
● Symbol table will be passed along with the intermediate representation to the synthesis part
Analysis phase
● Analysis of a source program is divided into mainly three phases. They are:

1. Linear Analysis: This involves a scanning phase where the stream of characters is read from
left to right. It is then grouped into various tokens having a collective meaning.
2. Syntax Analysis: In this analysis phase, based on a collective meaning, the tokens are
categorized hierarchically into nested groups.
3. Semantic Analysis: This phase is used to check whether the components of the source
program are meaningful or not.
Synthesis phase
● Synthesis part constructs the desired target program from the intermediate representation and the
information in the symbol table
Lexical Analysis
● First phase of compiler is also called lexical analysis/scanning
● Lexical analyzer reads stream of characters making up the source program and groups
characters into meaningful sequences called lexeme
● For each lexeme, lexical analyzer produces as output a token of form

(token-name, attribute-value)

● In token, first component token-name is an abstract symbol that is used during syntax analysis,
● Second component attribute-value points to an entry in the symbol table for this token.
● Information from the symbol-table entry 'is needed for semantic analysis and code generation
● suppose a source program contains the assignment statement

position = initial + rate * 60

position, initial, rate

You might also like