0% found this document useful (0 votes)
34 views32 pages

Unit 1st Compiler Desigen

Compiler design unit 1st aktu btech cse for all branches engineering

Uploaded by

universalbhaiya
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
0% found this document useful (0 votes)
34 views32 pages

Unit 1st Compiler Desigen

Compiler design unit 1st aktu btech cse for all branches engineering

Uploaded by

universalbhaiya
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
You are on page 1/ 32
a 5 Recognition of ToKens canine c 2 ononng Outline : : cs Recopnidion Cf Towns ele Oe “Transition Biagoam “BoM he sy Reeaynibon aig redeaved” words AD SdonhPiers — Bxa, gx- ai] .e-. ysl — Avchttecfure F ao Transit ost degen bosed Lecica)) Analysis: ce Min Conelelea na? $elbsing Gmaren "bon fg Bhlomebs: Stk —> If exp -jhem shat | if. ccpr den cht else gi ci : : ehmt Perel ne $2 Apinite tual at 4 { “ eepr S teran delop ters | dermm oy Heme p hid | nucbers oo 1 fe lop We Use dry om pars ony abereders ans Rive sal oo seu, where = b “equals” The Fermiqak of she Brrrnn, whiod Ore, then | “Ele Bebop yd aD numba ‘ane Ine nomex Ond< > 8 “redepua P tokens ay © fore a8 $2 leu'esd onetyzes ds emcemed « ‘Ot Na | ae o i | the Polleong these one desapbed usin 4 rqelor HPiniHons , AL Zhown holon: | Js [0-9] ae ahha Ga Kents —> digs ‘Dumba > gine digits) 9 (eG ~12 aig)? | letter —> La-za-z] Pedy yy then — 4hen Elee > else 1 %hop > 4|>] <2]>=]= )<> Sanaa we > (Slank| 44) nea bine )* we B wide peal | | Bg | Lex: “Leelga) Avoly2er BUmnadzed 6 bel ® | Tete wiih shows, foo each lexeme i) XY Kemer, WhO token name 46 TAU ty ane farrser AND wha) attdbule value ip veburred * Jake LexEMes TOKEN PANES | ArraiguTe Yaues Toke 1 be et |e Perak Ay Leal ottabste, fe \ Moyne Painter te fabts extn} ; | Peinber a9 -fablecdy Jur [re a Sa Name. i REC Class es adlop — Ge Bs ° TRancinion Di4aRay SAL om intermedtile tap 4 tne tonstrocien P Lexica) analyzer, We HPyit eenvesd” Pah Orns Into Alytires) | Flow ehasts , Cothed -trans'Hon chia gear”. 3 A THareltion Aiograms Sane eoveetien oP nects-yr cliche thah Could occur duning. the Process Of. £ canning ty input looking Pow a leceme Ins) medchex ane oP sever) Donde cPattermeen: 6 , ‘ 1 K Slates ate gummadzed cde kom ‘about Miho characters UR have Acen bebdeen 4Iho lecemeBegin pointer and foros Pointer. :] oF Edges ork Aivected, fam one etal OP na -hensikion Aiggsam'o Another * Fath eige.2 leaded ty a egmbel or < er-aP weprrbote- sp we are in dome RIE .s, then the nek thpuh aynbol Ba, we foole Aertend on ‘estge our P ole ¢ Istotlap hep ca - Bp we Fed such om edge, we adwan® Pre forword Printer ad Onis Ihe stale YP (Ts Boo No. Qe Name. Date. Se lass. onsite n chiowgraamn gto won jhe edge lasdlt- = We Shall assume trab ay oul Pransison Afagroms axe determinishg,, eet thal Ihese & Nev ey wore h hom ene 2 ot Pa Biron ele” WR Wish a Bren Symboh omgny a F absee Some thafamtem} conventions olavuh lransision diighrous af one : 4! Certain Kdals owe sod 4 4o be accepting oe Pina) : These. fats fndicete Ink a lexeme os been Pound , akine WY. aehudl bexeme. mage nef Comber eonsis opie aX Powders betmen the lesome Beg | GRD Reowane paintass | } ) { / me abouts uidictt “on aeception Mam bya | e Howe Circle, MOBY therve 2 a da Se tae | “aprotny ‘sotuonl ay ateken Ord om -+thabwta vats te ne, Posen — "we xhall, attagh Ine.achion +p I ot Tee apes ‘Ahi oaaln addition, YU recoueg % vebvag +ne ©” Rorored pointer Boe Prition Cie tre foveme doe, eb 2h clude the “ymbst thor Gorusr +o dre One Bee aehivesy ‘plats “Aron woe. Sheds Aig, | @ Plate ak Tew jhe ea Role, & . Fonte p Ub indicted ty ) Meeled Taqost”, exteniey eProm Nowhere: The “locnisit og, disgyrom, lmays Leal th the stor} Adde befeee, a. top) Apgrbyp: owe been wend + eee fo\rowing Pguse Ba tran Sten Chiexgoam jaf decogmaes jhe tab enalcheng he fokere velop @ebHendd Oparataas ) . re Ken, af al Fee, Eaves 2G) vn (exnpste) > oetuen (deloP, NE) Oromo St) vvetvon Cobp,u7)) (selap, EQ) ; G)reeriee se) | St f CB) ) seu (atop Y Se Class. a Book. No. SS Nane... x | " Recgrining sonk ‘and ish Pian. a Prablen « ‘ | Usatly, Ke aa Ure if os dhen are Peres | pS she ae rot identifa< even shough Ine j , ook Bye. UdentiFes. yp asecns * The Poinaing Piguve shows frangiben isgram _ Ae identifiers ad S coords GerToxenc9, eae) a Tramitien ee AMondiffes, 1 6 vent ® thee ose viol co “that WE. Com handle aeren ed) “wooeds) Hab Lovie Lice tHonbipen : -|nstal) dhe weserved wows jn dhe Ceobe) table indalt 2: Geshe o apna chransthen diomams fox each teoysoerde: an example for dre “Kepword hen’ is shoonhfigur e Sesh, ORO 2502202 OS oe pee ds ani ana ae pa [ je ® Combletion a alia Bronte the’ Hranstion ciagvam Por weihBer foe -teken ~ tum bee Crneignes number) 28, ehe2r”. ‘ Laigited) chee oh ABE > The deonsthon dingren 4 pon ait Pa Ce b Shown deli > wt @ Teensition diego Pos weeepace * Sh eateate efa Tronghon ~Diewgsain- Raxsed resend acetal oe Xx There ave pan a ways shar a cetvecton of tema Biegrams €5c com be Uned to build a ledca) analy 2e, a Repraiza’ pre overabe atwdiqy , exch SOLE S + my = Nim em Class, Sieben aetna + We mou Imogioe a veriable GlE Deldeng rk Dumber O2 curvent, alt Pos 9 WIAD Hon diagrae: | | * Stoucture Of Lex Prapzom | > ComPttch, Rereledioy. tn Lex if | i | | | —> The Lokaherd opeictyr & The. Lexica)- Analyzer Generar Lex | # bec/Flee: A donguage fox Specifying © yeahed Aralpcert: 4 Inplemenle) by lesk and Schmidt 2P Bets Lets Seidiolly Pow Unie « A Nbb only arable qererntor, but alto tear —@ | | Tachens” +5 axoctale with Reguiors Express - | A Lex % wid ey used Za the Unix Grmmuniisg a Produch'on Comp yens- & Len a no} |fficient enough iy Rowen er % Tne inpuk motation for Ine Lex too) 4 veffered | Qs the Lex Ponguage Ond tho took uvelp hing Lets eomprijen + | The Le Compilor Jranslorme the Tapa PaBor | anle teomibon diy ingrown Ong ni Lect yyctTt Geaien ae eect Goeee | SE vane. & Oy Class. Lex comee pam Meek Ain tee COS on tremens} 0 (Comet: 3 sl Be ouy p> Sequencs op Tokens argo a, Weal tees woth Lex, wy net | > An ip giles oo we eal) [exe Q % watlen in Hho Lex banguage and Clesex oe Abe. (ee'cal) ee ne bi ginncted aaa # ThE [eA Crips 1b tna e prey an 0 Bla Mot B snags namech Dee org re * The fsiter fle u compiled by the © ng ars 0 Pile cabted @-04h 05, abioasss - x The C~ Compiler owlpn F bG iovslet Leucal) onal tha Com Jake a... shxcam Rey lop Koraclert ond i Produce x Atsoom Of rotcenk, - Use o Lee - HX Phe Movmal wre 4no Gommpaled a Program + Defpesed to Og a Gua pr above *0 ba Aubbsttonn N of yno Powson ee i rts = Ly cha. Name, KYB ac Punchion -prak vehvens a Inlegen,, whidh | QO code fox ora f tne possible 4oKen Names - Kk The aljeibute value, whether It be arco neas armneai« Code ,O painkr to Ine & enbol table, oF worniegs g Placed in @ gee vaddable yy Oval *> wench v SHovad bdwEH yh Jeokca) analyrer AH foseery Thereby. making y--simple to veturn tapdh Jne 8) « name “Gnd ths aifibde value 8 a token’ | The vy thar appeags in yylval and leryy «© wepers to the Yace Parser- generaker, and which ‘a Commnaly Used va corfugeen with Lex. Strvokine afl Lex. Programs Stavetere Oh : 4 A LK Propeem Das the Following Remy -e| © declarations 1S Pots | bY | Aranslosiena) vues 1 ford (defaltien ep ToKent) mI. Ouixibiary Findione 15233 (methods ov | add fy ore | a defined ) | Me es SEE Nume.. hy clas... Ex planation 2#x The declarddions Sechons includ g declarettiqn “f Vawiaaler, manifest enostants Caenbfi exs declared +p Hong “for a! eanctont, ea Ine name af o Token), and segue AP nihons: In * The dranslaton THB each, doe the rw pavern {hcHenY » Eau. pattern yo wegular efrexinon, WW Ch mony we tne sequllaa cefinidiens oPare declaration Seehen ‘ x The achons are Pragments sie coda, typically, Walen inc, ahhough 7 eens ap Lex unin olher fonguoge dove been : ¢ 3m The thivd cecton duxiliasy Tinch'ons holds Uabever adcl'Hona Tinchens ae wed in she ads ons * . | Averndbively , these fandians com be Compiled suportey on® loaded with (ea'tab omaly ze - Lex Pragaam fos ihe tokens Le Progzom sina) segogMees yn rakers Ahewn beluoe ~d deburs tre toleen fomd LexE ME force n AAME Arernwe Weve gfe) baie atie 2 2 g. ¥ = han nen s E a [* dig cd « 2? kno AS xample + Lex Pragaom ys ani Tolkens * definition, OP manifest eontians LT, LE, Fa NE, Ws 4 delim FF | lees [y-za-z] 5 ee rr pee {lewer’s (4 lever |icp7.) yyoge ( pubeor Lain G4 4p)? ELT fee) Pi 8 = VD Ports bb FeOmslatronel wale (ie Pregrom fer thas pe) be |. £ \|e | Sale | oy qhen | 2 alee loam : 4 [* M0 achen and in g motown */} { retern CIF) 5} £ vetern CHEN) 5 4 freturn (ELE) 5 3 yyleal = Ltn Anstatl my ( d5 return (En) 5 ¢ numb £ yylvals Canty tactal Hum) 5 Detem Cuma ed), | yyha] = LT 5 vet (Revo p) > 1 Ohad 1 reluen (RELOP). 7} é & GT5GE, IF, THEN, Elee, ID, NUMBEE, RULop %/ 3 ®| ¢ ‘- as | /* Fegulae definlsons xf 4 delim. [i \t\n] 9 A Book No... sje @ 28 fag ‘|A ya Jyylud 2G; selernRELnP); J [52% oayglind & se, wetein (Reto#) 9 Coo) fyyvat = EA; setunn (RELOP) 5 Z > syybval = Gr webcam (RELR)S J BY = sranglahion cals - ' > In, 7} i f L5pbo-methodu ay wed -'e Ampstall DO Q inslal (Nu () Ant — {nskaiED C) § oA J % funchon +o inva the Jeromey Whose Pres} Chorvacker Pointed +o by yyted, aid whose f ui _pelengs3arg als he aymboe Labi@ or@ aeliten & PHmder the vedo +/ 4 { an} ansiaWNuw (3 4 [% Simibien Fo install S80, bub puly mumen'Ca) eoncdork mR ow aepoals tabs ©/ ia BOOR NO se The AoMo'y taken When id b malched nreeyol tt -Foneh'on inskall DC) G called to place -Ihe Jeveme Poundiin dhe ymbo) table - a:b This Bmetion aetumns a pointe taint gyre Ashe 5 hich B Placed m glabal vowablo yy? yal, where I Om be use) bby he Paxser, ot @ Labor Component af It Gmp'les - Aoie Phab Inslaid) gg Dou ovelabe ty I--+uo venable that one sd~ of ausdernah Coty ey The lex! Gy Onalyeer hak y Lex, gonnols , 0)) yylext oO psinte do the bexnotey a Ang ecemt , Omoesrosn by lexereaReg ry y ; b) wiley B thy Vena. te AP hexane Poirct - Ze Te token nome TS seturagd tb IH9 faicer-gy @ Conflict Resolutton os Lea. We have Augget to the +00 yale hah Lex usee by delde onthe Preper leeme ty 2eleor, Whey a leriCad 4 nabyser: & At tre foort 4P transition 2 Me Formalism lorem o4 Baste ‘qutomaar These are, essenttal gp gee Qa dransltyy ea) untth Ped ch'fPerence > Finite Automata, — 2. retegnices, ane simply. aay yes” om a abord eo0N poedieInpih stoi snp a Rinile automala comes tr Ho flavor: 4) Nondabermiaisirc Anite auwommda Cra) b) Determinighte Finite aubomala -CaPa) 2 Nondverminhe Fialbe Automata: - CNPA) have no resticHons on the labels +P jheit oe A ymbook Com Donok £everal edger ow Sia, anf & Tw op. ahinge a a Seas label. ‘ @ @ a Beerminishc Findse Sulomakas CDEA fer eoth aha, ond. Far ead sigma Y nth Papi ALphebe Co one ee uwtin A agree |. Aeaning 2 wal Hote Z> Baio DPA. 2 NPA, one Ca hg af vecopnicing | yno same langugrer + : Ky wf In fact nese languages cre. Cnafliz. no coma bang mege | Calted os ioe toparges Anak: rer expisinian | Con be Aeeen'sod Nendotorcinbie, Piaike, setogat, CHIPA) | A: NPA ba eae donoted bg M={QZS,w/O where |, Qs Fiaile or non- epg. act oP eas or interna) lala A. Lope | | et Bop tie oo ar hips aitip re OB | Foe Set of final or Accepting Atoka; £cQ | (|S %. Tranelton. function or Moving Functian or Mapping, Rindign. using. dig Run chon, ina nect siede Can LR determtned. - : S Tronsidon fem don @ mopping Rom QXZte Be S: QXZ-3 28 umere 26 5 power ser oP O, 4 TRE Sch of al) ates OP @ Naame “tS 8 &Y Class. mnemnnnes Roll. soo Subject Moy Oe hip ee Ce can cepresen} efter NPA or DPA peeing geoph. where ina nodet are iniates and labeled 4)) > I No: OP gtaliy wren trop floes ocwwr: , angels FAtHT6 i> FLO] SH z*8 yy Mejor Di fPerence & & Chronwikon Burt's) DEA NAR alowed avos'lable ; Covrosps aag bm eeraspendiqg 42 a” Inpupr am inpal- d & ~ move % Nor aiowed- | E- move % allowed - Digita) Computers ave Nen deerminwhc feodure it nema: ay met ascocicted wt}h real empl Dead Conivgfation S nor | Dead configuration 5b allowed + Multiple choices axe rot | Mattiple chotces ano availabe |. } | ke Resi amd) undeysleBiog reigning ond) wedersteding. ih NDPAIS | Non-dderminighe ee ny BoOR,No... oN ee) Name.. ao 4 “ Gr | NEA op au binary stags uh dds over Zl) Le4 p94) \un 4 sae t ol 221F Regutor Eeptestion mi (04) a \ n+l> ore & 3 ots | See w i (ord*s (or) 220 fast bis = How bo, convert NEA to DRA Sw = | } ss Glephrs Waite thelr 4rongiHon fable 3 with above Ot? » Steba Cons d a tronsihon for corrospo NDING DLA ofa» , Above Na transition Atog-rarm i ¢ Ins” | eri: wpe : In-30? fog | opiar 1 | OFS 0] Go| 4a, — a Fo) 0% 44, BORN on «Date. » Subject NFA usith epsilon’ Ce-NFA) Crulhmone) ab ha Pirther extension of NFA’ (input symee? 2 8) i S° AxXCz vg) 2 | * oe Find pla b berg I | i 7 a,> abt ace | B> ours coe a G@tore)* tee) 2 wterp | Elinunate E’psilon - E-moves ——’ @)+<«€ a E> e onine [Agente C4-s6ps) 4 D [Find all edges Mating Prom S)) 2 a Ol edges to sy withoud chongig BD) Y Si Pinta) phate, make 4 Inldtg 4) Uy 5 fina) abate, make Se Pina). S)) Remone hand Biel Cas i inochi na de ao a= Se @ 6 9 ©) Heda aniele D/P anere ome more S Psexed gtenl Aram the |art One Po (ues Coy Regedoa omg. for pindclog : far Anfiat he An nz ine Whew ae an later is exp Livwtation oP Feqy . Lined , M ened Linear Power - ot” ; ah Dy nt rete ata? i ase hobs taphs (hy » oe . Subject. ep Remove Un reachable ode Rest Cray re te Minimization OP DAA fj thseomnoeceaten cn AR REE ALL QP why ond where shen b o mead af rol mization of DPA wren NRA > DRA H cots 1 > 2? 296i Po.satetl has thE ; |e no: 4f Klos lnereoya thin Our mod) beams yore. compl j Ho seduce sholls )° ve | Ja.) ye 2 » Horeschle i i) aes” |r Io b ra % a a T Po = ry) \ a, 5 Be [3% [ae ea 4) 43 WS G3 \ 45 \4) V3 | Beh Mi iit, Date. . Subject 1 | } | | | | Conver+ pes Zfabis into equvalens doses - ais ‘ ‘ : it Non Auuta} as 3 Caen Pires oe) 2h 4 he, Cay St 4 ae ad, ke iste DOr Gaeep me Lie Kame “ F Yom 9 Ke Checke korne Per ateg alog group m had 4D ishke veor do’ 1 Gs Ait Ms > 6 y) ret pion) ee a Aas $y, ae coh Gar » ., Ostimizet'on ae DPA- Based Pattern vious In 4his Anere axe jnred Spm hod ave | keen wed to tiraploment ate epbinize pattern | modcens - constructed From ooguier expressions - @ ) he Rast algonom is usePud in @ Lex compiler, Because aVienpneuel eal taeetlt: Prom o regular fon, wighowd- eonctevckas On oper medial NFA The meauttiag DRA alo wd Drown Pener Alabo dran +h) DRA Consus eo) Via an NFA the second abgtnen minimizes ro numlse. AP says o et DAA) combinétng, «Calin thab hang dno Lomi Suture behaviows » The oath th arseh UselP a quieh efficient 5 aaa a oor 0 (n}ogn) ap alala mPrv ors here 1p, U the Mower oxllm prrocuces move Com pack : of Avandtion tables than tre Aadar, y @y}| ™ fried qeboresentaions cioo- dimenao nal) EN a= Ly & | Homma) Giramner- 4 Glonmer So Seb ay ecules hich wvabiclata phe Corseciness of AN. pend ences opm ongungese A mer So foud apele Cv 7 PS) orton V= Vamable ( Non- teemnod) ou T= Terminal Symbol C Token) t on @ P= Paocuctiyn Ruts (£3448 ) 8% Shond | semba) CPG a “als Application emt Conled Prec Aramme ib weed to defint Ing yr che sdruolue of a prepeamring Pann age: SH cobain a Seb oPrule ibled to Bodutten| © rude cre sS uotd. + Cheek sng sundax op o Programming fonguane Lonstrvs; AS ite: —~ alaebouie Lx freesolon fe —"¢ else’ etalmods ir — for Loop — wks lee ms Barex oeperenta tion! Konpti2 ~ Algebrate Grammey ’ Es ere fete fear }e/e |e) id Sententer. id-+id & ide Desivation: af. zerrlenes ° ESEsE. : > EX EXE | —> E+id aid ; —> id 4 ide id ‘ ae | Tes comlente Daidealned Prom tne abort Bosamme | hone bo wad senboots - vad oer 2 aH + spnsille-fireo Tw selene Com be Ge Prog Obone Aranmmer : Sore tabiris 36,91, YQ os-f0 |G2— 16Y Jol, SEI, Tem) WAS yy a 123,13) bie | “2K Be BOOR De Lty im OCF ga: poRene vv Bee Nome... LOS mentor.) izips. ey Class By, Poa Ile nn p22, pov, 10) , WPI 2B /TMMM/I NS) 64/13), (YY (Fostton y = tnth'al + aode #60 + (d)s= ‘Udo id3 & 60 Syndan Analy ger ai SS a eN tda te id Ns ' Bomanic Analyzer oe | yy ' a wh i” ds” tea) ® move ides 2 ‘ i MULE de Goo R2 a bo moyp ta /Al Iabermediade toe Genender App R2/R) : move Ry) -y | Code. oftient aati ma) a Cag O10 bel td2 + tempt Dig) Pronddtin af e€tnot

You might also like