0 ratings0% found this document useful (0 votes) 15 views17 pagesCD Unit1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here.
Available Formats
Download as PDF or read online on Scribd
I ONT-L
Tt pbrodu clon
i
5 Guede of a compiler, Phases oh conpil,
forsleton Process, Me jor Data shruchaes 9
Compile 7 acho Lropng and Porbng
esc open
a] comptes isa combination d slo £ Hl.
ple are moni , kee booed, Flouse ele .
“7 oes 2 TO pres. la 7
Lege FTES yes. PS pe Sse
Fg
» Application sl - HF we develop @ prym then
corespondin eye Ig a Sw.
i) Sele slo - By aang system glo we Work
with a gystens: § shen sla are -
0s, Compilers de ape assemblers, drives ‘files eke.
5 thee ave 3 types of mye) wae
m
of
) High bevel bang = This hang is in the m
alphabels, di gts, sym: fare & ct, crt, Java,
using these lan 6 ux develop epgtication sleo-
y foow heel bang) tlehine Hy sD} is in the
fom of o's 06 'S and -yaed deve hp gysten to-
Bur Assembly tode-timbinetin eb
both thay
vey ‘Cony 03 was
ii) riddle sel language: Ht i6
both Hud ELE ERC ban develops
4 em sho. since
developeel & evblen-
> Lew level language is Nachine language ses og
Hf becomes difheall fr hymen b remembey
rown fang to computer,
se,
phe 3 HiLis an ant
undvastend iE» Soy wereyidre.
whereas human can
cobain oko te ercude any pager ond we
fitao some steps br excedh
po excery 0 peer
ches ty exch 0 prs
Source Prego Cie)
Jv
Preprocssey ‘|
a a,
[erie |
[Linda |
Hochne code (8)
yr
'
Save Popem 18 gen a5
3 T Ger 23 tp so the Peper
oko tabah is bomen! Underrhndeble
cessor — The Slokment which are procened
yo Pf
febre
sor inckades fri delinken of parkceler
Gonelwos palo, cls. , Shim) ate
go oidiorh, coniorh , StAagrh hose slmls
entire before » compilebons Herve pers
t
rileban ose Frcun 059 pceing Sta
pepe
stmt s
avoileble
eed te b
is done bebe cemilaban . Pep
go ens
vad Laer, dnb sone Pe
begs
ii) > Comgiler
ig troliled te tong ri
| Compiles cheets Geta
None oy
“sah eym Cong' torgt
cH) + Cassety tom) rowemant
wo pssembler acces assembly bg cand denels
i . loge
fo. pelo cabeble inathine codes Hh, &
db offic aden: gras felecehbe pp
Seane FAY [issenb ew
Cossenty bog)
> hinkea acces gelocalable riche cok #8 ‘lp £
xs ae le af Vovow nj Fades
roi prom » combines, “them bo prt eneaableble
cohich
| addressoll
dant Fol —olft objects OX Apel ,
her to execahe be Pk
ghorels br 7
id wsides inthe,
> ky
one combines them all ae
tahich an is i “te frm»
_> cov eseades He pag whe
ade» The loader bads g
fo ercat tHe ry
Dit bla_aebwocta_d_ Compiler Deep
5 Adee ig the theo -fardabn fy
hile compiler design to a prachel apt
fo bat pay tak dle le fn me i
|
long bo anether-
Aloy hs
possi ee
ty 91 fee Ft G4,
13, 19,149, Sq 53,5455 |
Go) 301
|
fos ths prupsse leader is tina ve sp A
ev \.
Wi
wt
ev wl
understanding computation ond “formal lenpug | ————
] : re hoses ¢ of Compiler
pation dine io two pels analysis
Ss
»
Com)
ee
Frenkend) = First foun
9 Bays
Com
syplex oni Cemantic. onalsis 4 iw
cole. ge
i) Sgpthes scend)2- “The
is oph
awl ego
Ant tage peg
es ote ty carsich out 4 texed on
6%
64
n
phases of tier
Inlemediate ode.
T meehd » ther it 1S convertedAndis 4 s syns Medel
> frsgokes of Compiler
> this bey Goce, porlobl, musk gee ong
Hachine colt +
2 geet cole. rusk ork Oa with existin q
deboggts-
> Hast hove Gndank opbrizabon «
Phases of comply:
Sounce Clee
aaa
: yy ae \
a
_y bewcal ome weeds eave Pru chant
lewd ont covele came Sename of chores inh
Jremes :
gar ar beer bo
ba ves cher by chev ond tnlals “tinh fe
ree each Yone 5 repeesenkd trfarn ol toxens
py been be kegel Weaker, perth
Leh 0s consider leneme 4 bien.
>
doe shoreo
a death
= fqn of
b id
+ ANN op
‘ id
‘ reall op
bo constant
> Toren ts represented to the fon 4 spate sh
ag cctevename, atibute val uey.
data shudne » heh «
info abort -fokensy such as nr vanes wale,
oriable, “iehin type ~Pirelon ek «
2 yma tak 6 afn aebrewbo —vepeseal inthe f 4
Key
Zidsv7 , we Gon reine inf abel
basal on abtube value, hy
22>, Sid, 27> Lt, Sid, IHLAF5 CG,
oS
his Cane naw cout oS- isiedengy
i) sprees | Ps
5 The olp of lovee orelisa 9 gies
$ ord checks whether the yet
“b parser,
ol,
Corn espontin: i
f 1 Source mis corre
oh le are got
dL reports user &
itis x
at Ene handler ani
cred it-
> ithe ayers souwe pry Is weet ib
builds parse dre GD
a ie
Bs idteidarida tbe
Evoluate the expmscion foe viehl bral sth bre
sa fas agp poe em fH 08 idan
® ©
th
wi) enon tonal.
> an ins it checks
nevatel 50
f
the erro? Os
hordles
node.
oe
oie the oP & syne on.
> The Pe of gpl onal
ohdter posse bree
above fuse falar flows the
ox mab FE rok evey hondler
Page apne ws
oat rm pits eer.
es genes le to
Geman c nals Th cheaes “whetha the poy
| fh prise tue 8 corse ov nab For this. cheery
we tqure a HA called Type beckery cheets
the dota dyed wanils HF ay ype onvesien
se necked i gerfame ib
31 convert conctnt serke 0 seal 7 Iet us consider
to te onthe c07th Some fist tale! then the
mesitene wil be Plow»so the feo) pose wre >
i) Solera. code. geneslor
Tk Wnlemeliah code
cagng Taree Prddess cole
> Tnorder “bo 1"
generat we ome
epesenbation. The tn choud corks 3 Bice
3 Jo 3-adds Ob inebeehess mat
ab the QHS snot |
trave ctbmest one Ope
more ‘thon 4 oper el
D Some \nchwel? oy conta fewer tor 3
operrds oe re
> The Conia gene depend varable® |
Store the Besalls
Fa: idle dp vids & istovel (62)
t1= inttnel (69) ah hoy
kes ida
430 ide+h
jab 2 43
5 Tn same PIFOME thee Is ny nell of se
“Gloleneals 10 tase shols ove deat, bode.
will berebeed
Poets os
oh ef the
sol ca cobs '
ga: From Sbove phase, the ilp is waaced to
Seoes sleps
bye id3%6000 C infbreal
idi > ide tte eee
D Hencey using code ophmizer the slokiments are
elaed dempored fo Infowclish “code sins
x) ode geosisbor
Jace some machine code. )code,
> Tnorder fo pre
groves uses assenbhy Level oe oe
\ike LD, ST /ADD NUL ck =
Lo Cy aM
st hem 4]
App yer RB
Hol py Rr EF
=S—___—_Fs gyeids 1600
idvcidet
Lor Re, id3
MOLE Ro, R2, dbo
Ur ay, 2
Ave Ry, RL, R2
sie ia, RV
Ex Consider the fatten] Frag hb cab
int yds
i eintorita; wrile te olf batt
ghases campiles ire dave cle
isiatonlte
y
Lexical fine! 2
b= intbflodtw)
dy = itd
Ag > totide
dy = inttoflod(a)
45 = tatty
fdi = 45
dps VF 70-0
dpe Wt We
dg = bot 20
iesite if goo |
LOF = Ri, idl |
MULE Ry, Ri, tHFO-0
Loe Ra Ido
opr RA, RAR
POF RI, Ry,AERO
STF fat, RI
gla fos
3,441, 301, SIS, 19, Ue) 41,43) $7, rg
FFranelatin Proces
> A compiler 8 o longaag® Aranslelor. A
Lnensbte tne stokements: wriy
papreming toy
of methine instrudtins thet achiews the
of the stinb.
epee] ule
a
voy [HE | f°
[rset
reel
Compiler i
ne byh fed tribe & seque
effed
compikr eles 0m Screed key det dlrs
oP
to efanly emg °4 Pres cade, Aang the
ave the
[important Syme! table, Absloael
sees ase ASD> Cool x01 Flow rr (cre, 2
a
Inbemediale Reprsentetion Cit), hiteral “be, tse
mos!
chroctres help the congles perform “Ease lite
a hese
ent ee syntactic analysis, Semrhe Fi
Ud ede gencstons
ener: Orme ov Sequence of ch how
hive mean sguch os idembfers ,eey words, alelerley,
ow ws peaked by voralyzer an
cots eT 1 P
posed © porter:
y Synths: describe the syrtacle aleidne
shy according a
yee -
Grom the parse
a= ayes 16 represn
idl= idovida vas
dad os.wi) Symbol t
ndian about evetf a cenhined vig,
the pen
> keeps information accocioled wath all Kos o
deniers} dost, ver nd pornmekos pes eke
iG! ohetye= infe
ce Synbal Tle
code.
inlet
Vaid. 510 may
{
int um,
int tum.
J
art Nalues and Soi
7
) Lilad_‘Tahe + alores Cenak
ens tere
Ae ma
Thee, HH hel
b
code info Smaller pleees
fo breakdown the
ghreclie better,
understand the
gr. Gb) 8C es
Ye
ab
eb is ceed Fo Slote esceh
cdrode code TH ts
role middle step blo Heeblee,
v) —
ia belt? make ‘the inal code faster £ more Mend
a geben: Three-Adds- Code 1s used nen
peerd nat
‘oe bet
aeth-
gontstopny ore Peep
dei & compiler bolstopiog Ievuseh,
nodes © vepesent compiler we ase 3 bapa
i) Source a
) togh bg
i snjnoll Leng Ce bag nich comply
‘ovlln)
ot entbagrey
BA ong
> Reqsented with, the help A+ bg.
oe
Ex Thoikey “fo Ip
Source pepe a Simphe boy
ine Cempliceled anf produces even cme compete
ym goon
Jemest a. Compented
is week, bei
“ea
> sith the help al acempiley is,
ber
Creés a
DB compiler ehich ons on ove srochine. but
prices object Gede Br ancthes Mache & Ce
Sfegt > ule]
t
¢ cet
D> tee, wee reside conpler with ce#
7
? Deseo se, Blog
ore q mA
sea wa cag
le comple ot he beled corplr2-
ig ee
> Compl
“Vedder preue dng by
[ee
Th refers to the proces of oh lo
ap renon & different herdeare plHhvm
system.
oor)greet Leved ones, Sap Beng,
syrcfeen § ons) Reagrton, dh “ohne,
hese andes Gerry hex
> Kaeo lexical
The wef lericl onan, also known as
leet, is bo Yead 0 ghrean of chovackss ond
convert ik tnko a Shan dh Ankers, whch ore,
bane btding Bae 4 peyreny tog.
> The lexer also handles tasks he “ony
thtespace and comments onk being
table-
asa
Pas he
DDL prdvces a stream of rms.
i) TL removes comments
3)
| a Finders tm
Lom some payee
TE mmes thie pee chereces such as
Yr
une ne lab spare £ newlne chore cles.
1k mnts nes tambos dune page,
w t
Gymbot Lablee whch staves
wes a Sf
y at qe
Ye het ideobhers
fs
se proms mye et Comspnding
9 eas 2 calene nani
wwe 70"
5 teh eee
3 sxpston af Levee! Prolyeer fmm yr or rdpeer.-
a “a opi ae dege 0. compler: Toovder ty
a gre burden on sig! phase
ro increase the efficiency af a comple: Leweal
oe o ras Sah
pears OFS pick Acogae. Ry ho
my seaoko
sere
as For be veep CABS
a phase burden increase 7
i ingle
beth combines 4S
wet toves! mone “Heme
iy To enhance “he peutblty of @ compiler:
an ceva) platfains sxperelion
jerease, perteblty,
ojberting
af indo SA'S sreqined to In
9) Towens, _Lexemes_ ark pallens:
Grrmp of chas ot Seve of cher
Collehive mann *
ZAppenname,
being
i bate valle?F
ses + source chat OF 2b’ chor,
Lerms 2 St
Lene,
as camerded info leremes «
Eo mec ee2)
Topen,
E cid t7eld)
oe
Maid 2idee
lexan
Coper a cx?
13
RH opin sewer
2 ,
sine lew a. Variable ey identifier larts wth
cither lke os = oy dys
> pallens are usd 1 defme RE
D> Tdeavfiey
Gboalslo”
Cosh2 Yorn r04
D Lesital £12085: The Comment
4) Spelling Eres: shea
I) Unmatched éxrers - FCB) 5. nat cle
nereled ees ex
©) pero ial donc
th of, idenbfe
i eceg eng
the pet _tscoveny_ Mechamssms ane:
y) pelle a Simple char Frem-the ‘en ily.
vy tas a ising cer he
wi) Replace one chas y dlher char -
iy) Transpo adjacent cherecks-
fe encesne characles Goan te cin
Y) pele
: red. “been
ip exkl LA Teegnas
4, 3
Specification A beens
aa
mae ake Tea
Gees
1 b0r HAF
:) ,
2 To speerhy totens ve hove differen
methods-
)) Alphabets, stings, languages
2) operations 97 language 3
D deylar Expession
oy ee Definition,y
) Alphabet -- this
> Re is used be eneate QL (set sh
oP.
Elo, 1] bowny alphbet
e-{ a,b, Zi locuxcase alphebet:
get 4 gymbls
stung, Dis frie sel d ap fine
fm 2: g-fa bf.
a,b, ab, ba, obb, baa ---- +
denoted 4 Isl
Phength ha shring Tt is
chch are prety
> The -bhl ned aynbls
in the string.
G= 100 - Isl=4
> Em shyng : 2 length of stxng is 0
a oa pe eg
> Prehe of cashing: Any no d 7 Symi jo
the sling» Le as tensides 35 abe=S
S- Gabe
= abké
= Cabe €
Prchie he, abe, %, ab, & | ‘2 Proper pects da shy: Erapt 2b
Lom se aboe
ie
g.abe
e-abe-e.
#,a,ab
% oath fa stony TE is ony beeing ops
in the sting: s- abcé
abe
eabee
E yabe, abe, 6 be, &
> Proper suff: Ercept ce, abe
be.
skis obbiod by techy
2 Sabshooy
pes ond Seth fem the ar
S= banana, € banana —
(banana ©
€ banans
€, borane wen, aren, anes
> Proper subshings Erp € & she itself.
non, aren, NMA
> Corcatenetion b oshng Combmatan 4
qeabe
qe
ay bede
ut = deabo
stow sti ae
_
la
Loge The lang is sel slonas cis
ted Grom 2, the alphabet «
we gn
ze tabd
Lefaiebs abr hay ob, J
geectes oc ae + Union, Concrlendbm, Kleene
cloaire, Posthve closure -
ms. Lub-{sls ison ba sein
teefon |. Lenker 13 ]
Lyote-fo,4, eonnth,
aiplasectoo
anle A alos Linds =f-ng [ais vnlyond
g isnt}
Lelony Le-foong.
Line = ovo, o11, 19°) "3.
i) Seleene clasure; This 16 deeobd by « Sf
Bast A she cahich ilude © §Y
weoU
+ Putol..--
e-faj.
2 €,a,00daa,-
Ww) posrhve dosure a st
i Ge ge
£ diyts aig ts)? Cece 308) 2 yane Cet Brother compiler compiler).
fandeo of be
a yan tbe Finck olep Suxce ale which is:in
(23-45 a tg hovng file nome,” gues 33 nb
3-45 E23
eee sir ples (Lod te gd Ae lec yre
i2set23
Source (rg
aol tr hex leeyire-
tes by 8) 301 Filet conpiks
hesed. Araya Geneseor be cp terre wit bevsed ar tp # te op
7 Af compler anh sohch gives the olp in the form of an'e
Lente abel ot tmp PM 7 ‘i
the lp a-out will take the stream
: )qencneled ere fie 4
srecqoreisle pt clasfation Fm of cholo ond
Loose on thet perp:
te fast step of comple Lex gyre eho
> hened Pralyss hell
af dakes Input 4% ghiean of charac
Dea ik Aekes tops ca
and qe lp os tere Known a3 4 oh ast Sg
3 Wwhas phases Tokens” Fray Messages,
newtes Hotere as Olp-hex tile = 3
> A lex pagan consists of 3 parts and
aeperated by th delimiters:
Declar ations
tt:
Frans lation yaks
tf
Aaxihary procedines
declorbon? include eclaretig
5 useful for eons eels’, de>
J peblen anh
RE
fonctions used
> Declarations : “The
of \ariables: Be}
>? Transition rules: These quks consis
action Cac long stmt)
socedurts : holds auxliory
ilra
2
in these actions
Example « \edlarebron Lo =the 18 colt
~ ty. ver /@
: Z
translation j
if { relum ciAsy
teh
auxiliary function
int spumbes Sum ()
Conclusion hex is a loructal part of a Compiles
proper covers” of
jg essential for the
code into “pw lewel ode. Lents a too)
responsible for Lorenizecion ana analysts of
Up ghream of dil» Ker Files are gor
otores coith
i
and
hgh level
Lhe extensvon «| ov slew