210 likes | 509 Views
Compiler Construction Course at University of Montenegro. 7 th Workshop on “Software Engineering Education and Reverse Engineering”, Risan, 9 – 14. Sep. 2007. Agenda. History Module structure Workload Learning outcomes Lectures and practicals Recommended books Future. History (1).
E N D
Compiler Construction Course at University of Montenegro 7th Workshop on “Software Engineering Education and Reverse Engineering”, Risan, 9 – 14. Sep. 2007. Goran Šuković, University of Montenegro
Agenda • History • Module structure • Workload • Learning outcomes • Lectures and practicals • Recommended books • Future
History (1) • Started in 1988 – professor Ratko Orlandić • one-semester elective module for4th year students, Mathematics and Computer Science programme • 2 lectures + 2 practicals per week • From 1993 – compulsory module
History (2) • 2001 – first major revision • one-semester compulsory module for 3rd year students, academic studies, Computer Science programme, Mathematics and Computer Science programme, and also applied studies • 3 lectures + 2 practicals per week • 2006 – new revision, 2 lectures + 2 practicals, 5 ECTS credits, starting in 2008
Why to study compilers? • The number of people who write compilers is small, so why is a module about compiler construction a compulsory part of a computer science course? • One reason is that, though few graduates of the course will end up writing compilers, all will have to use them • Many of the techniques used in compilers have application in other areas such as dialogue and human-computer interface design
Module structure • Number of ECTS credits: 6 • Prerequisite knowledge • Students must have a prior knowledge of programming in C • Prerequisite modules • Programming I • Programming II
Taken by • academic studies, Computer Science programme • academic studies, Mathematics and Computer Science programme • applied studies, Information technologies programme
Workload • Lectures: 14 x 2 hr 15 min lectures. • Practicals: 14 x 1 hr 30 min practical. • Private study: 74.5 hrs. • Assessment: • Midterm – 3 hours written exam (worth 35 marks) • Final – 3 hours written exam (worth 35 marks) • Homeworks – 6 HW (worth 4 marks each) • Quizzes – 3 quizzes (worth 2 marks each)
Learning Outcomes (1) • The aim of this module is to introduce the student to the theory and practice of programming language compilation • It works through the “front end” of compilation: lexical and syntax analysis. By the middle of the module the student will be in a position to write a lexical scanner and a parser for a context-free language, including the use of compiler tools • Student will also have a solid understanding on the underlying theory of formal languages
Learning Outcomes (2) • Student should have a better appreciation of good programming practice in terms of program compilation • Student should be able to describe compiler construction methods and algorithms, and especially apply them to examples • Student be able to implement the "back end" of a compiler for a simple programming language using the techniques presented in the lectures
Learning Outcomes (3) • Student assess the advantages of standard programming language features with respect to their implementation and performance costs • Student read critically a programming language specification
Content – Lectures (1) • Introduction to compiling • Automata. Regular expressions. Intro to lexical analysis • Lexical analysis. Flex. Grammars and languages • Top-down parsing • Bottom-upparsing. LR(0), LR(1), and SLR(1) • LALR parsers • Syntax-directed translation
Content – Lectures (2) • Semantical analysis. Type checking for imperative languages • Run-time organization • Object-oriented languages • Intermediate languages • Code generation • Program analysis and transformation • Dataflow analysis • Loop optimization. Register allocation
Content – Practicals (1) • DFA and NFA • Regular expressions. Transforming regular expressions to NFA • Transforming NFA to DFA. Minimizing number of states in DFA • FLEX examples • Writing and transforming context-free grammars
Content – Practicals (2) • BISON examples • Intermediate code examples • Overview of MIPS • Using SPIM • Generating MIPS from AST
Homeworks • 1st HW – Automata • 2nd HW – Flex for Decaf • 3rd HW – Grammars and languages • 4th HW – Building AST for Decaf using Bison • 5th HW – Semantic analyzer for Decaf • 6th HW – MIPS Code Generation
Recommended Books • Torczon, Cooper -Engineering a Compiler, Morgan Kaufmann 2002 • Aho A.V. et al. - Compilers: Principles, Techniques and Tools, 2nd Edition, Addison Wesley 2006 • Andrew W. Appel - Modern Compiler Implementation in C/Java/ML, Cambridge University Press 1998/2002 • D Grune et al. - Modern Compiler Design, Wiley 2000
Teaching Materials • Notes and exercise sheets are provided • Copies of slides and examples used in lectures can be downloaded from the module web page • Information and feedback are posted on the module web pages (www.pmf.cg.ac.yu)
Student' remarks • Practicals/exams/lecturer are too demanding • Programming in C is very hard • I need more time for homeworks • I don't know how to use pointers in C... read data from files ... start Flex ...
Future • From 2008 • Substantial reduction of lectures • Less demanding homeworks • Using Java instead C • Using JLex and JBison instead Flex and Bison • MIPS or x86 or ... • More information • www.pmf.cg.ac.yu • compilers@rc.pmf.cg.ac.yu