0% found this document useful (0 votes)
3 views

Assignment_01_CD

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Assignment_01_CD

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Dote

Page

iFlsiqprment-01
1Phoses_of Compilest :

|AAcompiley tsanstoarM8 high-lerel 2oue COde irto


mochine cocle tho1DLgh &eeal cisoct phases.
ee asCthe main phse of a conpile
Lexîal Analusig This i the fisstphase.
uheuethe 80Uce cÓcle i
tead and dibideal iato tokeng_ Tokens aHe the
bosie unite a tte pongeiammiog lacquage
Qch os keeastcla opedatons bnd ftertfevg.
2Syntax Analgis : Alao knoun o-aeging. thia.
phase checka the tokersfolloto
Hhe goLampaticnl SIle? tho psoaIommina
Langbage. The output 8 tyccal on Atteoct
unta TeIee (AS T).
3. Senontc Analgis : his phoxe ensuA1E3 tat the
code moakes gense Seriorhally.
checks foel tupe egoyau3, undectate vaable
ond othet emonfie uRues.
4Totesiecliate Code Gueneation: The cooole
toonslates 4he A3 T
into an înteurnedinte code that is eggiey to
Optinise ahd teicnslateito machine coce.
Date
Poge

meciate cocle to' make t UD o0Ie


involhzc IeMOLKg aieclercdart
COcle. optmieing loops, cnc otheg pefosuionte
eh cnhanccnerts.

6Cocde icncyation: The final chae, whee thc


optimised igtesmeciate codei tsiqnalaterd
irto pochine code that Hhe cormpctels
hauidvQYe con exccte.
Pach s£ the phases plaL?g coICial s9le

ond elicertlly talansfaemec into executable cole

2.C1039 Compile
A Cao39 cormpiley î3 o tpe of copilex
thot geneLates executable cocde foL a tfoug
diffeient foDm the one C0 ehich Hhe comple
Compilec1 glInniyO0
ctunnim a PCmight gencACrte
Lcode that eiths on an embecldec &uctea o4
o difient opesorting system.
Why use Q Caios Compiley 2
bote
Poge

Emledced 3ysterns These. ayzterma often. heus


Limitecl91C20L19ICeg ohc CCnnot 3ippôotU
full deelopment enuis1onmrt.
Multiple gystes luhen ceelopingsoftuOse.
Hhatneede to Iun on LOus platfoa s., a.
099 Onpile atlousuou to compile cade.
noall tsoet
clevelopment hoct.
platosns from a' Qingle.
Bootstsappig: luhen csIeafing 8oftuise t .
a neu platfoam, 0 ca(O32 CODiley can be
LISed to Compile the initials toolegnd
opertig 8stem.
Hou ît ulokg ?
A CIngg Compies sepos/otes
the btild eniviennment foom the taOet
LenDiOOnent. Th 8epdsrtion i, cIUa
f sUcterns whee disect CODpilatio on the
platbsn

alPootstopping
Bootstappg în compiley cleaiqn i the
a conoiley in the ps1o
Date
Paoe

Lccrpile. tecbnique i cIsed to aseate a


gell- meplig, copilest, saluigg he
"chicken-an- tg poble în ompile deagn.
t
Hcu BootstoroppingLlootks"
1 Tnitia! Ccnpilcy: A
A minirnal euRiCn st
the oopiley i hetten îno cifes1ert

aSef Conpilotion: The minimal. ompilel i


Used f onpile0 sligtt masse tooplex
1ey9o0 o the compile toutten in the.

b. Ttessorthe TopsÔeMert: he psioce? il sepeote


teth ech nen esion A the comp iles
being mn9re compex ond npable. untl o
fulli fuctionol ompileu i, treca(o9rertect)

Compotihility Ensuse the compiles &lcomp


atia bleuth the (anguoge it compile.
Amp
Ooimizotion:- ALLOlua fos geenten contol
ouESI Oimi2otion gnd ode genenation.
Date
Page

in the m9cIectness o the COmpileer gince t à


3l-hoste
a Exapple: MM
Ruppose ou tar
anF to Csiearte. a
llcoopilee! fosi a neo) (angage X. You migfd
tat by tnetiting a cinple compile in loigu
y. that can gehen qte ode fo X Thi O
initiq ompile) can then be Used to
mye ocancec VeSiON O the X
Compileonc so on.

1, Jheae asie gene9al tupesof ompileR, each.


Ldesigned fe SpecHfic pLusIOORe3 ad enuisnmett
Hey ae 30Me of main tps
Sipale Pass Coopiles - paioressesthe g0u9Ce
codle in Onepass making t tsteg bct
es capable o optinizoifon.
Muti- Poss Compilec13- Porocezaeg the 9nuICe
cocle in multiple posses,allocingfos me
haugh malaia ond optimizatiyh
denert fonm the Dne onthich te
4 Tust- Jn: Tipc (11) Compik1: (onpiks coce
OiDDDcrte
at sun-time,often LIsed n
ike TVA Qnd NEL
g. Ahrod of Time (A0T) (omplec3- Conpils code
belocie execution. cften ISed to Impée
Statup time and peafosuarce
E rcoemertol ompley:- Reconpiles orl the pont
cf the caole that haue chargdusel
fost caeloprmert ervisronets.
fstallelizing Coppile i: (onnete sequertial
COce into posallel code to sUn on mutt
peDcesgoHs.
Lood-and-Gro Compley:- Compies and inpediatelu
exeçLutes the coce, cften ucecl inccucatbn
eniianmments..
l9: heenclec Cocle Compiley:- Ceretes ade that
uSes th¡CTds fosi execttion,impeniq
peos1mance on muti- thsreoded &uatene.
10. Biogsy Compiley eran:lotes object cocle
forcm one platfos mto arothes
Dete,
Poge.

B Tmplementotion of lexical Analygig:.


|Lexial Analgis. aleo kntun as.onrùng,
the potoess boreaking cbon the sotoxce.
Coce to mearingfub cimits ollecl token..
These tokens ai then usec by ttie &untox
analyze (pase) to onstyct the ontoy
toeehe lexical calze (lexes) sino the
8OUSre code chosocteby choactetqLOLups
them to loxeme., ondannete these exerneg
into tokens

t Key Components
h. Lexeme:AsEOLerce of chauactes thot
matches the prttessn fos q to ken.
2 Token:A Oig conaistng of a token Cthd on
otioral attsibtde alie.
E.Pottesn:A 31ulethat desibeg tthe set s
lexermes that an cIepSIÉSE nt a poctculoy
token.

Example
(onside the falloLing ainple C.
Data
Page

it main )
int o. bi

1. Taput he gOuHce code


9- Output Asequence of to kens.

tep- bË- Btep Token isation.


int: Keyuo9d to ken
main : Ilentifien token
: Lekt Rverthesis token
Right Panenthesis token
Left Bo/Cce to ken
Keywoc to kern
Tckntifien token
Comma token.
b: Tolentten token
SenicoloR token
Toentifie token
10
Assignmernt Opeatosi token
Numestie Constört
Constort token
Seicolon token
b
Iaentiflen token
:Aosigrmert Operetoot tokes
Icientifien token
Adition Operatoy torer
Nme ic Constort oker
Semicolon token
keywod to ker
O: Numeie Constorrt toker,
Sermicolon token
? : Right bsore token

1 Reading Chosioctey : The lexet s1egde the


SOUITe Codechasocten bu Chaortz.

2-Matchicg Patteane: Tt motchea gequne t ot


chasaea (lexemes) qgaint patfi
defined foet ench token spe.
3CueDEIOting Token : ttbon o moth ifotncl.
the lex genenates q token, nd
posest to the pusey.

6.ey (ompiles YAcC.


lex and YAC gye taolg tised in coDpiles
Ldesign to genesote lxlal Coalyzess cGnd
pass Meepectheg
Ley i Lcx a tool fa Qeneuaticg lezical

and genemtes Ccoce tkd thn iderlity


toket in the input gueten tieato
YACC: Yac CYct Ancthen Coropileo Coupits).
takesa set o constat-faeeQeICGAD
elules and genehate Cmce fosta caDES
that an analyze the tokem pucckrecd 4
Lex ond build a gurtay tsiee
t HO hey uok toqethey?
SousLCe Lex ’ Tokens
Code (Scannen)

Suntay YACC
T1ee (Pnise)
LexialAnalusis ( Lex): Lex seoca the
SOLHCe code and coovet it
into c seqIente o tokena.
Suntax Aoolugis (YAcc) : YACC takes the
tokens Gnd constslLuctsa Suntnx tsee
basel DO the 91Gm0C GlLler

You might also like