Page Ne
CC
Chs
Toboduction
*Compiler
Compilex iS a anslatur uhich
ate High level Lanquage CHTT)
Progrom
ohich u,
Low level longuageLLL )cr Mochine
level language CMLL)
* Phases of Compilex
SouTce. pogro).
Lexical
analysis
Töken
Syntox
analysis
Nparse tee
Symbal table Sem antic
management analysig Err handins
& rcovey
Semontic
Conrcctness
Tn tormediat?
code geneTation
Totormeciate
code
Tanget code
generation
Terget
Code
Code
optimizatin
opimized tont
Code
(Page No
Date
Olexicad analysis phase.
-Tt is also Koowo Ca
Tt is first phase of Comlo
-Tt tads the
ompila
the SourCe proqTom in
Scannig
he foomof charactea streom
the lagically elated charccters toge thes
that art Kngwo ag le xemes
-foreach lexeme, a token iS
qenerattd by the lexical analyzex
-Tokens Can be of difforcot types.
nomely keyLocnds identifiens. Constants.
operate Symbols
Symbols etc
2Syatax Aoalysis phase
also khowo as porSe
-Tt is Second [Link] compiler
Tt takes the tokeo prucduced by
lexical analysiS as input &qeoaates a
parse tte Cea Syntax tce
OSemantic
TE i s
AnalysiG phase.
-T1 detects alBokoowa
the
ad mappex
statemeats geneates"meaning"intémediate
Code
checks Luhethe the prse ttc
Constucted follows the ules of lanquage
9TatezMediate
-Ata the
Code gencnatian phase.
sernanhc JatAnedigte
the compilegqeneratcs Analssis phase
Cocde of the Souscecode
Date
-Tt Shold b¬
to trunslate into eiss to gentate 4te
machine Language.
ode optimization phase
he next phase of Compiler does
Code optimization of the inteamedlate cod
- Tt is an optia0a phaße.
optimization means making the cade
Shoyteo Jess ComplexSo thatit con
execute fster &tokes lesser space
O Code genenahion phale
-Tt is a phaße of Compilen
Al of above phases invalve the tuc
tasks namey. Symbol table mancqemeat
*Passes of (ompilex
O one -pass Compilen
Singlelone pass Campiler does
not aok back" d ode t bas prviouslu
Prucessed
Otoo.- pa5SCamp1lez
Tt iS an campileo which
thawgh assembly langucge tuite and
rate object Cade
Page No.
Date
Multi -pass Compilea
Ts a type of Compilea that proces
the SouYce code c abstract Syatax te
of a proqrom Sevtxal tima
Camss Compilea
A Compiler may un o0 o0e Machine
and poduce cbiect Code for Goather
machioe.
Bactstrapping
Tt iS apocess iO which Simple
lanquage is used to anslate mane
io t
CompliCattd pogTam which in o may
tun
handlefox mpliCatcd program
Page No
Date
ch2
# leical Analysis Cscanner )
Tokens
ToRen is a goup Of charocteas with
logical meoning
A patterp is a aule that cdcgibes
the choracter thot con be qzouped ioto
to kens
Lexeme
Ttotads SouTce progzom of sttan
chaacter & apoupthe logically 2lattd
chozacter together is kocws s jexeme
"Tnput Bulfening
The lexical analyzer scons he input
chaxactea by cha tactea qz0ups them
ioto tokens
SestinelS
Th sentinels cue use specicd charactea
that is not the pazt of SouYCe pogra,
Page No
Date
y 1EX Lexical Anolyzex Gheneador
- Lex is a Computes paDgsam td
Lqeneratcs lexical unolyzors
-he purpose of lex pzoqran is to
ead an input sttam # Xgoize okens.
- Lex is betten Koown as Lexi cal
Analyze Geoerto in uDix oSintoduce o
-lexical_ Analyzez Cheneata
tool Called Lex
iS_ geoerally avajlable on UNTX CA
- Lex
LINUX
Lex Libxant
()-This Auncion is used to
Oyylex
sAant ofSuMe scaonig
Oyytextwheneva
c token
a lexexmatcheg a in the
stoot d
the txt of the token is_
null teaominatd string yytoxt
yuaop( functiao
-The puxpose of i0cxdeD to
SSing
to addiional p0CE
bekee texminong
urap" things up
Yyenrc)!
is Caled uwhich
This_ function the usea
Cpeats the
Dcnts the ecY to
Page No
ch3 Date
Syatax analyzex
check wheathen the qiveo gramine,
S > 8D AB
A> aAålb
BBAale
fizst (s) >£ba.c
frst cA)’ab?
first C83’b¬3
fixst (D)’2E3
follaw(s)’ $2
follow (A) yb$
follow (B î¢3
fallow CD)
2 /2
A 2
5
S
The qirca qraMMA
1Parceg Gencsat CYAcc)
-stands fuu 'Yet AnDth eo Ccnpler
Compiler"
-YACC assists in the next phage ol
the Compile
1õp-down euttom -up
Tt uses devation - HUSeS ductia.
-No lert- Cu3Sic)
backtracking coe tuoland backbching
paoble0ns otcuing io.
this pesing TA acc(pt cmbiqoul
Ambigous gaammeS.
atno Suitabie fx qpamma.
top-douwn
T5is usespnsig
LLS This USes Rqzqanal
g2ammen - shifl-xduce ond
NO comflid ocur 2tduce cooflict