Ce diaporama a bien été signalé.
Nous utilisons votre profil LinkedIn et vos données d’activité pour vous proposer des publicités personnalisées et pertinentes. Vous pouvez changer vos préférences de publicités à tout moment.
MODULE CODE:055CS603 MODULE NAME: PRINCIPLES OF COMPILER DESIGN PRESENTED BY: A.ALMA CANDIDA , B.Sc .,MCA., January 21, 20...
TOPICS TO BE COVERED <ul><li>DEFINITION OF COMPLIER </li></ul><ul><li>LANGUAGE PROCESSING SYSTEMS </li></ul><ul><li>PHASES...
COMPILER <ul><li>Translates one language to another language. </li></ul><ul><li>Role - report any errors in the source pro...
Interpreter  <ul><li>Which convert from one language to another. </li></ul><ul><li>Convert line by line. </li></ul><ul><li...
Language Processing Systems <ul><ul><ul><ul><li>Preprocessor  </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Compiler </li><...
Steps for Language Processing System January 21, 2012 A.Alma Candida B.Sc.,MCA.,  DMI St.Eugene University
Pre Processor <ul><li>modules are stored in separate files. </li></ul><ul><li>source program is collected by  a separate p...
Compiler  <ul><li>Source program is fed to a compiler.  </li></ul><ul><li>Output- assembly-language program . </li></ul><u...
Assembler <ul><li>Assembly language into relocatable machine code. </li></ul><ul><li>Large  programs  are compiled  into  ...
Linker <ul><li>Resolves external memory addresses, </li></ul><ul><li>The code  in one  file may  refer  to a location in a...
Loader  <ul><li>Puts together all of  the executable object  files into memory for execution. </li></ul>January 21, 2012 A...
Phases Of Compiler <ul><li>There are six different phases available in the compiler </li></ul><ul><ul><ul><ul><ul><li>Lexi...
Symbol-Table Management <ul><li>Data structure  containing  a  record for each variable name, with fields for the attribut...
Lexical Analysis <ul><li>This is also called as  Scanning . </li></ul><ul><li>It collects sequences of characters into mea...
Lexical Analysis (cont..) <ul><li>General Form: </li></ul><ul><li>(token-name, attribute-value) </li></ul><ul><li>token-na...
Example of Lexical Analysis <ul><li>position =  initial +  rate  *  60 </li></ul><ul><li><id,1><=> <id,2><+><id,3><*><60> ...
Syntax Analysis <ul><li>This is also called as  Parsing . </li></ul><ul><li>Arrange tokens form of Tree called  Syntax Tre...
Syntax Analysis(cont..) <ul><li>Consider the example </li></ul><ul><ul><ul><li>position =  initial +  rate  *  60  </li></...
January 21, 2012 A.Alma Candida B.Sc.,MCA.,  DMI St.Eugene University
Semantic Analysis <ul><li>Convert from one data type to another. </li></ul><ul><li>Example: </li></ul><ul><ul><ul><li>posi...
Intermediate Code Generation <ul><li>translated to a simple machine-independent intermediate language. </li></ul><ul><li>C...
Code Optimization <ul><li>Attempts  to  improve  the intermediate code so that better target  code will  result. </li></ul...
CODE GENERATION <ul><li>Input an intermediate representation of  the source program and maps it into  the target language....
PHASES OF THE COMPILER January 21, 2012 A.Alma Candida B.Sc.,MCA.,  DMI St.Eugene University
January 21, 2012 A.Alma Candida B.Sc.,MCA.,  DMI St.Eugene University
Prochain SlideShare
Chargement dans…5
×

Principles of compiler design

6 914 vues

Publié le

Publié dans : Technologie
  • I have started the program this September and I must say I'm very pleased with the results. I was overweight and sick from candida and had severe swelling, and redness in the vulva area including vaginal discharge. Using your program I have lost a TON of weight. I no longer itch and scratch. The vaginal discharge had stopped and I'm feeling better than ever. I have also found through your book that some of my other health problems are from candida yeast overgrowth. My acid reflux and my skin texture had dramatically improved and I feel awesome physically. ♥♥♥ http://ishbv.com/index7/pdf
       Répondre 
    Voulez-vous vraiment ?  Oui  Non
    Votre message apparaîtra ici
  • Holistic Candida Secrets, Eliminate Yeast Infection Fast. Candida cure e-book reveals all ➤➤ https://tinyurl.com/y4uu6uch
       Répondre 
    Voulez-vous vraiment ?  Oui  Non
    Votre message apparaîtra ici
  • Tank you babye
       Répondre 
    Voulez-vous vraiment ?  Oui  Non
    Votre message apparaîtra ici

Principles of compiler design

  1. 1. MODULE CODE:055CS603 MODULE NAME: PRINCIPLES OF COMPILER DESIGN PRESENTED BY: A.ALMA CANDIDA , B.Sc .,MCA., January 21, 2012 A.Alma Candida B.Sc.,MCA., DMI St.Eugene University
  2. 2. TOPICS TO BE COVERED <ul><li>DEFINITION OF COMPLIER </li></ul><ul><li>LANGUAGE PROCESSING SYSTEMS </li></ul><ul><li>PHASES OF COMPILER </li></ul>January 21, 2012 A.Alma Candida B.Sc.,MCA., DMI St.Eugene University
  3. 3. COMPILER <ul><li>Translates one language to another language. </li></ul><ul><li>Role - report any errors in the source program. </li></ul>January 21, 2012 A.Alma Candida B.Sc.,MCA., DMI St.Eugene University Compiler Source Program Target Program
  4. 4. Interpreter <ul><li>Which convert from one language to another. </li></ul><ul><li>Convert line by line. </li></ul><ul><li>Error will be displayed at the time of conversion. </li></ul>January 21, 2012 A.Alma Candida B.Sc.,MCA., DMI St.Eugene University
  5. 5. Language Processing Systems <ul><ul><ul><ul><li>Preprocessor </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Compiler </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Assembler </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Linker </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Loader </li></ul></ul></ul></ul>January 21, 2012 A.Alma Candida B.Sc.,MCA., DMI St.Eugene University
  6. 6. Steps for Language Processing System January 21, 2012 A.Alma Candida B.Sc.,MCA., DMI St.Eugene University
  7. 7. Pre Processor <ul><li>modules are stored in separate files. </li></ul><ul><li>source program is collected by a separate program. </li></ul>January 21, 2012 A.Alma Candida B.Sc.,MCA., DMI St.Eugene University
  8. 8. Compiler <ul><li>Source program is fed to a compiler. </li></ul><ul><li>Output- assembly-language program . </li></ul><ul><li>Assembly language is easier to produce as output. </li></ul><ul><li>easier to debug. </li></ul>January 21, 2012 A.Alma Candida B.Sc.,MCA., DMI St.Eugene University
  9. 9. Assembler <ul><li>Assembly language into relocatable machine code. </li></ul><ul><li>Large programs are compiled into small modules. </li></ul><ul><li>The relocatable machine code have to be linked together with other relocatable object files and library files . </li></ul><ul><li>This code actually runs on the machine. </li></ul>January 21, 2012 A.Alma Candida B.Sc.,MCA., DMI St.Eugene University
  10. 10. Linker <ul><li>Resolves external memory addresses, </li></ul><ul><li>The code in one file may refer to a location in another file. </li></ul>January 21, 2012 A.Alma Candida B.Sc.,MCA., DMI St.Eugene University
  11. 11. Loader <ul><li>Puts together all of the executable object files into memory for execution. </li></ul>January 21, 2012 A.Alma Candida B.Sc.,MCA., DMI St.Eugene University
  12. 12. Phases Of Compiler <ul><li>There are six different phases available in the compiler </li></ul><ul><ul><ul><ul><ul><li>Lexical Analysis </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>Syntax Analysis </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>Semantic Analysis </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>Intermediate Code Generation </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>Code Optimization </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>Code Generation </li></ul></ul></ul></ul></ul>January 21, 2012 A.Alma Candida B.Sc.,MCA., DMI St.Eugene University
  13. 13. Symbol-Table Management <ul><li>Data structure containing a record for each variable name, with fields for the attributes of the name. </li></ul><ul><li>Designed to allow the compiler </li></ul><ul><li>Find the record for each name quickly and to store or retrieve data from that record quickly. </li></ul>January 21, 2012 A.Alma Candida B.Sc.,MCA., DMI St.Eugene University
  14. 14. Lexical Analysis <ul><li>This is also called as Scanning . </li></ul><ul><li>It collects sequences of characters into meaningful units called tokens. </li></ul><ul><li>The text is read and divided into tokens. </li></ul><ul><li>Lexemes </li></ul><ul><li>Reads the stream of characters </li></ul><ul><li>Groups the characters into meaningful sequences called lexemes . </li></ul><ul><li>The output will be in the form of tokens. </li></ul>January 21, 2012 A.Alma Candida B.Sc.,MCA., DMI St.Eugene University
  15. 15. Lexical Analysis (cont..) <ul><li>General Form: </li></ul><ul><li>(token-name, attribute-value) </li></ul><ul><li>token-name -> an abstract symbol </li></ul><ul><li>attribute-value -> entry in the symbol table for this token. </li></ul>January 21, 2012 A.Alma Candida B.Sc.,MCA., DMI St.Eugene University
  16. 16. Example of Lexical Analysis <ul><li>position = initial + rate * 60 </li></ul><ul><li><id,1><=> <id,2><+><id,3><*><60> </li></ul><ul><li>Position - mapped into a token (id, 1) </li></ul><ul><ul><ul><ul><li>id ->identifier and 1 points to the symbol- table </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Assignment symbol = mapped into the token (=). </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Initial - mapped into the token (id, 2), </li></ul></ul></ul></ul><ul><ul><ul><ul><li>+ - mapped into the token (+). </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Rate mapped into the token (id, 3) </li></ul></ul></ul></ul><ul><ul><ul><ul><li>* mapped into the token (*) . </li></ul></ul></ul></ul><ul><ul><ul><ul><li>60 mapped into the token (60) </li></ul></ul></ul></ul>January 21, 2012 A.Alma Candida B.Sc.,MCA., DMI St.Eugene University
  17. 17. Syntax Analysis <ul><li>This is also called as Parsing . </li></ul><ul><li>Arrange tokens form of Tree called Syntax Tree . </li></ul><ul><li>Interior node ->operation </li></ul><ul><li>Child node ->Arguments of the operations. </li></ul><ul><li>Output -> Tree. </li></ul>January 21, 2012 A.Alma Candida B.Sc.,MCA., DMI St.Eugene University
  18. 18. Syntax Analysis(cont..) <ul><li>Consider the example </li></ul><ul><ul><ul><li>position = initial + rate * 60 </li></ul></ul></ul><ul><ul><ul><li>The Syntax tree is in the form of </li></ul></ul></ul>January 21, 2012 A.Alma Candida B.Sc.,MCA., DMI St.Eugene University
  19. 19. January 21, 2012 A.Alma Candida B.Sc.,MCA., DMI St.Eugene University
  20. 20. Semantic Analysis <ul><li>Convert from one data type to another. </li></ul><ul><li>Example: </li></ul><ul><ul><ul><li>position=initial + rate*60 </li></ul></ul></ul><ul><ul><li>position, initial, and rate have been declared to be floating-point numbers, and that the lexeme 60 by itself forms an integer. </li></ul></ul><ul><ul><li>the integer may be converted into a floating-point number. </li></ul></ul><ul><ul><li>the output -> has an extra node for the operator inttofloat , which explicitly converts its integer argument into a floating-point number. </li></ul></ul>January 21, 2012 A.Alma Candida B.Sc.,MCA., DMI St.Eugene University
  21. 21. Intermediate Code Generation <ul><li>translated to a simple machine-independent intermediate language. </li></ul><ul><li>Convert into low level language </li></ul><ul><li>The output -> three-address code sequence. </li></ul><ul><li>Example: </li></ul><ul><li>tl = inttofloat (60) </li></ul><ul><li>t2 = id3 * tl </li></ul><ul><li>t3 = id2 + t2 </li></ul><ul><li>id1 = t3 </li></ul>January 21, 2012 A.Alma Candida B.Sc.,MCA., DMI St.Eugene University
  22. 22. Code Optimization <ul><li>Attempts to improve the intermediate code so that better target code will result. </li></ul><ul><li>Its is in the form of shorter sequence. </li></ul><ul><ul><ul><li>t1=id3*60.0 </li></ul></ul></ul><ul><ul><ul><li>id1=id2+t1 </li></ul></ul></ul>January 21, 2012 A.Alma Candida B.Sc.,MCA., DMI St.Eugene University
  23. 23. CODE GENERATION <ul><li>Input an intermediate representation of the source program and maps it into the target language. </li></ul><ul><li>Target language is machine code, registers or memory locations are selected for each of the variables used by the program. </li></ul><ul><li>Registers R1 and R2, the intermediate translated into the machine code </li></ul><ul><li>LDF R2, id3 </li></ul><ul><li>MULF R2, R2, #60.0 </li></ul><ul><li>LDF Rl, id2 </li></ul><ul><li>ADDF Rl, Rl, R2 </li></ul><ul><li>STF idl, Rl </li></ul>January 21, 2012 A.Alma Candida B.Sc.,MCA., DMI St.Eugene University
  24. 24. PHASES OF THE COMPILER January 21, 2012 A.Alma Candida B.Sc.,MCA., DMI St.Eugene University
  25. 25. January 21, 2012 A.Alma Candida B.Sc.,MCA., DMI St.Eugene University

×