CS 153: Concepts of Compiler Design
GREEN SHEET
Fall Semester 2008
Department of
Instructor: Prof. Ron Mak
Section 1: Mondays and Wednesdays, 7:00 – 8:15 pm, MacQuarrie Hall,
room 225
Office hours: Mondays and Wednesdays, 6:00 –
6:45 pm and by arrangement.
Office location: Duncan Hall, room 282
E-mail: mak@cs.sjsu.edu
(e-mail preferred over phone)
Phone: (408) 533-2726 (cell)
Course catalog description
“Theoretical aspects of compiler design, including parsing context free languages, lexical analysis, translation specification and machine-independent code generation. Programming projects to demonstrate design topics.” 3 units
But we’ll do more:
Student learning outcomes
Prerequisites
|
CS 47 |
Introduction
to Computer Organization |
|
CS 146 |
Data Structures
and Algorithms |
|
CS 154 |
Formal
Languages and Computability |
A grade C-
or better in each, or instructor’s consent.
You must be
at least a “decent” Java 5.0 programmer. Please review Java array lists, hash maps,
enumerated types, sets, and generics. You should know how to use a Java
development and debugging environment such as Eclipse.
Required texts
I will provide drafts of chapters from
the book I'm currently writing, Writing Compilers and Interpreters: A
Software Engineering Approach. Other books you'll need for reference:
|
||||||||||
|
||||||||||
|
||||||||||
|
There may
be additional reading assignments and use of tools from the Internet. URLs will
be provided.
Recommended texts
There is no
shortage of compiler books on the market! Prof. Louden's book is at about the
same level as mine but more rigorous. Cooper and Torczon is a more advanced
text. Lex and yacc are classic compiler-compiler tools that nearly every
compiler writer will encounter.
|
||||||||||
|
||||||||||
|
Procedure
This will
be primarily a programming class. Compilers and interpreters are complex
programs that will challenge your software development skills. You will learn
both by example and by doing. During the first part of the course, you’ll have
access to the source code of a working Pascal compiler and interpreter written
in Java. After you study how it works, your assignments will be to modify, debug, and add features to it. This
practice will give you a good understanding of the parts of a compiler or
interpreter, how they work, and how they operate together.
During the
last part of the course, you can be creative for your compiler project. You’ll write a “grammar” for a programming
language and use the JavaCC compiler-compiler to automatically generate a
scanner and a parser for that language. Using the code and what you learned
from the first part of the course, you’ll develop a new compiler for a language
that you chose – or invent your own language! I’ll also introduce you to some
of the theory and advanced algorithms of compiler writing, especially in the
areas of parsing and code generation.
Compiler
writing is best tackled by programming teams. Therefore, you will form small
teams of 2 or 3 students each to work on the assignments and on the compiler
project. Choose your team members carefully! Project tracking and source
control tools will be available. Bring your laptops to class – we’ll try to set
aside some “lab” time for all the teams to get together and share tips and
accomplishments.
Class
attendance and participation are important. At the end of the semester, each
team will turn in its project deliverables, and each student will individually
turn in a short postmortem report. Details are below.
Schedule
Subject to
change with fair notice.
Readings: WCI = Writing
Compilers and Interpreters (chapter drafts)
JVM = Programming for the Java Virtual
Machine
JavaCC = Generating Parsers with
JavaCC
Pascal = Essentials of Pascal I and
II
|
Week |
Dates |
Topics and activities (activities in italics) |
|
|
1 |
Aug 25,
27 |
Overview
of the course What are
compilers and interpreters? A
software framework for compilers and interpreters Form project teams |
WCI 1, 2 Pascal |
|
2 |
Sep 3 |
Scanning
(lexical analysis) |
WCI 3 |
|
3 |
Sep 8, 10 |
Symbol
table management Syntax
diagrams Top-down
recursive-descent parsing Parsing
assignment statements and expressions |
WCI 4, 5 |
|
4 |
Sep 15,
17 |
Intermediate
code (parse trees) Interpreting
assignment statements and expressions Parser
error handling Parsing
control statements |
WCI 6, 7 |
|
5 |
Sep 22,
24 |
Runtime error handling Interpreting control statements Parsing declarations |
WCI 8, 9 |
6 |
Sep 29 |
Parsing declarations (cont’d) Semantic actions and type checking |
WCI 9, 10 |
|
7 |
Oct 6, 8 |
Scope and
the symbol table stack Parsing
programs, procedures, and functions Parsing
procedure and function calls |
WCI 11 |
|
8 |
Oct 13,
15 |
Runtime memory
management The
runtime stack and activation frames Passing
parameters by value and by reference Interpreting
Pascal programs An
interactive symbolic debugger |
WCI 12 |
|
9 |
Oct 20,
22 |
Midcourse review Midterm exam (Oct 22) |
|
|
10 |
Oct 27,
29 |
BNF
grammars for programming languages Compiler
development tools The
JavaCC compiler-compiler |
JavaCC 1 |
|
11 |
Nov 3, 5 |
Generating
a scanner with JavaCC Generating
a parser with JavaCC JJTrees JavaCC
error handling |
JavaCC 2,
3, 4, 7 |
|
12 |
Nov 10,
12 |
The Java
Virtual Machine (JVM) architecture The
Jasmin assembly language Code
diagrams and code generation Code for
assignment statements and expressions |
JVM 1-5 WCI 16 |
|
13 |
Nov 17,
19 |
Code for
control statements Code for
procedure and function calls Compiling
and executing Pascal programs |
WCI 17 |
|
14 |
Nov 24,
26 |
Register
allocation Regular
expressions and DFAs Bottom-up
parsing |
Handouts |
|
15 |
Dec 1, 3 |
Lex and
Yacc Code
optimization |
Handouts |
|
16 |
Dec 8, 10 |
Compiling
object-oriented languages Course review Compiler projects and postmortem
reports due |
Handouts |
|
17 |
Dec 15 |
Final exam
MacQuarrie Hall, room 225
7:45-10:00 pm |
|
Assignments
Most of the
assignments will involve modifying, debugging, and adding features to the Java
source code of the Pascal compiler that you’ll be provided. These assignments
will be done by the programming teams, although a few of them may be assigned
individually. Each assignment is worth a maximum of 100 points. Late
assignments lose 25 points for each class meeting after the due date.
Extra-credit options will be discussed in class.
Compiler project
During the
final weeks of the semester, each programming team will develop a compiler
using the JavaCC compiler-compiler. This project will involve:
Deliverables
(what each team turns in) for the project include:
As part of
the deliverables, each student must also turn in a short (2-3 pp.) individual postmortem report that
includes:
You should start thinking about and
planning for your project early in the semester.
Exams
The midterm
and final examinations will be open book, notes, and laptops. Instant
messaging, e-mails, or other communications with anyone else during the exams
will be strictly forbidden.
Class grade
|
|
Classroom protocol
As mentioned
above, it is very important for each student to attend classes and to
participate. Cell phones in silent mode, please.
Academic integrity
Students
are expected to be familiar with the University’s Academic Integrity Policy.
Please review this at http://sa.sjsu.edu/judicial_affairs/. “Your own commitment to
learning, as evidenced by your enrollment at
“Instances
of academic dishonesty will not be tolerated. Cheating on exams or plagiarism
(presenting the work of another as your own, or the use of another person’s
ideas without giving proper credit) will result in a failing grade and
sanctions by the University. For this class, all assignments are to be
completed by the individual student unless otherwise specified. If you would
like to include in your assignment any material you have submitted, or plan to
submit for another class, please note that SJSU’s Academic Policy F06-1
requires approval of instructors.”
Campus Policy in Compliance with the
American Disabilities Act
“If you
need course adaptations or accommodations because of a disability, or if you
need to make special arrangements in case the building must be evacuated,
please make an appointment with me as soon as possible, or see me during office
hours. Presidential Directive 97-03 requires that students with disabilities
requesting accommodations must register with the DRC (Disability Resource
Center) to establish a record of their disability.”
Special
accommodations for exams require ample notice to the testing office and must be
submitted to the instructor well in advance of the exam date.
University Policies and Procedures
Please
familiarize yourself with SJSU policies and procedures:
particularly
the add/drop policy. It is your responsibility to know and
observe these policies. However, if there is something about a policy that you
don't understand, please feel free to ask! You can also find answers to many
questions at the Student Advising Center. Note that for the Fall 2008
semester, the last day to drop without consequence is Friday, September 5, and
the last day to add is Friday, September 12. After these dates it becomes very
difficult to drop or add a class, so be sure you are in good shape before these
dates arrive!