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)
26 views
Compiler Design Assignment 1
Uploaded by
Saurabh Verma
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 Compiler Design Assignment 1 For Later
Download
Save
Save Compiler Design Assignment 1 For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
26 views
Compiler Design Assignment 1
Uploaded by
Saurabh Verma
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 Compiler Design Assignment 1 For Later
Carousel Previous
Carousel Next
Save
Save Compiler Design Assignment 1 For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 13
Search
Fullscreen
Nome > Garotadty Naina Ryeantr & “Trfessnolefin “Technde a: Rell No +b ~ Q0643370) 20053, Sobfesk ¢- Oanaet 2 Puig —- AAsstenimen7 ob L ft. Define the following Uy_ Pre; Bee pl processor and Assembles . 5 A preprocessor. generally considwied ' 0 a’ pode 16f compilen 5 iS a tool the | preduces inpuk tor Compiles. Ib deals toith Mocro- processing augmulation stile fuclusiou.s ; language iextensie An assembles transkt: assembly language program into madre tece -The output gf an assembles: FR called an obpcttille, Which contains a combination ef machine ,, tstruchion a8 voll as He data vtequirec| -to place these Fnstruchions in Mmermory (ti) Types of Compiles : ya © Single —pass compiles: GIn this complies jtohen a line Source fs precesses| fs Scanned and the tokens asie extracted. ' ; G Then He syntax of te ling IS enalyred and “tree Altucluse gome tables, containing infor matte Jabout eaclt token. are bulb. ; { ® Matt ~ pass Comp less “ST Stan Hu inpul source once and produces Hrst modifred v term Aomiliosily again andl again, Vili» Loodess ond Linke ‘ a loades ‘fs a pank of og ‘and fs sespansible,, bor | executable files : oodirg into memory ancl execute themLinkeer Ps a computeet rogram that links and mye ee ebyect files together in order +o make an executable le, ® Grouping _ ¢| Phases into passes Grouping o] pases is divided in too Passes, o Gres Pass @®_Tho - sg Lextea] Analisis Lexfcal Rralyzis Syntax Pralyeis |. Frontend Syntax Analysis SIS { Semantic Aralysig Passes Thteinadiak Code aaa Cade [Bede Gensation | © Lex and ynce Tools i ana lexe This tool fs a Atancased comPponenk gf most UNE OS . The GRU kk Lexical anelyzess LLEK) ts genesiactad voit the help ol regular ee pression, Yace? - (Yer Anotus Compiles — ~Compilet) fs the Alandasid passes Qenesatow for Hue UNDS Ofesiating Syste , LAW oper Aource Progrou ,YACK genesiater, cede for the lava fn © Pregromming language.@) BNF and CNE i @. Backus-Naur form fs a nolation — technique for CF. Expl.) Exp2-] Expo ++
2 CNE = Chomasky Nowmol Fom fs a grammas i¢ all produchow ane the form — ) a's ® Whot is language Processing System? Bxplatn phases iin delar', Lyn a language processing Ayton a The rock Fiend source, progran Jem Hee fangeh axenbly prearam aagemblen +0 creat pra impuk fhe the seurce code is first preprocessecl is processed by the cempilen +O which fs then franslatel by Wu he denget program - Tt Is basecl OM Jronslator tokes ancl the Gubpak Tt produces sand a { e Jronsiatos ca" be defined oS CS gj wu fellovals high bee [Reapecsio= Frc CES Post i a macelsnc Cocky, Preprocessoy_ 3 ~ A preproc esso™ + generally considiecdl OS & compiler 3S reol thet procluces postr 3 tnpuk lor compiler Tnteipretet 3 - An. intesipretor slike @ compiles hiql lwel language into low - level, machine translates fanguaqe+ Assembluiy - An assembles tronslobis assembly languaae Programs ilo madaiur Cock.Linkest 2 - Linkess Ts a Computes: program That Unks ancl nuge Vasiious obgeck files — -togeltuss in ors to make an@) executable He. Loadtnt - Leaciey Ts a part | OS and is wiesponsible. bor leading execcitable Mles into mumory and exeutte {hem . Ous Whe are the ditterent phases of the compiles 2 Explain | phases in detail . Write doon the Phases in detall. Write. down “the outpur @} each phase for the expression = Ubte y* (btc)4a A compiles contains 6 phases which ovte follow , - 1. Phase 1 Clerical _firalyzest) Lexical Pralyzer phase take Source program as an input cud Aepeviates chanactesis eG) Aourco language) inte groups tring calltel token, 2. Phase 2 (Syntox Analyzes ) The syntax qnalyzess greups tokens Mig Abrucluses Cporse Tree) Apastpel Wis siping 3. Phase 3 (Somonttc Rralycen) Checks the source program fer Semantic ensiosis and gatlwis. type Informaton for Subsequent cede gen~ esakion — PRase- A. ek CIntuinediak Code genvration © Takes input (Surtax tree) for — Remanti has and generabs Trtesnudiatr Code. “press 5. Phage 5 (bode OpHmization ) Destqneol +o improve ty _ intesimediate code go Hhod- ul Hmerbe. obsect Program owns taster auralJakes less space. G. Phase 6 Cole _generiatton) SY @ generates Ho cissembly, codes G8 ange} language. code is trarslatts| @ We address in the bineeyy from logital address r Linput brecessing ‘In Compile Oubpak a a=a(btc) & (bic) + 2 — NE Wy =Cido+ ids) * Uda tidste [Taken Stream a Paso. 4 ey ; i N\, f es
\S Firskty lee teal analyzes: creates @ program lex-1 in theLex Language - Then Lex compiler oiun the lexd program anel preduces a CG program lex.yyee \S Finally C compiles oruns the lex gyre program ancl produces ON Object program a-oub & ‘ + > aout Ys lexical Analyzer that doanstams an input stream to a Sequence. oc} tokens. Lex Source, Program tex 7 [Lec Gonpitesr] leryyc Vex -yy.c, —> ——> aout fnput Steam —>[ aout] YACC 2 - > Sequence. o} -fokens * Yacc stands for Yet Anothesy Compiles Compiles. * Yace provides a tool to produce a passes bor a Qlven — Qrammas - ~ Yace” Specitication Y ace R translate J > | dompiten foes Ytab-c — > —> aout Trpuk = © Convent Ambiggus, Girammas, +o Dnombigour Grrowmiman . Exe E— Ete) ete E— IdKia Convert from NFA -to BFA uring Thompson's oul e fo~ larb)* abb a b oO) o2o-® NFA for (atb)tabb 2 E-dlosure (op 72 15254,13 ——letA e7 move (Aa) = 83,84 e-closure. (move (A,a)) = 21,2 ,3,4,6,1,83 ——lebB * Move CA jb) = YS% E-closune (Moe (A,b)) = &1,2,4,5,6,14 —let Cc « Move (8.4) =83,83 €-closune (Move (8, a)) =01,2,3,4,6,7,94 ——LetB * Move (6,b).= 25,94 Eclosune (move (8,b)) = €1.24,S56,1,9§ ——leb D * Move €C,4) = 23,83 E-Closunc Cmove Cot} = T1234 ,6,7,84 —lel B ® Moele,bl- ist, €-closure Cmovet¢,b)) = L 1,2,4,8,6,74 —c 2 Move(P 1a) =t3,84 €- clasune (Move (Da) =E1,2,304,6,7,84 —8 eMovel(D rb) = LS, 1% E-closune (Move (D1b)) 224 eMovel€,a) = $3,384 €-Cosere Cmove LE G)1=814,2,3,4,6,% 84 —¥8 (2,4, 86,7; 104 —EoMovelE.b) sUsh E-vlosune LMove (Eb) = L122,4,8,6,18 eS EQN usta GC + > eode tn PDP-\) | for bext formaltey Qed Creat a Cross compiles for tompiler , voritten fn PDP-3L, producing and a EQN language producing ode. TROFF written in ce — EQN TROFF wo Qu Solutions ¢ Em EsTlIT TOPelF F—> fd ie E @_ td+ Id tid =) we J% T 2 A\- “AN Tr hos 2 opesctor on ef thers E+E Bae Bide git. , | io | Wuielr operator should I! ia id id id iq Avociate this with ? \S Tp we wee associat Lolth leit operates —> [lee a%80- ® fa+ tartd YE Ldatiaa) Fuaiorio Uasta)etd f & eee \S Pex [ahh _axtcclalivily } Ee 4 E \ VAN is \, \ | 4 id oe td +Utd +f > + O-— lett associative So ISt panse Wee Corre Kg Precedence deosnth fake cane e 2. tp we taken core o} Prececdlance then — grammasi Now , Hote +e do that ? & © asscdakvity AG can be unaubigeuns. Qu Why are we getlns oth asrocialy sHea - Wune ? bIcG we one defini Aho Gromman vol houk any ordi, a for fd +d rid € E JIN J\\ E +e 1 AN /\ \ | él £ ett \4 i | | | ia id wi Lidatdd tid éd +tideid) leH- aecalve Right arsociativeWhen we Say Six Ap we con grow fh any direckon® To achieve Left associativity , we have to gro tn Lett DirecHow only. So we will otestrict the growth oJ parsee tree . Note we aie grotoing only in lett dlirection » BG grammoss fs dedinesl as Left Recwnsive. S for For _brecenclance problem we eat Jake | cone Hot highest precedance opescter Should be ak Me least level. So, we will fntreduce seveial AIF aymbelS like 76-7 eo From Hus hws Nave. reached T, we cannot pos Tele qenerckt OW F. rot Noo fd std *fd /t\ So, we aie taking ettrT Corre. o precerlence 1 7IN by detining AIF Gu \ lwels. | ' dd ia tdG Converting Re +o DirecHy +o DFA's > First we oun The given wtegulas: expression by wncate - haking tr with & Aptcial Aymbol ts ClAlete — augnunted srequlor expression éxe (a |b)* abb 4 Aug rented Requlass Expression 4 Calby ~bt Steps Ve & Converting a Ayntax tree for (a) > Travesise. the tree to construct function nlngplentestes. lastpos and follow pos. \& Computing — Followpos Ls tonveiting a RE Directly +o a DFA. nePules, Fox Computing tre Eunchou Node n nullable tn) Hrstpos th) laskpos(n) Rice | ee b b led by © A leak with ae LB Sis position i . vullable Ca) Hestpos( ww loxtres ca) i he yutlabletG,) — Hrstpesteo) lastpes C2) < nullable qECnullableced) TF Cnutlabl Ca) ond first post) & lost pes(cd 0" cy c= wullable (2) Hirst pesca) laskpos(@) » Sn else. Hrskpstery else laatpos( 2) ec, ue. HrstposCc) taskpos CG J————— Slax Bee 9 \ ot Lab) 9. a-beb He mullable * Finding Fixstpos and Lastpos bee te} atl nods for Syntax the! Tree was fdas \ uy atin b \ Final Syntexx 4 | Pay 423 Ree Kirst past pos pos % For Finding tdloco pos enly Atan(*) and concad. (Le) pods will consicuerad|, =a Sharn-nede) TF O(n 1s +2 a for Ceach fin last pos ny) tollowoposCid = follotopos ci) O fiestpostn)y for « > fk(nee Cy-C2C concatenation ~nek)) for Ceach f in lastpos Ccr)) Follow posti? = follow pos li) U Fixst pos Cea) 5 % Cowotting RE to DEA fo Te ED | A Nambytec Firedt Stabe
You might also like
Compiler Design Class Notes PDF
PDF
No ratings yet
Compiler Design Class Notes PDF
74 pages
Unit 1CD
PDF
No ratings yet
Unit 1CD
47 pages
Compiler Design
PDF
No ratings yet
Compiler Design
34 pages
CD_Notes
PDF
No ratings yet
CD_Notes
57 pages
Notes Compiler
PDF
No ratings yet
Notes Compiler
28 pages
2 3 Marks
PDF
No ratings yet
2 3 Marks
24 pages
CD Unit-I
PDF
No ratings yet
CD Unit-I
42 pages
cD
PDF
No ratings yet
cD
30 pages
Compiler
PDF
No ratings yet
Compiler
31 pages
Object-And Pattern-Oriented Compiler Construction in C++
PDF
No ratings yet
Object-And Pattern-Oriented Compiler Construction in C++
118 pages
Lexical and Code Generation
PDF
No ratings yet
Lexical and Code Generation
6 pages
CD Unit-1 Imp Question & Answers
PDF
No ratings yet
CD Unit-1 Imp Question & Answers
10 pages
CD-compiler Designe Akash
PDF
No ratings yet
CD-compiler Designe Akash
70 pages
Compiler Design
PDF
No ratings yet
Compiler Design
27 pages
1st Unit CD
PDF
No ratings yet
1st Unit CD
16 pages
Programming Languages and Compilers - Notes
PDF
No ratings yet
Programming Languages and Compilers - Notes
37 pages
Automata and Compiler Design: D.Rahul
PDF
No ratings yet
Automata and Compiler Design: D.Rahul
638 pages
SP Unit III-2024-25
PDF
No ratings yet
SP Unit III-2024-25
126 pages
Compiler End Sem
PDF
No ratings yet
Compiler End Sem
8 pages
Compiler Bipin
PDF
No ratings yet
Compiler Bipin
94 pages
Compiler Design
PDF
No ratings yet
Compiler Design
19 pages
Design Assembler Based On Lex and Yacc: Amera Ismail Melhum, Suzan Abdulla Mahmood
PDF
No ratings yet
Design Assembler Based On Lex and Yacc: Amera Ismail Melhum, Suzan Abdulla Mahmood
7 pages
CD - 2 Marks Questions With Answers
PDF
No ratings yet
CD - 2 Marks Questions With Answers
21 pages
CD Unit 1
PDF
No ratings yet
CD Unit 1
23 pages
Compiler Design
PDF
No ratings yet
Compiler Design
19 pages
Tranlsation Software
PDF
No ratings yet
Tranlsation Software
15 pages
Sak Notes
PDF
No ratings yet
Sak Notes
633 pages
Compilers: CS414-2017S-01 Compiler Basics & Lexical Analysis
PDF
No ratings yet
Compilers: CS414-2017S-01 Compiler Basics & Lexical Analysis
58 pages
Regular Expressions To Finite Automata: - High-Level Sketch
PDF
No ratings yet
Regular Expressions To Finite Automata: - High-Level Sketch
32 pages
CC Summary (Slides)
PDF
No ratings yet
CC Summary (Slides)
9 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
Compiler For Flat Tiny C
PDF
No ratings yet
Compiler For Flat Tiny C
24 pages
Unit-I - CD R2021
PDF
No ratings yet
Unit-I - CD R2021
60 pages
Compiler Design Unit 1 Notes
PDF
No ratings yet
Compiler Design Unit 1 Notes
49 pages
cd2m
PDF
No ratings yet
cd2m
5 pages
Notes - IAE-1-CD
PDF
No ratings yet
Notes - IAE-1-CD
14 pages
CD Unit 1
PDF
No ratings yet
CD Unit 1
24 pages
Compiler Design: Theory, Tools, and Examples. Java Edition (HQ)
PDF
No ratings yet
Compiler Design: Theory, Tools, and Examples. Java Edition (HQ)
311 pages
Lex and Yacc Tool
PDF
No ratings yet
Lex and Yacc Tool
39 pages
001. 1. Lexical analysis
PDF
No ratings yet
001. 1. Lexical analysis
66 pages
Get Essentials of Compilation An Incremental Approach in Python 1st Edition Jeremy G. Siek PDF ebook with Full Chapters Now
PDF
100% (4)
Get Essentials of Compilation An Incremental Approach in Python 1st Edition Jeremy G. Siek PDF ebook with Full Chapters Now
37 pages
PDF Essentials of Compilation An Incremental Approach in Python 1st Edition Jeremy G. Siek download
PDF
100% (3)
PDF Essentials of Compilation An Incremental Approach in Python 1st Edition Jeremy G. Siek download
47 pages
Compiler in 7 Hours
PDF
No ratings yet
Compiler in 7 Hours
318 pages
Question bank part A, part B&C
PDF
No ratings yet
Question bank part A, part B&C
15 pages
Essentials of Compilation An Incremental Approach in Python 1st Edition Jeremy G. Siek - The ebook in PDF format is available for download
PDF
100% (3)
Essentials of Compilation An Incremental Approach in Python 1st Edition Jeremy G. Siek - The ebook in PDF format is available for download
75 pages
Eex 6335 Tma 1
PDF
0% (1)
Eex 6335 Tma 1
12 pages
Compilers
PDF
No ratings yet
Compilers
294 pages
101174
PDF
No ratings yet
101174
47 pages
Compiler Design
PDF
No ratings yet
Compiler Design
89 pages
Lexical and Syntactic Analysis: Slide 1
PDF
No ratings yet
Lexical and Syntactic Analysis: Slide 1
39 pages
Compiler Design - Theory Tools and Examples
PDF
No ratings yet
Compiler Design - Theory Tools and Examples
322 pages
PCC Assignment 1
PDF
No ratings yet
PCC Assignment 1
10 pages
ATC IMPORTANT
PDF
No ratings yet
ATC IMPORTANT
7 pages
Language Translator
PDF
No ratings yet
Language Translator
71 pages