Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
4 views13 pages

CD Assignment

Uploaded by

shathiya1979
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views13 pages

CD Assignment

Uploaded by

shathiya1979
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

be-ou/ot/24

TTFIP
F E) Ird
FIRST(E) $C,id

Jo constuct the CLRCD paihtable for the given


FoLLow ses. the FIRST
FolLouo (e): S;t, ),3 4rmmar , wL kst nea to eompute
Fo;Low (1) ss, + ),* 3 eaehter minal 1hen, we
anol FoLLow Set kor
Parsilg table es tor populting ite paming
) fab

Redure sing Foi4


Reduce wing TT*F

ctacte In put Arction $CletT) Reduce ying FocE)


shitt, fushl'
Redue cihgE£T

Redue yikg EET


Accept

parser to
onatyze
to the
id) +id t 0/cnuide the kollewig, rammar Pekorma sLR

chitt Push y fa ble


(E+T)

{CE{Tti)
Table:
ta bde
tte SLR CI) pas ous{t, nduce or |state b
b ds B C
(onsirh o stafu anc act
sta te ano 4eminal/ non-trmih
ac(pt) 7or lach

SBB
R3 R3
eist, et's Lompute tte fost and follow gets toy R

RR)
F2RJT (L)-6dy
Follo se ts :
FoLLow (s)c4y
Ph the ta blu:
poLLow ()-b d3
Now, ot conyt uet the canonteal collec +on dreLReo)
em and LR o utomaton Roduoe
.

Canonical colection o LK (o) itenm ace" stand 7or Aceepd.


ta lole ryents the acthoh4 to hlo
Strate
pergon sLR pam on' input sarihg folloitbg

TO1*F/
Presictie
Qanmar.show
'show a tep tanre'k Heihput inig.
) iep -detn pai9 Ym ihal tqn
dirio Wula ble, Non tromihaly
vhen a. non-4p
i k t Recusso)
NULLABLE Le) dre
pstdae tiue Pariibg
parilg teble
hpoditie pajiy
Ambiguity anses when
)Cd /Folew Mmbiguy:
ruleu or ^ hon-teamhal
kany

dikicuc4
dnch to choe dug pa rs bg
oceerwlen Now let peforn pamig ser the
3LL) ontiA: LLC) cOnlrh he, coy t r t predicH
( moTe ne.
ah one. nosibl acttoh (ette aproolueh table
a toleen fo match)tor a g py Input Aetion
apfly fable.
statk
id t id id shkt pyh

Can dne the enmpty stmhg ah complicate e


prediction ro(el, (2adg to addoional checle
parsing Stt, wtid!
id id 4

TTtF|P $T4E id d çhitt puyhl

Hounen, it ha mula ble hont


enihal o Reduee uyihg FTid
potehhal LLC) (onkich: we need to ongrued

eyolue
palig
ACtept
FIRST (E)=

)eST (F ) Ci43
FE4T/T

cloy wre (l2 )- cE -EtiJ, tt-1], [1 -):1


DFA)and h ye it to pa +F]
th Al) automa ion (

LL atorna , LR lo) awtomahon


ohtruction [TFJLFdJ,
for T3:
closuse (13): &rr +F],DT FJ, Er.id],
gen natedi- LR lo) Automati on;

LsEJ Stote:6

LE1]

Let:]
state |:

State 2;
[F’.id]
Por tormihal(id.
LEE.+
stoute 3:
ror non -
t03ninalE' CE-7-]
for State y:
non. tomhal T'

CE-’¬t]
LE Tf]
CTFT
SAate q: <tate |0: stare 12

7
T-7*f.]

state 14: S tate l9: state- 4;

Now lels dyuwthe LRo) DPA

LE .+T] DFA to peofoonm LR parslhg- for any tnput


AssGnmint-2 pt-os/e4/24

+ T (b+)+a".
'a -(btc) * hationn Volvey sev l plas
t
macl.a
co de tnto eNleutqble.
dhas tvQnkoon qns04e
dei He e ls
state ): State . State 3 State y
a ?(btc)* Cbt c)t.
/scanne):
(: Lenical Anclyßbrea
Lenical anlyis lu tthe s ouore co de into an
Tohen idontitied
F
ctate
State hsignmnt eperaton
Antitten: b
7
F Ldentihn:c
pignt Paptntey :)
MuLhpicanoh Cpeoatr:
Analusis paitr
ASgntax
ding
structug 6> Co de henrahon
lvatisn tantter the ia tormdia t
(de ihto maches rod. foa Speriic ta r1
asehitectune
LoADb R
ADD C"R
MUL RIRlr R2

R2.1
ST ORE R2-a
3 jemanhe tnalys Each pha o coropilathon rontmbuty ty
trawtox mi ng the sourre co de ihto neeutebe
typ ceckiny aid anal machihe code Ensu mhg coYTlcthn, etticie
derlaradry. aud compai li iy with t tangut pladtfom.
Under laned vama bles type msmatch44 ct. 5 te an algoithn tor convrfirg an
an NFA into a DFA.

M Cenve rfhg a Non -)etermijte nire tu:


tutonato n
NPA) tna DeAninDte Finiie Autmato n(DFA)
4 Iaternediate Code Genoahòn! tn yolvey eploñhg ll posible. stat4 aho fr angittioy
.ntoncoiate code erathoh creatn an ntoned (he NFA to Statu and

Cut put Tntor nediate


rpryohtation: o
bytt cod )Tni Haliz DEA

(00te an DFA with states ano

$Ontiiz 2) Create laitial State;


For suamplu ation; Optmiahon
tonjeand oldigA 3h inremidate (al
(ommer Conpute he - cloSu Te
3) xgloe Toanistiong
A
set in dhe
’for laou state. S’AA
a) fo ecca in put symbo:
tompu cuoTlht stute jet cyr
’ LRI) t temy:
Sym bal.
LS’AA, $]

-)Ad d dransiin (0n the cuTTUnt state

eepeat sep 3;

to dhe DEA
I A , aJ
S) Masle Fihal stat
oru toechLRC)itn
Now de ts caleclote. the c
a kihah state o the NEA be comu fhal or he tirt pmduetion:
state o the DFA Ls’ AA, 7c tosune;
6>ini mize DFA
’ t desired mnimize the DE# to mduce
*he nu mber o state. For the se cond gductien:.
ys ogonthon yctemattcaly- expey
And tanyiio 01 the NPA to Lonstoact an
equvale nt D#nsumg that all porsibl
athy and tranyitfony ane
the qitn
theefoae ,dhe 1R(I) Hey "92-34) 42
*q2b) q2 (Lopaacle ctate)
)A., a] ’ piral Statt q2
)Convert NEA t0 DEA
3 A :1b]
me hod.

nikad DEA s+ct: (-cleyueL (40)4g0Y


TDFA tate a'

Thue LRC)item y r ytnt+ all po oible conbj:

ihto a clount a
Symbol.

B{ a's and b's ewht r the dhtd syn bol (ro ’final DFA state: Any state Contaihihg q2
is considoyed final

The ruultihq DFA accept all stihg t


Corsejpodhg bF4.

a's and b where he third Symbol

cratu:or4!q23
’Aqhatst:ia'} Find out
8} Detine (ondtx4 ee ggammar. folloiy
)ttal tate:40 te Contogt rel gra mman tor
the.
thot Conis
Janguage
1)eveny stn start and endsik
l-a)q2
6) 0 Symbod.
i-&ambnc) n mtp and myn p 0,
a) A (on tBt- Pree Goamn ar (CFG) a ii)L& amb"c n mtP
mip0):
kormal
S xcy 1

re (ommonly. wed to ol 0mbe the synaa Euplanaion:.


anel other fema "S is the. start Symbol.
danguagen. "Xgesa) any numbe rt o sa's tollo wed
by the same number of- b's tihcluding
Languag:
1) nurmber
c's(ineladiy
Ewenystng start ohd tnds widh the
$ame symbol ).
The productionSCY Tpos ents stDh
where t e numben q- as (m) equaly
the su he numnber
ok b'' Cn) ard
ber
c's (p), and x yaerate
S’asoa b Sb a b. lq'e,YeN Mtey
c?s, and 1 6's a re tnserfed tn be tween
eylanation: )4) state
S is the start symbol índicating the. tnput and Dutpuh of e ach
phcye. in tramlaihg the statenent "posi4te n
The produetton Tulu
gnMte stn
whte uerg stihy stah and
wrth dhe Same rdy
Symbol ( ka) or b').
*on inpus and butpuh n tranla tig tee
S tatement position = ihitral t ate 6o'ae ar jelea
u)ne meoiate (ode
Cheneeatoy
leen
ulHh dlei C07 D21 po nihy to analyis phe.
Dcetput Touens rehryentatfon of
Tolen Vyre -) Qutput hteomediate
Touen

Posithon Arsignmend Opaton


Tdentibi inijal
Addi tion 0peasr positiohe t2

Tate
S>0+nation
n tom the
Mutiplcaton Operator termedjete epoiehtatfo
Tnte Litral -> înpt!- phose.
Code 9e neetion
opimtzed antesmnediate Coda No
8) Synde Analys 0tput!-
thù (ye.
rom ecal cnlyi pha. optimizato peburmed tn
)In put: Touew
Genevehòn
CAST)o Pase 6) (ode
DOutput: Abs+oact Syntan foe d
¢he syntachc tuotune oeienta ion
-) Thput: Thttwmediahe
optimiza tion phue.
cocle o emblycod,
Doutput: Ta oget machine
posifion Lo4D ate,R4
fnittal MUL R4,601 R4
ate

3) SemanHe Analyso ADD Ra, R 21R3


SfoRE R9, pb si on
PanTe Iree 0m the synta n analy3
phae each pinsye. of the com pidsn pe fo om
SOpu:. Checles for se mantia
coTOleth e, ype Code, tnto Aneeutabla, nachiae (ede,
nsuihg coo0ecthn, cl 2nty- and copaie.
tuih the taogt lktfom.
wit } Fts+polto set (onflich
g4) explain
4mman )(0hHi ñJe. whn
cah qñe whin tompuing the IRIt
FolLOw set5 tor 97amman Tu,aqweng
anbr'guitg and ditelty in pang
in bp- down paosthg thelude:
Lq+ Recus ion : leadto
the sam de rmihal sym bol. ThÝ
biguity anddltichu ih in parihg
o am Path.d
?anon in bor down paTeriy (eadihg to stele

t’EteE*E, Whene &repTent an amith metic


ersuioh For the input 9 tS* a, thTe are tuwo
posible iniespetatoni 3t(S*a) and (3+S)* a
terminali sering ’pirst fo llouw set Conglich:
) longtrch ten anise when computhi ng the FIRST qnd
FoLLOW Set for 9ramnar rule, quying anblguw ty
and di stcuttiu h pamihg

it challengig for top where both and B demve stnhg stasting


down w th the sae teomhal ymbol J lead to
pasing path. in clatemini ng wch procuct'on to
biguou d0 ply bayed on the Look ahtad ymbol.

añthmeh
4hene aree two poyible.
nteopyetae, tactoed qnamma ules to Dpeate eb6ictively
34(52)ond (sts)*2
mequoe Teekouctuting or dsamhguahon ecbnig
3) Non- Dt0mìhis)
amma ules an lea what are the vamuy înterme diate torn 9 Muntion ih
to mul4iple persibli ch orres a eqch pj typy How wow d you irmpltrant the thrste ad drn
statemnb, Genrate interms drete cod for the followjha
Ie, compii cating the parsing yooreu. proq am fagnt. hisume thre q7e four byte per urd
eMampl, (onyi don gurm=o,
tor (ieIýin 20 ,7tt)
mulipl al te naue, uch ay A cum sum t 47]tbLiJ;
"he paojtr may Nedto bace track on
explose dik7esead passlng padths to cetm,Phtermadate torn an repentatien oy the
he coToectdeaon.
ode tht are betwtin the high vel oguase
and th maehne cocl Jhye toomy aTe

tddseuig y in vovey vamouy phae o cempilaion, epecaly


aud code. genetat'on
ammar to or ambijuty thclude ;
Jhe tye of in tamadict toomy
’ posth Notation)
tha the. garymar suitabl koY Alo hDON ay Rivee Poli?h No tauton, uwkone ojpure.
top- douon parsing- teehntg uy he )ThoeaaddrU) co du.
Msi n
Stremnt that invovL at moyt thme addr
operand.

Herarchial trte pTnahon of the syntae the


be. elauiied tnto
’ Quadyly and rtples
fosn wthfon
Reprlentahoy tht we a tabular
and thrle lolumn Te p2ehey
mplenttion af Thote- addren satemnt
implennteyhg:
*Jh o addsen cod can be eldy tor fhe
wich contah
) Qundepl
held ha ye a po
-) whch Ohtthe o t

c) 2ndrtet fnples
(toa level of thd'rtehon to
wwreh cuyey an

Sum0}
for (il;Ca0;7t+)
Cum= slem a[i]+ b[i

Sum0

Sum sum t aIi]t bli]

L er't

You might also like