













































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!














































Text book: Compilers, Techniques, and Tools
(Second Edition), Aho, Lam, Sethi, and
Ullman, Addison-Wesley, Pearson education,
Ref:https://nptel.ac.in/downloads/106108113/
can be used to make software reliably, securely, and efficiently
https://golang.org) and Clojure ( https://clojure.org/)
tools
parallelism and concurrency
depth an advanced topic in programming languages and
compilers of your own choosing.
Compiler Design 7th Sem BE(CSE) NMIT 5
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
in the source program on inputs supplied by the user.
error
diagnostics
diagnostics
& interpretation
Translator
Virtual
Machine
Source program
(byte code) Intermediate program
Input
Output
Compiler Design 7th Sem BE(CSE) NMIT 8
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)
source program and produces
assembly language program.
machine code as its output.
Note:
Fahrenheit and
centigrade are
lexemes
mapped into
tokens <id,1>
and <id,2> resp.
*is a lexeme
mapped to
token
or <*>
expression specifications
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.
a
b S a S ε
S b S
ε ε
( ab )
n has parse trees
n
n
n
ε 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 ).
ε a A b S
a A b S
ε ε