Syllabus
CSCI 5220
Program Translation and Compiling
Spring 2003

Class meeting 8:00pm-9:15pm MW Austin 304
Instructor Karl Abrahamson
Office Austin 233
Office hours MW 12:45-2:00;
Tu 9:45-11:00;
Th 6:45pm-8:00pm
or by appointment
Phone 328-1879
Email karl@cs.ecu.edu
Course web page www.cs.ecu.edu/~karl/5220/spr03/
My web page www.cs.ecu.edu/~karl/
Text Compilers: Principles, Techniques and Tools by Alfred V. Aho, Ravi Sethi and Jeffrey D. Ullman


Prerequisites

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


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 using popular tools.


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. (Text, Chapters 1 and 2)

  2. Lexical analysis. The role of the lexical analyzer. Finite state machines. Regular expressions. Lexical analysis tools and lexer generators. (Text, Chapter 3)

  3. Context-free grammars. Writing grammars for programming languages. Transformations on grammars. (Text, Chapter 4)

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

  5. Table management. The symbol table.

  6. Intermediate code and abstract machines. (Text, Chapter 8)

  7. Semantic-based translation using syntax trees. (Text, Chapter 5 and 8)

  8. Syntax-directed translation. Attributes grammars. (Text, Chapter 5 and 8)

  9. Semantic analysis. Type checking. (Text, Chapter 6 and 7)

  10. Back-end analysis and improvement. Code generation. Elementary optimizations. Basic blocks. Dataflow analysis. (Text, Chapter 9, 10)


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 Brewster A-114, to verify the disability before any accommodations can occur. The telephone number is 252-328-6799.