Compiler Design
CSCI 412, Section 01
Spring Semester 2007
Instructor
| John I. Moore, Jr. |
Phone: 843-953-7882 |
| Office: Thompson Hall 230 |
E-mail: john.moore@citadel.edu |
Course Description
This course explores the basic principles, algorithms, data structures, and tools
involved in the design and construction of compilers. Topics include formal
grammars, lexical analysis, parsing algorithms, semantic analysis, error recovery,
code generation, and optimization. Each student will be required to complete a
substantial programming project, the implementation of a compiler for a small
programming language.
Prerequisite
Formal Prerequisite: CSCI 355
Informal Prerequisite: Strong background in data structures, algorithms,
basic software engineering concepts, and both high-level and low-level
programming languages. If you have mastered the concepts in both CSCI 305
(Computer Organization and Programming) and CSCI 223 (Data Structures and
Algorithms), you should be able to perform well in this course.
Learning Outcomes
Upon successful completion of this course, a student will
- Understand the formalisms and techniques used in the specification
of programming languages (regular expressions, context-free grammars,
contextual constraints, etc.)
- Be able to analyze context-free grammars to compute first and follow sets
- Understand the basic structure of a compiler in terms of its functional
components (lexical analysis, syntax analysis, semantic analysis, error
handling/recovery, code generation, and optimization)
- Have completed a major programming project, the design, implementation,
and testing of a compiler for a small programming language
- Have gained a deeper understanding of the basic principles of software
design and object-oriented programming
Textbook
David A. Watt and Deryck F. Brown, Programming Language Processors in Java:
Compilers and Interpreters, Prentice Hall, 2000.
Also: Course Notes and Handouts
Compiler References
- [Aho 2006] Alfred V. Aho, Monica S. Lam, Ravi Sethi, Jeffrey D. Ullman, Compilers:
Principles, Techniques, And Tools (Second Edition – a.k.a. Purple Dragon),
Addison Wesley, 2006.
- [Appel 2002] Andrew W. Appel, Modern Compiler Implementation in Java
(Second Edition), Cambridge University Press, 2002.
- [Brinch Hansen 1985] Per Brinch Hansen, Brinch Hansen on Pascal
Compilers, Prentice-Hall, 1985.
- [Elder 1994] John Elder, Compiler Construction: A Recursive Descent
Model, Prentice-Hall, 1994.
- [Mak 1996] Ronald Mak, Writing Compilers and Interpreters: An Applied
Approach Using C++ (Second Edition), John Wiley & Sons, 1996.
- [Wirth 1996] Niklaus Wirth, Compiler Construction, Addison Wesley,
1996. (available online at
http://www.oberon.ethz.ch/WirthPubl/CBEAll.pdf)
Programming Project
This course requires that each student complete a major programming project,
the design and implementation of a small compiler. The project will be graded
primarily on completeness and correctness, but other factors such as overall
design and structure will also affect your project grade. The project must
be demonstrated during the time period allocated for the final exam. More
details on the grading criteria for the project will be discussed in class
as the course progresses.
Class Schedule
MWF 9:00-9:50, Thompson Hall 216.
Grading
The final grade for the course is based on 5 grades as follows:
- Two assigned in-class tests. Each test counts as a separate grade.
- Daily quizzes and minor assignments – collectively count as 1 grade.
(Lowest two quiz grades will be dropped.)
- Programming project – counts as 3 grades.
- Lowest grade from above 6 grades will be dropped. If the lowest grade is the
programming project, only one of the three grades will be dropped.
Miscellaneous Grading Policies
- Students are required to work individually or with approved team members
on all work done outside of class. Assistance from anyone other than the
instructor, a librarian, the writing center staff, or an approved team
member is forbidden.
- Daily quizzes will come directly from the material covered in the
previous day's class.
- Homework will be assigned but not collected; however, daily quizzes
will often be based on homework assignments.
- Class attendance and participation can influence borderline grades.
- A total of nine absences will result in a course grade of F. With respect
to this policy, three lates count as an absence. In addition, if you are
late by 15 minutes or more, you will be considered absent.
- Incomplete grades are given only in unusual circumstances. Consult the
catalog for policy on incomplete work.
Office Hours
| Monday |
1:00-2:30 p.m. |
| Tuesday |
1:00-2:30 p.m. |
| Wednesday |
10:00-12:00 a.m. |
| Thursday |
1:00-2:30 p.m. |
Other times by appointment
Important Dates
| Jan. 15 |
Martin Luther King, Jr. Holiday (no classes) |
| Feb. 16 |
Test #1 |
| Mar. 7 |
Last day to withdraw with a grade of “W” |
| Mar. 26-30 |
Spring Break (Work on project during break.) |
| Apr. 9 |
Test #2 |
| Apr. 26 |
Final Exam Period/Project Demonstrations 1:00-4:00 p.m. |
Expectations
- Do not miss the assigned tests without a valid excuse! Missing an
assigned test without a valid excuse will result in a grade of zero
for that test. The instructor gets to determine whether or not an
excuse is valid. In particular, guard duty is not an acceptable
excuse for missing an assigned test. When possible, students should
notify the instructor in advance if they will be unable to take an
assigned test. All make-up tests will be given outside of normal
class time. Once a test has been given in class, any subsequent
make-up tests may differ significantly.
- Show up for class on time and prepared. That means that you have read
the appropriate sections from the book plus any handouts, and you have
worked all assigned homework. If a test has been assigned, you should
be prepared to take the test. If you were late to class or absent from
the previous class meeting, you are responsible for getting class notes
and assignments from another student in the class or from the
instructor.
- If you are late to class, it is possible that you have already been marked
absent by the time you arrive. It is your responsibility to notify the
instructor after class that you were late rather than absent.
- Take care of any personal needs outside of class time. Except for
emergencies, you should not need to go to the bathroom, get a drink of
water, etc. If you need to leave the room at any time while class is
in session, you should ask for permission.
- There should be no personal conversations or moving around during
class without explicit permission. These actions are disturbing to
other students and to the instructor. Be courteous and respect the
rights of others.
- You should respect the property of your college. No eating, drinking
(other than water), smoking, dipping, chewing tobacco, etc. in the classrooms.
Also, no writing or carving on the desks, chairs, podium, etc. Any willful
vandalism or destruction of Citadel property will be dealt with severely.
Daily Schedule
| Dates |
Topics Covered |
| Jan. 10-12 |
Overview of Compilers and Language Translation |
| Jan. 15 |
Martin Luther King, Jr. Holiday (no classes) |
| Jan. 17 |
Structure of Compilers |
| Jan. 19-22 |
Context-Free Grammars |
| Jan. 24 |
Definition of the Programming Language CPL |
| Jan. 26-31 |
Lexical Analysis (Scanning) |
| Feb. 2-7 |
Syntax Analysis (Recursive Descent Parsing) |
| Feb. 9 |
Error Handling/Recovery |
| Feb. 12-14 |
Brief Review of Java and Object-Oriented Programming |
| Feb. 16 |
Test #1 |
| Feb. 19-26 |
Abstract Syntax Trees |
| Feb. 28-Mar. 5 |
Constraint Analysis |
| Mar. 7 |
The CPL Virtual Machine |
| Mar. 9-14 |
Run-Time Organization |
| Mar. 16-23 |
Code Generation |
| Mar. 26-30 |
Spring Break (Work on project during break.) |
| Apr. 2-4 |
Optimization |
| Apr. 6 |
CPL/1: Implementing Procedures and Functions |
| Apr. 9 |
Test #2 |
| Apr. 11-16 |
CPL/1: Implementing Procedures and Functions (continued) |
| Apr. 18-23 |
Full CPL: Implementing Arrays and Enumerated Types |
| Apr. 26 |
Final Exam Period/Project Demonstrations 1:00-4:00 p.m. |