Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
38 views
57 pages
CD_Notes
Compiler Design Notes for GATE
Uploaded by
rajat ghatode
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save CD_Notes For Later
Download
Save
Save CD_Notes For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
38 views
57 pages
CD_Notes
Compiler Design Notes for GATE
Uploaded by
rajat ghatode
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save CD_Notes For Later
Carousel Previous
Carousel Next
Download
Save
Save CD_Notes For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 57
Search
Fullscreen
7 Compiler De sign al er ® Lextoal Analysis ae ® Parsing Gise® ‘ @ conter fee gyammn os! © Top down > © Bottom vp ~ @ ena. - —~> ® Antesmediate cade gene” lon —> © code optimization =» Compiler Source = Targ a program (by prog) proqram © Assern bly language ® Relocatable machine code @ Absolule Machine code. erecutable- @ boby ; ‘ \ ed into 5 — Relaotes into mainmemory ak shoud 6a | —> js occupying seme Mined locations] ies 5 mel <> iLiccolled Absolute machine .,,; eth 0d ee aay bering injo ie this is called absolute ~~ > Acompilen is a language translolor mle code. because itis aS ushich takes input o somce program stoved in stahc oreo. [i : [ Sack] <2 and ovtputs an olteck program. s Es a ; Ia , 5The ob progiom can be assembly lonquge, yelocatitole mic code (oi absoloke mle code. ; ddddddd bodiceintial days 00 11.0000 '! Wand coding easy coding Add Ms rently lanquoge } Noe Nort) V Progiormming lang-1 v PL-2 v pe-s Longvage Processing Syste S¥eleton Source Program Pre processor exrponds mocyas | Source proqrom Assembly Language | J : Qelocatable mle ade atherfLelocatable | Vv mle col _pripvenTandes] ts0metime) Absclvte mie code naleodeocessav'- Expand the shot hands called macros. into Pre pr gource program stote ments the assembly Lang program into va Assembler! Translates relocatable mle code: Looden'- The process of loading consists of taking ele Yable mle code and altering relocatable addresses and places the dota and code into memory at Cen TIERED (0GNEEEngon ee loca Hons Unken:- The Uinken allows vs to make single progrom Rom several Piles of selocatoble mle code. Tnterpretent (Language transleto) translotes high level program to machine code urce) each inshuction and erecetes it against and interprets. the data‘ to produce the ovtpot ete | > ovtput -— nee toterpreten art-oj'ctorix+) re [ printé ( Hellou ’) scomplle — | Hme. BES & mare memory] Olessmemory intepreter —\0 to genera G0 fate le ovtpub each Hime. interpre feral | | erected' « Root Strapping vs — iB ili i A | =A concept of compiling a compiler program ini own Langvage to qenetatde a compiler for new program? fi Language. Z Cross compile ot —> ® compiler that uns on one machine and generotesq we ris code for new machine is called cross comptiler and eg erossraom er > process fs called cross compilotion Compilohion Process 7 pralyais Pod agnor ivp («6 pllads) @ Divide the progrom into tokens Unt, a) int a5 v
outpot proga ilen cade pterpret 1 TAH compli tattorm patton twormodele. independ. depen @ levioal Analysis cscanner) TE scans the ‘source program from left to. right and Jo tokens which are sequence of the LULL bddddddddddddd WeUVUUUL TUL > divide the program in having some meaning. The takens are of type TdenhFien operosors, epeciok chavactey covocters \eey wards, consbants, Qn = Total = Subj subt #25 Roffen % @ OO © 600 tdentifient- Toto), subl, sub2 special chonactey +) operator = yah covstonh= >EEE DE Synbol Table Cony for idenbFicsu) s Zitotal Float o.0 ~--- > oe a subl Floot gosibage aes we c subd Ploat Rehuade ee, oa _s Clemenates the whibe spaces and comments. a Basic Fonctions of lewieal_Analys's s @Divide program into tokens Ss @ eate a yecord for each (denhfies in dota shuctuve called symbol table 2 ® Removes white spades and comments: & @systan Analysis Phase (CE 3 It groups tokens togethes into syntache shuchres a and ave represented in the form ofa hee called posse S a tee —ottisee canter free Grammas (CFG) gsid=€ Total_=sub!+sub2x2] © €-> €4€] ere] jd |nom on g 1d fee Uy, cf Ws a ] } Ii Gontato) is w | Totol eta thd sob’ ce i < s ' ‘ 3 | if weiSubly ou Sonn svb) yi syntax free Se Panse tree [sitet of] SE the ponse tree, ‘on ~SE TTT oe a Pe 4) Surmante Analy+ of the syManoHe shruchw —S:Tt verifies the symanhes component af symantic anally sis shich checks the type of Mhe ccording to \anquage one of the important \s called type_chectey, .u Operands for an openalor a specific abon. C—5 Gee, [if eitype + Ex type then error] Gets details oF Crand €, Grom syrnboltable (1f @\ type Flood and es type=intege” then © type-tt CrP e.type= int and 4) type Float then Crkype= Flood] (Rased ov ® vequireme nts) COCCCECECEECECCEC ECE sub? 1 Flood @ Intemmediote code Generaten — > (nener ates the intermediate yepresentahion of the comce program, mosh of the compilers considers three address code (TAc) as their intermediate ve presentation phtch is o stokement contains otmost s memory teferen ees a-bic 53" t arbre L per tye Float) GUGULEEUE ojo =! i, esubr et fartotal= subly yelwn <=> 0 3 oblate subzx26) Code Optimization + OpHonal phose {n Compilation process. I+ performs some program thanstarmah'ons such thal executable tong et cade will take less hme j eur b= sobs * Floatts) from befne eromple) | total >sub\ +h_ l om befye ecrample @ Ae Bto =SAsB As AX¥L— A -A<<1 © Code Generation > Tt ts the Final phase of compiles generates the tome assembly language code. Prev— Re sub’ mov: Nersbb2 \ noe—~subr “ROY MIF Qa) 20 No Not O reel movF 24, svbt Qy —-svb ADPF = No Ry Roe No +R, stove Total;Qo — Totake—Ro Addi Hono) phases Symbol table: Tt is a data structure used to slave information about all idenh'fiers. , errot_btandlen- At any phase an error may occu. ond it us the responst bility of error handlen to collect the info about the erray ond continue the compilahon to collect some more. errors iFany ard yeport to the preg yormes) te moke debe gqing cosy, ns ees | g e \ Reeeemene Eee wh5 => Jenical Analysis tscorre”) Gi &> toto oe. , qo! J |= sub] 4 sob 1425 speciol: sy a> Bee SAT a: op const , 1 rau cb Ba , find ieemornben o} token. shite Ui>!o) ies int maind? rs 5 Aided . a> peate® iter aad Ww Aue 7as wars tN? 5 id printhita s7rd", al? ni Tt Irmessag & aC BTS © unite gg 8 Fas lege? 3 are7 sto @ which of the Following will be considered as a token ot charoater without Looking into next Imp int Gr [Ox | Ou Oren as intol +4 Fale y (3) whidk of » the following Fan We. iden ktcedosenteeen without depending on new while compile caeea @ Program © begin [@e>| @ none Piogrammer begines extoo! (Plex, FPlex) leno fi Ler} —plttis a tool as @ comman >The input specific atfoy to the levtool Janguoge: and the tool is called ter compiler, eT UU UU LLL Lad to design the lerica) analyser ik is aval lable g inthe unik opetoting system is called lex ub VLEA ler program has 3 secHan s- 0 dedarohion WY _sftransition sable] ® Transtah'on roles yy ® Aovxillosy procedure wnclod e 2etype:h> Jey Jleronpiten |= hei y'e pte + toy allyve of rp LUT) te aceat J. (lenteo! {OE stoverPUP), ana ys) AOR “source s[acoot } > sequence stove PULP) program of tevers { > The ovt of ler compiler ts vepre sentakion of tansiton dia vequlost expression along a ler yyee whichis a tabul wom constructed For the with some standand procedures Photuse the table to recognise the token. Binhen leruy-c ten Yhrough an ovtpet File aout which ts a rakes an in of totem lexical Cnt () Unites minoked comments /k — a ¢ compiles it generates exteal analyser and it pot a souyee program and outpots a sequence ja &)— th ths nat presedh , “J enupre sso ne & QO. von oe 8 98909 wa nmeeweeweeuwitr wel pet DD 9) 00.0000 ee ee ee ee es es es CifET en ® Nested moments, f&; —I 1} eal Ldentified bY PPA cognised: idenhfien (32 choract ns- but jam-not good cannot be re © Length of the longest ems maK) int oll- etodents — are- gocd- homo} @twvalid Tdentficn- ‘at sum@amovnt K int -salasy @sr00} * x © Invalid constant Int cals 28.00% jnt a= S000 wupees; @LUlegal Symbols int sal = ¥SOOO; Goi =) noascii value ts sed. Grror Reco! in lexical Analyse? (not recommend ed) nsevth Enserhing missing chavactens- [t—---- A*/ => insert this os compiler donlt enow w 40 ud Qelete+ Delete extra chovacters. end, commen) int surnO@saloory} Lodelete. Le) lace ia Se any sum salosy} > int sum —slodosyy ; 9 odgacewr charactery (notre commend eeu e Ube bb bb bd ddddddddd Tronspaser swap be /* jok ist month © jnt sitmonth; ¥] iter@ Syntax Analysis eo: Programming long will have set of rules to deface Syntan of Pr0q lang. >The cuntax of pL is deFined vsing a gramman colled content free qramman CEG A grammes G&-CviP3) is said to be a cfg, jf all the produchions in 'P are of the form AS where A is single Nonterminal ond ou (vot $4.5 ») \ Vee g §—>Aakb ve {sar} A->alb T-dabd} ote by B= dle pe Z classification of CPt 5 j_—— E q Bosed on No'of derivations e Dased_on no of stings a co v | Un ambiquovs Aro biquous C ay Qecursive. Non recursieg— ~ left vecursive Grenerol , ve cursive recursive RervoHtan: Tr provides a mean of generating a sentence of a Lanquege- é€ d yr e—> e+éli inpor tdxtd los —5e+é ees wy aif id+é Je a idatd Pansetree,a — » Sa d > At ead elep in devivolion we need to make two decision v @ Which AIF to be te placed first shich produchion tule to be ® for the selected NT o applied omanq available alternatives that leads to suceessfol derivation dypes af Devivalion | left most -Devivadion + each step the left most NT ts replon All the topdown parsers oses Left mast Derivation Right most Devi otion + each step the Right most NT is replace AU the bottom up pastses uses the Rigls most derivation a Pky *\ e\e vet e\eue Seo ny in revense. Gu- € 5 e+e] exelid ld+ids id Loup gmp Q @a5e+e ea ee: ce id+e e+ Ehid ¢ oe idte#e | es eterid 3 e-sidtid4e fe— evidtid e-sidsidaid le— id vid # td am\big UOUL ; ol Fs More thon ne Linp.or RMD ther tts called ambiguous =. Testing ambiguity of CFG is ondecidable problem (-e thaw ix no algorithm to verify the ambiquily oF cP Gh. if Lett mosh and Right most in Rts if same as tis of rhe produclio” uch produchion ts said to be ambiguous production ond grammosr is am biquous. id es i yes am biquous. Al ae. i954594444. ® Es erelleye) id which ho» mae than one pam a @ ia bauer © (iastia tied) +44 pare | tid alliae id aid) # i) © © o id = = on « £ cee ” = P- "A a Ca S S —n a E fet ik etl Sel oh oh ek aa 9 ll i ee = > oor 5 a = — mn + —1 a—n a x yi er = id Wr ri ae i id ly > While drawing parse tee if there ave Ho possipy \iHa make another oe Grate -2007 eS fers ia : yi & Shea ee w b hh, - b ie’ se) i SS i ay a 8 A sal 1 clDy >No algosithn enist for converting ambiquovs to unamb| = by using trail and error we can change some > > By reclefining the precedence and associotivily of the fp CRerctors some of ambiquous can be carverted to mamb MP St is not possible to convert an ambiguous granmay into onaeobiqu ous then they are colled inheren} ambiq converting Ambig vovs Gnaromos into_ unambiguous Zalsies We 4tol Gramma osin vecedence and associatur ty of Oss Os : operators @é-« Fe | ea ee | pal id id woe id id i hides id 4 Ud aia) a * Seas + Is right asso siative re (ss) following ambiguous fo. unambiguous based GEUEbbbbEEE fal e — > Convert the ” fs fl erelid Asspmphons ida*s + is left € ANG 4 ts Right iN EDR ais leftassosiahive: FB ey e— Ee +F it fo La ais left asses lahve. id SOAR #is vig associah ve.“id4id xid \ . i AS Rased o| ve N * | Wis ie. \ nn assumption Xs id G only Guaph passible © e— erele-el exe| etelid AssumpHons idahe (Ge =) ea Gal 5 me, ) Left e 3e+e=> epee pe, fig Cee eae eel e fi fo fF a FF GQ) Gr a3 aN => 5 weal ‘ye id: © Wrete precedence and asso ciaHvity, a A@sIs @cb-He reid poedelotale — @-teft el C= cto] e 4 = Right pone ae aiid 4h = left > Chg based on, Nowt Strings Non Reagisive Grammoy s Generate, Finite no of sentences ex g-5AalBd a ~ abldle sbings= | do,a,ed, Fd} Rel -) ave rigls asso clave CV oD ok od oO DoD OR a® Recwsive Grammasi Generates infinite no of sentences F ed GM Ys salb (left recursive) l=] b, ba, baa, baaa, ~~ - J |ba"lazo| ex geaglb (Right recursive) tc | balboa -- ~ + ~}e[ab/ nol a Fabbjdlsreneral yecurvie) Le] dyallbjaadbhe- ~~} > Jona” |nvo} Ew S56 eel Cambiguous) ' L={ bob, pabab, - ~~ Modifying Gr aronen. > bach parsing method can aceept only certain class of Gromman, IF the grammar ls pot suitable for the a porsing “method chosen then -modt Fy the Gwammos7 to make it suitable , ber I left recursion + pA lp 2 bbddddddddddddd bbb > A \eft recursive production of the form A—>A=)A and we can eliminate left recesion by rewriting the Aza ' ey QoAXxe a lg A ARR production rule, as | os ee Be 1 \ As e«ale nee© Clirninate leh recursion from Follawing ; 2 coe) ase é Torele esarele tT VF © , ele age ST tPaP fl Tsar lle ama te ar of fo id y-eFT a | | i plo feTlls [ op ® A> Aalabld a Teer nama SANE oth A>da'|da le Asana |e | [halaale-- I]t laine ee @ s—ssablsodleflqlh A> BAIL BAL = ~~ |p) a pls emille Sl - ss ef'|qs'|hel 1 ee ss abst |cds!] € - Bn bolP Soha-shao indirect le} recurs ian Wy 2 moraarel ‘ aces Roe eliminode, — s-3Aalb | A> Ac]Aad | bale convert Indirect to direct 6 ba] 1 ond then remove lePtre cursion aa eA Aa celloda'le A— Actsdle &— Aalb Left Factoring: ‘ concept of isolating the common park of wo productions Into a single production jte any produchon of the farm A—s eR lens] <8, ~~ Jac, can be replaced with) A—
Q)1R,|8,| — —~ ~ IB, Meenas~ Er ssa > A> bBI bc. F m~ Boa Atsba mn ce alone e 7} 2 ypu bea [for removing ambigul'd . DN @ s— tetSe s|iets}o im ON e¢—b / sa ietsstla ‘a! P \ siseSle 5 逗-b e cea OA sab AledAlabtla i aa non r onewoy a hia € ; [ =a bA oa ae => Final answer pAl—> bA le S a ol a Ponsing E4 ce OSI CSO Pik pep which tates an Ynpot sentence w and construth a posse tree if well&) oby it qenerades an enor message. weL(G) E Parse vee 4Lle) enor T roaches, Lore oe ; WUUGELULEEEL ve Rottomup Fopdown : r @ Bute force method © shiftreduce ‘ @® ce @ Recursive descent porcey tro) @ Predictive postser inet Luc) eer (Ley) eS @Dopenotey precedence.‘Te wisine eg lopdown posing CE Tt conshucts a parse tree stavting from root (stosdtry (yf Ve non termino]) and expand it towards the leafs input senteny \! uv . & s—scAd é ! A—ab)b é !! inpet cbd KS © ® Os Reo a ¥ ‘ | & Ee: g oll ® Brvteforce method ofl See ae topdown povsen with backhacking ckd $3 : oo be gs @ ae | - = Ty CER, AN ! Mn om ND ft a 1 so bact hae! same asexpec so accept} cabb 4+cbd | [Generabedk ts le nin Nae rs Advontog®? Easy to implement Dis advantages Time consoming because of é Racle tracking on a er TRV RSi ————— 3). Predictive [ Wedictive Ry sen Tt ts a tabvlay representation of recursive decent % BRB eho stack inpet . Acton 4 4 Accept c o Y g Ge y gy G 7, Ge oe G , > termi termi por $ NT ly poplis » Pesh Rus in reverse olw enc nit v stack topo! constuction of predichve posse table ts based on two Funchors called Fst and Follow 2 FirstSet fivstCe) be the set of terminals thab can be Y devived vsing &) sey — —--e/n whew X1GWVUT) them Ifeoy is es — visg feyminal then Prrst€¥) = 4 .e— i iw X% is non terminal then [Fish (0 = Fiske] = ast (es) has € then Firstl®) = Hirst (4)¢d Dy first (xi) contains & Soy od ici ton when x oo. farlo=e) i follow . @ s—saAlAs gs ae; bie 2 ae 6 Amable A e,€)b * ee i) Rel Z Wy Se Ro 5 Aa bdia soy le Pe Aace fm Boule : Pade eae O PP@ s—ietssla_ tra 3S ___ sie] ene eS Ss he ea 2 b € @ sah a $b q>ecld dee anbito posble eo. Aenlars c—Aale eda arsib Follow set} Followla) for NT to be the setof terminals that Can appeos tinme dicdely to the right ofA ef some step of derivation Ax S[k ids4 2 Aree | followl) = f Iowa) Follow = First if first (8) contains e) then Follow(6)= follenta)0 Et Ptedictive Raise table constuction 3 ® TF Ase is a production then odd A—™ to “ua! @ TF Airskt<) contains € then add A Kx to conshuc} a predic Hive posise table for the Following Ro Sh ie 508 b ] FistCoSb) atc belie Saree 5 [ab[s=e[se] GSR inpt ale , i ane) AcHoo stack \ope’ LeER > 4¢ abs ; = ab4 Pe Ae BERL UARRAREBARUATY $bsa - $b b+ e—>¢ ba | - 4b bt ae Por eee | = 4 ce Dat ecepted y = a @ine Bolte? aane ae "Pollo wlA)= Fivst(B) = be, 4 sacle ‘pot Acton LAA-AMMMIADEOOKRIOOE OS COE SCE ES see 4s ed s— AB $A et AS€ | oa dys 3 Accepted Je yanre | gS staclt input Actos : 5 A ee iy» b4 re | ar] | ba bob é b poP A cere ” rete not suitable For predict sh porser as it bay mulhpe poBa AZea ie Zelen's At & gee go ane B nmRaA—e plededededededndedidided'did Demos A nok : oy eo: rol as \F\Sble af : 7 fee ¥ Qe (ey ® 3 oa a a , z e | 3 | q I> 0 |« A> bAaladls cg 4 . Qa b d ‘ Pa ec A Taob ie ja ond ; - = Ree | Road] AE Ae ‘og e i : ee = « ® s sierss'la - Ae e Sle a ; - pan sf S soletss ‘ = q a —_ |, multiples! z - ervor = 3 c = ¢ Q) Girommor Reeernon eateblelnes bs . any symbol! predictive posse? c- 5 Lookaheo 3 ie _ ~ lef} most dervivodton ‘a Tkkoda 0, bid Firs) ny eer hovigh can nm chusthey ec moody s row 0 s—paslbsld SLU AA a hie “lo Veey verey columns ki ‘velthay so fable Lo multiple euhies vondow kaaloli Lig)- ee pet Yas ee SabSladsle iLkada 3 productions No First teymino) a,ae rendu same vonng _ =. co sona entry lo two enties vosthay vabath Ltt) qranomoy owadho odhey at aHme two terminals ni scan che sthey no mo tiple entbies so odhi LUL2) ave thundhi dd Propenties of LUC) Ga mmos >No moltple defined entries in poxsing table. No left recursive graman, con be Wty LLt) rddedidided'd a> Ne ambiguous qiormman can be >A Grommet 's.LUt!) iF for every production is of the fom A—S6 iF the Following condition are met @® Fivstle\a FirstWY=p @ First(@) hase then first@-<)a Follow (A) A Sw s—ietssla tifofay-s ds esle felofet} =le}—> rot uty +6 oO Lafoltowts) \ o 6a AIA Ja} athh =p A blé sha ish “| Le) poodle tal ash bv— SS SA. “Ss08|abs Bhat Lucy : ! . $= Sald Beenor ltl) Lert ve curswe ss Sa8]d => nat LL) ambiquovs Re ‘Free from le Pt 2019 —> Aa ee, follow(t) p> BP tl eoble ED podleie: Bottom Up Passing sit, constructs _& parse tree stonting from leaves Cinpet) ard vedueing ** te the stonting WT (toot) ene sS—>aAcBe a> Ablb qeduction PaNSSt os fete. input _abbede pans poabcded A—>Ab 4 ahcde4 hod yanebed g—pahcBe al ae accepted a OOODOCC.e.c.ce cee cee: nnnnnneeWordle». ge of 0 prodyction in some derivahion dap is called Newelle Replacing Handle vith ih, LHs ss called Mangle pruning > Gack the process of veduc ing on input sertenr « to he lanting Mr is called yeduchon. Noles Ait the bottom up paisey uses M.D 10 veVertse arden ’ @ Shift yeduce por sen > An EF Froient woy of Implementing 40 porte js Sou a stock to hold Qrarman symbole and input boffer te bold PIR cekianss. ac meek 1 intially 4 wt J @ Shie¢+--——— —) Push ilp ® Reduce H-4)—> Pop Mis: pushLls @) Acept-————> if stock is $s 4 ond input ie4 ® ev0r ———> onsoccessful poise €—564¢ \exclid stock inp ction 4 id+idxid$ shift tid tidtid¢ [eid] ke aideid $ posh hex {did posh qed rid here wid} [@seael‘$ id posh ferid 4 pestd $eve 4 (e>erd ~e 4 Accept — > sf porsen possible for come of ambiquovs gramm @® Cc .esplexn|n : which of Following are handle while posising Nina 4 nanan £6 anxnd 4eé anxens (GD -*vY ae xnt 4D aLe¥) Pavser __s ¥ look ahead symbol . __—s vid most devivation in yeveruc _—> \ef4 +0 right scanning LR-fomily . Lato) estRh) eLaLna < Le cir on ayenbiquors pt\ ere0) LALTO) canes — Every UL) ie LR) Grammean bot LR need notbe tity to) is st ety) Bot every sir t) Need not be wed) > Svevy Wh tet) need not be si rv) > eveny SURO) ts Laney Qt evey Lb > every LAL) t's LAO) bot every ERE) need not be Lares’ SS vou tty ts Lert) but every URW need not be ett) > evoy Lew ts enambiquons —> Among all Lt ponser iy 10 Fomily L&C ts more powerFut as ttaccept mae lass of gia mman.URW) ponsen stuchre vols anc assump tion, stock © inital stode. oo = ol ¢ « > v 4 achoy action ¥ 3 Z = 2) Reduce ¥ 8 ® accept $ 8 @ enor a 5 e 3 @ e e @ @ a e © C In Hal _ cont uRoh'on t shitt — posh inpotand Piatel es § ioe Sao Neduce: pop~ push A ¢ io os Are pus Groto ena at ssa oth; ‘a A— be From ie © na ; : ‘ ‘ ten ‘ Lnco) ° ¢ : . rena) ‘ SLM) : ; Leu) ae, ’ { SNe UL _ uses Lilo) itemy ise LOL) itemy———————————————rrttttss—‘“sSCCS LQlo) Hem ae here + An LN) jem, of the form A sf wher ot come posihon in RUS ee A —> Lye Genevals 4 a A—- rye 5 How Fon Passing is dane Pal hot to e*Pect ae M Yq x t and. w ese B= hye | A— Wy. ee derived. alyeady done OLS =P ees ' , mal Generates only, J | —>-3 one item : Bi ~ Sdeavolion campleted ait A se | Finding LRo) posisen state dddeaeededren nda) @ Agument the gramman with prodockon sis stonting Non terminal. J started | end, i . ‘ iS ® Finding the peer items. tem of Porm sade is {in state T and B57 is aproduchon then add p—s-2 fo state Ll itis nob i Pena one closwe colled one slote.a ) Rind Goto Move dot (.) ane positon right and Pind its closure 3 | se z > be o oF ae a veal He yo se 6 Rid Re all Lite) poansen table © Fill the shift entries jf there ts & bransiton wrt terminals. @ Fill goto eoties IF there tsa transiHon wr NT> © Endstohe wrt $ C5) is alway accep @ stoke, which eontaiy tems, with. at the end are onsidened for yeduce. acHon on ald input peer a — inet \ NAS \ BERR EREDAR ELMAR RED a oe © 6 S.6, . Let al el ol el EL wed WS WE. VS Ve aeons Depp ern yide sla NUUNUALALeL Uadelndeldededdadedededed ddd dW vv Shook input 40 Abol + Lofyl bd 4 eae eb tozbg 44 Ens ae po Pel i 4o@kS Ve @ “GYAN the ondefined enti ave considere db oy ean agi tae D acho? a cam s4 pop 4: reduchon : | S6 | A>Ob sy Rd SSA accept (o iS mol ‘ple ayCece ee eeecee v chifl > Reduce mulb'ple ents ~ RRconfiict Nedvee Yeduce contre stobes=t ., sof con Hicking ehigg= y {lo PonsenclonFicts + o shiftled vce, : @ Reduce Reduce @ No: of conf lictstod4 eDAT a O- , e—-T FF € T: >| a Seat £ else Be cote pea ‘ae Mame Comet aa noes a 4 THF Ne et A ak ee of.
% Reduce A~ 10h) table For oe Lato) exept thol of Fillig in ctote I thenb Se g o $—5AoaAb S+RbRa od. Follow) + b fad pallevsta) 2018 = EI] |e ae | =n Sade Follow) = hc Ad.) Follow (s)= 4 Df he PPPPPVDD PRIDDIS re ea d ‘G not stanu) 7 ® > anothen —sd. in Rallow tal sa. molhple entries, @ s—faacd bbb sea st aadd)bbb ¢>aasBh aoosbbb sg KaaskRd acas Bb b ¢ 9 aaad RRR oof bb | , 4 ieee ns aasBb © as Peer Js Lik ash ss aaadbbh s @@ \ 5.86 C5 S—s -S#cs 5 esa s— s+ < S> s@
*-Bia where An Lay them Aas vn is an LR Co) item and he second cormpanent is a look ahead symbol: carne as Lfto) stotes except cet (states) i.e if Pose ‘Bd then add Finding LQ) stoles is that of Finding the closwe ; is in stote T ond RY tsa produchon Rs -2, Husk (Ro) tor IF its not atready be € \ 4 6leles et atc! cea x bb tdbd dd ddddddddddd dd A—saA-lalb a4) CLAW LR posus iy conshucHon of LRU) parser is. same as that of SLR) parser ercept thak af Filing the reduced enbie, fe A—s%.ja Is in state T then set ‘ochon (110) = a (11a) = Reduce (A J e > Fill the reduces only in the Loot ahead terminals URW) table _conshruction Se ceecceecees PLT aTananannea eee Ss s mm | edegegesdddeeon ea sk/ i , [sess mal ey ele sO Saga Sis hi sos bs; | s—y-dit ; TERS oe — sop oes 0 Eber 2 08, [¢ so -bs,t WV sods ft only vedvceheve No multiple _ enhia so rae | @ s-saa S—5bhe SS bBc Aad md z E Ad-1¢ + Red.;c RReanf lich J ROT LAL) B potgetting oma XD \qnove , i ® s—=Aa mi , ie F ce Ad. Seek. Bee ~~ | nd ofa Roda shift reduce WU UL TT Led edd ddd dd,| : LALRLA) Look Ahead LAY = To get LALRU) potser'slaks we ose Lou) states by merging the Led) Ee thot have SAMS Cad and tave the onion of they Lookaheod syrn Pols {f state I 20 pe | ti iv [ames tuasnt ast) Previous LAu) example. ye saMEe m gq are } eretCnonnsts lootaheads and combine © Ver ee a ee sane lca them and mombest the stota accandin gly. sD AA A>0A + Aes } (saseut &) 7 ore same AS (Ral. alblty A=-a8,albls Ab, albl¢frat any, ew J s—>-bAc4 ss Bat ss. bBa ch Amdo not LaLely) 5 Ne st conflict in LUC) slotes \eflected in LALLY) bot merging teu) tt will never be stoke WntolAn may yesolt VR conflrct er not se conf lve. LALTU) are same which ts tess or equal to Pec euy Een Geemt tL LALO Gals LN) 10 3 = Among all La parse Laty is moe porsenfol as tb peer eee ebhee err eree er rere | : " accepts More clon of grammerThe parser generator tool! Yace * gh ‘ j
Falla wiy f @(Sea are ' i oe S$. SS4, $]r]4 eee so sek gilt so, $44 Qpenotr Presedence Pansen Tt is an @fPectve SR parser to idenHfy the handles by aling 7 the « ae eens relodions ble poly 1 DPADSAESSE4S4K ECS of terminals. é s ae the precedence relabions ate 4,=/> tA Precedence Meaning ‘ ; oT nels a qives precedence tob ; oy a-b o has same precedence as b FT asb " ataves precedence over'b 3 I peakbecHd>$ ge| = a3 vk ind beg . ~~ aa begin ~ ‘a —~7 We c First on havdle. _ io ‘ c IE > tes re lotion purpose is te ilenbity bang a - with 2 left anol = at interay of- handle and greate oe thon appeoss at end of hondle.acc epts only some : ‘ on ee bY -5 An op etoloy precedence qyari ae se class of grammas called an operator Givaro Vico alas a Noll Ree grammes: and Fos o property Ce fro eo. sible far some s—sex not ollowed. a i us s_sap % nd allowed. ombigva a5 AaB S—> faa Bu li er Sab —> Consthoct an operator precedence pasise table Fay following ambi quous based on precedence ard associahy | — 3 es ids #5 ‘ : } ! ¥ and tareleft associahive accom plion } 4 ered EERE me a = : 4} accept e a 2 faccept : | 7 | AN, G yr ydotid x id 4 tdareidskald ot eid IN 1 e+ gids ez AReunnemeauaneaenoonaneany, ‘dod ' 4 id > 7 ga re tdatdda$ eid l } 4e As wHidot$ i@—> e+ ia) id eida — Precedence ‘relabions is based o7 1° me called Lead and ‘Toil: ———< O Asan then Lead(a) =a -O Boe aGheve.o lis single NT then lead (A)=0 © A-s pe then teodcad= lead (B) lead fois = S—aAbB A>dB A ae See ne e C+>fq B Va Ve\e Velo oo -_ Trail Seb @ Asa nailla)=0 @ A>xKe — tail(a)+ hail Ca) G A—swoB railed) =Sv braille) aid computing Precedence RelaHion _ * £4 gto) _stwo terminals adgaced in RUS of a production then the Relotton blw the two terminals ou equal. => th oubermingls mowe seperated with single NT the eee en ’ Beeeeen aa telakion bly terminely is equal, <5 Teo terminal followad NT: then o terminol ¢ lead Ca} : le) ond — hail Ca) s next terminal, oA acteadtAy, Ne pet | mata) > b i b ANT ' os ON 1—————————— —S 4 is lessen wilh lead ts) and | haills) > + where Siisa stonting WT G+ ay sconshuct’ openador precedence ponse lable a chead (a) ach a taille) se => cod fd dd dd Ss afd aed As be bet ae S73) Pian construct porse bree From above toble. inpot= abed 7 yap deashecod=* mid wi $¢oAdad s-sand tye 4 \ss 1 “YA accep! f pie 3 1 Ryalleye* Gaigat — os) _syntar Directed Translation —svsed to associate symantic infermeHon with gramman, pI0d echon- > Two notoh on) , @ Syntax directed definition (spp) . ® Nonslohon scheme. Sqnhow ditected definihion— tris an agumente d erg, iy ochLh Ue ea i —— 2 Yo bic @ on mman production" is dissocioted | with cot of ah vs 7 ond the grarmmast symbols! are associated ces a = a? athibote, (synthesized and inberited ath itl) if Sunthesized athibute f i ie value ata parse, hee, ode i deta A Interms of childrens of that node. _ A Production symontic whe: shy A e—> CAT, Jevalue eqvaluesT
eb 4T C-term =r term|) t.term | /+ be e-term > €-term]t 1 -berml] — Sy €-sT CLerm ehetetin / S I {—Num S aa _ tnum =num a I ioe a—t2 ca aI e. berm ie I asin! al Sienna ; post hin. al a . above grammar writen to aia L sterm convert to post hx at | ~ ! co «l cel| i Y " ee (SN, 0 porse thee showing athibute valuy ot each node Te, i: called avno) jonse Hee iy aN label pet ae sf Loot g ale. cleo ; Vw (= 160] wes 12 G4 Qui lo ’ as as /\ f 5&2) ures 6 4 - ; Ths aeaannee pL | | num we 2 = 2O22_gole. 200% gote. A gid: =& : gid side a 4ew e 5! " ex ie gid €14 id ie i 1 f se s-a ids
Bc 1A eRracrf Aid rope @ . 7 hoa) Rs ak t defined interms => Cory sathibuted definition bot need nob vice versa. whe jac AAtONy a of childiens athibuted definition Vsi_L @ none Pege Res @® A—B-e for arabs L_ottribute ac Gate ror f->pa A-—>*Y ye L ol. lol [ues & ele) bh > rol ps, spo ee ] ? zhr & pie * Tatton) 7 nf Pre ° iP Pr t 1 a| aititast 4 fh ASASSA a Translation Scheme BORUNVENS Bp Where the (orderoh ii ISMimplicit fo; shen symantic action to be ae is specified by including it Bos. Phe mist o Insevting it with in RNS SF ‘production A, “4 A— 5 4njprinb¥fo + cosy understand | meee eapel: A A + Rorintes) < S—sT ft i qrs4r nar terion rhe le T—5 num } print nv m} num [privtoow) Be “Tprint +) a cae \\ = a or ' S ‘ eg prin tea) ery 5 | asa ut | nom (print aim) © fom print 1 ; ae 1 1 a.pasmiclls Ab © AN 7 4 veri ca =S —————————————————————— Code optimizelton Types of otimizotion code! machine independent code opti a code by consHe intermediate Performed on thout considering the _ ving the proqramiyy Lanquoge Features. 0! Propretia of Tang eb madkint: Modine depended Performed on tonget cots by considering e machine propsis such 03 In struch'on format, addresiy modes ard Tnsboction, set te. , ri \ 1a eo. ontengt ee wre = seg code an “ generation 7 wledependest Scope _of optimization J ce optimization is pe by considering the solemets of only locol optimization SLF opt mi zotton performed on a basic block by consid exing the stotemeuks of athen blocks colled qlobol ophimizohton go bol scope. Rasic Block es , Group ot consequi'Hve stotemeuds where the codnk ed ay ob begininy and leaves only ob the end withoot the hakk av Branch statement crept of the end bdddddddddddddddd: farmed on @ asic block that block. i called so noha basic Block. A WU bdbdddddddddd Rasic block ”—— Q es : 6 nodes 4- Basic lack. a 6 edges Ri— & Bids R,—> 8B, Br =o Baa By conbol Flow I ick Plow qraph Procedure to Mind Rasic_ Rlocle PLLLLLA ADL AISI L ALA KAA A
You might also like
Compiler Design
PDF
75% (8)
Compiler Design
262 pages
Compiler Design
PDF
100% (1)
Compiler Design
104 pages
Compiler Design Unit 1 Notes
PDF
No ratings yet
Compiler Design Unit 1 Notes
49 pages
CD
PDF
No ratings yet
CD
238 pages
cD
PDF
No ratings yet
cD
30 pages
Unit 1CD
PDF
No ratings yet
Unit 1CD
47 pages
Introduction To Compiling
PDF
100% (1)
Introduction To Compiling
26 pages
CD Unit-I
PDF
No ratings yet
CD Unit-I
42 pages
Compiler Design - YesDee(1)
PDF
No ratings yet
Compiler Design - YesDee(1)
427 pages
Compiler Design
PDF
No ratings yet
Compiler Design
34 pages
Compiler Design Assignment 1
PDF
No ratings yet
Compiler Design Assignment 1
13 pages
Compiler Design
PDF
No ratings yet
Compiler Design
89 pages
CD DSTC Notes
PDF
No ratings yet
CD DSTC Notes
35 pages
Unit-1-Part-2
PDF
No ratings yet
Unit-1-Part-2
6 pages
Compiler Designassignment
PDF
No ratings yet
Compiler Designassignment
15 pages
Compiler Design
PDF
No ratings yet
Compiler Design
27 pages
CD Notes
PDF
No ratings yet
CD Notes
20 pages
Introduction To Compilation
PDF
No ratings yet
Introduction To Compilation
33 pages
Compiler Design
PDF
No ratings yet
Compiler Design
48 pages
ATCD Assignment 3
PDF
No ratings yet
ATCD Assignment 3
18 pages
Compiler Design
PDF
No ratings yet
Compiler Design
19 pages
1BTCO602_Syllabuspdf__2025_01_17_08_58_02
PDF
No ratings yet
1BTCO602_Syllabuspdf__2025_01_17_08_58_02
3 pages
Pdfcoffee.com Compiler Design 2 PDF Free
PDF
No ratings yet
Pdfcoffee.com Compiler Design 2 PDF Free
262 pages
Compiler Design
PDF
No ratings yet
Compiler Design
121 pages
CD Decode
PDF
100% (1)
CD Decode
169 pages
Overview of Compiler
PDF
No ratings yet
Overview of Compiler
56 pages
CD Unit-1 Imp Question & Answers
PDF
No ratings yet
CD Unit-1 Imp Question & Answers
10 pages
Compiler - Analysis Phase
PDF
No ratings yet
Compiler - Analysis Phase
5 pages
Compiler 1
PDF
No ratings yet
Compiler 1
5 pages
CS1352 May07
PDF
No ratings yet
CS1352 May07
19 pages
Demonstrate the Phases of a Compiler With Example
PDF
No ratings yet
Demonstrate the Phases of a Compiler With Example
16 pages
cd unit 1
PDF
No ratings yet
cd unit 1
63 pages
Chapter One-Introduction
PDF
No ratings yet
Chapter One-Introduction
6 pages
Compiler Design Slide Chapter 1-6
PDF
No ratings yet
Compiler Design Slide Chapter 1-6
250 pages
Compiler Construction i Csc310 1719310228
PDF
No ratings yet
Compiler Construction i Csc310 1719310228
112 pages
2-Introduction to Compilation and Lexical Analysis-19!07!2024
PDF
No ratings yet
2-Introduction to Compilation and Lexical Analysis-19!07!2024
135 pages
CD Model Set - 2 Answer Key
PDF
No ratings yet
CD Model Set - 2 Answer Key
20 pages
Compiler Design Quantum
PDF
100% (1)
Compiler Design Quantum
89 pages
Tranlsation Software
PDF
No ratings yet
Tranlsation Software
15 pages
Compiler Design_ 2-Mark and 16-Mark Answers (1)
PDF
No ratings yet
Compiler Design_ 2-Mark and 16-Mark Answers (1)
19 pages
1-Structure and Phases of a Compiler-19!07!2024 (1)
PDF
No ratings yet
1-Structure and Phases of a Compiler-19!07!2024 (1)
99 pages
CD Unit 1
PDF
No ratings yet
CD Unit 1
23 pages
Compiler Key2
PDF
No ratings yet
Compiler Key2
18 pages
Compiler Unit1
PDF
No ratings yet
Compiler Unit1
48 pages
Chapter 1 - Introduction To Comp
PDF
No ratings yet
Chapter 1 - Introduction To Comp
27 pages
Compiler Book Note
PDF
No ratings yet
Compiler Book Note
68 pages
Compiler Design KCS5
PDF
No ratings yet
Compiler Design KCS5
10 pages
System Software Notes
PDF
No ratings yet
System Software Notes
81 pages
Compiler Design
PDF
No ratings yet
Compiler Design
19 pages
6th Sem Cs CD Ct1 11 Solution
PDF
No ratings yet
6th Sem Cs CD Ct1 11 Solution
20 pages
LPUNIT1 ppt1
PDF
No ratings yet
LPUNIT1 ppt1
41 pages
1_Introduction to Compiler
PDF
No ratings yet
1_Introduction to Compiler
26 pages
PCD Notes - Unit - 1
PDF
No ratings yet
PCD Notes - Unit - 1
15 pages
Compiler Desining Complete Notes
PDF
No ratings yet
Compiler Desining Complete Notes
175 pages
Compiler Design Note
PDF
No ratings yet
Compiler Design Note
313 pages
Unit-1,2
PDF
No ratings yet
Unit-1,2
33 pages
Lecture 1,2 Introduction
PDF
No ratings yet
Lecture 1,2 Introduction
40 pages
1st Unit CD
PDF
No ratings yet
1st Unit CD
16 pages