0% found this document useful (0 votes)
15 views7 pages

Compiler Design

The lexical analyzer breaks down a string of text into individual tokens by identifying characters and patterns. It outputs a stream of tokens to the syntactic analyzer. The syntactic analyzer constructs a parse tree based on the program's grammar to represent the syntactic structure of the code. It performs syntax checking and outputs a syntax tree. The translation phase then generates intermediate code from the syntax tree.

Uploaded by

Rithika S
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)
15 views7 pages

Compiler Design

The lexical analyzer breaks down a string of text into individual tokens by identifying characters and patterns. It outputs a stream of tokens to the syntactic analyzer. The syntactic analyzer constructs a parse tree based on the program's grammar to represent the syntactic structure of the code. It performs syntax checking and outputs a syntax tree. The translation phase then generates intermediate code from the syntax tree.

Uploaded by

Rithika S
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/ 7

17 The Jtefa e§ 1M ilx1cal anaiJt,eJt

~ #mt
"7

., Meal ~ .)A ~ pi,cMe ~ a CfJm(lllvt.


flu matn tcuk ~ l& .ffla.d fht t°n[ud chaJtactm pJltxiuU M
©tllput a m.tvit1na ~ teh_w, #ial 1Af f)CWVt lMl!, ~O)f f1fjntax
0
Cllnalyo"u.. 7fUJ ilui.Jfettlt on, 8wnmaJt!ypl 1n fflR ~ln~dltlf~tl m
nr
Jj inyiPww, ted bf! W.JtlH Cl 8 llbJtoufuu ()1 ct CO-JWuli.nt /µ-I
#Lt hxlcai anail(!JeY1 1 wAf&i 11, eaihd by #if, fXW,eJf u.JlunweJt
11 'nQQcU Ot nwJ- lekin.

30UJl~ /..Qx?cal 70KQh


- 7
<pxogJtam Ana4}teJ1 ~-..__rp_aJfl£Jt
_~
- ~ - 6tet
nut
~en.
~Mb~
'Table

JnteJtaclt'on e§ h.xical An~e>t u!ttn p~eJt


VpOn }{QWl)[n.r; Cl '' get fUXt ~ 11 command. -/Jwm flM
(j)aJ!,WI , the. ..&:<leaf anaPtmvt Jtiac/;, 1lu iryud MwtadeJt W11U
Jt can idmlt~& mxt telw,.
-/hQ_

7/iQ. M cal anaJu'!P' ~ 1D tht fXW,eJt a. Jufl)llJent


. . on ~(>Jf #w, .1ekui .11, 1hl> ~ound · 7m JtR{lYtf/JenfCW()n wJli ht.
ari 'lfl.kf!J' cuh' 1/J 1ne l8ktn ~ a r$Chl(lh CtJnJfrud f1culi £U
~ n fh,U, V:, 1 Cl>mfr/a OJt l Mt>n • 1nR. JtRfiJU1, entalwn rray IX! ~
p{)))/ cenib,fin.8 ~ an ?nr,eJt trxh and a_ polnfm -ID a fflble
4 1'11 .,tehn. 1J a moxe CIJmpfu e&mmt r3tllh a& 7duJHft'
!(> /.D'T-reaJ Ana1fj?)eJ1 ma+/ aho PR-xg{)Hm Wilcu"
n C?!,ewn~
-fti.m M #IP. tJ6Vt 7nte!t.[;w . Om. -ow:h fcuk J& eftrippl~ out
#',Om t2Bowtc..e ,P.JU981cim 1he lomm.,_ni), a.no/. f»h'ib ia,,ttl'.f in
1f,J;

-!fte. -blYf m 19§ bfMk, .ia..b Otnc1 tUW .Mu chMade;v., . /Jno Mzvt i.!,

[OHJidafln(/ (!)(JW}f mi-Jo~ ~ ffw. CtJmplJ»r W7fti flu! i&Jww


'PJ<~·m.m le 1 1hR. h~f cai a.naly?)eJt mD.ff h.ep frac.k l'J§ ihR. numbeJt
~ tu.wf1fl.e ehOJ-tacteH /2een, do 1ha1 a 1ihe tU.unJ:w, can be
eu1>0c1cJ:id wi tf1 an {?}(,H OJf tnvl,o°{Je .

d >- 7hR. JiM ~ flv2- J)Wt6e>t

1AfpaJt.Wr 0Jf (jyn ta.ck M..aiy?)eJt ob-/rlJ.;u, a. !;lt.Lnfj e#


f812uu. ffetorn -lfz.e hxlcal anoJ.ff()ut and v.vrlglt..,,, dfud 1fu! ~
Can hi, ff OWtaiRd hy #U- 8Jtamrr1aJt ffe>t 1Af 0'ewtCR. ..eu,,!l~. 'flt8
.Jf.RJW.,,,t;,. Mlj 4Jn1i:i.x e.Nt{T/ 1n -fflR_ f>.Jt0f)9fan1. St also .JC£{.(}/}{Jl/., r
wmmtm4J occw1}1J (!)t)Uyy .60 Hial .1t Can CoriwuLl fJ}(.o(LM ing 11$
1nrudu

..10().)11.R, rr-----. ~e
pQJtl:,eJt fie e ~ .?fll, t 8§ 7nt e"orntdfie
gd IUX I. .ffetonf end '+i,'U&entali.
.fohn

pt;J&1Hen ~ fOJt/J.J/ in rornpi le.Jt modd .


?aJi!JlJt i_n., Cnmp !Junc:luJm e/) 1hi j)aJtl>.Vt :
-7 flt V.00~ +he e£:bw.ilwtR., @en.vtaled bf! Mu
~ btUed on fAf g1ta.mmQJ1.
->- St c~ truw fnP- f.WtJe tree.
->- 6t JtQ/1().JW, fhll eMom,
-+ flt p»t.f;oJt nu eJfJtQJf J(R_co UVtfl.
:£~UM :
'f}o.m m canno t dwd eMl»1 ~uch eu:, :
-~ Vcmlabei J11 - ruclaJtalien
--+ V ~ lnllal12Jalien be#(Yll IJ6e
->- futa lfj(l! f'fWmalch ~ em O(Wtcdion.
--vii_ ah oVf. ~ UM aJt£ ,,!zanc1fld. bf! 05em cmllc ~n aiyotD
<f>hal.,e .

'2ty ntax envr P-to.ncJJlna :


{j)J11!fjJ1a~ ca_n Confatn OtJtOYM al many dJ~nt l!wek.
fOJI, eK: ·
• /..Qx1rcJ.J ~ud, ab tYUU>reIDn8 an ?d.tnft~ , k,Qywmrd
~ orexllltrf .
• 8tJ ntacii c. , ~u.ch oh lln lUll tfm'tdic. ex.~·, crYt w~ ~
Ul\bda..nLecl r;:xoo-n~el> ·
• 3emantrc , e5tA.ch ab an ormato1 ~ed -to a.n

1n wrripatibLe. q,ma.rd. ·
• J_ea~ e.ok , $uc½ ab an 1n BYn1tel~ ~twtil ve ('_all .
3>- Si1r(lllcaiioM til ~~ ritax d1 aeet.ul fram,1riJiim .
7hL 'f)Jf1View, pha!,e 0§ -/& fJmru}»r a1mJ, al fnr1m8 otd
,JPie. QS~ntalic r.o,oocffJ.Uo 0§ i'1P. ~ - onu if1R ~enlw.t. ls
~oond .le ht ce«ecl al. f)lJf fhR. 8.9fClmmaJt, .a );, mC1Mrmy te
~
0

.A}(.{WJah, ffl£ f1talmwiti guid.ed by 1hR. Crmfut f!'mmmwtc,.


'Th£ allJJ.buit ww. cw,~c'lattd wJth -/tu. J)YLDfJYi~mm~ l~u _af
COn!, truW, . 7fu rwta1icn.1l lJJed ~ cw., ou ~ '1fJR7 an He .JUt1a
wY-111 pucdudlo m aJt£
->- ifjntctx cWIRcb.d ~O m, and
->- T.9ttuU laiJm ~ .
Jyntax dvt.ecitd deffer,1 lwm OJtR ¥ W .-6/lfclfo"caiJ,611,1,

-ffeJJt traJVJoJiorv,. 'di ~ -fm /J!,£Jt ~m f£(ZPdjfjing 111£ OJtd»,


ep fPt! lJt flll!Ja:l/tJYM .
7'Jtan&Jrilion cMwru .incltcait Mu OJtdm tJ# evaw.a1uy;
1fu t;:£un a.n1i.c .Jut1u . '7lu nota1ional ,#twm wOJtk W,ed
]E cl£fm Mu intvtrmdlah CtJd.i 9e1Wtalien ~ frZR <£~1ifax-
d»u c!Ld .»tCt116.1.cilieri (:Je.Pwm_ • 7m '1f!IU4x CWlect,_d fr-an&falwn
.)1, 1.21,e d le OW, f.H1 he 1he infvtmullah, t ode .into a Stfniac11c
atruclwu ~ #ii (&{)unte ~an9uage.
~, ya,uarz,U r;D Syntax tree& •

->- 'J)lMciecl Aeycf.tc &.rapm, -&O)( t~i{m .1,

->- 7kt Yaim. -Numbm NtfFu:d pt Corn tr" ~ l>IJ6t g


-;,- J)iM cJicl AEtJWC 6vt~ !Jo>1 EP<.~ ltJm

~ Lih 1fu @yntax :bcu ~0J1 an ex~"lfm I


ct 'J)A&, )'lab

lP.o»eJ lDJ{J(»,pon cl1ng iE abm!c O(liJf,andA and i ril»tio r t! fXXl),

CfJJlJ1J.Jpondlna Je o/Wfab}tg . 71w dl~na 1.J inai a ntd.P- N .1ri


a. 1>/J 61 ~aJ m()Jle 1ha.n 0111!.- p»u.ni, ~ N }11f!Jt.Rl:£:1u1> a. wmm on
All -fr1Jt 1m wmrmm
@.lb~lrm J,n, a k.ifjn:lax, .)Ju£ 1 1flR.
eGuhe~iem wBUJ.d be JU(lllcalul ru many ~ ao 11?£
~ .k #w. oJ-JgincJ ~ten - 71zuJ) a 1JA61 not rm4f
~enh ~ irnu mom auctlnclfr) JJ 8~ i1u. wrrytfu
YmpoJttOJ11 c1utb ~OJtdin8 1-flQ_ gerw1cilie-n eB eB§lw.nt CDru te
evc&uo..h -tM. e~~hrrl.2> ,

->- 71-te, Vaiul -r.Jumbm method ,pt UJn6lra.i1mJ Vf/ot'g

I efjun , 1/u norlu e# a <2fyfV.ilfi .1Jtll, CJJ1 7>A61 (1Jll ~lw<i.d 7n


an ClW1a'rf eg !JtiCfJ,ch 1 ~ fae.Pz JUJw eg 1/u MYtay ~enh
one .)(1lfJJfol) OJ1d 1PuJte#oN om ncd.R. tn each Jtf.cOJtd / 1nR.
fN>t IJlld 7ndlc_a1lng flu la!Jei eg 7n12.
1A an O(Wtcdion CtXU_)
flf)de. ~ Jw»e eru addlfrenai ~ 1 wmdi ~ me
Mw Vaiw. and 7nlmi!Jr ncdu liave .b.>0 adcllHtmal ~do
1rdlcaling -Ifie )41, and Jdt,1 cluldm.

5r VpJiml't)aiiffy, eg ~M7c 'Bloch.

c!Jjwcliuu pJlWJWj.ng lHmzJfr»-tmril.&rM can be


1/il
,rrt(lf»m-rwd hy conJ trucl1"8 a 7>Aut ~Jt a brute blocle. 7nJJll
lo CL rusck- .1t, 1he 1JJJ~ ~ each @§ 1he ~ Va1uu, eg 11zt
' { ~ ~ n g 1n Mu baJtc hloe,k ) and tlwu .u Md.i 11
aMoclahd w,ffl eacPt kitahm.P.nl 8 euifflln tm block. rm
clilPtoort ell n QM ~e. ~ UJ~pondlng .b r;Mcdimmf
#Lat am 11w, ja.,g t o&giru frrrM pJiltJ11 f-o g ~ ffz£ OfW1CV1d6 U/2ecl.
bCJ $. nodJ_ n JJ 1aiJe2Rd qJ tfte DfWia:1.B'Y ~ d at sI aJ1cL
ciPJo a,linJtQd ~ n 1A 1m Jui ~ VMiaMM JjoJt wkidi 11 ~ tne
iru1 ~ w7-/ruJi -fPli block# ll1P- ak,o rwk fho:je ntx:l.u, J6 any
/1)Mc,e Vaiu.M ~ 1lue £m ex1f_ ~ ,lflp_ h&Jck I r/fzw! ClJtl #ze
~LJ4wl nor:Jij.
[ommon ££uh er<(lJ(lM ten!, w.n be dduiul- h~ 1W "Itcln8 , ao
a_ hf!uJ IUKU m 15 ahotd -~ be addul.J wlzdlwt rlhvt£ ~ an..
fw +?ng IUx:b. n Wlfn iPiR, .hJ,,nQ cAfPr/Jt.en J tn fl1.p_ ctamR. oJ«Wt ,
ancl w1 tn iPl£ '2$amQ ~fWlaToo. ~ go J n lDmpl.il»u 1m_ ~
vafu.Q ~ r11 and mafl ~ V6ecl k 1h piau .

~ : Corll>1ewt #Ii. blDck e§ ,0fcili!YW_ruJ


Cl ., ....- bt c
b : = a- d.
C. : !:: bt c

cl ; :=- Q-cl

7n,L VA & JU(IJlU, e. rihd A hoWo fi?e Wfr1it ten& trt..tdlr;


11 rxh ~ #1£,fhittd.. (;;§ ft11un.ui1 e: = b te 1Pu__ lUl e/} /J ln
~ ./;) lfw rwolt .,la.P,ef£d_ - , b er CU,l!,e #ud 1J IP,,e ma5f ~
t 1;
~ &§ b • 71t.u& Hu Vafu.e CfJmpu:1.id al r;ttcW.rrz.ent one.
{)J1d 1/?XeP l!1)(1 not co1ry2llcaml . fwwwe>t, flu naiR. {,fJ.JtJW.pondin,r;
Jo ff//, ~fJtOtfli c;:Jfaiunmt d:-= a-ci -Aa1, Im tJ(ZVfaior - and -Iii£
ncc/.,t,& Ja}J(it.d a and do a& chlfdx£n _ .Jlnu -!ht D(lRJ1aioJtJ and
1fil chlitbcui aJll ffi2 c:l'/1/'Yli aJ #wJe ~r»t iAe ncdi tlWW.pohd,7]
J,s cJfaJi.,mnt lu:Jo , W.t dD no ~ 1

#ZQ 1u t ~ ~ p
ifu nedi_ 1aMd I_ I•

Jinu 1hm£ ())11, 8WJd ~ ~ u,i ~ VA& 0§ #LR,


biock ran h-e JU(lPaacl by a. /wJck w '/ffl on4J efhJaQ f1, tah.nwz/J.
In ta.cl, ~ uffuJt h t)ft d 11, not 1wl on exit ~ ihf_ ~
<1fim 'Wl cw nBt. 'lllRd 10 CDm(l11b rtnrxl v~ ruu:1 wi u-0e ~
o#t!H te Jfi»iwY {Int YaiuP. ~ b8 rinI2_ noa& ~ -
~ : 1!J b 1 rwt 1wf, rm exlt.1 w,,e could ~e
a:=b+C..
d: -: : a.-cL
c : == d1-c

bo

}& bofft b anel ci coo. 1wt tm exit.) #w1 a


Hou:JeUeJf /
g~wtlh d/atufwd tnlll,/ be U&ecL le C.i!11d di/£ va.&D. #,em
8Ytl- le #u o#wt.

You might also like