Syllabus
CSCI 5220
Program Translation and Compiling
Section 001
Spring 2006

Class meeting 2:00-3:15 TTh, Austin 306
Instructor Karl Abrahamson
Office Sci&Tech C-113
Office hours
Tu,W,Th 9:30-10:30am
Tu,Th 5:30-6:30pm
or by appointment
Phone 328-9689
Email abrahamsonk@ecu.edu
Course web page www.cs.ecu.edu/~karl/5220/spr06/
My web page www.cs.ecu.edu/~karl/
Text Modern Compiler Design by D. Grune, H. E. Bal, C. J. H. Jacobs and K. G. Langendoen


Prerequisites

You should have a good understanding of programming and be able to write well structured and well organized programs in C++ or Java.


Introduction

The first real compilers were written in the 1950s. Compiler developers had a poor understanding of what they were doing, and did everything in an ad-hoc way. The popular wisdom was that it took 30 person-years to write a compiler, even for a very simple programming language such as early versions of Fortran. (Considering the state of the art at the time, the compiler developers did a remarkably good job. Their code optimizers produced excellent machine code.)

There is probably no aspect of software development that has benefited from developments of the last 35 years more than the construction of compilers. Developments in the theory of computing have led directly to very powerful tools that not only make compiler writing much easier than it once was, but are also useful for other kinds of software. It is now feasible to write a compiler for a small programming language as a course project.

It is useful for a computer scientist to study compiler design for several reasons.

  1. Anyone who does any software development needs to use a compiler. It is a good idea to understand what is going on inside the tools that you use, in order to have a better understanding of their capabilities and their limitations.

  2. Compilers are sophisticated text processors. Most programs need to do some text processing, even if only to read in the contents of a configuration file. Techniques that were developed for writing compilers are useful in a variety of other software.

  3. One of the more useful techniques for software design for large projects is to develop a special-purpose language that makes the project easy to implement. It can take less time and effort, and lead to a higher quality product, to spend the time to develop and implement a small special purpose language and to write the software in that language, than to write the software in a general purpose language.

  4. Compilers benefit tremendously from careful analysis of a problem, and from tools for performing that analysis. A study of compiler design gives a good feeling for how a large problem can be broken down and solved in a manner that is not ad-hoc.

  5. Compiler design makes use of formal methods that are rarely seen elsewhere except when fairly difficult formal methods are used for general purpose software design. The study of compilers provides a gentle introduction to formal methods.

  6. A course in compilers offers a good opportunity to get experience with a larger piece of software.


Course objectives

The student should understand both the theory and practice of compiler design, and be able to implement a complete compiler for a small programming language.


Topics

This course covers principles and practice of writing compilers. Topics will be as follows.

  1. Overview of compilers. The compilation process and the anatomy of a compiler. Bootstrapping.

  2. Lexical analysis. The role of the lexical analyzer. Finite state machines. Regular expressions. Lexical analysis tools and lexer generators.

  3. Context-free grammars. Writing grammars for programming languages. Transformations on grammars.

  4. Parsing. Top-down predictive parsing and LL(1) grammars. Table-driven parsers. Bottom-up parsing, SLR(1), LR(1) and LALR(1) parsers. Parser generators.

  5. Table management. The symbol table.

  6. Intermediate code and abstract machines.

  7. Semantic-based translation using syntax trees.

  8. Syntax-directed translation. Attributes grammars.

  9. Semantic analysis. Type checking.

  10. Back-end analysis and improvement. Code generation. Elementary optimizations. Basic blocks. Dataflow analysis.


Attendance policy

I will not take attendance. It is up to you to attend class. You are responsible for announcements and assignments given in class. If you miss a class, it is up to you to obtain notes and any other information that was provided in the class. Excuses that you did not know about something because you did not come to class and did not obtain the information will not count for anything at all.

Those who choose not to attend class can count on doing poorly in this course. If you choose not to attend class, then you must live with the consequences of that decision, however bad they are.

No incompletes will be issued in this course except for extraordinary circumstances, and even then only if you are nearly done already, and have done work of acceptable quality that it is realistic that you can pass the course.


Grading

Grading will be based on two midterm exams (16% each), a final exam (28%), and programming projects (40%). Although you may discuss your project with others, your work is expected to be your own. Do not write your project in teams.


Weather emergencies

In the event of a weather emergency, information about ECU can be accessed through the following sources:

ECU emergency notices http://www.ecu.edu/alert
ECU emergency information hotline 252-328-0062


Students with disabilities

East Carolina University seeks to comply fully with the Americans with Disabilities Act (ADA). Students requesting accommodations based on a covered disability must go to the Department for Disability Support Services, located in Slay 138, to verify the disability before any accommodations can occur. The telephone number is 252-737-1016.