CS 153: Concepts of Compiler Design
(Also SE 153)
GREEN SHEET
Spring Semester 2011
Department of
Instructor: Ron Mak
Tuesdays
and Thursdays, 7:00 – 8:15 pm, MacQuarrie Hall, room 225
Office hours: Tuesdays and Thursdays, 6:00 –
6:45 pm and by arrangement.
Office location: Duncan Hall, room 282
E-mail: ron.mak@sjsu.edu
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 much more:
This is a major programming class and a Computer Science Department deep course.
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. The Department of Computer Science strictly enforces prerequisites,
especially for a deep course. A student not meeting any prerequisites must
fill out an Add Form at the beginning of the semester to explain his or her
justifications to take the course, and it will be the instructor’s and the
department’s decision whether or not to allow the student to enroll.
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
|
||||||||||
|
There may
be additional reading assignments and use of tools from the Internet. I will
provide URLs.
Recommended texts
|
||||||||||
|
||||||||||
|
Procedure
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 be given the source code of a working Pascal
interpreter written in Java. After your programming team studies how the
interpreter works, your team 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, your team can be creative for your team 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, your team will 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. All students must form teams of 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.
This class
will move rapidly and cover a lot of complicated material. 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.
|
|
WCI |
= Writing Compilers and Interpreters |
|
|
JavaCC |
= Generating Parsers with JavaCC |
|
Week |
Dates |
Topics and activities |
|
|
1 |
Jan 27 |
Overview
of the course What are
compilers and interpreters? Form programming teams |
WCI 1 |
|
2 |
Feb 1, 3 |
A
software framework for compilers and interpreters Scanning
(lexical analysis) Symbol
table management |
WCI 2, 3,
4 |
|
3 |
Feb 8, 10 |
Syntax
diagrams Top-down
recursive-descent parsing Parsing
assignment statements and expressions Intermediate
code (parse trees) Interpreting
assignment statements and expressions |
WCI 5, 6 |
|
4 |
Feb 15,
17 |
Parsing
control statements Parser error handling Interpreting
control statements Runtime error handling |
WCI 7, 8 |
|
5 |
Feb 22,
24 |
Parsing declarations |
WCI 9 |
6 |
Mar 1, 3 |
Semantic actions and type checking Scope and the symbol table stack |
WCI 10, 11 |
|
7 |
Mar 8, 10 |
Parsing
programs, procedures, and functions Parsing procedure
and function calls |
WCI 11 |
|
8 |
Mar 15,
17 |
Runtime
memory management The
runtime stack and activation frames Passing
parameters by value and by reference Interpreting
Pascal programs |
WCI 12 |
|
9 |
Mar 22,
24 |
An interactive
source-level debugger Midcourse review Midterm exam March 24 |
WCI 13 |
|
10 |
|
Spring recess |
|
|
11 |
Apr 5, 7 |
BNF
grammars for programming languages The
JavaCC compiler-compiler |
JavaCC 1 |
|
12 |
Apr 12,
14 |
Generating
a scanner with JavaCC Generating
a parser with JavaCC |
JavaCC 2,
3 |
|
13 |
Apr 19,
21 |
JJTrees JavaCC
error handling The Java
Virtual Machine (JVM) architecture Jasmin
assembly language |
JavaCC 4,
7 WCI 15 |
|
14 |
Apr 26,
28 |
Code
diagrams and code generation Code for
assignment statements and expressions Code for
procedure and function calls Code for
string operations |
WCI 16,
17 |
|
15 |
May 3, 5 |
Code for
control statements Code for
arrays and records Executing
compiled Pascal programs |
WCI 18 |
|
16 |
May 10,
12 |
Regular
expressions and DFAs Bottom-up
parsing Lex and
Yacc |
WCI 19 |
|
17 |
May 17 |
Code
optimization Heap,
stack, and garbage collection Compiling
object-oriented languages Course review |
WCI 19 |
|
18 |
May 19 |
Final exam
MacQuarrie Hall, room 225 7:45-10:00 pm |
|
Assignments
Assignments
during the first half of the semester will involve modifying, debugging, and
adding features to the Java source code of the Pascal interpreter that you’ll
be provided. Except for the first one, these assignments will be done by the
programming teams. The assignments in the latter half of the semester will help
the teams make progress on their compiler projects.
Each
assignment is worth a maximum of 100 points. Late assignments will lose 20
points and an additional 20 points for each 24 hours after the due date.
Compiler project
During the
last half 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 (1 or 2 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, texting, tweeting, or other communication with anyone else
during the exams will be strictly forbidden.
Class grade
Your individual
class grade will be weighted as follows:
|
30% |
Assignments* |
|
35% |
Project* |
|
15% |
Midterm
exam** |
|
20% |
Final
exam** |
|
|
|
|
|
* project team scores |
Each assignment
and exam will be scored (given points) but not assigned a letter grade. The
mean score and standard deviation will be announced after each assignment and
exam. Final individual class grades will be assigned based on the class curve.
Your final class grade can be adjusted up or down depending on your level and
quality of participation on your project team as determined by the project
tracking tools and your team members’ assessments of your performance.
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
Your own
commitment to learning, as evidenced by your enrollment at SJSU, and the
University's Academic Integrity Policy requires you to be honest in all your
academic course work. Faculty members are required to report all infractions to
the Office of Student Conduct and Ethical Development. The policy on academic
integrity can be found at http://www.sjsu.edu/studentaffairs/.
Further Information
If you need
course adaptations or accommodations because of a disability, or if you need
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 register with the
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 Academic Advising and Retention Services web
site. Note
that for the Spring 2011 semester, the last day to drop a course without an
entry in your permanent record is Monday,
February 7, and the last day to add a course and register late is Monday, February 14. 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!