0% found this document useful (0 votes)
53 views23 pages

CD Unit 1-1

Uploaded by

vvvcxzzz3754
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)
53 views23 pages

CD Unit 1-1

Uploaded by

vvvcxzzz3754
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/ 23
A compiles Wwonslales Whe cole vofithen “in one ! iene to some other \anquage wilheuk chonding the wean, of She peyan. a ts also enfecled Mak a coragler sheuld wale the Aaaggt code elticeak and opdirnited fn Aesms A tine | nk space » Comgtler design covers basic AsanckAion ineckontsm and ever deletion & ee covery M includes lexical - sytax and semandic analysis as front end and cede ognercion ond ofkirfaction cy buck-end j SSCS rafley OME regen | Obigck Progam >[ Assen nent Tasaeh parqiar Execucion process of Source. Presper compiles Othe shracuse of a comyplers + Any, lange Sho ‘8 eaSex to undewland and fe * YA divided rho well: defined a Tatack progam (As mb cede) we Phe Kio phaser ram ry aval onde pure chore avalgs phos! Crees an wdeHME ale xepresentation fiom the qven sousce code "Syothests “pos Crecles an equiverlent Aarget Prrqvam from Ihe gudermediake repesentation, othe compilation process contatins the sequence cf vation, phases. Gack prose tates souce proyam in one Yepresentation and produced olp Sn anche sepresertetn) S Gach phase fakes ‘put Arom Ws. previous acy. dherteat. Analysis! arnalyes pase So tne 1 phase of confor scune cede as mp ee f - Lexical avalires vepresents Brew lexemes in the ) fe of Acdkens. source program flexical avalases] Glexemen, Akers y x cmaly sis’ oT. avaliss 4s the wi prose of compiladfon Sa is prase, Ane Patses checks hak the expression ‘ a. tokens 4s synlacKically Comeck ox ek. Ale : olen ole passe tree i : ot fs Yrird phase of compilation proce checks ichether the parse tree {ellos Xhe subg wn Lrack of Sdertifiess “hes eee and expressions Noble fs @ dale Peckucer Ged . anes compiles, consis all he fdentefte o!s york their Aupes. s 4s the anverated vee sya af nerakton > éler goers the source code Ane \iqh- level \anquage and the machine lanquage Wee opliniization* eM As an optional phase t of ‘s wed Ao improve Awe inkes mediate ode se Yat Ake olp of We Prograin could wun fastey and date NES oper. tk Morevee Me Uenecessory Kes of he code and Mops The Sequence of shotements Sn ores to speed a Progarn ereculion. od nevedion’ ts the final, phase of the Compilalion proces M Aakes the optinfized intermediate cede as pul 2 rags & Ao the Aongek “racking larquogy: Path keanslates We fwlermediate code filo the mec hing | Fise of Me spectfted computer. ace Bie Ol. sum 4 Role x50 [Lexical Analyzes | td4 =d2 4 dd xidg ‘ntloveall we e (de “fenertor emp; = intloreal(so) Jernp2: = ids klemopt Aemps:, = ‘dik Aemp2 fds: = temps Lempa : Ads x $0.0 fdas = tle Lemps enera\ion _ Move ids, Re, Ase MULE ral Rr Move {d2,R2 ADDF R2/R MOF Rt dt ot biilaing o a compiler { o ‘s a Be ict tos task. The main to accept Ye source % into suttable an Ney - a eee “Comglers Audy ts focused Wadi on Shudy of » » hee to design We covceck mothemettad mod el avd cues torveck algpcithns , Keeping iw mind \o balance We need for generally and efficiency, Fite hate. machine & yequlat caprersion udrich ioe — have already shud, dan FLAT ave he prevequistles 4, ‘ Aes any Are lef unths of proqrams(Aokens) # for ) Aescetiing the algptthims used by compiler to. Wenity E hese Ackens. s4n comgiley destqn dhe deom “Code Opi ni zation’! : indfcales Me atAenpls wade by a Compiler to preduce | fede hich ts mere efficienck Yhan the previews cede. This code shold be faster han amy ovher code that Performs the same tact. : The objectives to be fulfilled bby the compiles optingeations jyclude: The meaning! of the comple pregyaon rows be -pesewed. Opkientration should improve Programs performance. : ee hes completion abe dite seasetry if Regs ANE LT — weer ’ A\lal F iw skedle 4 wrapping, {rom \eeationg 14 yloy, » Ao wets vahues. els weve it slate ; y Vannes \ocedtons Velues (watiabla) | DAakte scope @ block struchwes Whe vastable decacalfons wlilltin the stfnents & Enon as shakte- ae An C, for declating the veutiable gran c_ softy x dayatic scoping the comptles fwsh seavches ihe aan \leck & Aen Succ emively all ihe calling gunckions Mk cased akbar hao the execiclion of program \as eceaurttigy ¥) Pacamedes Parsi " ¥) Pasar v YY os mechantsin: AMO, 4S lenny The Lovededt colle, medium Vike procedures Acces pace (Ons «? patameer parsiva. The valued of dhe vasiables from a callirg procedure. axe Lransfewed Ao the called procedure bby some mechanism. «To process Mts mechavfsm, some methedls cue Lesing | ke call toy value, call ty seferen@ or beh. and Jaleo tke calh-lay-nome- MAtiasiaas » Abasing, descxioes a Sthuadkion tn udtich a deta Sain fm memory can be accertel Mveugh det{erert siyvdoclte names in the Proqrcun, | 4h She Atco formal patamelers can veler to the same locaton, such variables ase soi 40 be alfase of one anolner, Loexicah Aw ts fs the proces " converting a ers From source Progra weko a a \extedd awalyres Clerc), Aokenize oy SCanner, cLewenk cwalags consisls of 2 stages of PRO (ear ’ are’ - Sean » Tokenivadtion © AQ \erteoh Asken ts .& sequence of chatackes hak Com tbe Arented ag x” unit We Qcenmar of eae Avips cud vcliike spaces & CBinmenbs Liem, scurr pegs .qloakes. C8VOr YeMsages SAM dhe source prenram te ays ENOL Medyane wll As oceunernce by pectfyires ge ve weenbet tarts Of lertcal avalyred ‘s Atvided tnto’ 2. procemes Scanmiing Performa vesidling of Alp chatacters, vemoal ok whtle spaces @ comments {yntal arate Produces tokens «& the ole SSu ~" ok Lexical aralyres’s Sonpltcthy of destan of compiler The vemeval of white Spaces & comments enables the syntax avalipes for efficient Suita Mic, Constucks. . Compiles efficiency Ss impreved - Specialized Buffering techniques Acs veadkirg chascicke ss speed up the compiler Process | desuey ‘or ledtcall orale Helen gnttale io | , - Compiles porabittty ts enhanced — Spectatinedl tecls have been devianed to help automate the construction 1 lewical analyzers K parsers uchen they ave sepnicted. Coen Baftesage “Snpat ering 43 veadk pmgram Part ¢ 4 bt i 8 in Pt ‘heateh araluger will te 25 40 So% of the Usually, scanner (lexical aval ner) tse \ock~chead » with double buffering to winintee the overhead AL reams one butler Can be reading & second duffer cart be \endtivg chookahead {s yegutred to dectde chen me token will end amd dhe neck token will begin. p cherical analysts veads several chatacters those chotade, | called as lenewn, These lenem wmnetched votth Me pater Coequlad expression. ox grammar vula) , & once ‘ts mabe, ib gentrales dokens acordigly & Hits foten ack a4 Mpa Pane {oar pikes scparadicg, ten hanna ceo AEST TE ta bes \exeme Laying 1&4 ' 4 gpneveded . Hee berets ate, 4, Read Nn bates tho one halt of the butter each Mune, Si aie Tt nerd of file cia EL icfsl4 i lect : Mh Anput hes \exs tha N byes, pur a special EOF eases tw She bull: When one buffer yaa been pocemed, red N bates Salo he okhes buftes half. i) Sentinels : wan the previews scheme, each time 1 n the'gp’ fs cd. oa Check 45 done to ensure Yad one Vold of the buffer | has nok weve of St RS done, tren the chher half must pe ae _ the ends of the later rabies. requdsed Lice kests |i each aduante of SHC forsetd peintes- Tak bs For end of buffer: Toko To detewmine iat daractes The Use of sedkindh veluces We co desls to ome boy extendig cack buffer halt 40 hdd a Sentinel dotacley ok We end wThe stdigd “a special clatacker Yok canner be path PF Ame apunce_ preg (ek chosacker 5 used as sentinel, ae alerts \ fs vead )Recoanition Aokengs AAA A eee + Recegnttton Ot Awtens can be done & 4 Aulowela so Yet WY can be seconrtived by ™ Aranelfon Agave & Ararg Mable Vanialle J Sedewtélfey) onslant | Keyword - Tokens cou be Yecogntaed wth he Velp of Aveunedfon Aiagvans Receopition of eters identi) \etker —salbl. . . \a\ Alp). 9 le dig polis. (le Wy lethal ether Langit) re fo vat} ° leather | en alas fea {hel & the.) fie \ @ leAhe adit om UY )Revognitton of svelatfonal opercchors 0) : Ar) LS) © ols 6) oa +989 yRecegeton 4 uchike spaceas b alo, space Erker al 68-6 ® OF aig Ewkes By the \eulandne Sevan de whe ts 0 Proyam Wad agnerates \extcak avoliper MA fs used with VACC paises agnerater. «Mb veads dhe Snpad Kream & produces the source cede os olp {wvough fonglementing Mae lexical aralases fn the, | Cpregam, f Functons of bent nid in the +Fiesily lexical ovabyper creas a progam le “Then Len comgiler runs the lex! Progen lee ond. puodaces a C proayam Nex.yy + Fel My © compiles vans dhe lex yy¢ poyam ¢ pcre wok. Len Sle Somat A \ex Prearain “s se posed ‘whe thre seckions b. le “Je Acdtnaters The 4arol oh Le Souce 4s an i ? definttionsl 4, lat teh ¥ user subroutines -Delintttona | Sncude Seclatalion, of constad vatiabk + sequlat deftwAtons, Rules « dubine due stalemad of fom pilactions| palace : ~ -Pafackfony Whee 0% desetba the seals cupreasion & actions dercr'be, é Pre actions uskek aclon ane leviaal awaly(tes shod take vehen pollen Py medches a leneme, th* Gre uatltany procedures, needed by subroutine can be loaded with ures A compiled sepatately, Alo werd eee eel he Auk ee le eaducrela, § slale vrouline dot decker o xing of ye . wpel and chan ths Anke cvdivgly Fintle curclomeda { sete 1: X sevegnfier for vequlat expression whens. aqulah) exprenton stitng 8 Ged tle ssi automata, 4 changes Ws stale for each \eal AG Ane type wena 4 successfully precessd 2 the mutonta veaches Ae final stake, TH fe acepted jie, Mu siving just fed woas sold te be a valid teen of We larguace fn Vand. sMothewakical model of FA donsists of; La. £.%, &, Fb where Gz sek of finite slater & = sch of input symbel Yo = iviltal shade | F = seh of ral states | $= Arvanstlon furnclion(@ xs @) s aay sean . Re Bawquoge of OL avd edi we a Ofson a ag . automata’ Tokens \ : Regubat €prexsion| a aurkoworka ie sescgnt on of tokens, « Regalos epewion ts a seh of sAvings tohich al Twcludea Bese + Cuviton) ov / Cunfon) cpeverkeys ¥~ 0 oF move OCOUMTEN Cet (or + - Loo moe OCCU ENICEy + = Cncderad fon Ea hie & RE fm fnskh vlth Stuttg Sa! eng wah ‘ab! RE = Cayaasharyt » From requlon expression bo eee q)Opheriaction ot DEA bued pode ns Relat capretion (a/b)¥ qb F _ Croke Saree tree ” Nukes dhe leof nodes A Find wnullable ef ear node x! a | tind 4 skpos of eadr vole /* F | Fad Jax\pos of each. vede i¢ + Plad felleaopes of each node / » §) ne then, e fieshpesCea) Nagy se) 4A ; + *) a4 hen a. Fixskpasn)—lastpastn) [Nolet Thue p gt Naleg(t) false $i OS & jwae Paskgac,) Lastpestes) {ine ial i ae A, tsk K y NM ys = {s way f ; ae fal i ¥ Sia : W EH 3k / a rh Fop Quay Yay ; ; Folewopes _ wk. / a fers ra oa pa teh $3, \iah * ; s tay G fa 0 is} ; ' : | Lasts 118 Fivstges(Rootnode) =§1 2, 4—H) (Ara) = Usk = Foplt) U For(s) = UAshoL ay 24\,2/3,44% —3®) A>) =i = FoPC2) = LAs} o® (Ba) =1.3} > Fopt) U Fopls) = Ya, 3,4} 3B) Bb) = 12,4) som Fop(4)= Lie shu {sh =flas, te er eee se 7 . yo iuss ea) > A & = FOPLIVEOPL) is. ° {yr dey 3H Be ¢ jar) = U8 ac] A = Pop.) AD ah ts wetting DFA dor gen RE. OD oh 9 Leal Auliger Sexo sbekcal analyzes agvercclos ‘nbveluce a Aool cabled hex, latch, allows one to specify a Nexcal curl aer by SECA INQ requlas ex preasiont to describe pecdesn for totens The Slp for lee Aocl ts ler fawquegg . i » Shuchure ob Genevaloy col | | | Leg a | psa 1A lex Pryam 4s tuned into a Arensitfon tahle &. a YRS vahich, cre used fy a fintke- coctormoton > ; ‘ ‘ Gh tall sivavleten the actions from dhe ‘puck Proqyam, okich appre cf Fragments of cele to be qnvoted. at Ane appropriate time by Ane adoration simulator. A transition lable fo the awtometon, functions ae passecl Ureckly Aprough ke to Awe elp Fp «To conshuck the cudomedon, vol begin ty taking cach reqalan ~eaprension padkan ta the leapogam e lowering ih, usivg, algorithm. do an NFA, & REsat OSHA~-OS0) (NFA) & a *, Padkern vnalching based on NEAS — Sf the levicad eweliges simulales am niFA, then TH ruck read np bedinntirg ak Yhe powwk on ‘As Anpict which we hare sefened Ao od \exemebestin. J As wh moves the pointes cabled focasd ahead in dhe faput , 7 calculates Ave “sed of skates ih ts Nek each point: cWhen && teaches to final’ state , 7 accepina slate There! we can dectte the Vengess prefic Las said bo be (lexeme) worcling Some pecttenn LDENS for lerical onalpers — Another aschitectsre, Veserabolirg, Wwe ofp cf lea, {s to converd the NFA for all the patterns tite an equivalert DFA. ? oo ' F . ; “We can Converk the NEAE bo DFA o oy wasting Hae algorithm tohich We have ae FS 2 used Sr FA. $ aot woe reed Lo Tmaplement the lookahead ppesdor: — At allows 4o peek abted, $0 40 vead &’ | pyghusak © a portion of fhe Input so eant without achually, {oncanding We location of the siveam. n vneelches . Srrhtcctt ~Base @Operteation of DEA "Coed exten ge ts | OM ope.

You might also like