Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
27 views

Compiler Design Assignment01

This document discusses the phases of compilation: lexical analysis, syntax analysis, semantic analysis, optimization, and code generation. Lexical analysis breaks source code into tokens. Syntax analysis checks that tokens form a valid syntax tree. Semantic analysis verifies the code is semantically correct. Optimization improves the intermediate code. Code generation produces machine code from the optimized intermediate code. Top-down parsing uses a top-most production rule to derive the next symbol. Bottom-up parsing uses the right-most derivation to construct a parse tree from the bottom up. Input buffering is a technique that allows chunks to be processed and reduces overhead.

Uploaded by

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

Compiler Design Assignment01

This document discusses the phases of compilation: lexical analysis, syntax analysis, semantic analysis, optimization, and code generation. Lexical analysis breaks source code into tokens. Syntax analysis checks that tokens form a valid syntax tree. Semantic analysis verifies the code is semantically correct. Optimization improves the intermediate code. Code generation produces machine code from the optimized intermediate code. Top-down parsing uses a top-most production rule to derive the next symbol. Bottom-up parsing uses the right-most derivation to construct a parse tree from the bottom up. Input buffering is a technique that allows chunks to be processed and reduces overhead.

Uploaded by

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

AssIoNMENT 01

|Name Peasbamt ShoNa


Beanch Data-Sciemce (5hSeo)
Section G-2
Subjace 2 Comhile design
Rode ND 21E`KCXO43
Past A

hexical onalysls is thajistphase af the


Comhilox as% Rnona Scammer tcon
vexte the. high level oapt þogeamlmto
aseqmce ap T6 Romà heXicaL malysis can
bo imblenented Loitththe dotteminitilc
timitiautomata. The Qutput seqearce
ftoRamA that ls semt tothe þaHAeefo
Syntak unalysis
Anshexicalamalyais has toacceld secend
memay eachtime to identily token
s a imi-Canming. amdLTOtl
So the Input bing& aostoRd lmto &
bulex and them }camnedi hy loxica&
amalysiz
AnsnDFAoe Camnst toove eom
to amothex otthout Conumnng aSym
bol NDFA a00oOS hule)ather Secen
axgumemt af the bamaitionfumctim
This meamd hat tho NDFA Can ake
makea taamsitiom withat Conduming
Imput Smbal

mtthOse peedicom vt.


ahhlied to amonteminalSmbal tog
Laucdles o its Contextt

An Top-coonþaxsingusea lapepositdawiat
ia-Battom us-sinq isea the ight
mast oloxiatin Toh +dom þaaing
seachea Jer hxocucton utetobeaed
to Consfruct asbing . Bottonn u fxslng
seazchodrapocuctn ule to be
to rede a dtiag to qet a Staxttna y
mbal ogammna

Ars nput buleusngls atechnique thatalae


chumkdLohich camlnbove
Ce and reduce OVehead
AmsA Comhile 0Sa ptgeam that Conveto
the emtiresoUrCe
0nto executoblelma
Chhné code.
tkedQOece orogram Cnd ns it
Rinebyline gtromaltimg each Rine a
itcomemt

AsAceSs comler s a Combiilex. Capable


o Cfeating exe cutablecncle xa þlat
emGthetham the me 0n chech

Ans A Qkommar. that makes nmOx tham ne


Lamstderivathimihtmtdo
' Vàtim) e a Sinilax Sentemels called
ambigiua geammar
Rinra' dea behind.lejtctoang (sto
eommm þxobx b mtauctrg a neonan
teminal. synbol and bmakdan the
comnm þoix.
S’abXlaby
Y’ cle
yfoned ftamz lS
S ’ abz
X ’ cd
Y cle
PautB
CQuell
Lcheckag,opimizatim and coo gem
eseatianThocaroslao be, Lesed. oxe
xeemt the sCHNe-Gf cthexbes
lingustc, logical stueta Such
asgicaeexpxeuientences
hatcal o

lea paces Imohich sinple


to toTmslate mecom
amgiago
blicated þxgam ohich m'tumosoon
hamdla me omaicoted
Thiscpnmhlicatedfgam eamithex
handle elem mre cobltated faogam

peom ccaateh.Hemco Sioble language


Sued to qenexate taged. coe
Stag.
sti
Symal
TRLA reducin cam be achiese bydi
ectl. handling th rightmadt da~iva
tnomtho StaetingsymbatOthe
2fn lmbut bex. to hald
themt `hing AStack to Reop the
atatnax Synabola fox cccessing te

lsaty ap Context

doiatian 1tokam Lookahead!


ues orincingS EIRSTLS fuoctzn
Ol4, x lGa. tenmoal Syatol then fiRSr
X s anom-teminal Syabal and
there, 1s,a poduction X7yyy
them

tb FIRST(X) amd so cmumtie:e s e t


n FIRSE(Y)
utstag
Ile
l qeneeates that atol neXls
dy'fLow
(E) fRSTE)
EO;DAGT)RST(T)fx£y 4
5
t 3)FoLo() =Lyidy aFIRST
(r)
={Lidy1FIRST(E) 2
.. FoLLaW.
wseta. bermaola
to
me mo
util 20nd3 +Ropeat
ste can nges
OwB)
oDuction
3 A le BA
tOFOLOw(B) FOuoA) thare
syabacumaabbeaz
atanly
ouctianX’Y al dca
) FRST(),RST
(Y2)--
-- b 3
ed. by JAcc þ»opeartre Ao gemekata Com
þlete.bosers Tiesee coco mamye vetar'ns
available fox lex,but_the mGat
la feoxwhich ls reasllybilabl 'on
Linixsy[tema as apat GNUCmb
liee package
Paet CP

Ouals The phasea p Compieiese. aeloxical amaly


Aya
amalyaE, Semmtia amnalys
eogctaticcds. qemexatin ofp
gatim Qnd CDde generatim
Kexiealanalsis:The fist þhase'a Compil
SoLurCe Codeamol breaks it ento aSth

Stata anolais t lealso kmoon aA


oàralng This phae tated the SteamGe
tORen Geneeated bylexical, amlysis
andchahetthetHay Conpemm ho
`emat'e analyis The thil phase
Is semantic
a Comnþilechecks analys's
thi phase hothex tho Cocle
Is Sememtically Coanect
nezates an ntexmediate eeeNteqn
.thesOLra Code that can be .easily
machioe Code
bamated to
Thi bhae abhleavaxiy
Chtimigatin iImtemodiat code to
techalasto
macheh, Cod
gereAthion i 1he inalbhae afCom
C gemetottn 4t take the
pilezIs
optinizedcde Gnd qemirat actual
machne Coole.

E’TE!

TFT folD Sets


F ’ (E) Lid
FRSTSETS
FRST(E)s{yidy FoLow}t
FiRST (E t E
ERST (I
EIRSTT)=
ERST L)- lgtd!
Mugis

axsing teble
Non

ETE

E! tT:. EE

TF

F F’(E) F’id

Stack E

AtAiag:matched A ly bajyt
sfaçki
stpék nput Actien
Hagic

Stack mput Ation


idtidtidp Sht
t id*id replace.
T+T E!
shyt
traplace
id idg
FtLE sht
eplaceyt
idy*f,T;E
T mehlace
relace

(s a bottom

mathemacol expresland, þrgama


Tng Lamgage exþexlan a d bthox
contexA fe getne) S ls based
on the þxocodoco lowels a< oßesatok
Imtheamna thatea precoden
pcocsexae paeticullyf oeee-Suitet
where the okdex. af obekatin matte
3t5*(2-i)
sumning
Syste
host the om ont el lg
that
ctoe target a
baogtam
woata other aumming
-hn Compilex
(3
Omlonbh
the cne the fom Ren
mm ckorexeutable
ccle qenerates
that clewelnhrmont
kool soytea a
Comble
la CosS A
Yeduce 3+5
beduce 3t5*(E)*t
5*(E 3+
redu 3+5*[-id
ce shift
Shilt 3t5*[2
Shtlt 3t5*9.
Shyt
Shyt 3+5
Shyt *3+5
Shijt 5*(2-1)
Shiyt (2-) +5*
Shyt 't5*(2-1)
Action nput stack
Magi

embeddod[Aem
dolleuing Scemaios
Platfoxth Mismatch
Reaouxce Conatacint
A ta
stimlzain
Platlomm
4slatlon:
Yolalpendal

You might also like