Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Compiler Design, Slides of Compiler Design

An overview of Compiler Design, including Language Processors, Structure of Compiler, Compiler Construction tools, Science of building a compiler, Applications of compiler technology, Basics of lexical analysis, and Syntax Analysis. It also covers the topics of Intermediate Code generation, Code Optimization, and Code Generation. the difference between compilers and interpreters, and the advantages and disadvantages of each. It also discusses the concept of high-level languages, pre-processors, assembly languages, and relocatable machine code.

Typology: Slides

2021/2022

Available from 09/23/2023

avishek-1
avishek-1 🇮🇳

4 documents

1 / 53

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Compiler Design
18CS73
Text book: Compilers, Techniques, and Tools
(Second Edition), Aho, Lam, Sethi, and
Ullman, Addison-Wesley, Pearson education,2007
Ref:https://nptel.ac.in/downloads/106108113/
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35

Partial preview of the text

Download Compiler Design and more Slides Compiler Design in PDF only on Docsity!

Compiler Design

18CS

Text book: Compilers, Techniques, and Tools

(Second Edition), Aho, Lam, Sethi, and

Ullman, Addison-Wesley, Pearson education,

Ref:https://nptel.ac.in/downloads/106108113/

Overview

  • (^) Language Processors
  • (^) Structure of Compiler with illustration
  • (^) Compiler Construction tools
  • (^) Science of building a compiler
  • (^) Applications of compiler technology
  • (^) Basics of lexical analysis

Why study Compiler Design?

  • (^) Computational thinking in language design
  • (^) Understanding how modern language and compiler technology

can be used to make software reliably, securely, and efficiently

  • (^) Motivation for new programming languages such as GO (

https://golang.org) and Clojure ( https://clojure.org/)

  • (^) Understanding modern program translation techniques and

tools

  • (^) Awareness of language and compiler issues in dealing with

parallelism and concurrency

  • (^) Get experience on a project in which you can explore in some

depth an advanced topic in programming languages and

compilers of your own choosing.

Compiler Design 7th Sem BE(CSE) NMIT 5

Language Processor

  • (^) If the target program is an executable machine language program it

can be called by the user to process inputs producing outputs.

Source program

Compiler

Errors

Target Program

Input

Target Program

Output

Running the

target program

Source program

Interpreter

Errors

Output

Input

  • (^) Interpreter directly executes the operations (one by one) specified

in the source program on inputs supplied by the user.

  • (^) Faster
  • (^) Limited

error

diagnostics

  • (^) Slower
  • (^) Better error

diagnostics

A Hybrid Compiler

  • (^) Java language processors combine compilation

& interpretation

Translator

Virtual

Machine

Source program

(byte code) Intermediate program

Input

Output

Compiler Design 7th Sem BE(CSE) NMIT 8

Language Processing System

  • (^) A preprocessor –The statements

which are processed before

compilation are known as

preprocessor statements. Any

preprocessor statement begins with

#.modifies the source program.

Contains code with no

preprocessing statements. Collects

modules of source program from

files, expands shortcuts, & macros.

Includes corresponding function

definition.eg-file

include(#include),macro(#define PI

3.14)

  • (^) Compiler processes the modified

source program and produces

assembly language program.

  • (^) Assembler produces relocatable

machine code as its output.

Phases of a Compiler

Front End

Lexical Analysis (LA)

Note:

Fahrenheit and

centigrade are

lexemes

mapped into

tokens <id,1>

and <id,2> resp.

*is a lexeme

mapped to

token

or <*>

Lexical Analysis

  • (^) LA can be generated automatically from regular

expression specifications

  • (^) LEX and Flex are two such tools
  • (^) LA is a deterministic finite state automaton
  • (^) Why is LA separate from parsing?
  • (^) Simplification of design - software engineering reason
  • (^) I/O issues are limited to LA alone
  • (^) LA based on finite automata are more efficient to

implement than pushdown automata used for parsing

(due to stack)

Grammars are Used for Specifying Syntax

The grammar S aSbS | bSaS | ε generates all strings of a ’s and b ’s

with the same number of a ’s as b ’s.

This grammar is ambiguous: abab has two parse trees.

S

a

b S a S ε

S b S

ε ε

( ab )

n has parse trees 

n

n

n

S

ε a S b S

a S b S

ε ε

Programming Languages are not

Inherently Ambiguous

This grammar G generates the same language

S aAbS | bBaS | ε

A aAbA | ε

B bBaB | ε

G is unambiguous and has

only one parse tree for

every sentence in L ( G ).

S

ε a A b S

a A b S

ε ε