1 2 0 4 8 com pilers i i 1 2 0 4 8 com pilers i i
play

1 2 0 4 8 Com pilers I I 1 2 0 4 8 Com pilers I I Computer - PowerPoint PPT Presentation

1 2 0 4 8 Com pilers I I 1 2 0 4 8 Com pilers I I Computer Science Engineering, 8 semester Mandatory, 2 Cycle Theoretical credits: 3.0 Theoretical credits: 3.0 Lab credits: 1.5 Lab credits: 1.5 Theory: Jos Neira Labs: David


  1. 1 2 0 4 8 Com pilers I I 1 2 0 4 8 Com pilers I I Computer Science Engineering, 8º semester Mandatory, 2º Cycle Theoretical credits: 3.0 Theoretical credits: 3.0 Lab credits: 1.5 Lab credits: 1.5 Theory: José Neira Labs: David Ken Vallejo, Javier Fabra, Luis Carlos Gallego 1 2 0 4 8 - J. Neira – University of Zaragoza 1

  2. Schedule Schedule Compilers II Year 2007-2008 Monday Tuesday Wednesday Thursday Friday 8-9 A 9-10 A 10-11 11-12 C C Tutoring 12-13 Tutoring 13-14 Tutoring 14-15 15-16 16-17 Tutoring 17-18 Tutoring 18-19 Tutoring B 19-20 B 20-21 1 2 0 4 8 - J. Neira – University of Zaragoza 2

  3. 1 2 0 4 8 , English group ( C, 4 6 ) 1 2 0 4 8 , English group ( C, 4 6 ) • Classes – Classes will be taught in English – Slides are available in Spanish and English – Students can ask questions in Spanish or English – Students can answ er questions in Spanish or English http://webdiis.unizar.es/~neira/ • Lab w ork: – Lab instructions will be in Spanish – Review ing will be in Spanish • Exam s: – Exam s will be in Spanish – Students can answer in Spanish 1 2 0 4 8 - J. Neira – University of Zaragoza 3

  4. Prelim inaries Prelim inaries • Compilers I y II: ‘Front-ends’ ‘Front-ends’ ‘Back-ends’ ‘Back-ends’ C 68000 C++ 80386 ADA Compiler SPARC Fortran .... .... Analysis Analysis Synthesis Synthesis Compilers I: Compilers II: theory pragmatics • Lexical analysis • Semantic analysis • Syntactic analysis • Code generation • Optimization 1 2 0 4 8 - J. Neira – University of Zaragoza 4

  5. Prelim inaries Prelim inaries • Prerequisites: – 1 2 0 2 5 Languages, Gram m ars y Autom ata – 1 2 0 4 4 Com pilers I Context free unambiguous LR(k) • Grammars: LR(1) LALR(1) SLR(1) LR(0) regular • What should I know beforehand? – Lexical analysis using lex – Syntax analysis using yacc 1 2 0 4 8 - J. Neira – University of Zaragoza 5

  6. Prelim inaries Prelim inaries • What should I know • Prerequisites: beforehand? – 12015 Computer – Elements of an Architecture architecture – Instruction set Activation block – Addressing modes local m local 1 Parameter n STC n push(n) SRF n1 n2 push(display[DP - n1] + n2) + 4 DRF push (frames[pop()]) + 3 Parameter 1 ASG frames[pop 2 ()] = pop 1 () + 2 Return address ASGI frames[pop 1 ()] = pop 2 () Size of static link of + 1 outer block (l) BP Dynamic link display p display p-1 l display p-l+1 1 2 0 4 8 - J. Neira – University of Zaragoza 6

  7. Prelim inaries Prelim inaries • Prerequisites: • What should I know beforehand? – 12021 Algorithms and data structures: – Tree structures – Search algorithms Sym bol tables » Hashing, … . program main { 1 Λ X 2 X int W; int X; W 2 W 1 A 0 void A() { Z 1 Λ int W; int Y; Λ int Z; Λ void B() { int X ; ... } A 1 Λ B 2 void C() { int X; int Y ;...} ... Λ W 2 W 1 C 1 } - end of A void D() { int Z ; ... } } 1 2 0 4 8 - J. Neira – University of Zaragoza 7

  8. Prelim inaries Prelim inaries • What can I learn? – Sem antic analysis using yacc (use of attributes) – Code generation for stack machines – General techniques for code optim ization • What is left out? – I nterpreters » Other execution modes – Debuggers » Increase efficiency in use of space » Increase efficiency in execution time – Unassem blers » Software recovery 1 2 0 4 8 - J. Neira – University of Zaragoza 8

  9. Prelim inaries: program Prelim inaries: program • I ntroduction • Part 1 : Sem antic analysis – Lesson 1: Symbol tables – Lesson 2: Type checking – Lesson 3: Semantic analysis using attributed grammars • Part 2 : Code generation – Lesson 4: Abstract machines – Lesson 5: Generation of intermediate code – Lesson 6: Code optimization • Exercises and problems in each lesson 1 2 0 4 8 - J. Neira – University of Zaragoza 9

  10. Lab w ork Lab w ork 5 sessions 3 hour sessions in 5 sessions 3 hour sessions in • Practical credits: 1.5 merlin (L0.04, Building A) merlin (L0.04, Building A) Compiladores II Curso 2007-2008 Lunes Martes Miércoles Jueves Viernes 8-9 9-10 10-11 11-12 Pr 3,6 Pr 1,2 12-13 Pr 3,6 Pr 1,2 13-14 Pr 3,6 Pr 1,2 14-15 15-16 Pr 4,5 Pr 7,8 16-17 Pr 4,5 Pr 7,8 17-18 Pr 4,5 Pr 7,8 18-19 19-20 20-21 1 2 0 4 8 - J. Neira – University of Zaragoza 10

  11. Lab w ork Lab w ork • Teachers • Javier Fabra – Acerete to Dom inguez • Luis Carlos Gallego – Elbal to Muro • David Ken Vallejo – Noé to Viñuales 1 2 0 4 8 - J. Neira – University of Zaragoza 11

  12. Lab w ork Lab w ork • What is done in lab work in Compilers I I ? – A Pascual Compiler to P(ortable) Code – A P Code assemblers – A P Code interpreter • W e have chosen Pascal even if: Why Pascal is Not My Favorite Programming Language Brian W. Kernighan, AT&T Bell Laboratories, 1981 – It is a reasonably simple but complete subset of Pascal • W e have chosen the P m achine because: Algorithms + Data Structures = Programs N. Wirth, P-H 1976 – Code generation is very simple – Stack machines are in use at present 1 2 0 4 8 - J. Neira – University of Zaragoza 12

  13. Lab w ork w ork : : com m ents com m ents Lab • Lab work is individual • Learn from your colleagues, they are your best resource. • You know perfectly well what constitutes copying • Everything you submit must be your ow n • Copying in lab work means grade 0 in lab work 1 2 0 4 8 - J. Neira – University of Zaragoza 13

  14. Evaluation Evaluation • Final grade: if (exam >= 5) and (lab_work >= 5) then if (exam >= 5) and (lab_work >= 5) then grade := exam * 0.6 + lab_work * 0.4; grade := exam * 0.6 + lab_work * 0.4; else else grade := ’Suspenso’; grade := ’Suspenso’; end end • You must pass BOTH lab work and one exam 1 2 0 4 8 - J. Neira – University of Zaragoza 14

  15. Evaluation Evaluation • Lab w ork: – Submit the day specified in the instructions – W e penalize late lab work (one point per week, or fraction, maximum 5 weeks of delay). – If lab work is ok, the m inim um grade will be 5 .0 – Lab grades are valid for all exams – Lab work is different for each exam • Exam : – Grade only valid for one exam – If you pass the exam but not the lab work, your grade will be fail (you will have to take another exam and submit new lab work). – No notes, books, exercises… 1 2 0 4 8 - J. Neira – University of Zaragoza 15

  16. Bibliography Bibliography Compiladores: principios, técnicas y Compiladores: principios, técnicas y herramientas. A. Aho, R. Sethi, J. herramientas. A. Aho, R. Sethi, J. The dragon book The dragon book Ullman. Addison-Wesley Iberoamericana, Ullman. Addison-Wesley Iberoamericana, 1993 1993 Advanced Compiler Design and Implementation. Advanced Compiler Design and Implementation. The whale book S.S. Muchnick. Morgan Kaufmann Publishers, The whale book S.S. Muchnick. Morgan Kaufmann Publishers, 1997 1997 Programming Language Pragmatics. M.L. Scott. Programming Language Pragmatics. M.L. Scott. Morgan Kaufmann Publishers, 2000 Morgan Kaufmann Publishers, 2000 State of the art State of the art Engineering a Compiler. K.D. Cooper & L. Engineering a Compiler. K.D. Cooper & L. Torczon. Morgan Kaufmann Publishers, 2004 Torczon. Morgan Kaufmann Publishers, 2004 lex & yacc. J. Levine, T. Mason, D. lex & yacc. J. Levine, T. Mason, D. Reference manual Reference manual Brown. O’Reilly & Associates, 1992 Brown. O’Reilly & Associates, 1992 1 2 0 4 8 - J. Neira – University of Zaragoza 16

  17. More inform ation at More inform ation at • Web page: http: / / www.cps.unizar.es/ ~ neira/ compii.htm • Anillo Digital Docente: http: / / add.unizar.es • Moodle: http: / / moodle.unizar.es 1 2 0 4 8 - J. Neira – University of Zaragoza 17

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend