Middle East Technical University CENG introductory compiler course
This is the website of the course when I teach it.
Term: Fall 2019
Instructor: Cem Bozsahin. TA: none.
Office hours: Open door except lecture days (i.e. except TTh this term; my office is B-209 at Informatics, tel: 7758)
Course hours: T/8.40/9.40, Th/8.40/9.40 at BMB-2 (CENG building)
We will actually do 75 minutes without break each day. The course is not 200 minutes!
Textbook: Engineering a compiler, by Keith Cooper and Linda Torczon, 2nd ed, Morgan Kaufmann, 2012.
This is a professional reference, used throughout the world. We will cover a fragment of it, and it's great for future reference if you are into this sort of CS-ey things.
Catalog description: Formal description and classification of programming languages. Syntactic specification. The parsing problem. Top-down and bottom-up parsing. Attaching semantics to syntax. Translator writing systems. Translator writing case study.
Course objectives: Assuming familiarity with formal grammars, i.e., Ceng280 material, we emphasize modern tools and techniques for compiler construction, which can be used for any task of mapping from one formal representation to another.
Course prerequisite: Officially, none, according to METU catalog. Unofficially, you need to feel comfortable with programming, data structures, and formal languages. 3rd-year standing in CS, or CENG280 in the bag, or COGS501 and COGS502 will suffice.
Course outline
- Introduction: a walk through all stages of compiling (1 week)
- Scanning (lexical analysis) (1)
- Parsing (syntactic analysis) (3)
- Intermediate code (1)
- Virtual machines (1)
- Code generation (syntax-directed derivation/description---SDD) (1)
- Scope handling and run-time (1)
- A preview of compiling functional languages (2)
Course conduct: 11 weeks of lecture, 2 weeks of in-class labs; 1 week in-class exam; 2 programming projects; no extra homework.
We will use 4 tools for compiler design, (1) antLR
for LL, (2) LALR parser of Mark Johnson for LR, (3) spim
for MIPS code generation, or
(4) Spike
for RISC-V code generation.
There is an interface to LALR parser written by me, called yalalr.
In-class labs introduce antLR, yalalr, MIPS/spim, RISC-V, and a bit of Lisp.
The second project includes code generation and execution, using MIPs architecture simulator called spim. We also look at a public-domain RISC, RISC-V, using Spike.
Grading:
- Mid-term exam: %25 ( 26.11.2019, in class)
- mini-project 1 (LL parsing and abstract syntax trees): %20
- mini-project 2 (LALR parsing and code generation): %35
- Final exam: %20
- Gazozuna Kompaylır Ödülü : priceless!!
Highest honour we give out to best successful completion of the second project.
It is, ehm, officially recognized,
and those who are in the know reading your CV at least in Turkey would know what you achieved.
Usually handed by the end of first spring term after completion, with a ceremony!
You will be a proud owner of 4 bottles of a yerli ve milli soft drink,
with a certificate in a low-budget print, namely my handwriting.
And, since you asked, we can't afford 444 bottles; or 44, in fact.
2019-2020 Gazozuna Kompaylir odulleri:
- Yunus Can Cakir: bison/flex -> LLVM
- Emre Gullu: yalalr -> MIPS
- Ozan Akin : rust -> x64
tebrix!