Compiler Structures 0. Preliminaries 240-437, Semester 2, 2018-2019 0. Preliminaries Please ask questions Who I am: Andrew Davison CoE, Info. Eng. Research Lab (WiG Lab) ad@fivedots.coe.psu.ac.th Objective to give some background on the course
Overview 1. Why Study Compilers? 2. Course Objectives 3. Prerequisites 4. Meeting Time / Location 5. Workload 6. Course Materials 7. Further Information
1. Why Study Compilers? Compilers use techniques from many areas of Comp. Eng. These include: data structures & algorithms formal languages (e.g. REs, grammars) computer architecture programming language design
Compiler-related Tools are Everywhere Editors (syntax highlighting) Small languages (e.g. game scripting) Pretty printers (e.g. doxygen) Static checkers (e.g. lint) Text formatters (e.g. LaTeX) Silicon compilers (e.g. VHDL) Query interpreters/compilers (databases)
2. Course Objectives By the end of the course, a student will: Know how to build a compiler for a (very simplified) C-like programming language. Know how to use compiler construction tools, such as generators for scanners and parsers. continued
Be able to write LL(1) and LALR(1) grammars (for new languages). Be familiar with code generation. Be familiar with virtual machines.
Main Topics Lexical Analysis (lex) Syntax Analysis Attribute Grammars top-down, bottom-up (yacc) Attribute Grammars Semantic Analysis (parse trees) Intermediate Code Generation for expressions and loops
3. Prerequistes You must have passed 240-207 “Computer Programming Techniques” or something similar this subject requires you to have a good knowledge of C/C++ all the code examples are in C, on Linux
4. Meeting Time / Location ?? ??– ?? ?? In the first 1-2 weeks of semester, you can ask me to change the meeting times a majority of the class must agree
Non-Attendence Penalty I may take registration at the start of a class. If someone is not there, they lose 1% (unless they have a good excuse). A maximum of 10% can be lost deducted from your final mark
5. Workload (% of total score) 4 Exercises: 50% total Exercise 1 (lexical), week 4, 10% Exercise 2 (syntax), week 7, 10% Exercise 3 (semantics), week 13, 15% Exercise 4 (parse trees), week 15, 15% continued
Mid-term exam: 25% (2 hours) week 9 Final exam: 25% (3 hours) weeks 17-18
6. Course Materials I will only hand out the exercises. Print out and BRING TO CLASS. I will only hand out the exercises. All the handouts (and other materials, such as code examples) will be placed on-line at http://fivedots.coe.psu.ac.th/ Software.coe/Compilers/
Textbooks In our library Compilers: Principles, Techniques and Tools by Aho, Sethi, and Ullman Addison-Wesley Lex and Yacc by Levine, Mason, and Brown O'Reilly; 2nd edition
7. Further Information awesome-compilers Let's Build a Compiler list of learning materials, tools, frameworks, technologies and code projects https://github.com/rsumner31/ awesome-compilers Let's Build a Compiler by Jack Crenshaw a good, less technical introduction to compiler construction http://compilers.iecc.com/crenshaw/