CD ShortNotes
CD ShortNotes
) Tabu Construchions
# Simpu LRI) [SLRUJ: " COnstrUct aumented gramm0.
) SLRU) = LRD) + Arst POlUOw " CenstYUCH CR) m DEA
NO O reouccd achGn is less cOmpQTed 2)Const ruct porsing tablu.
LRLI) (tem= LRLO itm+ LOOkahd
t9 LRo).
3)TAbu construtin sam Us LRlo), SUsH NOTE: FirsF) =t
achon.
dos1sn.
S’ A(B$
A’ a Tmatning
string SLRU) CLRL)S LALR)
4) S’AB,$ ono S ’AB. (LRLO SLRUO D LRO)
5) A0GKche ad dor LALRU) NO 3tates :
Cuyment td produion CLRI) rom ambinubv)
unombiaubus
LRCO) =SLRLI) =LALRly
<CLRL)
6) Pit HCduu in tabu at
lO9KCUhcod
thn put Ha ct Set a ètmyi states
A’ 'cX,ti} TCI4,QJ,T[I4,]yACC
A’x tet
(Yeranother compiler cerpiei
used t0 desisn LRcmpiti
u
B’Y, Ytay Jt uses
O.
LALR() tabu
Fa c tay
SR CSnyict. then
it NO Jhitt achon in LRU) SR
then RR congiit FORIAtos psc cdenci poACis
(tM DEA ,then (H CLRO .
2)) Shit cdua pOTsinQ.
9Tabu ConstsuChon: 3)Suitabu g Only per aty
gíammOs. may bt Qmbi5uL
Aupmntcd 8rammor cniruchien)
oCenstruct LRCI)
4) ©ptvator
Cpt qrammor is a cfG
- rinimi
ttms DeA.
D¾A b mursin statel. hO cajacant non ttrmtnal at RHS
Contrch porsig tab 5) a zb a is higher preUcdtnce
3 Stats with
AOm LRIO) Port ord
difteunt OoIcGheod au ab
thtn SR Confut
4) No RR on Pit in
iftisauy0
then RR Conylia Push n stacIk ,incemu pointo
iRecluce
Chane g thing RRCLR)’
COngli in
Replau honclu in stalc.
NO SR Cenf lict in cLRU) ’ NO SRLALR S4 CX9]-Acccpt SUCce
Conglict in LALRU).
Conyir öh ciRU) cônpich in lALRJ6) TCUbu hes ho tcrminal t J
TOws A COlUmn
’ COnitUchnep0T6ing tabui
Construct LRi) tms DFA.
oCheot for conyict sta 9 LR0) lowr (Cvce peY ator has hig hc
ochecr fur coylit stae G SLRU) prorÍty
|° ConNtruct paY6'ng tabu.
)
Pavsing?
w give
L) Parsing
Parscr ,it ambiguous ammor t9 L
witl Aave ConlicK. wt on a CuYnt aymbt n ip
Jumgvc Conflit fom the table. buffey
EX: EEtE + Accept, SICCOS
E’ E*e Is|s31H)| PP X Om aCk
E’(d tnCrement LoOKCh Cad
int stak AShift ints io
burfc. Rcplace by prduchn (Ct TLX,a])
RHS in steVese .
in &ioC JAt do Syntax enOY
Jt u nt to do Redulc. * The
pcrctY in p pPrOduchins wwhick ace tecl
Cn par4ín
bulea foÜm tlble Ce useal
to csnStuct
Parse tce.
hnce umove Jnitially
gammCr pusk
S
NOTE : Ambiguo
mT[S,+]. in stcTbng
stak. aymbol ef
CLR), LALRU)ramm0r au ng
,SLRU) LRIO)
NOTE: Prachcoly cALR is scd. (f anyhOw PCUse trCe posible
vIab preix = Stack Content Bhjt nedue then
LSeKchcad lengt
E: S’ AB ; 4 (BQHOm up forS)Parsin*
a: B’b LA),etmost clesivatiVe
Stuck !p Actint yt to Jight
Perfosm BOttOm Up posi ng abs Shifl
wnt prcix upto londnic A Reoluca COtlechOn cl viabu retixes for l
AB EA, MB Shift strings n gramor is allvays a
A bC, AAb Ab Redua * OFA which we scSulo
AB) Reduu is thu DFA f this esOr sei
" Tare (Teminas t $) n ColUmn, Let ReCUTsi n s Prblm ony to
non-ttmine n Tow. [A»B tOPdLUn p01K0 ,not te batt)
AIgO: henl in
Ar(0)-eJu[fircc) A’ AXIAKal Ads l BilB2
For CaCh Pruchan eotown
A’X
)Acdd AN to TEA, FuNSL(X)J by S!.
) D9 S' plduCe! JucrAiVL PUTt
Add Ax t0
to TCA, FS(u Usiny usht sucursion (put
for ttminahGn).
*LLL) Grammar: muttipe produchir A B1A'|BH
Presen in | bOx in paTsing table
thn itt ngt LLLI) otherwike cLU)
o eyt tecerssi en my be
unombigueus
(LL))ommg
Direct gndirect
(Ambiguou A’ A&/B ABalb
BOth Ou
B-Ab/a
LU).
checking or L) AYammgr witha ElminahÛn qindirece LcqE MECUS
tabu: by One veify PYOcchOns
RLlle 1: Sinsu prsducion that dnt hQve ecyt CLYsI0n
Srammor LLU).
Rula2: 4n Cae g muuthpe B’6 tesminaL cOn be replCCAC by
Onducbion venia pYOCluchen thn Yplace
t any two Gr More Thn eiminate clircc lelt sCUT
semething in COmmn frrstlai) fave A’Balb
then ngt LLU) a A’ Balb v
B’ Abla BBab| bbla
NOW eminate
LLLA) CLRK)
LLo) LlK) TC 0(n) (f(A:-b)
3)9t is nor suitabb dOs leqt
YccusÍNe 8r Gmmar bease
Parser fals iotd n{ init iOop
EvyLcK) is LRK). Ex: E’EtT E)
3) TO hech fy CLRU), (6t Gheck f r LI)
9Aess pewesful thCn LLS
I4 ngt LL) thn consruct DFA 4ChCkS) Simples t implemet ttonttN
NOTE: ReSlar 9Tommng may be DoWbOr POYSC Y : cont
ambiguGUs but Heguor eonsUase
UnamosuGus (LeCs On3The delewing aemantic errOS e
not aetcctcà by paSCTi
4)For every DCL .LR) exAt but LL) 0n8 a ariablu withut decloáto
Mltiple timo dtcaaho ame
for evCIy
Vamiable in Same sCope.
5) o áncempatabl type expycsOn
HeIlGx Lang LRLDexut,
grommor
LLli) exit.
LRU)Ur
:EvexY efuuor gYammos u,cL) Fole PanamercY
Cm·y be cmbi6UOUA) Anay ndex ELt G 6Ound.
’ LRU)
oñamb(5UOUS gomm06 )For LL
gromHnot
6) 34 mlhiple prOducios atu th cu fosa 3) Fox LR
non tesmnaL then its nOt L2O) SLRU) C LALRC)CLR)CLRU)E
g5ammar: LRLO)
.cLRK)
Vfos L2) check a lenet 0kahecd 3) LLCK) cLRI)
Common net LLa) 4) Efrce LLU) grammor SLRCI)
not generating e
3) FUs LL3) CacCK 3 lcnsth AO0Kahec
S’ cal cco NO COmmon ': Lll3) 1)foT LR
o LR)= DCEL
OTE C I (ang ’ Hony grammoo LRLO) = DCFL with prix pYpTy
|Gommor’ (org. (e ang2 8trings not p h h
= LALR) =LRI) = SLRK)
GTommor
not LLC) 4
thunLLUk)fr SOm Ke2bUt LRIo)C SLRU)
has LALR(K) =LRCK)
= D=FL
LL) but nor LLID2) foY LL
Olp : Anngtated par8e Fsee LDccoYAted INheo ttdattT: atr value ata de
Par&e toce)
U)AnnSratcd Porse tec: gn passe A’
Cach Sgmbe is asCiated with tree
GttibHe ino SDT
7 Advantass flled in symb9t tabe in scnanhi)
anal34 PhasC
) usd to design Scmanhit analysis phcse, 4nheritcd
(nttomciat coce generatiOn phase. ato is usCd
) scd for detciGn g semnhc eTUSS. NOTE: we may hove a set f Yles
Symb table. even nS SUle fUr a POduch
Jn) wscd for construch On
i) s d fos impitit typc Cnvosion. |*Based On types atrributes, SD* EX
|v) uscd for syntax toce/ DAG CoNstsuhin
|S-attributed : uses nly synthcsizd aH A
2
i)2- atibredi WSes beOIh Synthcsizd
Cnrl n C t d Cttyibí ites.
-attbibutca dt Satt butCd thn * NOt in exam point fviCw
5-attvibuted lefini tely L TYanstahon Scheme with bttom up
Qttribdal9. PaNsest we need to nmodify
in midole asnheriird a) ynthes i3d)
NOTE: Jn SDT thete mest bc at (CQSE I E'’+TY praHl t)} E'|E EtTMEIe
SHnthCsid t ibue Only syntAeAizd attr
NOTE: acdtypelid nom,tpe
typoingo -Static Stmanhc Dynamic Seman tig
(t a fu to Qdd
Symbot toble. ype inyo into
int sing
Using undecloned
Vosiable Of bUnd.
’ Tranblaien SCheme :(SyntaK oMuipte
Of om deciarahen
o
vonable. Division by O.
aiscctcd tsansLatin 8hcm) Incompathible data
,o TYans LaH n Scheme ès a SDT in ohich
SemantiC tles may presen in thul SDT 4uitablu |SDT NOt sui tabla
miadtc prductisn. * SDT (Ont be wntn dus
ýnhcited atribute shaud be placc semanhc cOI8 dynamic
.: (tr alo aled
at prepr p itin. Runtime error Þr excaptin.
*ConstUchoni |* EVen yttr compilanOn, esoY Cxst
i) AW ynthesizd atoibuter uues au (YUnhnu emoA), hondld by
plaud at igthtmsst end CXcuptiOn hanadlin.
procuchOn. enhnce portabilíry,
i1) Snheittd attnibutt
manic les is JrOntcnd
o Conpile
p(aud byr that non t(mínal whe
Valu is calClated. nttrmcdi cte CLe GeneYahon
Ilp: Annotatd pae tsee
* Evaluahen: Olp: Three adodiC cde.
) Construct arse tsee and atrach |2) HLL s COnvCYttd into intmdiccte
semanttc tules to the tree by COcu tS perfom Sptimizaien.
Coidering it s gTOmmor smbe, ) SOT iS Uscd to clesign thç phase.
i) Pexm DES tiovesal Intermcdiate COdu
ights When TWle comcsjom tet te
, exeute.
NOTE: t olp SDT 00 tronslaHOn TYCe form Lencar form
Shee
Parse tree a peyfUrm DFS Lng trce
Dirccted
Qcyciccpl
*TAC
Cole
4 Strength Reducin
oe cheaper cn ttns Speratiôns ohicafrli0 i i<4n; itt)
ay 0nplementoHo,
forliO, i<aniit)
will Mpace Ompux oPeraSns. Printf (H/)
PrintlHi)
(ndt
5) De Cad code eliminahn: Remve fur li-0; C<99; (tt) fr li0i
OmcaChcble 4 nevCsWsed codes. i<49;in
X2
constant
dead ce pYintLH)
Print CHi)
pst(Hi)
ebe
PrtlHi) eiminanUn
Cse
PsttHt) printl Hi)
pstlBy) PrtByc) NOTE LOttia prOfrom i wscd tos
Pninr (eye) Ophmi3ahon.
In
a,Cid, n,9,Z oUt
1) Resats allNCUIOn (56apR Coloin) atz
LOoing
at
* Gl0bal Sptim: is aOnu by LSoicin at NOTE: iVC VOTiCblu t ttahing dinatio
whoe contGt flOw qapk" Ex: ltadcodal ae Path baccl ohcseas Gtnd iU
eiminanGn, Spy propagahon.
degnihÔn Anatysu: Tep
|2) ReachingX-?
J) Jt is a machi ne deoendent phase. bttOm
a) IIp : Inttrmediat CCod
Pitx
Op : Asembly code
3) COdu generahgn rquires i
X=2
.o Resistea MeSis ttr clcanon ttca hique
macin adores
AadícMins moous
* De< -Use cAan : For a wr te find
’ DCa fIOw Analysis
)ite NOTíQb ANalyss i (BOttom to tep)* we- D Chaini Fos a Lad, find
At any Peint (n PrTam, varíables WeA all posibu wite.
cy tts it withLt bung writ) cve NOTE: ElLMents live at a stmnt/blOck
ive vaTicables. Unt writtcn means ive fust beort that stm(bck
a iv bforc thç
not tiv cyter thustmt.
nen(M-n0)
Herc bt ) u ng
Propoatt consont o
hose VOY that ha bç cacnse
Ony I dle|inition a NOTC Expy Cionu
means QvailabluavaiIabli
last
Btmt S
y03y3ta jUst by0TL Btmt S.
Diuploy sa global array pointe r
to al achivaion sors
Jst acce to nen 9cal voriables.
Zi7-yta Caling a subprof rom cn 1ami teve
print a ýn higher l(vee adol an tntry.
’ tive Vaniable analySn Jeston it whn SubprorGm retUon
Con be
Re achins
dyinitiOn anolysA Con
|*Snstrut
) T3
OAG for TË=atb
Basic
NO' nod e = 6