Middle East Technical University CENG introductory compiler course
This is the website of the course when I teach it.
Term: Fall 2022 (for the academic year 2022-2023)
Instructor: Cem Bozsahin (Cogsci). TA: Cem Onem (CEng).
Office hours: Open door except lecture days TWTh (my office is B-209 at Informatics, tel: 7758)
Course hours: W 14.40-16.30, Th 15.40-17.30 Room BMB-2 (CENG building).
The course is 3 lecture hours, not 4. I asked for two two-hour slots for flexibility.
We will probably do 75 minutes without break each day, something like W14.40-15.55 Th15.40-16.55.
If there is course clash, we can try 2+1 or 1+2 on WTh. We'll discuss this in FIRST class.
(So please attend first class, whether you are registered or not.)
Textbook: Compilers: Principles, Techniques and Tools. Aho, Lam, Sethi, Ullman (2007). Addison-Wesley/Pearson. 2nd Edition of the Dragon Book.
The first edition was a classic in CS, and 2nd edition adds more to the legend.
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.
Informatics Students: Please contact me DURING REGISTRATION so that I can tell you whether you are eligible for the course, and to inform CENG department in time for them to open a quota for you.
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 TWO tools for compiler design: (1) sly.py
(which is lex and yacc in python; see the bottom of this page for sly install), (2) Spike for RISC-V code generation.
In-class labs introduce sly.py and RISC-V.
We will give you a newly designed PL. You will write a compiler for it.
The first part of the project uses sly to do lexical analysis and parsing into abstract syntax trees.
The second part of the project includes code generation and execution, in
RISC-V, using Spike
. (We also accept LLVM, MIPS, x86 code generation; however, these
you have to do without expecting too much help from us.)
Grading:
- Mid-term exam: %20 ( in class)
- mini-project 1 (lex analysis and parsing into abstract syntax trees): %25
- mini-project 2 (code generation and execution): %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.
2022-2023 Gazozuna Kompaylır ödülü:
- Lütfullah Erkaya: Vox -> sly -> RISC-V
Tebrikler!
- Cem Bozşahin, Cem Önem