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)
41 views
47 pages
Unit 1CD
CSE AI ML CD NOTES
Uploaded by
Vasu 22
AI-enhanced title
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
Save
Save UNIT 1CD For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
0 ratings
0% found this document useful (0 votes)
41 views
47 pages
Unit 1CD
CSE AI ML CD NOTES
Uploaded by
Vasu 22
AI-enhanced title
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
Carousel Previous
Carousel Next
Download
Save
Save UNIT 1CD For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
Download
Save UNIT 1CD For Later
You are on page 1
/ 47
Search
Fullscreen
a ew Pert er ttt eet ert ta fee pce rs PUNUT-1 ¥ Compiler :- Compiles oer thal can read 0 progiore in one language Gomes language) and tranclate if into on equivalent proqiore 10 aother language Clongel language): | : ae important vole of the compiles is to eport any Uree Program that v1 delechs during fhe hhanslation process gource Progra + [cori =m” | tonget program c TP the target progiom iv an executable machine- language praqsore it can then be called by the uses bo process inputs and produce | outputs | input —\taigel proqiam| ape fq Running the forget program _ Pogeno: Ol exors in the | | | | ¥Interpreler An in) Kind of lonquage, procesvot Gnelead apreter is anathes common of producing 0 loagel programe 06 © Jaanslation an Anteapreler appears to diveclly execute the operations apecified i0 the source program ON inpote supplied by the uve Hen > Source progran —~ inpol SS tole > oulpol | |4 ava Compilation procass:- — Tava language procerssors combine compilation and inleiprelotion | A Tova source prograre may fal be coropiled into an intewrnedlt form called b eke >The bylecodes then inlerpreled by vnlual machine in order to achieve faster processing ol inpuls bo oulpols, compilers, called jost—in- time compilew, tianclales the bytecode Machine language immedialely belore they v0 the infearnediate | Program lo process the inpol ale sorne “Tove nto source progiom | [rant | inkamediate” programs —I Victool | Mochine |” output input Tag: A hybrid Compiles — | & A Looguage processing kero Source Program JL [Preprocessor] modified wovice praqrorn £ a [Eornpilea] comers Aargel asserobly pro get oF ern yp qiare [ Aeceeser] + ‘elocalble machine code wv | Linker | Loodev’|<— fbvaay files ’ Telocalole abject files targel machine code po ee: ee © « ‘ o © © © c c ¢ c ¢ e ¢e ¢ ¢ e ¢ ¢ ‘ |< 6 6 4 ‘~ <2 “2 <2 <2 <2 <2 2
~> ~e ss } Coed dbeededdad o> [essSeveral olf L Lance! pow may} be ‘vequinedl 1a caeale an evecoloble p> The task of collecting It 1 \q The source proqrarn js cornelimes & Jiucled | 9 a weperale program, called o pleprocewaot nes entrusted | ~The preprocessoo 7 eas [ert oe. expand ghoihonds, called rnoctos, into we modified! source program is then fed 19.0 ¢ | 4 produce an oasembly - lanquage proqrare as ile ovtpo = The assembly language is then processed by 0 prograr? called an assembler that produces aclocalable machine code a¢ its ootput poate iets aT Fay have 40 be linked togelher with other alable object files and libraay files i ‘ a oatine ibiaay “les inlo the code thot actually Y° > ‘The loader then puts logethes all of the executable obje memory for execution 4 The Slauclure of 2 Compiler: - The Staucture 2 2 ' " Analysis possi > at is alco called as Pont end of the compiles Le anol ysis pat breaks up the source program into conskhuent ‘pieces and imposes © marnenatical structure on them cit Hhen uses dhis structure do create an intesrnediate representation af source prograrn > The analysis port program and stores ornpiler. The coropiles ct files into also collecks information about the source bin a datastiucture called a symbol fable | ay Synthesis pass onst The cyntbesis pant ct inlesmediate nepresentalion and the information in 4 oft is the back end ucts the devinedl fanget prograre fron he symbol fable. | en| «Analysis pass phases are > Levical Analyze* > Syntax Analyzer Semantic Analyzer L,€ntermediate code genew — code optirnization (option ss dynthesis pass phases ave: + code generation + code aplierzation (optiane! phase) «Phases of a compiler ation al phase) chavocler tian [Lexical Analyze" token ‘shearo \ MS rs L J Syntax Analyzet_]. syntax’ tree : iSemaolic Analyze oyntax tree Pr ‘Inferenecliate Code Grenertor 7 inlermediate representation ~ i — ,_leleamedt ol ep Hate - J. Cook Ganeat} | T toxgel machine code \ 4 ue 4 © taagel_ machine code. _—_ error handley— oo G2 G~> c—~3 C3 C= eye obet d ddlill P d - f 5 eT i he |& Lexical Analysis: he \ i “the fiat phawe bla compiler is callod lexical analysis of geanning 2sLevical Analyzer is alvo called as Scanner 3-the lexical analyzer reads Ihe clrearo of characters Prore the source Progvare and qroops Ihe charactews into meaning lu lexemes. far each lexeme, the lexical analyzes produc | of the form thal if pacses 10 the eyntax analysis phase Pattern: A gel of tules hal define 0 token sLexeme: A sequence of characters thal are tnalched by the “Token: A qroup of characters having collective meaning choken-name , aliibute - value> | nthe token the fre! component token n is used duving eyplax analy s) and vecond cormponen’ points to an enkay in the symbol table for thi token. f sequences called ex oo ov tpt token pattean foro token | | ame is a absliacteyrnbol that + atttibule value | eq: position = intial + vale ¥ 60 position is alexeme thal wold be mapped into o Tattaiboke | token Lid t> 2 7 | value 2 The asaignment eyrobol = isa lexeme Hat is mapped | into a token <=?- y —|| = intiol is a lexene thal ie mapped into o token ss | tid, 2> | yt is a lexerne 4hal © mapped into a token 2+ erne thot is mapped into the token did, 3> al iy mapped into fhe token <4 into the token 60> stale is alex 6) + is a lexeme th 4) 60 is a lexerne thal is roapped Lid)! = Cid, 29 £49 Lid) 3? CF? 460 + Blanks eeperating fhe lexernes yaould be dis carded by he lexical | | analyzer ’ Rogulaa graromar ie used in lexical analyzer | t = 7/¥Syntov Anal sis: + The second ghost of the compiler is syntax andlysiv ot paseing. “The cyntax analyzes is called paises “The parwer vees he fine! componente of lexical analyzer to create a tiee-like intermediate vepres depicls the qrammalical glruclure af token tieam. ation. is a wyntox tree. inlanal nodes ave op led as parse tee mmmatical utaucture the tokens produced by the. entation tha! +A typical aepresent syntax bree: The bee in which external nodes are operands - Gt ts alvo col -Context-free grammars are used to upecity the qua 3) (607 eiatow and 23 Lay cid, > ¢ oq: did, de> did ve, token cheam ie The syntax tyoo for abo | J. \ | cid, Ds Lido He Lids» 8 -Ero1s foond af the syntax analygiv phase ave Called syptactical evtors I the end of ctatements egrmivsing of cemicolan al |g Semantic Analygis -- The semantic analyzer uses dhe wy analyzer and checku the gemanticness fic analyzer is typechecking, vshac the has matching operands. ntcx tee as inpol frome the syntox Cmeaning fulness) of a cyntax tee |. The immportan! role of eemanl | compiles checks that each operator | The lonquage speci fication may permit core Hype conversions called coerciong binovy arithmetic operator may be applied 40 eithevo pa of int -point numbers IF the operator iv um be and an inkegew the compiler may into o floating ~ poink number - | For example 6 | integers ov toa pair of float applied toa Moating 2 paint n | convert ov coerce the inkeqar | |p e Semantic er ek soe Si ore ae eg: idt= idaa idat 60 uppose idi, ido ‘and ida hove been ¢ and lexeme 60 formu an integer The typechecker is \he vemantic analyzer divcovews that toa floating -paint number ae ida and en integer 60 inlega may be converted into o foaling- poink nurnbet’ | the oolpul of the cemante analyzer hav 0. exlao node | iallofloat - | adie iat ida intlofloat C60) foclared Moaling poin] nurnbav ‘y/ic applied Go, the for the oparolor 666666666660 = 21d, inltglloat | | 60 ddedaud ¥ Intermediate Code Generation * eee <3 After syntax and, cemontic analysis of the vource prograry, firto torgat ate an explicit tootevd | code, cornpiter mmo) mony compilew genes © ot machine -like intermediate septeven lotion - This intewmediote | pou called thee oddrece code: | yamec_ address code: “sn code which contain! Yee -addvess owsigqnrne 5 A code which conloiny atmos atmost one operates on {he aighteide in the J jqsloction. ' 4 Uhre add vesoes intermediate code generation ave semantic ev1048 ¥ Exors found by pid edad’eg idi = Idaridat inltofloat (6a) Three address code Ut: intlofloal c60) dos idgrtl 13 < ida ates idi-45 |x Code Optimizatios 41 iv also called as code hhanufosmation 45} 16 used to transform the code fo reducing the burden on 9 compile ond improves dhe speed and efficiency of a code, vilhoot chon ing the meaning of a code 29: 41 inttofloat (60) dozida ell dae ida ate ids- ts code ransformation + t= ids #600 its ida+th ¥ Code- Greneralion:- | the code generator takes ac input on intermediate representation of the | «_! i | source proqrar ond maps iF into tangel langueg?- | «t +f the target longuage machine core , veqisters 0% memory locations | <_ one welecled for each of the Variables used by the proqrare s les Rl and R .by eshicb inlevmediale code | S “For exarnple conuider 4vo0 vreqiut © i nanslated 40 machine code LOAD g1,id3 | MUL 21,4160:0 | LOAD 29,12 | ADD Q2,RI TORE idl, R2 sexsows foond in code generation ove like umieachable error, oa Array neles OutOf Bound evra ele, qe S i S e Ss c e ®i a =~ : | —_ | position = inlial-tsale ¥ 6O | . | ao | [Lexical Analyzer | | =e dae | did) D> = 5 cid as C4 2c 87 CY SEO” | | exo | | Synlox Analyret | | | ' C= | = ( = | a = ' dtd,2> |, | cus i | - aids, 60 | T2 | L x | | [/Sermanhe Analy: > : ren | = = 7 j erm | SYMBGL TABLE wid Pera! 7 = wl id) 2> 1D 1 _. zids> ae i .| eral code reared 1 sot ktreinttetloalted : | |. 4 ‘ : brzidaxeetl | oe ; | | | | REEEEET ? } LoAD Wyids! iy yy MuL @1,4160:6 [code Generator |, - 7 e ape el? Loap R2,id2 . : “CARD? 22) \ \ A ed STORE idt/R2., n a |o Sgbol Tele Ahe Gymbol table is a dataslsycluse conloining a tecotd for each | variable name wilh fields for the allaibules of the norne. | @ ‘The datastaucture should be designed to allow a cornpiles 40 find | the record for each name quickly and to clore ond «elrieve data a from that record quickly. © fnto Com piler a | & Grouping phases pases cleals with the logical | the discussion of pl organi zation of a Compiler: | tp an Implementation, activittes ford Several phases ynay be grouped togethers inte pass that reads an toput file and wites an oustpuct file - / «en -the front-end phares of. lewteal analysfs, syn tat analysts, Semantic analysts, and fotermediate ight be qroupect fn one pP2sd- leode qenevatton ™ code opti zation be fan ‘opttonal pass: end pass consisting of + There could be a back- Pov a Pay tieular target machine - ler phases foto passes fs | code generatton _s Grrouping tbe corp? divided foto woo passes: iyone pass Compiles a HHP PPPPP PLE e rages 1) One Pas Compt let Dem the phases are, BT aedi into! one! pass ie called as One Pass Com piler- | hyTw20 pase com pilet | | L4 ‘t we eee eae eee b bbb bbl hbk kek et a ees ; i will take the. input’ ad dhe gounce, prograrn a and prodiices” the vietpiel as "th laygel: Progra « Sowree , proqvarn : | G phases | gt 1 oe Lpavget | progany.. : the. comp tile (2 agi a sTwo- Pass Wy Two Pass complies 4 » All the! Sit phases oF foto two Passes te ‘called | zed compileirperg ssrund_fl 1 ; eure che #49390 tenor + ; © [iknalysis PaS3)-5 Fegan aennie) Gaik ") En betiedate code 1 ist wn ~ 7 sytbesie Pp! F aa “range cbdevomhov' ee! Is vnc y 1 5 Analysts | p23 to) Ehat which! te fodlependent i lutea | ate > synthesis pas? 1 ve, crteguis- of corget Ae .o0 Be sha | {S “independent” jof gouvee code Ww £ \Le A The Setenca ots Bulldtog a. Cornptler Comper design 14 full oF beawh'ful erarnples wh eve complicated veale wold problerns are solved by abstracting the essence, of the problem toat hema tically’ sThese Sewe aS excellent Mlustrattens of bow abstracttons can be usecl to Solve Problern % “stake @ problem, Formulate a wathematteal abstyactton that captures the Bey characteris Hes, and solve tt using mathematical -bechniques ° The. Problets formulation must be ground ed fn @ leoltd understanding of the chavackestst'c3 oF computer Progyans, and the golubfon rusk) be: valiclated and refined emptrt cally > } +h compiley must accept all Source programm S- —> Modeltng 1p comptler Design and “roplemertaton] ihe study of compilers ‘te matoly a gtudy of how we des?a thé. aight mathe matt cal model S and choo the wight alacnithms, while balance Png Ure need Roy general! by and] powes aga inst Sen eltery and ef cfency * at fundamental roodels ave Pintle — id rrequiay eLPTesston © + These rmodel® ase useful fox deiscribing the jetical units oF progsarosLHeyoor as ideotters, and euch) and Luge describing the algurithre used py the oom piler * Sone, oF roost state machine's om 4p vecognize. those ants » —e, oi AS555 § wi PPP R LL ssid ddl SAAS SASS AS2a27€¢0UGO é COC EEEAEdHHHHHHHHHEHEEEEEKL oC 1%, + M80. among, 4 — EE ee Rtuchtee ices vrtal rpdels ave gyntackie Ghucluve, ne ca a ae desert be, the Such a& the nesking of. eee teste languages aongtructs ie conte! egimtlanly , Hees ave. an important roodel for sepresen bio gbructue of Programs and Lheiy Asrapela bon toto | object cod e- : / -s The Science of code O ptinizaken,:
comptley pptimtza Hons, pus méet othe, | Ppiowteg dea"gn objectives , The oplimtz.4 tion musk be correct} that the meaning oe the Lomnpiled program - g) Aehe ae ‘esdle boot & portant; archi tectieres tes : parallel fs, presewePE OE, = NR * : ~ ee nee 1y The opttintyaltoo must Improve ‘Lhe. pertPorrnance Fok many Proqmains lathe compilatton Hime, mus and tbe engineering ‘effort srogutrec| fou 1 be Kept reason able, gt be “manageable . , * Programming ‘Language, Basics: | “The programming Language Bastes involve | i) stabte | dynamic disvinetton | 41) Envi vonments! and. states | tity etal, Scope and, Block Siuctu-re | | ty) Expect abcess | control, a ' |” vy) Declava ¥en and De Pint Hons | viy Dynamic. Scope simitgg cot n Vii) Pavameter passing méohanfems . vit) Alfasing.. ae | iy Sta ia |idynarn re, distiog Hor , Ardong the most Gmpostant Igsued. that! we face , a. Gomeptles Fox. 4 lanquage faq "Gan! thé! comp? lev’ mate about a. dot wher destgntog Hiihat decistons | progvarn! i _& HWE DM A TE a language uséesva poltey that. allows the evito jdectde an fasue, Then, we ‘gay that wy, that the | corp? the langu-o 9% rague can be uses a statta’ polf cy decide d at’ compile Hoe. & a N07 a o rrr rong ppp sf > fpS At iS eee T ETT ITTT TAA in td jf ) pre WT ) 2 €q% Stable vod mata 6? i Mere nov semi eolon esrer ink pum) »num® : M Fak gun = Dut) num) cours iat) compile. Hine 4 te eTP Ube dectston f% nade. at wun Ucn dyparnfe polfetpold vadho bo te €g > public Voi dithainl), Id ‘ Lh ire, usteg.; oe le \ aT ‘i U\ Environment, cand States: 1 tod he envivment fs o rapping Prin Pames to. Lfons fn the Stovage Since variables vedev +O \ocat tons, We gould altemnad vely deffne an environmen! as malpping from names Jp Vartable 1 = 9 bai iThe state 19 @ mapping Porn jwicatton % in storage +9 thety valued: 3 loca ace . envitonment Iwealfons ove values (var ables) t Jocks Stature « alge on Progvarn names ae Stale Scope anal Bl ithe scope ules for carve! bi atwuctire . id ps + Scvpe of a Vaviable te tmpligitly 4 creelwhere declavatton appears in the prograrn: “Tin languages Ihe cpt, clk, and Java) provide? erplicht Contwl over) Scope Upwugh use of Keywords Vike public’, private and prtectedl » fuel «ghalic scppe can be given by wing blocks S C. noe braces €% te dengte a blook, Algol uses “Upegtp g Nend" to denvie a beet : ‘ ; A can be peSted other ook S).4 : “Bech Gay oe Vartable declavatten D belong? +0 a block B Tf ik,'8 declaved fp Br ~Te the declaralen’ De pf name, op wid B as well a& any ™ bot have Scope fin PF laxed fo. Hat blocs: &« po et Ft ll & fa’ B, then s ested ‘block « Node! ~ wil sted block eh Tb Te cwedec eet sehor or . ManvE: on 9« Lint to : a 2 rege | ee bite B2| basmea | TCS steeeeera ? Jounkeeareb, Bs) | Ountz2qzebs LBuptictatebsn %y LZea alyip wunk yg “V4 @ 4 SF SH aan y a |) a ta} fF f$ § . 0 9 i a PIRIPP LLLP SL
You might also like
1 Lexial Analysis
PDF
No ratings yet
1 Lexial Analysis
24 pages
C D
PDF
No ratings yet
C D
30 pages
CD Unit-I
PDF
No ratings yet
CD Unit-I
42 pages
Compiler CH1
PDF
No ratings yet
Compiler CH1
24 pages
Compiler Design Unit 1 Notes
PDF
No ratings yet
Compiler Design Unit 1 Notes
49 pages
Compiler Design
PDF
No ratings yet
Compiler Design
89 pages
Introduction To Compilation
PDF
No ratings yet
Introduction To Compilation
33 pages
CD Notes
PDF
No ratings yet
CD Notes
57 pages
Compiler Design Note
PDF
No ratings yet
Compiler Design Note
313 pages
CH 1
PDF
No ratings yet
CH 1
23 pages
Introduction To Compiling
PDF
100% (1)
Introduction To Compiling
26 pages
Lec-1 Phases of Compiler - 14422914 - 2024 - 03 - 03 - 19 - 27
PDF
No ratings yet
Lec-1 Phases of Compiler - 14422914 - 2024 - 03 - 03 - 19 - 27
10 pages
Automata and Compiler Design: D.Rahul
PDF
No ratings yet
Automata and Compiler Design: D.Rahul
638 pages
Introduction, Lexical Analysis 1.1 Language Processors:: Compiled By: Dept. of CSE SJEC, M'luru
PDF
No ratings yet
Introduction, Lexical Analysis 1.1 Language Processors:: Compiled By: Dept. of CSE SJEC, M'luru
52 pages
CD
PDF
No ratings yet
CD
238 pages
Compiler Design Slide Chapter 1-6
PDF
No ratings yet
Compiler Design Slide Chapter 1-6
250 pages
CD - 1
PDF
No ratings yet
CD - 1
22 pages
CH1 3
PDF
No ratings yet
CH1 3
32 pages
Compiler Design Quantum
PDF
100% (1)
Compiler Design Quantum
89 pages
Compiler Design Mod 1
PDF
No ratings yet
Compiler Design Mod 1
75 pages
ATCD Assignment 3
PDF
No ratings yet
ATCD Assignment 3
18 pages
Lec00 Outline
PDF
No ratings yet
Lec00 Outline
27 pages
CD Finalized Notes
PDF
No ratings yet
CD Finalized Notes
6 pages
Lecture1 - Compiler Design
PDF
No ratings yet
Lecture1 - Compiler Design
52 pages
Compiler Design Assignment 1
PDF
No ratings yet
Compiler Design Assignment 1
13 pages
CD Notes
PDF
No ratings yet
CD Notes
20 pages
Chapter 1 - Introduction To Comp
PDF
No ratings yet
Chapter 1 - Introduction To Comp
27 pages
CD Decode
PDF
100% (2)
CD Decode
169 pages
Unit 1 Part 3 - Compiler
PDF
No ratings yet
Unit 1 Part 3 - Compiler
45 pages
Compiler Design Unit 1
PDF
No ratings yet
Compiler Design Unit 1
30 pages
Lecture#1 2
PDF
No ratings yet
Lecture#1 2
54 pages
CD Unit-1 Imp Question & Answers
PDF
No ratings yet
CD Unit-1 Imp Question & Answers
10 pages
Compiler Design: Dr. M. Moshiul Hoque Dept. of CSE, CUET
PDF
No ratings yet
Compiler Design: Dr. M. Moshiul Hoque Dept. of CSE, CUET
53 pages
Introduction
PDF
No ratings yet
Introduction
23 pages
CSC 415
PDF
No ratings yet
CSC 415
52 pages
Unit 1
PDF
No ratings yet
Unit 1
109 pages
Unit 1
PDF
No ratings yet
Unit 1
29 pages
Unit 1
PDF
No ratings yet
Unit 1
29 pages
Unit 1,2
PDF
No ratings yet
Unit 1,2
33 pages
Chapter 1
PDF
No ratings yet
Chapter 1
43 pages
Compiler Design Note1
PDF
No ratings yet
Compiler Design Note1
111 pages
SCSA1604
PDF
No ratings yet
SCSA1604
133 pages
Module 1
PDF
No ratings yet
Module 1
86 pages
Unit 1
PDF
No ratings yet
Unit 1
49 pages
Unit 1,2 PDF
PDF
No ratings yet
Unit 1,2 PDF
31 pages
Unit 1,2 PDF
PDF
No ratings yet
Unit 1,2 PDF
31 pages
Compiler Design: Instructor: Mohammed O. Samara University
PDF
No ratings yet
Compiler Design: Instructor: Mohammed O. Samara University
28 pages
1-Phases of Compiler
PDF
No ratings yet
1-Phases of Compiler
68 pages
Slides 01 - Compiler Construction - UET CS - Introduction
PDF
No ratings yet
Slides 01 - Compiler Construction - UET CS - Introduction
37 pages
Basic of Compiler
PDF
100% (1)
Basic of Compiler
17 pages
Automata Theory and Compiler Design
PDF
No ratings yet
Automata Theory and Compiler Design
55 pages
CS416 Compiler Design
PDF
No ratings yet
CS416 Compiler Design
20 pages
Unit I SRM
PDF
100% (1)
Unit I SRM
36 pages
L2 - Structure of A Compiler
PDF
No ratings yet
L2 - Structure of A Compiler
43 pages
Chapter One-Introduction
PDF
No ratings yet
Chapter One-Introduction
6 pages
m433-نظرية المترجمات د عبدالباقي
PDF
No ratings yet
m433-نظرية المترجمات د عبدالباقي
146 pages